From bbbe95e733827c38d13e23e26e7c5327d2972cac Mon Sep 17 00:00:00 2001 From: Per Hedbor <ph@opera.com> Date: Fri, 23 May 2014 16:54:11 +0200 Subject: [PATCH] Removed code that has been #if 0 for quite some time It mainly confuses things when you are searching for code. I also removed a few instances of 'well, this would be nice, but is not possible' and 'this code is obviously broken because X' etc. We do, after all, have a revision control system. With history. :) --- src/OCPikeInterpreter.m | 9 - src/apply_low.h | 19 -- src/builtin.cmod | 51 ----- src/builtin_functions.c | 62 ------- src/callback.c | 92 --------- src/fdlib.c | 402 ---------------------------------------- src/mapping.c | 23 --- src/module_support.c | 8 - src/multiset.c | 12 -- src/operators.c | 19 -- src/pike_memory.c | 106 ----------- src/pike_types.h | 57 ------ src/rbtree.c | 122 ------------ src/smartlink.c | 10 - src/sprintf.c | 28 --- src/svalue.c | 30 --- src/testsuite.in | 23 --- 17 files changed, 1073 deletions(-) diff --git a/src/OCPikeInterpreter.m b/src/OCPikeInterpreter.m index 182e27cb4d..84e25062ae 100644 --- a/src/OCPikeInterpreter.m +++ b/src/OCPikeInterpreter.m @@ -173,15 +173,6 @@ void shared_interpreter_cleanup(int exitcode) if ((m = load_pike_master())) { back.severity=THROW_EXIT; -// pike_push_argv(argc, argv); -#if 0 - // Ok, I've no idea how this is supposed to work since I - // can't find the actual _main call anywhere, but it - // does not expect to receive an environment array - // anymore. /mast - pike_push_env(); -#endif - } return YES; } diff --git a/src/apply_low.h b/src/apply_low.h index 7362ae7de0..2fbc1c1c7b 100644 --- a/src/apply_low.h +++ b/src/apply_low.h @@ -10,21 +10,10 @@ struct pike_frame *new_frame; struct identifier *function; -#if 0 - /* This kind of fault tolerance is braindamaged. /mast */ - if(fun<0) - { - pop_n_elems(Pike_sp-save_sp); - push_undefined(); - return 0; - } -#else #ifdef PIKE_DEBUG if (fun < 0) Pike_fatal ("Invalid function offset: %d.\n", fun); #endif -#endif - check_stack(256); check_mark_stack(256); @@ -348,13 +337,5 @@ Pike_fatal("Unknown identifier type.\n"); #endif } - -#if 0 -#ifdef PIKE_DEBUG - if(Pike_fp!=new_frame) - Pike_fatal("Frame stack out of whack!\n"); -#endif -#endif - POP_PIKE_FRAME(); } diff --git a/src/builtin.cmod b/src/builtin.cmod index fee6f7634b..bd6b0fa0e3 100644 --- a/src/builtin.cmod +++ b/src/builtin.cmod @@ -74,56 +74,11 @@ PIKECLASS TM #define SET_ZONE(TM, VAL) (VAL) #endif -#if 0 -/* This is supposed to make any timezone work. - * However: It does not really work. And makes things even slower than - * the calendar module. - */ -#ifndef HAVE_EXTERNAL_TIMEZONE -#define timezone 0 -#endif -#define WITH_ZONE(RETURNTYPE, FUNCTION, ARGUMENTS, CALL ) \ - static RETURNTYPE FUNCTION##_zone ARGUMENTS \ - { \ - RETURNTYPE res; \ - int reset = 0; \ - char *old_zone = NULL; \ - if( GET_ZONE(x) ) \ - { \ - reset = 1; \ - old_zone = getenv("TZ"); \ - setenv("TZ", GET_ZONE(x), 1 ); \ - tzset(); \ - SET_GMTOFF(x, timezone); \ - } \ - \ - res = FUNCTION CALL; \ - \ - if( reset ) \ - { \ - if( old_zone ) \ - setenv("TZ", old_zone, 1 ); \ - else \ - unsetenv( "TZ" ); \ - tzset(); \ - } \ - return res; \ - } - - WITH_ZONE(time_t,mktime,( struct tm *x ),(x)); - WITH_ZONE(struct tm*,localtime,( time_t *t, struct tm *x ),(t)); - WITH_ZONE(char *,asctime,( struct tm *x ),(x)); - WITH_ZONE(int,strftime,( char *buffer, size_t max_len, char *format, struct tm *x ),(buffer,max_len,format,x)); -#ifdef HAVE_STRPTIME - WITH_ZONE(char *,strptime,( const char *str, const char *format, struct tm *x ),(str,format,x)); -#endif -#else #define strftime_zone strftime #define mktime_zone mktime #define strptime_zone strptime #define asctime_zone asctime #define localtime_zone(X,Y) localtime(X) -#endif #ifndef HAVE_EXTERNAL_TIMEZONE #undef timezone #endif @@ -1863,12 +1818,6 @@ PIKEFUN program __empty_program(int|zero|void line, string|void file) { struct program *prog = low_allocate_program(); if (file) ext_store_program_line (prog, line, file); -#if 0 - push_program (prog); - safe_pike_fprintf (stderr, "Creating empty program %O (%x)\n", - Pike_sp - 1, Pike_sp[-1].u.program); - Pike_sp--; -#endif RETURN prog; } diff --git a/src/builtin_functions.c b/src/builtin_functions.c index e8e080605e..da59a5a38f 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -3776,21 +3776,6 @@ PMOD_EXPORT void f_object_program(INT32 args) struct object *o=Pike_sp[-args].u.object; struct program *p = o->prog; -#if 0 - /* This'd be nice, but it doesn't work well since the returned - * function can't double as a program (program_from_svalue returns - * NULL for it). */ - if (p == pike_trampoline_program) { - struct pike_trampoline *t = (struct pike_trampoline *) o->storage; - if (t->frame && t->frame->current_object) { - add_ref (o = t->frame->current_object); - pop_n_elems (args); - push_function (o, t->func); - return; - } - } -#endif - if(p) { if (SUBTYPEOF(Pike_sp[-args])) { @@ -6040,17 +6025,6 @@ PMOD_EXPORT void f_mktime (INT32 args) } #endif /* !HAVE_GMTIME && (STRUCT_TM_HAS_GMTOFF || STRUCT_TM_HAS___TM_GMTOFF) */ -#if 0 - /* Disabled since the adjustment done here with a hardcoded one - * hour is bogus in many time zones. mktime(3) in GNU libc is - * documented to normalize the date spec, which means that e.g. - * asking for DST time in a non-DST zone will override tm_isdst. - * /mast */ - if ((isdst != -1) && (isdst != date.tm_isdst)) { - /* Some stupid libc's (Hi Linux!) don't accept that we've set isdst... */ - retval += 3600 * (isdst - date.tm_isdst); - } -#endif /* 0 */ } pop_n_elems(args); @@ -9736,36 +9710,11 @@ void init_builtin_efuns(void) ADD_PROTOTYPE("handle_inherit", tFunc(tStr tStr tOr(tObj, tVoid), tPrg(tObj)), 0); ADD_PROTOTYPE("write", tFunc(tStr tOr(tVoid,tMix), tVoid), OPT_SIDE_EFFECT); ADD_PROTOTYPE("werror", tFunc(tStr tOr(tVoid,tMix), tVoid), OPT_SIDE_EFFECT); - - /* FIXME: Are these three actually supposed to be used? - * They are called by encode.c:rec_restore_value - * /grubba 2000-03-13 - */ - -#if 0 /* they are not required - Hubbe */ - ADD_PROTOTYPE("functionof", tFunc(tStr, tFunction), ID_OPTIONAL); - ADD_PROTOTYPE("objectof", tFunc(tStr, tObj), ID_OPTIONAL); - ADD_PROTOTYPE("programof", tFunc(tStr, tPrg(tObj)), ID_OPTIONAL); -#endif ADD_PROTOTYPE("read_include", tFunc(tStr, tStr), 0); ADD_PROTOTYPE("resolv", tFunc(tStr tOr(tStr,tVoid) tOr(tObj,tVoid), tMix), 0); -#if 0 - /* Getenv and putenv are efuns, they do not HAVE to be defined in the - * master object. -Hubbe - */ - - /* These two aren't called from C-code, but are popular from other code. */ - ADD_PROTOTYPE("getenv", - tOr(tFunc(tStr,tStr), tFunc(tNone, tMap(tStr, tStr))), - ID_OPTIONAL); - ADD_PROTOTYPE("putenv", tFunc(tStr tStr, tVoid), ID_OPTIONAL); - -#endif - - pike___master_program = end_program(); add_program_constant("__master", pike___master_program, 0); @@ -9774,18 +9723,7 @@ void init_builtin_efuns(void) tFunc(tObj, tVoid), OPT_SIDE_EFFECT); ADD_EFUN("master", f_master, tFunc(tNone, tObj), OPT_EXTERNAL_DEPEND); -#if 0 /* FIXME: dtFunc isn't USE_PIKE_TYPE compatible */ - ADD_EFUN_DTYPE("replace_master", f_replace_master, - dtFunc(dtObjImpl(pike___master_program), dtVoid), - OPT_SIDE_EFFECT); - /* function(:object) */ - /* FIXME: */ - ADD_EFUN_DTYPE("master", f_master, - dtFunc(dtNone, dtObjImpl(pike___master_program)), - OPT_EXTERNAL_DEPEND); -#endif /* 0 */ - /* __master still contains a reference */ free_program(pike___master_program); diff --git a/src/callback.c b/src/callback.c index 2d4e9fbc16..8fe028a42b 100644 --- a/src/callback.c +++ b/src/callback.c @@ -29,12 +29,6 @@ struct callback }; #define CALLBACK_CHUNK 128 -#if 0 -#ifdef PIKE_DEBUG -#undef PRE_INIT_BLOCK -#define PRE_INIT_BLOCK(X) X->free_func=(callback_func)remove_callback; -#endif -#endif static struct block_allocator callback_allocator = BA_INIT(sizeof(struct callback), CALLBACK_CHUNK); @@ -47,29 +41,6 @@ void count_memory_in_callbacks(size_t * num, size_t * size) { #ifdef PIKE_DEBUG extern int d_flag; -#if 0 -static int is_in_free_list(struct callback * c) -{ - struct callback_block *bar; - int e; - - if (!c) return 0; - - for (bar = callback_blocks; bar; bar=bar->next) { - if ((bar->x <= c) && ((c - bar->x) < CALLBACK_CHUNK)) { - struct callback *foo; - for (foo = bar->free_callbacks; foo; - foo = (void *)foo->next) { - if (foo == c) return 1; - } - return 0; - } - } - - return 0; -} -#endif - static void check_callback_chain(struct callback_list *lst) { int len=0; @@ -92,58 +63,6 @@ static void check_callback_chain(struct callback_list *lst) } len++; } - -#if 0 - /* The checks doesn't work with memory checkers like valgrind. - * It's also not compatible with the delayed free in block_alloc - * when dmalloc is used. Something like this should perhaps be - * provided by a consistency check function in block_alloc. - * /mast */ - { - struct callback_block *tmp; - for(tmp=callback_blocks;tmp;tmp=tmp->next) - { - int e; - for(e=0;e<CALLBACK_CHUNK;e++) - { - int d; - struct callback_block *tmp2; - - if(tmp->x[e].free_func == (callback_func)remove_callback) - { - if(!is_in_free_list(tmp->x+e)) - Pike_fatal("Lost track of a struct callback!\n"); - - if(tmp->x[e].next && - !is_in_free_list(tmp->x[e].next)) - Pike_fatal("Free callback has next in Z'ha'dum!\n"); - - }else{ - if(is_in_free_list(tmp->x[e].next)) - Pike_fatal("Non-free callback has next in free list!\n"); - } - - if(tmp->x[e].next) - { - d=CALLBACK_CHUNK; - for(tmp2=callback_blocks;tmp2;tmp2=tmp2->next) - { - for(d=0;d<CALLBACK_CHUNK;d++) - { - if(tmp2->x+d == tmp->x[e].next) - break; - - if(d < CALLBACK_CHUNK) break; - } - } - - if(d == CALLBACK_CHUNK) - Pike_fatal("Callback next pointer pointing to Z'ha'dum\n"); - } - } - } - } -#endif } } #else @@ -192,11 +111,6 @@ PMOD_EXPORT void low_call_callback(struct callback_list *lst, void *arg) } *ptr=l->next; -#if 0 -#ifdef PIKE_DEBUG - l->free_func=(callback_func)remove_callback; -#endif -#endif ba_free(&callback_allocator, l); }else{ ptr=& l->next; @@ -217,12 +131,6 @@ PMOD_EXPORT struct callback *debug_add_to_callback(struct callback_list *lst, l->arg=arg; l->free_func=free_func; -#if 0 - /* This is meaningless - free_func should never be free(). */ - DO_IF_DMALLOC( if(l->free_func == (callback_func)free) - l->free_func=(callback_func)dmalloc_free; ) -#endif - l->next=lst->callbacks; lst->callbacks=l; diff --git a/src/fdlib.c b/src/fdlib.c index 8e27e5c725..b189c64368 100644 --- a/src/fdlib.c +++ b/src/fdlib.c @@ -1610,405 +1610,3 @@ PMOD_EXPORT void closedir(DIR *dir) free(dir); } #endif - -#if 0 - -#ifdef FD_LINEAR -struct fd_mapper -{ - int size; - void **data; -}; - -void init_fd_mapper(struct fd_mapper *x) -{ - x->size=64; - x->data=xalloc(x->size*sizeof(void *)); -} - -void exit_fd_mapper(struct fd_mapper *x) -{ - free(x->data); -} - -void fd_mapper_set(struct fd_mapper *x, FD fd, void *data) -{ - while(fd>=x->size) - { - x->size*=2; - x->data=realloc(x->data, x->size*sizeof(void *)); - if(!x->data) - Pike_fatal("Out of memory.\n"); - x->data=nd; - } - x->data[fd]=data; - -} - -void *fd_mapper_get(struct fd_mapper *x, FD fd) -{ - return x->data[fd]; -} -#else /* FD_LINEAR */ -struct fd_mapper_data -{ - FD x; - void *data; -}; -struct fd_mapper -{ - int num; - int hsize; - struct fd_mapper_data *data; -}; - -void init_fd_mapper(struct fd_mapper *x) -{ - int i; - x->num=0; - x->hsize=127; - x->data=xalloc(x->hsize*sizeof(struct fd_mapper_data)); - for(i=0;i<x->hsize;i++) x->data[i].fd=-1; -} - -void exit_fd_mapper(struct fd_mapper *x) -{ - free(x->data); -} - -void fd_mapper_set(struct fd_mapper *x, FD fd, void *data) -{ - int hval; - x->num++; - if(x->num*2 > x->hsize) - { - struct fd_mapper_data *old=x->data; - int i,old_size=x->hsize; - x->hsize*=3; - x->num=0; - x->data=xalloc(x->size*sizeof(struct fd_mapper_data *)); - for(i=0;i<x->size;i++) x->data[i].fd=-1; - for(i=0;i<old_size;i++) - if(old[i].fd!=-1) - fd_mapper_set(x, old[i].fd, old[i].data); - } - - hval=fd % x->hsize; - while(x->data[hval].fd != -1) - { - hval++; - if(hval==x->hsize) hval=0; - } - x->data[hval].fd=fd; - x->data[hval].data=data; -} - -void *fd_mapper_get(struct fd_mapper *x, FD fd) -{ - int hval=fd % x->hsize; - while(x->data[hval].fd != fd) - { - hval++; - if(hval==x->hsize) hval=0; - } - return x->data[hval].data; -} -#endif /* FD_LINEAR */ - - -struct fd_data_hash -{ - FD fd; - int key; - struct fd_data_hash *next; - void *data; -}; - -#define FD_DATA_PER_BLOCK 255 - -struct fd_data_hash_block -{ - struct fd_data_hash_block *next; - struct fd_data_hash data[FD_DATA_PER_BLOCk]; -}; - -static int keynum=0; -static unsigned int num_stored_keys=0; -static unsigned int hash_size=0; -static struct fd_data_hash *free_blocks=0; -static struct fd_data_hash **htable=0; -static fd_data_hash_block *hash_blocks=0; - -int get_fd_data_key(void) -{ - return ++keynum; -} - -void store_fd_data(FD fd, int key, void *data) -{ - struct fd_data_hash *p,**last; - unsigned int hval=(fd + key * 53) % hash_size; - - for(last=htable[e];p=*last;last=&p->next) - { - if(p->fd == fd && p->key == key) - { - if(data) - { - p->data=data; - }else{ - *last=p->next; - p->next=free_blocks; - free_blocks=p; - num_stored_keys--; - } - return; - } - } - if(!data) return; - - num_stored_keys++; - - if(num_stored_keys * 2 >= hash_size) - { - /* time to rehash */ - unsigned int h; - unsigned int old_hsize=hash_size; - unsigned fd_data_hash **old_htable=htable; - if(!hash_size) - hash_size=127; - else - hash_size*=3; - - htable=xalloc(hash_size * sizeof(struct fd_data_hash *)); - - for(h=0;h<old_hsize;h++) - { - for(last=old_htable+e;p=*last;last=&p->next) - store_fd_data(p->fd, p->key, p->data); - *last=free_blocks; - free_blocks=old_htable[h]; - } - if(old_htable) - free(old_htable); - } - - - if(!free_blocks) - { - struct fd_data_hash_block *n; - int e; - n=ALLOC_STRUCT(fd_data_hash_block); - n->next=hash_blocks; - hash_blocks=n; - for(e=0;e<FD_DATA_PER_BLOCK;e++) - { - n->data[e].next=free_blocks; - free_blocks=n->data+e; - } - } - - p=free_blocks; - free_blocks=p->next; - p->fd=fd; - p->key=key; - p->data=data; - p->next=htable[hval]; - htable[hval]=p; -} - -void *get_fd_data(FD fd, int key) -{ - struct fd_data_hash *p,**last; - unsigned int hval=(fd + key * 53) % hash_size; - - for(p=htable[hval];p;p=p->next) - if(p->fd == fd && p->key == key) - return p->data; - - return 0; -} - - -#define FD_EVENT_READ 1 -#define FD_EVENT_WRITE 2 -#define FD_EVENT_OOB 4 - -struct event -{ - int fd; - int events; -}; - -#ifdef FDLIB_USE_SELECT - -struct fd_waitor -{ - fd_FDSET rcustomers,wcustomers,xcustomers; - fd_FDSET rtmp,wtmp,xtmp; - FD last; - int numleft; - int max; -}; - -#define init_waitor(X) do { (X)->numleft=0; (X)->max=0; \ - fd_FDZERO(&X->rcustomers); \ - fd_FDZERO(&X->wcustomers); \ - fd_FDZERO(&X->xcustomers); \ - } while(0) - -void fd_waitor_set_customer(struct fd_waitor *x, FD customer, int flags) -{ - if(flags & FD_EVENT_READ) - { - fd_FD_SET(& x->rcustomer, customer); - }else{ - fd_FD_CLR(& x->rcustomer, customer); - } - - if(flags & FD_EVENT_WRITE) - { - fd_FD_SET(& x->wcustomer, customer); - }else{ - fd_FD_CLR(& x->wcustomer, customer); - } - - if(flags & FD_EVENT_OOB) - { - fd_FD_SET(& x->xcustomer, customer); - }else{ - fd_FD_CLR(& x->xcustomer, customer); - } - - if(flags) - if(customer>x->max) x->max=customer; - else - if(customer == x->max) - { - x->max--; - while( - !fd_ISSET(& x->rcustomers,x->max) && - !fd_ISSET(& x->wcustomers,x->max) && - !fd_ISSET(& x->xcustomers,x->max) - ) - x->max--; - } -} - -int fd_waitor_idle(fd_waitor *x, - struct timeval *t, - struct event *e) -{ - int tmp; - if(!x->numleft) - { - x->rtmp=x->rcustomers; - x->wtmp=x->wcustomers; - x->xtmp=x->xcustomers; - - tmp=select(x->max, & x->rtmp, & x->wtmp, & x->xtmp, &t); - if(tmp<0) return 0; - - x->last=0; - x->numleft=tmp; - } - while(x->numleft) - { - while(x->last<x->max) - { - int flags= - (fd_FD_ISSET(& x->rtmp, x->last) ? FD_EVENT_READ : 0) | - (fd_FD_ISSET(& x->wtmp, x->last) ? FD_EVENT_WRITE : 0) | - (fd_FD_ISSET(& x->xtmp, x->last) ? FD_EVENT_OOB: 0); - - if(flags) - { - numleft--; - - e->fd=x->last - e->event=flags; - return 1; - } - } - } - return 0; -} - -#endif /* FDLIB_USE_SELECT */ - -#ifdef FDLIB_USE_WAITFORMULTIPLEOBJECTS - -#define FD_MAX 16384 - -struct fd_waitor -{ - int occupied; - HANDLE customers[FD_MAX]; - FD pos_to_fd[FD_MAX]; - int fd_to_pos_key; - int last_swap; -}; - -void fd_waitor_set_customer(fd_waitor *x, FD customer, int flags) -{ - HANDLE h=CreateEvent(); - x->customers[x->occupied]=h; - x->pos_to_fd[x->occupied]=customer; - fd_mapper_store(customer, x->fd_to_pos_key, x->occupied); - x->occupied++; -} - -void fd_waitor_remove_customer(fd_waitor *x, FD customer) -{ - int pos=(int)fd_mapper_get(customer, x->fd_to_pos_key); - - CloseHandle(x->customers[pos]); - - fd_mapper_store(customer, x->fd_to_pos_key, NULL); - x->occupied--; - if(x->occupied != pos) - { - x->customer[pos]=x->customer[x->occupied]; - x->pos_to_fd[pos]=x->pos_to_fd[x->occupied]; - fd_mapper_store(x->pos_to_fd[pos], x->fd_to_pos_key, (void *)pos); - } -} - -FD fd_waitor_idle(fd_waitor *x, struct timeval delay) -{ - DWORD ret,d=delay.tv_usec/1000; - d+=MINIMUM(100000,delay.tv_sec) *1000; - - ret=WaitForMultipleObjects(x->occupied, - x->customers, - 0, - delay); - - if(ret>= WAIT_OBJECT_0 && ret< WAIT_OBJECT_0 + x->occupied) - { - long tmp; - ret-=WAIT_OBJECT_0; - if(-- (x->last_swap) <= ret) - { - x->last_swap=x->occupied; - if(x->occupied == ret) return ret; - } - tmp=customers[ret]; - customers[ret]=customers[x->last_swap]; - customers[x->last_swap]=tmp; - - tmp=pos_to_fd[ret]; - pos_to_fd[ret]=pos_to_fd[x->last_swap]; - pos_to_fd[x->last_swap]=tmp; - - fd_mapper_store(x->pos_to_fd[ret], x->fd_to_pos_key, ret); - fd_mapper_store(x->pos_to_fd[x->last_swap], x->fd_to_pos_key, x->last_swap); - return x->pos_to_fd[ret]; - }else{ - return -1; - } -} - -#endif /* FDLIB_USE_WAITFORMULTIPLEOBJECTS */ - -#endif /* 0 */ diff --git a/src/mapping.c b/src/mapping.c index 9ef3296657..2b9e3e5167 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -1477,27 +1477,6 @@ PMOD_EXPORT struct mapping *mkmapping(struct array *ind, struct array *val) return m; } -#if 0 -PMOD_EXPORT struct mapping *copy_mapping(struct mapping *m) -{ - INT32 e; - struct mapping *n; - struct keypair *k; - struct mapping_data *md; - - md=m->data; - n=allocate_mapping(MAP_SLOTS(md->size)); - - md->valrefs++; - add_ref(md); - NEW_MAPPING_LOOP(md) mapping_insert(n, &k->ind, &k->val); - md->valrefs--; - free_mapping_data(md); - - return n; -} -#else - /* deferred mapping copy! */ PMOD_EXPORT struct mapping *copy_mapping(struct mapping *m) { @@ -1522,8 +1501,6 @@ PMOD_EXPORT struct mapping *copy_mapping(struct mapping *m) return n; } -#endif - /* copy_mapping() for when destructive operations are ok. * * Note: It destructive operations on the resulting mapping *will* diff --git a/src/module_support.c b/src/module_support.c index 18ea9aa812..29b47b4733 100644 --- a/src/module_support.c +++ b/src/module_support.c @@ -521,16 +521,8 @@ PMOD_EXPORT void get_all_args(const char *fname, INT32 args, switch (info) { case ARGS_OK: case ARGS_OPT: - break; - case ARGS_LONG: -#if 0 - /* Is this a good idea? */ - if (!TEST_COMPAT (7, 4)) - wrong_number_of_args_error (fname, args, ret); -#endif break; - case ARGS_NUL_IN_STRING: bad_arg_error( fname, sp-args, args, diff --git a/src/multiset.c b/src/multiset.c index d449c7b493..9f1008e41c 100644 --- a/src/multiset.c +++ b/src/multiset.c @@ -2010,11 +2010,6 @@ static ptrdiff_t multiset_insert_2 (struct multiset *l, l->msd = resize_multiset_data (msd, ENLARGE_SIZE (msd->allocsize), 0); msd = l->msd; } -#if 0 - else - if (msd->size == msd->allocsize) - fputs ("Can't rebalance multiset tree in multiset_insert_2\n", stderr); -#endif add_ref (msd); find_type = low_multiset_track_eq (msd, ind, &rbstack); @@ -4675,10 +4670,6 @@ void test_multiset (void) pop_stack(); l2 = l; -#if 0 - l2 = copy_multiset (l); - check_multiset (l2, 0); -#endif TM_VERBOSE((stderr, "delete: ")); for (j = 0, v = 0; j < 12; j++) { TM_VERBOSE((stderr, "arr[%d]=%d ", j, arr->item[j].u.integer)); @@ -4691,9 +4682,6 @@ void test_multiset (void) if (v != 9 || l2->msd->root) multiset_fatal (l2, "Wrong number of entries deleted: %d (%d)\n", v, i); TM_VERBOSE((stderr, "\n")); -#if 0 - free_multiset (l2); -#endif free_multiset (l); pop_stack(); } diff --git a/src/operators.c b/src/operators.c index 04e1b41ce2..70dbc6c507 100644 --- a/src/operators.c +++ b/src/operators.c @@ -1975,25 +1975,6 @@ static node *optimize_eq(node *n) Pike_fatal("Couldn't find argument!\n"); #endif -#if 0 - /* Disabled these - boolean falsehood is not the same thing as - * equality with the integer 0. */ - - if(node_is_false(*first_arg) && !node_may_overload(*second_arg,LFUN_EQ)) - { - ret=*second_arg; - ADD_NODE_REF(*second_arg); - return mkopernode("`!",ret,0); - } - - if(node_is_false(*second_arg) && !node_may_overload(*first_arg,LFUN_EQ)) - { - ret=*first_arg; - ADD_NODE_REF(*first_arg); - return mkopernode("`!",ret,0); - } -#endif - if (((*second_arg)->token == F_CONSTANT) && (TYPEOF((*second_arg)->u.sval) == T_STRING) && ((*first_arg)->token == F_RANGE)) { diff --git a/src/pike_memory.c b/src/pike_memory.c index 3d286b2134..9fa439ef31 100644 --- a/src/pike_memory.c +++ b/src/pike_memory.c @@ -327,25 +327,6 @@ static inline size_t low_hashmem_ia32_crc32( const void *s, size_t len, CRC32SI(h,&p[7]); p+=8; } -#if 0 - while( p+3 < e ) - { - CRC32SI(h,&p[0]); - CRC32SI(h,&p[1]); - CRC32SI(h,&p[2]); - CRC32SI(h,&p[3]); - p+=4; - } - while( p+1 < e ) - { - CRC32SI(h,&p[0]); - CRC32SI(h,&p[1]); - p+=2; - } - while( p<e ) { - CRC32SI(h,p++); - } -#endif /* include 8 bytes from the end. Note that this might be a * duplicate of the previous bytes. * @@ -574,9 +555,6 @@ static INLINE void *mexec_do_alloc (void *start, size_t length) static size_t sep_allocs = 0, grow_allocs = 0, total_size = 0; #endif -#if 0 -#define MEXEC_MAGIC 0xdeadfeedf00dfaddLL -#endif /* 0 */ struct mexec_block { struct mexec_hdr *hdr; ptrdiff_t size; @@ -822,13 +800,6 @@ PMOD_EXPORT void mexec_free(void *ptr) /* Join with bottom. */ hdr->bottom = (char *)blk; hdr->free = blk->next; -#if 0 - if (hdr->bottom == (char *)(hdr + 1)) { - /* The entire mmapped block is free. - * FIXME: Consider unmapping it. - */ - } -#endif /* 0 */ } else { hdr->free = blk; } @@ -2324,32 +2295,6 @@ PMOD_EXPORT int dmalloc_check_allocated (void *p, int must_be_freed) return res; } -#if 0 -/* Disabled since it isn't used. */ -void dmalloc_check_block_free(void *p, LOCATION location, - char *struct_name, describe_block_fn *describer) -{ - struct memhdr *mh; - mt_lock(&debug_malloc_mutex); - mh=my_find_memhdr(p,0); - - if(mh && mh->size>=0) - { - if(!(mh->flags & MEM_IGNORE_LEAK)) - { - fprintf(stderr, "Freeing %s still in use %p at %s.\n", - struct_name ? struct_name : "small block", p, LOCATION_NAME(location)); - if (describer) describer (p); - debug_malloc_dump_references(p,0,2,0); - } - mh->flags |= MEM_FREE | MEM_IGNORE_LEAK; - mh->size = ~mh->size; - } - - mt_unlock(&debug_malloc_mutex); -} -#endif - PMOD_EXPORT void dmalloc_free(void *p) { debug_free(p, DMALLOC_LOCATION(), 0); @@ -2724,57 +2669,6 @@ static void low_search_all_memheaders_for_references(void) } if( ! ((sizeof(void *)-1) & (size_t)p )) { -#if 0 - if(m->size > 0) - { -#if defined(__NT__) && !defined(__GNUC__) - __try { -#endif -#ifdef PIKE_EXTRA_DEBUG - fprintf(stderr, "PIKE_EXTRA_DEBUG:\n" - " Scanning memory block at %p, %ld bytes, " - "generation %d, flags: 0x%08x\n", - m->data, m->size, m->gc_generation, m->flags); -#endif /* PIKE_EXTRA_DEBUG */ - for(e=0;e<m->size/sizeof(void *);e++) { - void *addr = p[e]; - if (!addr || ((sizeof(void *)-1) & (size_t)addr)) { - /* No need to hunt for memhdrs for NULL or - * unaligned addresses. - * This also filters out memory areas that have - * been cleared by block_alloc.h:really_free_*() et al. - * /grubba 2003-03-15 - */ - continue; - } - /* NOTE: We must not use find_memhdr() here, - * since it might alter the data-structure - * we're looping over... - * - * A specific case is a bucket containing two - * self-referring memhdrs, using find_memhdr() - * will then cause an infinite loop. - * /grubba 2003-03-16 - */ - if((tmp=just_find_memhdr(addr))) - tmp->flags |= MEM_REFERENCED; - } -#if defined(__NT__) && !defined(__GNUC__) - } - __except( 1 ) { - fprintf(stderr,"*** DMALLOC memory access error ***\n"); - fprintf(stderr,"Failed to access this memory block:\n"); - fprintf(stderr,"Block: %p, size=%ld, gc_generation=%d, flags=%d\n", - m->data, - m->size, - m->gc_generation, - m->flags); - dump_memhdr_locations(m, 0, 0); - fprintf(stderr,"-----------------------------------\n"); - } -#endif - } -#endif } } } diff --git a/src/pike_types.h b/src/pike_types.h index 09123a3ed4..b9b6e9fd93 100644 --- a/src/pike_types.h +++ b/src/pike_types.h @@ -320,63 +320,6 @@ void register_attribute_handler(struct pike_string *attr, visit_ref (pass_type (T), (REF_TYPE), \ (visit_thing_fn *) &visit_type, NULL) -#if 0 /* FIXME: Not supported under USE_PIKE_TYPE yet. */ -/* "Dynamic types" - use with ADD_FUNCTION_DTYPE */ -#define dtStore(TYPE) {int e; for (e=0; e<CONSTANT_STRLEN(TYPE); e++) unsafe_push_type((TYPE)[e]);} -#define dtArr(VAL) {unsafe_push_type(PIKE_T_ARRAY); {VAL}} -#define dtArray dtArr(dtMix) -#define dtMap(IND,VAL) {unsafe_push_type(PIKE_T_MAPPING); {VAL} {IND}} -#define dtMapping dtMap(dtMix,dtMix) -#define dtSet(IND) {unsafe_push_type(PIKE_T_MULTISET); {IND}} -#define dtMultiset dtSet(dtMix) -#define dtObjImpl(PROGRAM) {push_object_type_backwards(0, (PROGRAM)->id);} -#define dtObjIs(PROGRAM) {push_object_type_backwards(1, (PROGRAM)->id);} -#define dtObj dtStore(tObj) -#define dtFuncV(ARGS,REST,RET) MagicdtFuncV(RET,REST,ARGS) -#define dtFunc(ARGS,RET) MagicdtFunc(RET,ARGS) -#define MagicdtFuncV(RET,REST,ARGS) {unsafe_push_type(PIKE_T_FUNCTION); {ARGS} unsafe_push_type(T_MANY); {REST} {RET}} -#define MagicdtFunc(RET,ARGS) dtFuncV(ARGS {}, dtVoid, RET) -#define dtFunction dtFuncV({},dtAny,dtAny) -#define dtNone {} -#define dtPrg {unsafe_push_type(PIKE_T_PROGRAM);} -#define dtProgram {unsafe_push_type(PIKE_T_PROGRAM);} -#define dtStr {unsafe_push_type(PIKE_T_STRING);} -#define dtString {unsafe_push_type(PIKE_T_STRING);} -#define dtType {unsafe_push_type(PIKE_T_TYPE);} -#define dtFlt {unsafe_push_type(PIKE_T_FLOAT);} -#define dtFloat {unsafe_push_type(PIKE_T_FLOAT);} -#define dtIntRange(LOW,HIGH) {unsafe_push_type(PIKE_T_INT); push_type_int_backwards(LOW); push_type_int_backwards(HIGH);} -#define dtInt dtStore(tInt) -#define dtZero {unsafe_push_type(PIKE_T_ZERO);} -#define dtVoid {unsafe_push_type(T_VOID);} -#define dtVar(X) {unsafe_push_type(X);} -#define dtSetvar(X,TYPE) {unsafe_push_type(T_ASSIGN); {TYPE}} -#define dtNot(TYPE) {unsafe_push_type(T_NOT); {TYPE}} -#define dtAnd(A,B) {unsafe_push_type(T_AND); {A} {B}} -#define dtOr(A,B) {unsafe_push_type(T_OR); {A} {B}} -#define dtOr3(A,B,C) dtOr(A,dtOr(B,C)) -#define dtOr4(A,B,C,D) dtOr(A,dtOr3(B,C,D)) -#define dtOr5(A,B,C,D,E) dtOr(A,dtOr4(B,C,D,E)) -#define dtOr6(A,B,C,D,E,F) dtOr(A,dtOr5(B,C,D,E,F)) -#define dtMix {unsafe_push_type(PIKE_T_MIXED);} -#define dtMixed {unsafe_push_type(PIKE_T_MIXED);} -#define dtComplex dtStore(tComplex) -#define dtStringIndicable dtStore(tStringIndicable) -#define dtRef dtStore(tRef) -#define dtIfnot(A,B) dtAnd(dtNot(A),B) -#define dtAny dtStore(tAny) -#define DTYPE_START do { \ - unsafe_type_stack_mark(); \ - unsafe_type_stack_mark(); \ -} while (0) -#define DTYPE_END(TYPESTR) do { \ - if(Pike_compiler->type_stackp >= type_stack + sizeof(type_stack)) \ - Pike_fatal("Type stack overflow.\n"); \ - type_stack_reverse(); \ - (TYPESTR)=pop_unfinished_type(); \ -} while (0) -#endif /* 0 */ - #ifdef DEBUG_MALLOC #define pop_type() ((struct pike_type *)debug_malloc_pass(debug_pop_type())) #define compiler_pop_type() ((struct pike_type *)debug_malloc_pass(debug_compiler_pop_type())) diff --git a/src/rbtree.c b/src/rbtree.c index 7705564387..e76a19b71b 100644 --- a/src/rbtree.c +++ b/src/rbtree.c @@ -117,86 +117,6 @@ void rbstack_insert (struct rbstack_ptr *top, struct rbstack_ptr *pos, *pos = rbp2; } -#if 0 -/* Disabled since these aren't tested and not currently used. */ - -void rbstack_assign (struct rbstack_ptr *target, struct rbstack_ptr *source) -{ - struct rbstack_slice *src_slice = source->slice; - struct rbstack_slice *tgt_slice = target->slice; - -#ifdef PIKE_DEBUG - if (target->ssp) Pike_fatal ("target rbstack not empty.\n"); -#endif - - target->ssp = source->ssp; - source->ssp = 0; - - if (src_slice->up) { - struct rbstack_slice *prev_slice; - target->slice = src_slice; - do { - prev_slice = src_slice; - src_slice = src_slice->up; - } while (src_slice->up); - MEMCPY ((char *) &tgt_slice->stack, (char *) &src_slice->stack, - STACK_SLICE_SIZE * sizeof (struct rb_node_hdr *)); - prev_slice->up = tgt_slice; - source->slice = src_slice; - } - else { - MEMCPY ((char *) &tgt_slice->stack, (char *) &src_slice->stack, - target->ssp * sizeof (struct rb_node_hdr *)); -#ifdef RB_STATS - tgt_slice->maxdepth = src_slice->maxdepth; - tgt_slice->depth = src_slice->depth; -#endif - } -} - -void rbstack_copy (struct rbstack_ptr *target, struct rbstack_ptr *source) -{ - struct rbstack_slice *src_slice = source->slice; - struct rbstack_slice *tgt_stack_slice = target->slice; - size_t ssp = source->ssp; - -#ifdef PIKE_DEBUG - if (target->ssp) Pike_fatal ("target rbstack not empty.\n"); -#endif - - target->ssp = ssp; - - if (src_slice->up) { - struct rbstack_slice *tgt_slice = - target->slice = ALLOC_STRUCT (rbstack_slice); -#ifdef RB_STATS - rbstack_slice_allocs++; -#endif - MEMCPY ((char *) &tgt_slice->stack, (char *) &src_slice->stack, - ssp * sizeof (struct rb_node_hdr *)); - ssp = STACK_SLICE_SIZE; - while ((src_slice = src_slice->up)->up) { - tgt_slice->up = ALLOC_STRUCT (rbstack_slice); - tgt_slice = tgt_slice->up; -#ifdef RB_STATS - rbstack_slice_allocs++; -#endif - MEMCPY ((char *) &tgt_slice->stack, (char *) &src_slice->stack, - STACK_SLICE_SIZE * sizeof (struct rb_node_hdr *)); - } - tgt_slice->up = tgt_stack_slice; - } - - MEMCPY ((char *) &tgt_stack_slice->stack, (char *) &src_slice->stack, - ssp * sizeof (struct rb_node_hdr *)); - -#ifdef RB_STATS - target->slice->maxdepth = target->slice->depth = source->slice->depth; -#endif -} - -#endif /* Not tested or used. */ - /* Offsets all the rb_node_hdr pointers in rbstack from their offsets * relative oldbase to the same relative newbase. Useful if the memory * block containing the tree has been moved. */ @@ -955,25 +875,6 @@ struct rb_node_hdr *low_rb_unlink_with_move (struct rb_node_hdr **root, return unlink; } -#if 0 -struct rb_node_hdr *low_rb_unlink_with_move (struct rb_node_hdr **root, - struct rbstack_ptr *rbstack_ptr, - int keep_rbstack, - size_t node_size) -{ - struct rb_node_hdr *node = RBSTACK_PEEK (*rbstack_ptr), *next = rb_next (node); - struct rb_node_hdr *unlink = - real_low_rb_unlink_with_move (root, rbstack_ptr, 1, node_size); - debug_check_rbstack (*root, *rbstack_ptr); - if (node != unlink) next = node; - if (RBSTACK_PEEK (*rbstack_ptr) != next) - Pike_fatal ("Stack got %p on top, but next node is %p.\n", - RBSTACK_PEEK (*rbstack_ptr), next); - if (!keep_rbstack) RBSTACK_FREE (*rbstack_ptr); - return unlink; -} -#endif - /* Like low_rb_unlink_with_move, but relinks the nodes instead of * moving over the data. Somewhat slower unless the size of the nodes * is large. */ @@ -1051,21 +952,6 @@ void low_rb_unlink_without_move (struct rb_node_hdr **root, *rbstack_ptr = rbstack; } -#if 0 -void low_rb_unlink_without_move (struct rb_node_hdr **root, - struct rbstack_ptr *rbstack_ptr, - int keep_rbstack) -{ - struct rb_node_hdr *node = RBSTACK_PEEK (*rbstack_ptr), *next = rb_next (node); - real_low_rb_unlink_without_move (root, rbstack_ptr, 1); - debug_check_rbstack (*root, *rbstack_ptr); - if (RBSTACK_PEEK (*rbstack_ptr) != next) - Pike_fatal ("Stack got %p on top, but next node is %p.\n", - RBSTACK_PEEK (*rbstack_ptr), next); - if (!keep_rbstack) RBSTACK_FREE (*rbstack_ptr); -} -#endif - /* Constructs a stack from the given root down to the given node. The * stack is constructed at *rbstack_ptr, and it's updated so that the * node is on its top on return. The given root must be the root of @@ -1281,10 +1167,6 @@ void rb_remove_node (struct rb_node_hdr **root, RBSTACK_INIT (rbstack); #ifdef PIKE_DEBUG if (!node) Pike_fatal ("Tree is empty.\n"); -#if 0 - if (find_fn (key, to_delete)) - Pike_fatal ("Given key doesn't match the node to delete.\n"); -#endif #endif LOW_RB_TRACK_NEQ (rbstack, node, cmp_res = find_fn (key, node) >= 0 ? 1 : -1, ;, ;); while (node != to_delete) { @@ -1335,10 +1217,6 @@ struct rb_node_hdr *rb_remove_node_with_move (struct rb_node_hdr **root, RBSTACK_INIT (rbstack); #ifdef PIKE_DEBUG if (!node) Pike_fatal ("Tree is empty.\n"); -#if 0 - if (find_fn (key, to_delete)) - Pike_fatal ("Given key doesn't match the node to delete.\n"); -#endif #endif LOW_RB_TRACK_NEQ (rbstack, node, cmp_res = find_fn (key, node) >= 0 ? 1 : -1, ;, ;); while (node != to_delete) { diff --git a/src/smartlink.c b/src/smartlink.c index 9d6b72c235..c6c2012fd7 100644 --- a/src/smartlink.c +++ b/src/smartlink.c @@ -391,16 +391,6 @@ int main(int argc, char **argv) } } -#if 0 /* Enabling this messes with the definition of EOPNOTSUP */ -#ifdef USE_OSX_TWOLEVEL_NAMESPACE - /* Mac OS X needs to be 10.3 or better for ld to accept - "-undefined dynamic_lookup" */ - if (putenv("MACOSX_DEPLOYMENT_TARGET=10.3")) { - fatal("Out of memory (8)!\n"); - } -#endif -#endif - if (getenv("SMARTLINK_DEBUG")) { int i = 0; fprintf(stderr, "SMARTLINK:"); diff --git a/src/sprintf.c b/src/sprintf.c index 2b19fa05f1..02ccdef3f8 100644 --- a/src/sprintf.c +++ b/src/sprintf.c @@ -763,10 +763,6 @@ INLINE static int do_one(struct format_stack *fs, rest=f->b; for(d=0;INDEX_PCHARP(rest,d) && e;d++) { -#if 0 - if(rest != f->b) - fix_field(" ",1,0,1," ",1,0); -#endif while(INDEX_PCHARP(rest,d) && INDEX_PCHARP(rest,d)!='\n') d++; @@ -802,10 +798,6 @@ INLINE static int do_one(struct format_stack *fs, for(d=0;rest.ptr && d<col;d++) { -#if 0 - if(rest != f->b) - fix_field(" ",1,0,1," ",1,0); -#endif /* Find end of entry */ for(e=0;COMPARE_PCHARP(ADD_PCHARP(rest, e),<,end) && @@ -1007,26 +999,6 @@ INLINE static int do_one(struct format_stack *fs, * recursively during the '%{ %}' parsing. The string is stored in * the buffer in save_objectII.c */ - -#if 0 -/* Looks to me like forgotten debug code. Anyway, we can't make this - * fatal since it might trig in _sprintf/sprintf recursions in pike - * code. /mast */ -#undef check_c_stack -#define check_c_stack(X) do { \ - ptrdiff_t x_= (((char *)&x_) - Pike_interpreter.stack_top) + \ - STACK_DIRECTION * (Pike_interpreter.c_stack_margin + (X)); \ - x_*=STACK_DIRECTION; \ - if(x_>0) { \ - /*low_error(Pike_check_c_stack_errmsg);*/ \ - Pike_fatal("C stack overflow (%d): x_:%p &x_:%p top: %p margin: %p\n", \ - (X), x_, &x_, Pike_interpreter.stack_top, \ - Pike_interpreter.c_stack_margin); \ - } \ - }while(0) -#endif - - static void low_pike_sprintf(struct format_stack *fs, struct string_builder *r, PCHARP format, diff --git a/src/svalue.c b/src/svalue.c index dc784ba1da..db506f9cae 100644 --- a/src/svalue.c +++ b/src/svalue.c @@ -510,16 +510,6 @@ int complex_svalue_is_true( const struct svalue *s ) /* Uninitialized trampoline, or trampoline to destructed object. */ return 0; } - } else { -#if 0 - /* We should never get a function svalue for a prototype. */ - struct identifier *i = ID_FROM_INT(s->u.object->prog, SUBTYPEOF(*s)); - if (IDENTIFIER_IS_PIKE_FUNCTION(i->identifier_flags) && - (i->func.offset == -1)) { - /* Prototype. */ - return 0; - } -#endif } return 1; } @@ -588,16 +578,6 @@ PMOD_EXPORT int safe_svalue_is_true(const struct svalue *s) /* Uninitialized trampoline, or trampoline to destructed object. */ return 0; } - } else { -#if 0 - /* We should never get a function svalue for a prototype. */ - struct identifier *i = ID_FROM_INT(s->u.object->prog, SUBTYPEOF(*s)); - if (IDENTIFIER_IS_PIKE_FUNCTION(i->identifier_flags) && - (i->func.offset == -1)) { - /* Prototype. */ - return 0; - } -#endif } return 1; @@ -1004,11 +984,6 @@ static int complex_is_lt( const struct svalue *a, const struct svalue *b ) int fun; a_is_object: -#if 0 - /* safe_check_destructed should avoid this. */ - if(!a->u.object->prog) - Pike_error("Comparison on destructed object.\n"); -#endif p = a->u.object->prog; if((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*a)].prog, LFUN_LT)) != -1) { @@ -1041,11 +1016,6 @@ static int complex_is_lt( const struct svalue *a, const struct svalue *b ) struct program *p; int fun; -#if 0 - /* safe_check_destructed should avoid this. */ - if(!b->u.object->prog) - Pike_error("Comparison on destructed object.\n"); -#endif p = b->u.object->prog; if((fun = FIND_LFUN(p->inherits[SUBTYPEOF(*b)].prog, LFUN_GT)) == -1) { diff --git a/src/testsuite.in b/src/testsuite.in index 318aa30818..2859de8f78 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -5275,29 +5275,6 @@ void test() t->wait(); //werror ("%O\n", rounds); -#if 0 - // The thread yielding is really bad - even the following very - // weak tests trig alarms: On FreeBSD 7.1-STABLE i386 the - // thread_disablers do over 1000 times more rounds than the - // imutex_lockers. On Linux 2.6.15-1.1833_FC4 x86_64 and Linux - // 2.6.24-23-server i686 they do over 100 times more. On SunOS - // 5.11 i86pc the thread_disablers do only 1-20 rounds in total. - - int minimum = min (@values (rounds)), maximum = max (@values (rounds)); - - if (minimum < 10) { - werror ("A thread got stuck: %O\n", rounds); - return 0; - } - - // This span is currently very generous, since the time slicing in - // threads.c:check_threads can be flaky on some systems. - if (minimum * 100 < maximum) { - werror ("Too uneven distribution between threads: %O\n", rounds); - return 0; - } -#endif - return 1; ]], 1) -- GitLab