cvs diff: Diffing . Index: Whats_New RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/Whats_New,v retrieving revision 1.59 diff -r1.59 Whats_New 1c1 < For the 95/09/01 release version 1_60_beta4 --- > For the 95/09/xx release version 1_60_beta4 2a3,12 > Ports > SGI running IRIX-5.3 > > Additions > Added pthread_sigprocmask(). > Added CV attributes > > strtok() and strtok_r() (Greg Hudson) > getsockname() (Sean Levy) > 5a16,29 > pthreads/sig.c : Remove enum pthread_sig_flags and just use the vector. > Added pthread_sigprocmask(). > pthreads/signal.c : Protect calls to pthread_sig_process(). > configure : Create the obj directory. > tests/test_preemption_float.c : Rewritten to actually work. > machdep/engine-i386-linux-1.0.c : Added __strtol_internal() > tests/test_stdio_1.c : Don't use base_name or dir_name as variables. > gen/getcwd.c : fstat => machdep_sys_fstat, since kernel fd's are > used in the DIR data structure > gen/isatty.c : Fixed call to fd_lock() to pass the right # args. > pthreads/pthread_init.c : Fixed uninitialized members of > pthread_initial. > > cvs diff: Diffing bin cvs diff: Diffing bin/finger Index: bin/finger/finger.c RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/bin/finger/finger.c,v retrieving revision 1.51 diff -r1.51 finger.c 52a53 > #include 54,55c55 < #include < #include --- > /* #include */ 59c59 < void *netfinger_thread(); --- > void *netfinger(); 72c72,74 < int thread_time = 0, program_timeout = 0, lflag = 0, maxcount = 0; --- > int thread_time = 0, program_timeout = 0, lflag = 0; > pthread_tad_t parse_file_tad; > pthread_tad_t netfinger_tad; 74,81d75 < /* < * These globals change and therefor do need mutexes < */ < pthread_mutex_t netmutex = PTHREAD_MUTEX_INITIALIZER; < pthread_cond_t netcond = PTHREAD_COND_INITIALIZER; < int parse_count = 1; < int net_count = 0; < 98,116d91 < void thread_done(void * arg) < { < pthread_mutex_lock(&netmutex); < if (arg == (void *)&parse_count) { < parse_count--; < } < if (arg == (void *)&net_count) { < if (maxcount && (net_count == maxcount)) { < pthread_cond_broadcast(&netcond); < } < net_count--; < } < if (net_count || parse_count) { < pthread_mutex_unlock(&netmutex); < return; < } < exit(0); < } < 124a100 > pthread_atexit_t atexit_id; 132d107 < pthread_cleanup_push(thread_done, &parse_count); 139c114 < pthread_cleanup_push(fclose, fp); --- > pthread_atexit_add(&atexit_id, fclose_nrv, fp); 145c120 < pthread_cleanup_push(pthread_attr_destroy, &attr); --- > pthread_atexit_add(&atexit_id, pthread_attr_destroy_nrv, &attr); 147d121 < pthread_mutex_lock(&netmutex); 149,152d122 < /* Wait for a new thread before allocating more memory */ < while (maxcount && (net_count == maxcount)) { < pthread_cond_wait(&netcond, &netmutex); < } 161,162c131,133 < if (pthread_create(&thread_id, NULL, netfinger_thread, thread_arg)) { < fprintf(stderr, "Error: couldn't create another thread\n"); --- > if (pthread_tad_create(&netfinger_tad, &thread_id, NULL, > netfinger, thread_arg)) { > fprintf(stderr, "Error: pthread_tad_create() netfinger_tad.\n"); 165d135 < net_count++; 167d136 < pthread_mutex_unlock(&netmutex); 172a142 > pthread_atexit_t atexit_id; 173a144 > int max_count = 0; 180c151,155 < pthread_init(); --- > /* Setup tad for parse_file() threads */ > if (pthread_tad_init(&netfinger_tad, max_count)) { > fprintf(stderr,"Error: couldn't create parse_file() TAD.\n"); > exit(1); > } 195,196c170,172 < if (pthread_create(&thread_id, NULL, parse_file, optarg)) { < fprintf(stderr,"Error: couldn't create parse_file() thread\n"); --- > if (pthread_tad_create(&parse_file_tad, &thread_id, NULL, > parse_file, optarg)) { > fprintf(stderr,"Error: pthread_tad_create() parse_file_tad.\n"); 199d174 < parse_count++; 200a176,178 > case 'c': > max_count = atoi(optarg); > break; 231,232c209,213 < /* Push cleanup handler so we don't have to worry about it */ < pthread_cleanup_push(thread_done, &parse_count); --- > /* Setup tad for netfinger() threads */ > if (pthread_tad_init(&netfinger_tad, max_count)) { > fprintf(stderr,"Error: couldn't create netfinger() TAD.\n"); > exit(1); > } 237,238d217 < pthread_mutex_lock(&netmutex); < 240,244c219,221 < while (maxcount && (net_count == maxcount)) { < pthread_cond_wait(&netcond, &netmutex); < } < if (pthread_create(&thread_id, NULL, netfinger_thread, *argv)) { < fprintf(stderr, "Error: couldn't create another thread\n"); --- > if (pthread_tad_create(&netfinger_tad, &thread_id, NULL, > netfinger, *argv)) { > fprintf(stderr, "Error: pthread_tad_create() netfinger_tad.\n"); 248d224 < net_count++; 250,251c226,228 < pthread_mutex_unlock(&netmutex); < pthread_exit(NULL); --- > pthread_tad_wait(&parse_file_tad, 0); > pthread_tad_wait(&netfinger_tad, 0); > exit(0); Index: bin/finger/net.c RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/bin/finger/net.c,v retrieving revision 1.51 diff -r1.51 net.c 41a42 > #include 46c47 < #include --- > #include 51d51 < 59,60c59 < extern void thread_done(void *); < extern int lflag, net_count; --- > extern int lflag; 102c101 < void *netfinger_thread(char *name) --- > void *netfinger(char *name) 103a103 > pthread_atexit_t atexit_id; 113,114c113 < pthread_cleanup_push(fflush, NULL); < pthread_cleanup_push(thread_done, &net_count); --- > pthread_atexit_add(&atexit_id, fflush_nrv, NULL); cvs diff: Diffing bin/finger.working cvs diff: Diffing book cvs diff: Diffing book/chapter7_example1 cvs diff: Diffing config Index: config/configure RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/config/configure,v retrieving revision 1.44 diff -r1.44 configure 579c579 < cat > conftest.$ac_ext < cat > conftest.$ac_ext < test -d lib || mkdir lib || \ > { echo "configure: error: Can't create lib directory." 1>&2; exit 1; } > > test -d lib/libpthreadutil || mkdir lib/libpthreadutil || \ > { echo "configure: error: Can't create lib/libpthreadutil directory." 1>&2; exit 1; } > > test -d bin || mkdir bin || \ > { echo "configure: error: Can't create bin directory." 1>&2; exit 1; } > > test -d bin/finger || mkdir bin/finger || \ > { echo "configure: error: Can't create bin directory." 1>&2; exit 1; } > 2311a2324,2327 > lib/Makefile:../lib/Makefile.in \ > lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \ > bin/Makefile:../bin/Makefile.in \ > bin/finger/Makefile:../bin/finger/Makefile.in \ 2359a2376,2379 > lib/Makefile:../lib/Makefile.in \ > lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \ > bin/Makefile:../bin/Makefile.in \ > bin/finger/Makefile:../bin/finger/Makefile.in \ Index: config/configure.in RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/config/configure.in,v retrieving revision 1.39 diff -r1.39 configure.in 505a506,517 > test -d lib || mkdir lib || \ > AC_MSG_ERROR(Can't create lib directory.) > > test -d lib/libpthreadutil || mkdir lib/libpthreadutil || \ > AC_MSG_ERROR(Can't create lib/libpthreadutil directory.) > > test -d bin || mkdir bin || \ > AC_MSG_ERROR(Can't create bin directory.) > > test -d bin/finger || mkdir bin/finger || \ > AC_MSG_ERROR(Can't create bin directory.) > 559a572,575 > lib/Makefile:../lib/Makefile.in \ > lib/libpthreadutil/Makefile:../lib/libpthreadutil/Makefile.in \ > bin/Makefile:../bin/Makefile.in \ > bin/finger/Makefile:../bin/finger/Makefile.in \ cvs diff: Diffing datalib cvs diff: Diffing dce_compat cvs diff: Diffing doc cvs diff: Diffing gen cvs diff: Diffing include Index: include/pthread.h RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/include/pthread.h,v retrieving revision 1.69 diff -r1.69 pthread.h 32c32 < * $Id: pthread.h,v 1.69 95/09/24 06:04:06 ghudson Exp $ --- > * $Id: pthread.h,v 1.69 95/09/23 02:30:25 ghudson Exp $ 121a122,123 > #define PTT_USER_THREAD 0x0001 > 122a125 > int thread_type; 127,128c130,131 < sigset_t sigmask; < sigset_t sigpending; --- > sigset_t sigmask; > sigset_t sigpending; cvs diff: Diffing include/arpa cvs diff: Diffing include/pthread cvs diff: Diffing lib cvs diff: Diffing machdep cvs diff: Diffing machdep/alpha-osf1 cvs diff: Diffing machdep/bsdi-1.1 cvs diff: Diffing machdep/freebsd-1.1 cvs diff: Diffing machdep/freebsd-2.0 cvs diff: Diffing machdep/hpux-9.03 cvs diff: Diffing machdep/irix-5.2 cvs diff: Diffing machdep/linux-1.0 cvs diff: Diffing machdep/netbsd-0.9 cvs diff: Diffing machdep/netbsd-1.0 cvs diff: Diffing machdep/sunos-4.1.3 cvs diff: Diffing machdep/sunos-5.3 cvs diff: Diffing machdep/ultrix-4.2 cvs diff: Diffing net cvs diff: Diffing pthreads Index: pthreads/cond.c RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/pthreads/cond.c,v retrieving revision 1.67 diff -r1.67 cond.c 150c150 < pthread_cond_debug_ptrs[pthread_cond_debug_count] == NULL; --- > pthread_cond_debug_ptrs[pthread_cond_debug_count] = NULL; Index: pthreads/mutex.c RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/pthreads/mutex.c,v retrieving revision 1.60 diff -r1.60 mutex.c 39c39 < static const char rcsid[] = "$Id: mutex.c,v 1.60 95/03/10 04:06:45 snl Exp $"; --- > static const char rcsid[] = "$Id: mutex.c,v 1.60 1995/03/10 04:06:45 snl Exp $"; 166c166 < pthread_mutex_debug_ptrs[pthread_mutex_debug_count] == NULL; --- > pthread_mutex_debug_ptrs[pthread_mutex_debug_count] = NULL; Index: pthreads/sig.c RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/pthreads/sig.c,v retrieving revision 1.66 diff -r1.66 sig.c 117a118 > return(0); 125c126 < int pthread_sig_process() --- > void pthread_sig_process() Index: pthreads/signal.c RCS file: /afs/sipb.mit.edu/project/pthreads/src/CVS/pthreads/pthreads/signal.c,v retrieving revision 1.74 diff -r1.74 signal.c 66c66,70 < static volatile sigset_t sig_to_process; --- > > static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, }; > static sig_atomic_t sig_to_process = 0; > > /* static volatile sigset_t sig_to_process; */ 159,160c163,166 < sigdelset((sigset_t *)&sig_to_process, SIGVTALRM); < if (SIG_ANY(sig_to_process)) { --- > signum_to_process[SIGVTALRM] = 0; > if (sig_to_process) { > /* sigdelset((sigset_t *)&sig_to_process, SIGVTALRM); > if (SIG_ANY(sig_to_process)) { */ 175d180 < sigdelset((sigset_t *)&sig_to_process, SIGVTALRM); 177c182,185 < if (SIG_ANY(sig_to_process)) { --- > signum_to_process[SIGVTALRM] = 0; > if (sig_to_process) { > /* sigdelset((sigset_t *)&sig_to_process, SIGVTALRM); > if (SIG_ANY(sig_to_process)) { */ 216c224,225 < if (!(SIG_ANY(sig_to_process))) { --- > /* if (!(SIG_ANY(sig_to_process))) { */ > if (!sig_to_process) { 234c243,244 < sigdelset((sigset_t *)&sig_to_process, SIGVTALRM); --- > /* sigdelset((sigset_t *)&sig_to_process, SIGVTALRM); */ > signum_to_process[SIGVTALRM] = 0; 299a310,375 > * sig_handler_switch() > */ > static inline void sig_handler_switch(int sig) > { > int ret; > > switch(sig) { > case 0: > break; > case SIGVTALRM: > sigvtalrm(); > break; > case SIGALRM: > /* sigdelset((sigset_t *)&sig_to_process, SIGALRM); */ > signum_to_process[SIGALRM] = 0; > switch (ret = sleep_wakeup()) { > default: > if (pthread_run && (ret > pthread_run->pthread_priority)) { > sigvtalrm(); > } > case 0: > break; > case NOTOK: > /* Do the registered action, no threads were sleeping */ > sigdefault(sig); > break; > } > break; > case SIGCHLD: > /* sigdelset((sigset_t *)&sig_to_process, SIGCHLD); */ > signum_to_process[SIGCHLD] = 0; > switch (ret = wait_wakeup()) { > default: > if (pthread_run && (ret > pthread_run->pthread_priority)) { > sigvtalrm(); > } > case 0: > break; > case NOTOK: > /* Do the registered action, no threads were waiting */ > sigdefault(sig); > break; > } > break; > #ifdef SIGINFO > case SIGINFO: > pthread_dump_info (); > /* Then fall through, invoking the application's > signal handler after printing our info out. > > I'm not convinced that this is right, but I'm not > 100% convinced that it is wrong, and this is how > Chris wants it done... */ > #endif > > default: > /* Do the registered action */ > /* sigdelset((sigset_t *)&sig_to_process, sig); */ > signum_to_process[sig] = 0; > sigdefault(sig); > break; > } > > } > > /* ========================================================================== 309,310d384 < int ret; < 315c389,391 < sig_handler_top:; --- > if (sig) { > sig_handler_switch(sig); > } 317,328c393,396 < switch(sig) { < case 0: < break; < case SIGVTALRM: < sigvtalrm(); < break; < case SIGALRM: < sigdelset((sigset_t *)&sig_to_process, SIGALRM); < switch (ret = sleep_wakeup()) { < default: < if (pthread_run && (ret > pthread_run->pthread_priority)) { < sigvtalrm(); --- > while (sig_to_process) { > for (sig_to_process = 0, sig = 1; sig <= SIGMAX; sig++) { > if (signum_to_process[sig]) { > sig_handler_switch(sig); 330,369c398 < case 0: < break; < case NOTOK: < /* Do the registered action, no threads were sleeping */ < sigdefault(sig); < break; < } < break; < case SIGCHLD: < sigdelset((sigset_t *)&sig_to_process, SIGCHLD); < switch (ret = wait_wakeup()) { < default: < if (pthread_run && (ret > pthread_run->pthread_priority)) { < sigvtalrm(); < } < case 0: < break; < case NOTOK: < /* Do the registered action, no threads were waiting */ < sigdefault(sig); < break; < } < break; < < #ifdef SIGINFO < case SIGINFO: < pthread_dump_info (); < /* Then fall through, invoking the application's < signal handler after printing our info out. < < I'm not convinced that this is right, but I'm not < 100% convinced that it is wrong, and this is how < Chris wants it done... */ < #endif < < default: < /* Do the registered action */ < sigdelset((sigset_t *)&sig_to_process, sig); < sigdefault(sig); < break; --- > } 372c401,402 < /* Determine if there are any other signals */ --- > > /* 379a410 > */ 397c428,430 < sigaddset((sigset_t *)&sig_to_process, sig); --- > signum_to_process[sig] = 1; > sig_to_process = 1; > /* sigaddset((sigset_t *)&sig_to_process, sig); */ 418c451,453 < sigaddset((sigset_t *)&sig_to_process, sig); --- > /* sigaddset((sigset_t *)&sig_to_process, sig); */ > signum_to_process[sig] = 1; > sig_to_process = 1; 424c459,460 < if (SIG_ANY(sig_to_process)) { --- > if (sig_to_process) { > /* if (SIG_ANY(sig_to_process)) { */ 452c488,489 < if (SIG_ANY(sig_to_process)) { --- > if (sig_to_process) { > /* if (SIG_ANY(sig_to_process)) { */ 479c516,517 < if (SIG_ANY(sig_to_process)) { --- > if (sig_to_process) { > /* if (SIG_ANY(sig_to_process)) { */ 500c538,539 < if (SIG_ANY(sig_to_process)) { --- > /* if (SIG_ANY(sig_to_process)) { */ > if (sig_to_process) { cvs diff: Diffing scripts cvs diff: Diffing stdio cvs diff: Diffing stdlib cvs diff: Diffing string cvs diff: Diffing syslog cvs diff: Diffing tests