Use catomic_* operations instead of atomic_*.
authordrepper <drepper>
Wed, 11 Oct 2006 08:59:28 +0000 (08:59 +0000)
committerdrepper <drepper>
Wed, 11 Oct 2006 08:59:28 +0000 (08:59 +0000)
elf/dl-close.c
elf/dl-fptr.c
elf/dl-open.c
elf/dl-profile.c
elf/dl-runtime.c
elf/dl-sym.c
gmon/mcount.c
malloc/memusage.c
nptl/sysdeps/unix/sysv/linux/rtld-lowlevel.h
resolv/res_libc.c
stdlib/cxa_finalize.c

index 2e7c506..84e57e0 100644 (file)
@@ -423,11 +423,11 @@ _dl_close (void *_map)
              imap->l_scoperec = newp;
              __rtld_mrlock_done (imap->l_scoperec_lock);
 
-             if (atomic_increment_val (&old->nusers) != 1)
+             if (catomic_increment_val (&old->nusers) != 1)
                {
                  old->remove_after_use = true;
                  old->notify = true;
-                 if (atomic_decrement_val (&old->nusers) != 0)
+                 if (catomic_decrement_val (&old->nusers) != 0)
                    __rtld_waitzero (old->nusers);
                }
 
index 78beecf..e068124 100644 (file)
@@ -1,5 +1,5 @@
 /* Manage function descriptors.  Generic version.
-   Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
+   Copyright (C) 1999-2004, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -40,7 +40,7 @@
 
 #ifndef COMPARE_AND_SWAP
 # define COMPARE_AND_SWAP(ptr, old, new) \
-  (atomic_compare_and_exchange_bool_acq (ptr, new, old) == 0)
+  (catomic_compare_and_exchange_bool_acq (ptr, new, old) == 0)
 #endif
 
 ElfW(Addr) _dl_boot_fptr_table [ELF_MACHINE_BOOT_FPTR_TABLE_LEN];
index 5c90e06..35712b5 100644 (file)
@@ -429,9 +429,9 @@ dl_open_worker (void *a)
                  imap->l_scoperec = newp;
                  __rtld_mrlock_done (imap->l_scoperec_lock);
 
-                 atomic_increment (&old->nusers);
+                 catomic_increment (&old->nusers);
                  old->remove_after_use = true;
-                 if (atomic_decrement_val (&old->nusers) == 0)
+                 if (catomic_decrement_val (&old->nusers) == 0)
                    /* No user, we can free it here and now.  */
                    free (old);
                }
index 41214c1..47033f3 100644 (file)
@@ -1,5 +1,5 @@
 /* Profiling of shared libraries.
-   Copyright (C) 1997-2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1997-2002, 2003, 2004, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
    Based on the BSD mcount implementation.
@@ -509,24 +509,24 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
              size_t newfromidx;
              to_index = (data[narcs].self_pc
                          / (HASHFRACTION * sizeof (*tos)));
-             newfromidx = atomic_exchange_and_add (&fromidx, 1) + 1;
+             newfromidx = catomic_exchange_and_add (&fromidx, 1) + 1;
              froms[newfromidx].here = &data[narcs];
              froms[newfromidx].link = tos[to_index];
              tos[to_index] = newfromidx;
-             atomic_increment (&narcs);
+             catomic_increment (&narcs);
            }
 
          /* If we still have no entry stop searching and insert.  */
          if (*topcindex == 0)
            {
-             uint_fast32_t newarc = atomic_exchange_and_add (narcsp, 1);
+             uint_fast32_t newarc = catomic_exchange_and_add (narcsp, 1);
 
              /* In rare cases it could happen that all entries in FROMS are
                 occupied.  So we cannot count this anymore.  */
              if (newarc >= fromlimit)
                goto done;
 
-             *topcindex = atomic_exchange_and_add (&fromidx, 1) + 1;
+             *topcindex = catomic_exchange_and_add (&fromidx, 1) + 1;
              fromp = &froms[*topcindex];
 
              fromp->here = &data[newarc];
@@ -534,7 +534,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
              data[newarc].self_pc = selfpc;
              data[newarc].count = 0;
              fromp->link = 0;
-             atomic_increment (&narcs);
+             catomic_increment (&narcs);
 
              break;
            }
