Skip to content

Commit

Permalink
* include/atomic.c: Define catomic_* operations.
Browse files Browse the repository at this point in the history
	* sysdeps/x86_64/bits/atomic.h: Likewise.  Fix a few minor problems.
	* stdlib/cxa_finalize.c: Use catomic_* operations instead of atomic_*.
	* malloc/memusage.c: Likewise.
	* gmon/mcount.c: Likewise.
	* elf/dl-close.c: Likewise.
	* elf/dl-open.c: Likewise.
	* elf/dl-profile.c: Likewise.
	* elf/dl-sym.c: Likewise.
	* elf/dl-runtime.c: Likewise.
	* elf/dl-fptr.c: Likewise.
	* resolv/res_libc.c: Likewise.
  • Loading branch information
Ulrich Drepper committed Oct 11, 2006
1 parent 2a6ee54 commit 8099361
Show file tree
Hide file tree
Showing 15 changed files with 415 additions and 148 deletions.
15 changes: 15 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2006-10-11 Ulrich Drepper <drepper@redhat.com>

* include/atomic.c: Define catomic_* operations.
* sysdeps/x86_64/bits/atomic.h: Likewise. Fix a few minor problems.
* stdlib/cxa_finalize.c: Use catomic_* operations instead of atomic_*.
* malloc/memusage.c: Likewise.
* gmon/mcount.c: Likewise.
* elf/dl-close.c: Likewise.
* elf/dl-open.c: Likewise.
* elf/dl-profile.c: Likewise.
* elf/dl-sym.c: Likewise.
* elf/dl-runtime.c: Likewise.
* elf/dl-fptr.c: Likewise.
* resolv/res_libc.c: Likewise.

2006-10-10 Ulrich Drepper <drepper@redhat.com>

* nis/nis_subr.c (nis_getnames): Add trailing dot to NIS_PATH
Expand Down
4 changes: 2 additions & 2 deletions elf/dl-close.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions elf/dl-fptr.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions elf/dl-open.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
14 changes: 7 additions & 7 deletions elf/dl-profile.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -509,32 +509,32 @@ _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];
data[newarc].from_pc = frompc;
data[newarc].self_pc = selfpc;
data[newarc].count = 0;
fromp->link = 0;
atomic_increment (&narcs);
catomic_increment (&narcs);

break;
}
Expand All @@ -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:
;
Expand Down
8 changes: 4 additions & 4 deletions elf/dl-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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)
Expand Down Expand Up @@ -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);
}

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions elf/dl-sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gmon/mcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/*
Expand Down
Loading

0 comments on commit 8099361

Please sign in to comment.