Branch: Tag:

2003-02-08

2003-02-08 02:31:57 by Martin Stjernholm <mast@lysator.liu.se>

Added configure test to see whether the time returned by get_cpu_time is
thread local or not.

Rev: src/acconfig.h:1.113
Rev: src/configure.in:1.682
Rev: src/global.h:1.79
Rev: src/pike_threadlib.h:1.28
Rev: src/threads.c:1.199

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: threads.c,v 1.198 2003/01/26 11:09:01 mirar Exp $ + || $Id: threads.c,v 1.199 2003/02/08 02:28:40 mast Exp $   */    -  + #ifndef CONFIGURE_TEST   #include "global.h" - RCSID("$Id: threads.c,v 1.198 2003/01/26 11:09:01 mirar Exp $"); + RCSID("$Id: threads.c,v 1.199 2003/02/08 02:28:40 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0; -  + #endif /* !CONFIGURE_TEST */      #ifdef _REENTRANT -  +  + #ifndef CONFIGURE_TEST +    #include "threads.h"   #include "array.h"   #include "mapping.h"
38:   PMOD_EXPORT COND_T threads_disabled_change;   PMOD_EXPORT size_t thread_stack_size=256 * 1204;    + #else + #include "pike_threadlib.h" + #endif /* !CONFIGURE_TEST */ +    /* SCO magic... */   int __thread_sys_behavior = 1;    -  + #ifndef CONFIGURE_TEST +    #if !defined(HAVE_PTHREAD_ATFORK) && !defined(th_atfork)   #include "callback.h"   #define PIKE_USE_OWN_ATFORK
74:   }   #endif    + #endif /* !CONFIGURE_TEST */ +    #ifdef __NT__      int low_nt_create_thread(unsigned Pike_stack_size,
179:      #endif    + #ifdef POSIX_THREADS + pthread_attr_t pattr; + pthread_attr_t small_pattr; + #endif    -  + static void really_low_th_init(void) + { + #ifdef SGI_SPROC_THREADS + #error /* Need to specify a filename */ +  us_cookie = usinit(""); + #endif /* SGI_SPROC_THREADS */ +  + #ifdef POSIX_THREADS + #ifdef HAVE_PTHREAD_INIT +  pthread_init(); + #endif /* HAVE_PTHREAD_INIT */ + #endif /* POSIX_THREADS */ +  + #ifdef POSIX_THREADS +  pthread_attr_init(&pattr); + #ifndef CONFIGURE_TEST + #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE +  pthread_attr_setstacksize(&pattr, thread_stack_size); + #endif + #endif +  pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED); +  +  pthread_attr_init(&small_pattr); + #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE +  pthread_attr_setstacksize(&small_pattr, 4096*sizeof(char *)); + #endif +  pthread_attr_setdetachstate(&small_pattr, PTHREAD_CREATE_DETACHED); + #endif + } +  + #ifndef CONFIGURE_TEST +    #define THIS_THREAD ((struct thread_state *)CURRENT_STORAGE)      static struct callback *threads_evaluator_callback=0;
199:   struct program *mutex_key = 0;   PMOD_EXPORT struct program *thread_id_prog = 0;   struct program *thread_local_prog = 0; - #ifdef POSIX_THREADS - pthread_attr_t pattr; - pthread_attr_t small_pattr; - #endif +    PMOD_EXPORT ptrdiff_t thread_storage_offset;   #ifdef USE_CLOCK_FOR_SLICES   PMOD_EXPORT clock_t thread_start_clock = 0;
1758:      void low_th_init(void)   { - #ifdef SGI_SPROC_THREADS - #error /* Need to specify a filename */ -  us_cookie = usinit(""); - #endif /* SGI_SPROC_THREADS */ -  +     THREADS_FPRINTF(0, (stderr, "THREADS_DISALLOW() Initializing threads.\n"));    - #ifdef POSIX_THREADS - #ifdef HAVE_PTHREAD_INIT -  pthread_init(); - #endif /* HAVE_PTHREAD_INIT */ - #endif /* POSIX_THREADS */ +  really_low_th_init();       mt_init( & interpreter_lock);    low_mt_lock_interpreter();
1778:    mt_init( & rosie);    co_init( & live_threads_change);    co_init( & threads_disabled_change); -  +     thread_table_init(); - #ifdef POSIX_THREADS -  pthread_attr_init(&pattr); - #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE -  pthread_attr_setstacksize(&pattr, thread_stack_size); - #endif -  pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED); +     -  pthread_attr_init(&small_pattr); - #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE -  pthread_attr_setstacksize(&small_pattr, 4096*sizeof(char *)); - #endif -  pthread_attr_setdetachstate(&small_pattr, PTHREAD_CREATE_DETACHED); -  + #ifdef POSIX_THREADS +  /* FIXME: Why set this only when POSIX_THREADS? /mast */    th_running = 1;   #endif   }
1977:   #endif   }    + #endif /* !CONFIGURE_TEST */ +    #endif