@@ -547,7 +547,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
     }
 
   /* Increment the counter.  */
-  atomic_increment (&fromp->here->count);
+  catomic_increment (&fromp->here->count);
 
  done:
   ;
index 83d565a..05fd974 100644 (file)
@@ -97,7 +97,7 @@ _dl_fixup (
        {
          __rtld_mrlock_lock (l->l_scoperec_lock);
          scoperec = l->l_scoperec;
-         atomic_increment (&scoperec->nusers);
+         catomic_increment (&scoperec->nusers);
          __rtld_mrlock_unlock (l->l_scoperec_lock);
        }
 
@@ -107,7 +107,7 @@ _dl_fixup (
                                    DL_LOOKUP_ADD_DEPENDENCY, NULL);
 
       if (l->l_type == lt_loaded
-         && atomic_decrement_val (&scoperec->nusers) == 0
+         && catomic_decrement_val (&scoperec->nusers) == 0
          && __builtin_expect (scoperec->remove_after_use, 0))
        {
          if (scoperec->notify)
@@ -199,7 +199,7 @@ _dl_profile_fixup (
            {
              __rtld_mrlock_lock (l->l_scoperec_lock);
              scoperec = l->l_scoperec;
-             atomic_increment (&scoperec->nusers);
+             catomic_increment (&scoperec->nusers);
              __rtld_mrlock_unlock (l->l_scoperec_lock);
            }
 
@@ -209,7 +209,7 @@ _dl_profile_fixup (
                                        DL_LOOKUP_ADD_DEPENDENCY, NULL);
 
          if (l->l_type == lt_loaded
-             && atomic_decrement_val (&scoperec->nusers) == 0
+             && catomic_decrement_val (&scoperec->nusers) == 0
              && __builtin_expect (scoperec->remove_after_use, 0))
            {
              if (scoperec->notify)
index 1c66310..4393346 100644 (file)
@@ -124,7 +124,7 @@ do_sym (void *handle, const char *name, void *who,
        {
          __rtld_mrlock_lock (match->l_scoperec_lock);
          struct r_scoperec *scoperec = match->l_scoperec;
-         atomic_increment (&scoperec->nusers);
+         catomic_increment (&scoperec->nusers);
          __rtld_mrlock_unlock (match->l_scoperec_lock);
 
          struct call_dl_lookup_args args;
@@ -141,7 +141,7 @@ do_sym (void *handle, const char *name, void *who,
          int err = GLRO(dl_catch_error) (&objname, &errstring, &malloced,
                                          call_dl_lookup, &args);
 
-         if (atomic_decrement_val (&scoperec->nusers) == 0
+         if (catomic_decrement_val (&scoperec->nusers) == 0
              && __builtin_expect (scoperec->remove_after_use, 0))
            {
              if (scoperec->notify)
index 32a5f1e..5a4a249 100644 (file)
@@ -69,8 +69,8 @@ _MCOUNT_DECL(frompc, selfpc)  /* _mcount; may be static, inline, etc */
         * check that we are profiling
         * and that we aren't recursively invoked.
         */
-       if (atomic_compare_and_exchange_bool_acq (&p->state, GMON_PROF_BUSY,
-                                                 GMON_PROF_ON))
+       if (catomic_compare_and_exchange_bool_acq (&p->state, GMON_PROF_BUSY,
+                                                  GMON_PROF_ON))
          return;
 
        /*
index 8b37c43..9003d80 100644 (file)
@@ -1,5 +1,5 @@
 /* Profile heap and stack memory usage of running program.
-   Copyright (C) 1998-2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1998-2002, 2004, 2005, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -128,8 +128,8 @@ update_data (struct header *result, size_t len, size_t old_len)
 
   /* Compute current heap usage and compare it with the maximum value.  */
   memusage_size_t heap
-    = atomic_exchange_and_add (&current_heap, len - old_len) + len - old_len;
-  atomic_max (&peak_heap, heap);
+    = catomic_exchange_and_add (&current_heap, len - old_len) + len - old_len;
+  catomic_max (&peak_heap, heap);
 
   /* Compute current stack usage and compare it with the maximum
      value.  The base stack pointer might not be set if this is not
@@ -152,15 +152,15 @@ update_data (struct header *result, size_t len, size_t old_len)
     start_sp = sp;
   size_t current_stack = start_sp - sp;
 #endif
-  atomic_max (&peak_stack, current_stack);
+  catomic_max (&peak_stack, current_stack);
 
   /* Add up heap and stack usage and compare it with the maximum value.  */
-  atomic_max (&peak_total, heap + current_stack);
+  catomic_max (&peak_total, heap + current_stack);
 
   /* Store the value only if we are writing to a file.  */
   if (fd != -1)
     {
-      uatomic32_t idx = atomic_exchange_and_add (&buffer_cnt, 1);
+      uatomic32_t idx = catomic_exchange_and_add (&buffer_cnt, 1);
       if (idx >= 2 * buffer_size)
        {
          /* We try to reset the counter to the correct range.  If
@@ -168,7 +168,7 @@ update_data (struct header *result, size_t len, size_t old_len)
             counter it does not matter since that thread will take
             care of the correction.  */
          unsigned int reset = idx - 2 * buffer_size;
-         atomic_compare_and_exchange_val_acq (&buffer_size, reset, idx);
+         catomic_compare_and_exchange_val_acq (&buffer_size, reset, idx);
          idx = reset;
        }
 
@@ -337,24 +337,24 @@ malloc (size_t len)
     return (*mallocp) (len);
 
   /* Keep track of number of calls.  */
-  atomic_increment (&calls[idx_malloc]);
+  catomic_increment (&calls[idx_malloc]);
   /* Keep track of total memory consumption for `malloc'.  */
-  atomic_add (&total[idx_malloc], len);
+  catomic_add (&total[idx_malloc], len);
   /* Keep track of total memory requirement.  */
-  atomic_add (&grand_total, len);
+  catomic_add (&grand_total, len);
   /* Remember the size of the request.  */
   if (len < 65536)
-    atomic_increment (&histogram[len / 16]);
+    catomic_increment (&histogram[len / 16]);
   else
-    atomic_increment (&large);
+    catomic_increment (&large);
   /* Total number of calls of any of the functions.  */
-  atomic_increment (&calls_total);
+  catomic_increment (&calls_total);
 
   /* Do the real work.  */
   result = (struct header *) (*mallocp) (len + sizeof (struct header));
   if (result == NULL)
     {
-      atomic_increment (&failed[idx_malloc]);
+      catomic_increment (&failed[idx_malloc]);
       return NULL;
     }
 
@@ -403,36 +403,36 @@ realloc (void *old, size_t len)
     }
 
   /* Keep track of number of calls.  */
-  atomic_increment (&calls[idx_realloc]);
+  catomic_increment (&calls[idx_realloc]);
   if (len > old_len)
     {
       /* Keep track of total memory consumption for `realloc'.  */
-      atomic_add (&total[idx_realloc], len - old_len);
+      catomic_add (&total[idx_realloc], len - old_len);
       /* Keep track of total memory requirement.  */
-      atomic_add (&grand_total, len - old_len);
+      catomic_add (&grand_total, len - old_len);
     }
   /* Remember the size of the request.  */
   if (len < 65536)
-    atomic_increment (&histogram[len / 16]);
+    catomic_increment (&histogram[len / 16]);
   else
-    atomic_increment (&large);
+    catomic_increment (&large);
   /* Total number of calls of any of the functions.  */
-  atomic_increment (&calls_total);
+  catomic_increment (&calls_total);
 
   /* Do the real work.  */
   result = (struct header *) (*reallocp) (real, len + sizeof (struct header));
   if (result == NULL)
     {
-      atomic_increment (&failed[idx_realloc]);
+      catomic_increment (&failed[idx_realloc]);
       return NULL;
     }
 
   /* Record whether the reduction/increase happened in place.  */
   if (real == result)
-    atomic_increment (&inplace);
+    catomic_increment (&inplace);
   /* Was the buffer increased?  */
   if (old_len > len)
-    atomic_increment (&decreasing);
+    catomic_increment (&decreasing);
 
   /* Update the allocation data and write out the records if necessary.  */
   update_data (result, len, old_len);
@@ -463,16 +463,16 @@ calloc (size_t n, size_t len)
     return (*callocp) (n, len);
 
   /* Keep track of number of calls.  */
-  atomic_increment (&calls[idx_calloc]);
+  catomic_increment (&calls[idx_calloc]);
   /* Keep track of total memory consumption for `calloc'.  */
-  atomic_add (&total[idx_calloc], size);
+  catomic_add (&total[idx_calloc], size);
   /* Keep track of total memory requirement.  */
-  atomic_add (&grand_total, size);
+  catomic_add (&grand_total, size);
   /* Remember the size of the request.  */
   if (size < 65536)
-    atomic_increment (&histogram[size / 16]);
+    catomic_increment (&histogram[size / 16]);
   else
-    atomic_increment (&large);
+    catomic_increment (&large);
   /* Total number of calls of any of the functions.  */
   ++calls_total;
 
@@ -480,7 +480,7 @@ calloc (size_t n, size_t len)
   result = (struct header *) (*mallocp) (size + sizeof (struct header));
   if (result == NULL)
     {
-      atomic_increment (&failed[idx_calloc]);
+      catomic_increment (&failed[idx_calloc]);
       return NULL;
     }
 
@@ -517,7 +517,7 @@ free (void *ptr)
   /* `free (NULL)' has no effect.  */
   if (ptr == NULL)
     {
-      atomic_increment (&calls[idx_free]);
+      catomic_increment (&calls[idx_free]);
       return;
     }
 
@@ -531,9 +531,9 @@ free (void *ptr)
     }
 
   /* Keep track of number of calls.  */
-  atomic_increment (&calls[idx_free]);
+  catomic_increment (&calls[idx_free]);
   /* Keep track of total memory freed using `free'.  */
-  atomic_add (&total[idx_free], real->length);
+  catomic_add (&total[idx_free], real->length);
 
   /* Update the allocation data and write out the records if necessary.  */
   update_data (NULL, 0, real->length);
@@ -567,22 +567,22 @@ mmap (void *start, size_t len, int prot, int flags, int fd, off_t offset)
                 ? idx_mmap_a : prot & PROT_WRITE ? idx_mmap_w : idx_mmap_r);
 
       /* Keep track of number of calls.  */
-      atomic_increment (&calls[idx]);
+      catomic_increment (&calls[idx]);
       /* Keep track of total memory consumption for `malloc'.  */
-      atomic_add (&total[idx], len);
+      catomic_add (&total[idx], len);
       /* Keep track of total memory requirement.  */
-      atomic_add (&grand_total, len);
+      catomic_add (&grand_total, len);
       /* Remember the size of the request.  */
       if (len < 65536)
-       atomic_increment (&histogram[len / 16]);
+       catomic_increment (&histogram[len / 16]);
       else
-       atomic_increment (&large);
+       catomic_increment (&large);
       /* Total number of calls of any of the functions.  */
-      atomic_increment (&calls_total);
+      catomic_increment (&calls_total);
 
       /* Check for failures.  */
       if (result == NULL)
-       atomic_increment (&failed[idx]);
+       catomic_increment (&failed[idx]);
       else if (idx == idx_mmap_w)
        /* Update the allocation data and write out the records if
           necessary.  Note the first parameter is NULL which means
@@ -619,22 +619,22 @@ mmap64 (void *start, size_t len, int prot, int flags, int fd, off64_t offset)
                 ? idx_mmap_a : prot & PROT_WRITE ? idx_mmap_w : idx_mmap_r);
 
       /* Keep track of number of calls.  */
-      atomic_increment (&calls[idx]);
+      catomic_increment (&calls[idx]);
       /* Keep track of total memory consumption for `malloc'.  */
-      atomic_add (&total[idx], len);
+      catomic_add (&total[idx], len);
       /* Keep track of total memory requirement.  */
-      atomic_add (&grand_total, len);
+      catomic_add (&grand_total, len);
       /* Remember the size of the request.  */
       if (len < 65536)
-       atomic_increment (&histogram[len / 16]);
+       catomic_increment (&histogram[len / 16]);
       else
-       atomic_increment (&large);
+       catomic_increment (&large);
       /* Total number of calls of any of the functions.  */
-      atomic_increment (&calls_total);
+      catomic_increment (&calls_total);
 
       /* Check for failures.  */
       if (result == NULL)
-       atomic_increment (&failed[idx]);
+       catomic_increment (&failed[idx]);
       else if (idx == idx_mmap_w)
        /* Update the allocation data and write out the records if
           necessary.  Note the first parameter is NULL which means
@@ -673,33 +673,33 @@ mremap (void *start, size_t old_len, size_t len, int flags,  ...)
   if (!not_me && trace_mmap)
     {
       /* Keep track of number of calls.  */
-      atomic_increment (&calls[idx_mremap]);
+      catomic_increment (&calls[idx_mremap]);
       if (len > old_len)
        {
          /* Keep track of total memory consumption for `malloc'.  */
-         atomic_add (&total[idx_mremap], len - old_len);
+         catomic_add (&total[idx_mremap], len - old_len);
          /* Keep track of total memory requirement.  */
-         atomic_add (&grand_total, len - old_len);
+         catomic_add (&grand_total, len - old_len);
        }
       /* Remember the size of the request.  */
       if (len < 65536)
-       atomic_increment (&histogram[len / 16]);
+       catomic_increment (&histogram[len / 16]);
       else
-       atomic_increment (&large);
+       catomic_increment (&large);
       /* Total number of calls of any of the functions.  */
-      atomic_increment (&calls_total);
+      catomic_increment (&calls_total);
 
       /* Check for failures.  */
       if (result == NULL)
-       atomic_increment (&failed[idx_mremap]);
+       catomic_increment (&failed[idx_mremap]);
       else
        {
          /* Record whether the reduction/increase happened in place.  */
          if (start == result)
-           atomic_increment (&inplace_mremap);
+           catomic_increment (&inplace_mremap);
          /* Was the buffer increased?  */
          if (old_len > len)
-           atomic_increment (&decreasing_mremap);
+           catomic_increment (&decreasing_mremap);
 
          /* Update the allocation data and write out the records if
             necessary.  Note the first parameter is NULL which means
@@ -733,19 +733,19 @@ munmap (void *start, size_t len)
   if (!not_me && trace_mmap)
     {
       /* Keep track of number of calls.  */
-      atomic_increment (&calls[idx_munmap]);
+      catomic_increment (&calls[idx_munmap]);
 
       if (__builtin_expect (result == 0, 1))
        {
          /* Keep track of total memory freed using `free'.  */
-         atomic_add (&total[idx_munmap], len);
+         catomic_add (&total[idx_munmap], len);
 
          /* Update the allocation data and write out the records if
             necessary.  */
          update_data (NULL, 0, len);
        }
       else
-       atomic_increment (&failed[idx_munmap]);
+       catomic_increment (&failed[idx_munmap]);
     }
 
   return result;
index 9087314..b16fd21 100644 (file)
@@ -62,9 +62,9 @@ typedef int __rtld_mrlock_t;
              {                                                               \
                int newval = ((oldval & __RTLD_MRLOCK_RBITS)                  \
                              + __RTLD_MRLOCK_INC);                           \
-               int ret = atomic_compare_and_exchange_val_acq (&(lock),       \
-                                                              newval,        \
-                                                              oldval);       \
+               int ret = catomic_compare_and_exchange_val_acq (&(lock),      \
+                                                               newval,       \
+                                                               oldval);      \
                if (__builtin_expect (ret == oldval, 1))                      \
                  goto out;                                                   \
              }                                                               \
@@ -72,7 +72,7 @@ typedef int __rtld_mrlock_t;
          }                                                                   \
        if ((oldval & __RTLD_MRLOCK_RWAIT) == 0)                              \
          {                                                                   \
-           atomic_or (&(lock), __RTLD_MRLOCK_RWAIT);                         \
+           catomic_or (&(lock), __RTLD_MRLOCK_RWAIT);                        \
            oldval |= __RTLD_MRLOCK_RWAIT;                                    \
          }                                                                   \
        lll_futex_wait (lock, oldval);                                        \
@@ -83,10 +83,10 @@ typedef int __rtld_mrlock_t;
 
 #define __rtld_mrlock_unlock(lock) \
   do {                                                                       \
-    int oldval = atomic_exchange_and_add (&(lock), -__RTLD_MRLOCK_INC);              \
+    int oldval = catomic_exchange_and_add (&(lock), -__RTLD_MRLOCK_INC);      \
     if (__builtin_expect ((oldval                                            \
                           & (__RTLD_MRLOCK_RBITS | __RTLD_MRLOCK_WWAIT))     \
-                         == __RTLD_MRLOCK_INC | __RTLD_MRLOCK_WWAIT, 0))     \
+                         == (__RTLD_MRLOCK_INC | __RTLD_MRLOCK_WWAIT), 0))   \
       /* We have to wake all threads since there might be some queued        \
         readers already.  */                                                 \
       lll_futex_wake (&(lock), 0x7fffffff);                                  \
@@ -107,7 +107,7 @@ typedef int __rtld_mrlock_t;
              {                                                               \
                int newval = ((oldval & __RTLD_MRLOCK_RWAIT)                  \
                              + __RTLD_MRLOCK_WRITER);                        \
-               int ret = atomic_compare_and_exchange_val_acq (&(lock),       \
+               int ret = catomic_compare_and_exchange_val_acq (&(lock),      \
                                                               newval,        \
                                                               oldval);       \
                if (__builtin_expect (ret == oldval, 1))                      \
@@ -115,7 +115,7 @@ typedef int __rtld_mrlock_t;
              }                                                               \
            atomic_delay ();                                                  \
          }                                                                   \
-       atomic_or (&(lock), __RTLD_MRLOCK_WWAIT);                             \
+       catomic_or (&(lock), __RTLD_MRLOCK_WWAIT);                            \
        oldval |= __RTLD_MRLOCK_WWAIT;                                        \
        lll_futex_wait (lock, oldval);                                        \
       }                                                                              \
@@ -125,7 +125,7 @@ typedef int __rtld_mrlock_t;
 
 #define __rtld_mrlock_done(lock) \
   do {                          \
-    int oldval = atomic_exchange_and_add (&(lock), -__RTLD_MRLOCK_WRITER);    \
+    int oldval = catomic_exchange_and_add (&(lock), -__RTLD_MRLOCK_WRITER);   \
     if (__builtin_expect ((oldval & __RTLD_MRLOCK_RWAIT) != 0, 0))           \
       lll_futex_wake (&(lock), 0x7fffffff);                                  \
   } while (0)
index 834773c..8af57f7 100644 (file)
@@ -33,7 +33,7 @@ extern unsigned long long int __res_initstamp attribute_hidden;
 #if __WORDSIZE == 64
 # define atomicinclock(lock) (void) 0
 # define atomicincunlock(lock) (void) 0
-# define atomicinc(var) atomic_increment (&(var))
+# define atomicinc(var) catomic_increment (&(var))
 #else
 __libc_lock_define_initialized (static, lock);
 # define atomicinclock(lock) __libc_lock_lock (lock)
index bb49f36..148d57f 100644 (file)
@@ -45,8 +45,8 @@ __cxa_finalize (void *d)
              /* We don't want to run this cleanup more than once.  */
              && (cxafn = f->func.cxa.fn,
                  cxaarg = f->func.cxa.arg,
-                 ! atomic_compare_and_exchange_bool_acq (&f->flavor, ef_free,
-                                                         ef_cxa)))
+                 ! catomic_compare_and_exchange_bool_acq (&f->flavor, ef_free,
+                                                          ef_cxa)))
            {
              uint64_t check = __new_exitfn_called;