apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: apr/memory/unix apr_sms_threads.c
Date Wed, 18 Jul 2001 18:41:37 GMT
trawick     01/07/18 11:41:37

  Modified:    memory/unix apr_sms_threads.c
  Log:
  use a macro for obtaining the thread hash value so that
  the gory details aren't spread all over
  
  make an attempt to compute the thread hash value using
  a mechanism which will work when apr_os_thread_t is a
  scalar (e.g., glibc), pointer (e.g., Tru64), or even a
  structure (e.g., OS/390); previously, it only compiled
  on systems where apr_os_thread_t was a scalar
  
  Revision  Changes    Path
  1.2       +6 -4      apr/memory/unix/apr_sms_threads.c
  
  Index: apr_sms_threads.c
  ===================================================================
  RCS file: /home/cvs/apr/memory/unix/apr_sms_threads.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_sms_threads.c	2001/07/12 16:50:19	1.1
  +++ apr_sms_threads.c	2001/07/18 18:41:37	1.2
  @@ -104,6 +104,8 @@
   
   #define HASH_SIZE 1021
   #define SIZEOF_HASHTABLE APR_ALIGN_DEFAULT(HASH_SIZE)
  +#define THREAD_HASH(tid) \
  +(*(int *)&(tid) % HASH_SIZE)
   
   typedef struct apr_sms_threads_t
   {
  @@ -159,7 +161,7 @@
       size = APR_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
   
       thread = apr_os_thread_current();
  -    hash = thread % HASH_SIZE;
  +    hash = THREAD_HASH(thread);
      
       /* If the thread wasn't registered before, we will segfault */ 
       thread_node = SMS_THREADS_T(sms)->hashtable[hash];
  @@ -304,7 +306,7 @@
           return APR_SUCCESS;
   
       thread = apr_os_thread_current();
  -    hash = thread % HASH_SIZE;
  +    hash = THREAD_HASH(thread);
       
       thread_node = SMS_THREADS_T(sms)->hashtable[hash];
       while (thread_node->thread != thread)
  @@ -562,7 +564,7 @@
       node_t *node, *sentinel;
       apr_uint16_t hash;
   
  -    hash = thread % HASH_SIZE;
  +    hash = THREAD_HASH(thread);
       
       if (sms->threads > 1 && !SMS_THREADS_T(sms)->lock) {
           apr_lock_create(&SMS_THREADS_T(sms)->lock,
  @@ -630,7 +632,7 @@
       apr_uint16_t hash;
       apr_size_t min_alloc, max_free;
   
  -    hash = thread % HASH_SIZE;
  +    hash = THREAD_HASH(thread);
       free_list = NULL;
       
       if (SMS_THREADS_T(sms)->lock)
  
  
  

Mime
View raw message