1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

* sysdeps/generic/ldsodefs.h (_dl_load_lock): Declare it here with

__libc_lock_define_recursive.
	* elf/dl-open.c: Don't declare it here any more.
	* elf/dl-close.c: Likewise.
	* elf/dl-lookup.c: Likewise.
	* elf/dl-iteratephdr.c: Likewise.
	* elf/dl-lookup.c (add_dependency): Use __libc_lock_lock_recursive and
	__libc_lock_unlock_recursive.
	* elf/dl-close.c (_dl_close): Likewise
	* elf/dl-iteratephdr.c (__dl_iterate_phdr): Likewise
	* elf/dl-open.c (_dl_open): Likewise

	* sysdeps/generic/bits/libc-lock.h
	(__libc_lock_define_recursive): New macro.
	* sysdeps/generic/bits/stdio-lock.h (_IO_lock_t): Use it.
	(_IO_lock_lock): Use __libc_lock_lock_recursive.
	(_IO_lock_unlock): Use __libc_lock_unlock_recursive.
This commit is contained in:
Roland McGrath
2001-08-23 06:03:42 +00:00
parent 8179dcc108
commit c12aa80156
13 changed files with 91 additions and 72 deletions

View File

@ -1,5 +1,23 @@
2001-08-22 Roland McGrath <roland@frob.com> 2001-08-22 Roland McGrath <roland@frob.com>
* sysdeps/generic/ldsodefs.h (_dl_load_lock): Declare it here with
__libc_lock_define_recursive.
* elf/dl-open.c: Don't declare it here any more.
* elf/dl-close.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-iteratephdr.c: Likewise.
* elf/dl-lookup.c (add_dependency): Use __libc_lock_lock_recursive and
__libc_lock_unlock_recursive.
* elf/dl-close.c (_dl_close): Likewise
* elf/dl-iteratephdr.c (__dl_iterate_phdr): Likewise
* elf/dl-open.c (_dl_open): Likewise
* sysdeps/generic/bits/libc-lock.h
(__libc_lock_define_recursive): New macro.
* sysdeps/generic/bits/stdio-lock.h (_IO_lock_t): Use it.
(_IO_lock_lock): Use __libc_lock_lock_recursive.
(_IO_lock_unlock): Use __libc_lock_unlock_recursive.
* conform/conformtest.pl (checknamespace): Sort the output list. * conform/conformtest.pl (checknamespace): Sort the output list.
* sysdeps/generic/bits/poll.h (POLLWRBAND): New alias for POLLOUT. * sysdeps/generic/bits/poll.h (POLLWRBAND): New alias for POLLOUT.

View File

@ -1,5 +1,5 @@
/* libc-internal interface for mutex locks. Stub version. /* libc-internal interface for mutex locks. Stub version.
Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc. Copyright (C) 1996,97,99,2000,01 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -29,6 +29,7 @@
begins with a `*'), because its storage size will not be known outside begins with a `*'), because its storage size will not be known outside
of libc. */ of libc. */
#define __libc_lock_define(CLASS,NAME) #define __libc_lock_define(CLASS,NAME)
#define __libc_lock_define_recursive(CLASS,NAME)
#define __libc_rwlock_define(CLASS,NAME) #define __libc_rwlock_define(CLASS,NAME)
/* Define an initialized lock variable NAME with storage class CLASS. */ /* Define an initialized lock variable NAME with storage class CLASS. */

View File

@ -22,12 +22,17 @@
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
__libc_lock_define (typedef, _IO_lock_t) __libc_lock_define_recursive (typedef, _IO_lock_t)
/* We need recursive (counting) mutexes. */ /* We need recursive (counting) mutexes. */
#define _IO_lock_initializer ... #define _IO_lock_initializer ...
#error libio needs recursive mutexes for _IO_MTSAFE_IO #error libio needs recursive mutexes for _IO_MTSAFE_IO
#define _IO_lock_init(_name) __libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) __libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) __libc_lock_lock_recursive (_name)
#define _IO_lock_unlock(_name) __libc_lock_unlock_recursive (_name)
#define _IO_cleanup_region_start(_fct, _fp) \ #define _IO_cleanup_region_start(_fct, _fp) \
__libc_cleanup_region_start (_fct, _fp) __libc_cleanup_region_start (_fct, _fp)
@ -35,14 +40,6 @@ __libc_lock_define (typedef, _IO_lock_t)
__libc_cleanup_region_start (_fct, NULL) __libc_cleanup_region_start (_fct, NULL)
#define _IO_cleanup_region_end(_doit) \ #define _IO_cleanup_region_end(_doit) \
__libc_cleanup_region_end (_doit) __libc_cleanup_region_end (_doit)
#define _IO_lock_init(_name) \
__libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) \
__libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) \
__libc_lock_lock (_name)
#define _IO_lock_unlock(_name) \
__libc_lock_unlock (_name)
#endif /* bits/stdio-lock.h */ #endif /* bits/stdio-lock.h */

View File

@ -32,11 +32,6 @@
typedef void (*fini_t) (void); typedef void (*fini_t) (void);
/* During the program run we must not modify the global data of
loaded shared object simultanously in two threads. Therefore we
protect `dlopen' and `dlclose' in dlclose.c. */
__libc_lock_define (extern, _dl_load_lock)
void void
internal_function internal_function
_dl_close (void *_map) _dl_close (void *_map)
@ -61,7 +56,7 @@ _dl_close (void *_map)
_dl_signal_error (0, map->l_name, N_("shared object not open")); _dl_signal_error (0, map->l_name, N_("shared object not open"));
/* Acquire the lock. */ /* Acquire the lock. */
__libc_lock_lock (_dl_load_lock); __libc_lock_lock_recursive (_dl_load_lock);
/* Decrement the reference count. */ /* Decrement the reference count. */
if (map->l_opencount > 1 || map->l_type != lt_loaded) if (map->l_opencount > 1 || map->l_type != lt_loaded)
@ -80,7 +75,7 @@ _dl_close (void *_map)
/* One decrement the object itself, not the dependencies. */ /* One decrement the object itself, not the dependencies. */
--map->l_opencount; --map->l_opencount;
__libc_lock_unlock (_dl_load_lock); __libc_lock_unlock_recursive (_dl_load_lock);
return; return;
} }
@ -277,7 +272,7 @@ _dl_close (void *_map)
free (list); free (list);
/* Release the lock. */ /* Release the lock. */
__libc_lock_unlock (_dl_load_lock); __libc_lock_unlock_recursive (_dl_load_lock);
} }

View File

@ -23,8 +23,6 @@
#include <stddef.h> #include <stddef.h>
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
__libc_lock_define (extern, _dl_load_lock)
int int
__dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
size_t size, void *data), void *data) size_t size, void *data), void *data)
@ -34,7 +32,7 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
int ret = 0; int ret = 0;
/* Make sure we are alone. */ /* Make sure we are alone. */
__libc_lock_lock (_dl_load_lock); __libc_lock_lock_recursive (_dl_load_lock);
for (l = _dl_loaded; l != NULL; l = l->l_next) for (l = _dl_loaded; l != NULL; l = l->l_next)
{ {
@ -51,7 +49,7 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info,
} }
/* Release the lock. */ /* Release the lock. */
__libc_lock_unlock (_dl_load_lock); __libc_lock_unlock_recursive (_dl_load_lock);
return ret; return ret;
} }

View File

@ -61,15 +61,6 @@ struct sym_val
/* Statistics function. */ /* Statistics function. */
unsigned long int _dl_num_relocations; unsigned long int _dl_num_relocations;
/* During the program run we must not modify the global data of
loaded shared object simultanously in two threads. Therefore we
protect `_dl_open' and `_dl_close' in dl-close.c.
This must be a recursive lock since the initializer function of
the loaded object might as well require a call to this function.
At this time it is not anymore a problem to modify the tables. */
__libc_lock_define (extern, _dl_load_lock)
/* We have two different situations when looking up a simple: with or /* We have two different situations when looking up a simple: with or
without versioning. gcc is not able to optimize a single function without versioning. gcc is not able to optimize a single function
@ -92,7 +83,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map)
int result = 0; int result = 0;
/* Make sure nobody can unload the object while we are at it. */ /* Make sure nobody can unload the object while we are at it. */
__libc_lock_lock (_dl_load_lock); __libc_lock_lock_recursive (_dl_load_lock);
/* Determine whether UNDEF_MAP already has a reference to MAP. First /* Determine whether UNDEF_MAP already has a reference to MAP. First
look in the normal dependencies. */ look in the normal dependencies. */
@ -174,7 +165,7 @@ add_dependency (struct link_map *undef_map, struct link_map *map)
} }
/* Release the lock. */ /* Release the lock. */
__libc_lock_unlock (_dl_load_lock); __libc_lock_unlock_recursive (_dl_load_lock);
return result; return result;
} }

View File

@ -58,15 +58,6 @@ extern int _dl_lazy; /* Do we do lazy relocations? */
static void show_scope (struct link_map *new); static void show_scope (struct link_map *new);
#endif #endif
/* During the program run we must not modify the global data of
loaded shared object simultanously in two threads. Therefore we
protect `_dl_open' and `_dl_close' in dl-close.c.
This must be a recursive lock since the initializer function of
the loaded object might as well require a call to this function.
At this time it is not anymore a problem to modify the tables. */
__libc_lock_define (extern, _dl_load_lock)
extern size_t _dl_platformlen; extern size_t _dl_platformlen;
/* We must be carefull not to leave us in an inconsistent state. Thus we /* We must be carefull not to leave us in an inconsistent state. Thus we
@ -349,7 +340,7 @@ _dl_open (const char *file, int mode, const void *caller)
_dl_signal_error (EINVAL, file, N_("invalid mode for dlopen()")); _dl_signal_error (EINVAL, file, N_("invalid mode for dlopen()"));
/* Make sure we are alone. */ /* Make sure we are alone. */
__libc_lock_lock (_dl_load_lock); __libc_lock_lock_recursive (_dl_load_lock);
args.file = file; args.file = file;
args.mode = mode; args.mode = mode;
@ -363,7 +354,7 @@ _dl_open (const char *file, int mode, const void *caller)
#endif #endif
/* Release the lock. */ /* Release the lock. */
__libc_lock_unlock (_dl_load_lock); __libc_lock_unlock_recursive (_dl_load_lock);
if (errstring) if (errstring)
{ {

View File

@ -1,3 +1,21 @@
2001-08-22 Roland McGrath <roland@frob.com>
* sysdeps/pthread/bits/stdio-lock.h: Include <bits/libc-lock.h>
instead of <pthread.h>.
(_IO_lock_t): Define this typedef using __libc_lock_define_recursive.
(_IO_lock_initializer): Add braces.
(_IO_lock_lock): Use __libc_lock_lock_recursive.
(_IO_lock_unlock): Use __libc_lock_unlock_recursive.
* sysdeps/pthread/bits/libc-lock.h (__libc_lock_recursive_t): New type.
(__libc_lock_define_initialized_recursive): Use it.
(__libc_lock_init_recursive): Likewise.
(__libc_lock_fini_recursive): Likewise.
(__libc_lock_lock_recursive): Likewise.
(__libc_lock_trylock_recursive): Likewise.
(__libc_lock_unlock_recursive): Likewise.
(__libc_lock_define_recursive): New macro.
2001-08-14 Jakub Jelinek <jakub@redhat.com> 2001-08-14 Jakub Jelinek <jakub@redhat.com>
* lockfile.c (__pthread_provide_lockfile): New variable. * lockfile.c (__pthread_provide_lockfile): New variable.

View File

@ -26,8 +26,10 @@
#ifdef _LIBC #ifdef _LIBC
typedef pthread_mutex_t __libc_lock_t; typedef pthread_mutex_t __libc_lock_t;
typedef pthread_rwlock_t __libc_rwlock_t; typedef pthread_rwlock_t __libc_rwlock_t;
typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
#else #else
typedef struct __libc_lock_opaque__ __libc_lock_t; typedef struct __libc_lock_opaque__ __libc_lock_t;
typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
typedef struct __libc_rwlock_opaque__ __libc_rwlock_t; typedef struct __libc_rwlock_opaque__ __libc_rwlock_t;
#endif #endif
@ -45,6 +47,8 @@ typedef pthread_key_t __libc_key_t;
CLASS __libc_lock_t NAME; CLASS __libc_lock_t NAME;
#define __libc_rwlock_define(CLASS,NAME) \ #define __libc_rwlock_define(CLASS,NAME) \
CLASS __libc_rwlock_t NAME; CLASS __libc_rwlock_t NAME;
#define __libc_lock_define_recursive(CLASS,NAME) \
CLASS __libc_lock_recursive_t NAME;
/* Define an initialized lock variable NAME with storage class CLASS. /* Define an initialized lock variable NAME with storage class CLASS.
@ -68,8 +72,8 @@ typedef pthread_key_t __libc_key_t;
/* Define an initialized recursive lock variable NAME with storage /* Define an initialized recursive lock variable NAME with storage
class CLASS. */ class CLASS. */
#define __libc_lock_define_initialized_recursive(CLASS,NAME) \ #define __libc_lock_define_initialized_recursive(CLS,NAME) \
CLASS __libc_lock_t NAME = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; CLS __libc_lock_recursive_t NAME = {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP};
/* Initialize the named lock variable, leaving it in a consistent, unlocked /* Initialize the named lock variable, leaving it in a consistent, unlocked
state. */ state. */
@ -86,7 +90,7 @@ typedef pthread_key_t __libc_key_t;
pthread_mutexattr_t __attr; \ pthread_mutexattr_t __attr; \
__pthread_mutexattr_init (&__attr); \ __pthread_mutexattr_init (&__attr); \
__pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \ __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
__pthread_mutex_init (&(NAME), &__attr); \ __pthread_mutex_init (&(NAME).mutex, &__attr); \
__pthread_mutexattr_destroy (&__attr); \ __pthread_mutexattr_destroy (&__attr); \
} \ } \
} while (0); } while (0);
@ -100,7 +104,7 @@ typedef pthread_key_t __libc_key_t;
(__pthread_rwlock_destroy != NULL ? __pthread_rwlock_destroy (&(NAME)) : 0); (__pthread_rwlock_destroy != NULL ? __pthread_rwlock_destroy (&(NAME)) : 0);
/* Finalize recursive named lock. */ /* Finalize recursive named lock. */
#define __libc_lock_fini_recursive(NAME) __libc_lock_fini (NAME) #define __libc_lock_fini_recursive(NAME) __libc_lock_fini ((NAME).mutex)
/* Lock the named lock variable. */ /* Lock the named lock variable. */
#define __libc_lock_lock(NAME) \ #define __libc_lock_lock(NAME) \
@ -111,7 +115,7 @@ typedef pthread_key_t __libc_key_t;
(__pthread_rwlock_wrlock != NULL ? __pthread_rwlock_wrlock (&(NAME)) : 0); (__pthread_rwlock_wrlock != NULL ? __pthread_rwlock_wrlock (&(NAME)) : 0);
/* Lock the recursive named lock variable. */ /* Lock the recursive named lock variable. */
#define __libc_lock_lock_recursive(NAME) __libc_lock_lock (NAME) #define __libc_lock_lock_recursive(NAME) __libc_lock_lock ((NAME).mutex)
/* Try to lock the named lock variable. */ /* Try to lock the named lock variable. */
#define __libc_lock_trylock(NAME) \ #define __libc_lock_trylock(NAME) \
@ -124,7 +128,7 @@ typedef pthread_key_t __libc_key_t;
? __pthread_rwlock_trywrlock (&(NAME)) : 0) ? __pthread_rwlock_trywrlock (&(NAME)) : 0)
/* Try to lock the recursive named lock variable. */ /* Try to lock the recursive named lock variable. */
#define __libc_lock_trylock_recursive(NAME) __libc_lock_trylock (NAME) #define __libc_lock_trylock_recursive(NAME) __libc_lock_trylock ((NAME).mutex)
/* Unlock the named lock variable. */ /* Unlock the named lock variable. */
#define __libc_lock_unlock(NAME) \ #define __libc_lock_unlock(NAME) \
@ -133,7 +137,7 @@ typedef pthread_key_t __libc_key_t;
(__pthread_rwlock_unlock != NULL ? __pthread_rwlock_unlock (&(NAME)) : 0); (__pthread_rwlock_unlock != NULL ? __pthread_rwlock_unlock (&(NAME)) : 0);
/* Unlock the recursive named lock variable. */ /* Unlock the recursive named lock variable. */
#define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock (NAME) #define __libc_lock_unlock_recursive(NAME) __libc_lock_unlock ((NAME).mutex)
/* Define once control variable. */ /* Define once control variable. */

View File

@ -17,12 +17,17 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include <pthread.h> #include <bits/libc-lock.h>
typedef pthread_mutex_t _IO_lock_t; __libc_lock_define_recursive (typedef, _IO_lock_t)
/* We need recursive (counting) mutexes. */ /* We need recursive (counting) mutexes. */
#define _IO_lock_initializer PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #define _IO_lock_initializer {PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP}
#define _IO_lock_init(_name) __libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) __libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) __libc_lock_lock_recursive (_name)
#define _IO_lock_unlock(_name) __libc_lock_unlock_recursive (_name)
#define _IO_cleanup_region_start(_fct, _fp) \ #define _IO_cleanup_region_start(_fct, _fp) \
@ -40,11 +45,3 @@ typedef pthread_mutex_t _IO_lock_t;
} }
#define _IO_cleanup_region_end(_doit) \ #define _IO_cleanup_region_end(_doit) \
__libc_cleanup_region_end (_doit) __libc_cleanup_region_end (_doit)
#define _IO_lock_init(_name) \
__libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) \
__libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) \
__libc_lock_lock (_name)
#define _IO_lock_unlock(_name) \
__libc_lock_unlock (_name)

View File

@ -1,5 +1,5 @@
/* libc-internal interface for mutex locks. Stub version. /* libc-internal interface for mutex locks. Stub version.
Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc. Copyright (C) 1996,97,99,2000,01 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -29,6 +29,7 @@
begins with a `*'), because its storage size will not be known outside begins with a `*'), because its storage size will not be known outside
of libc. */ of libc. */
#define __libc_lock_define(CLASS,NAME) #define __libc_lock_define(CLASS,NAME)
#define __libc_lock_define_recursive(CLASS,NAME)
#define __libc_rwlock_define(CLASS,NAME) #define __libc_rwlock_define(CLASS,NAME)
/* Define an initialized lock variable NAME with storage class CLASS. */ /* Define an initialized lock variable NAME with storage class CLASS. */

View File

@ -22,12 +22,17 @@
#include <bits/libc-lock.h> #include <bits/libc-lock.h>
__libc_lock_define (typedef, _IO_lock_t) __libc_lock_define_recursive (typedef, _IO_lock_t)
/* We need recursive (counting) mutexes. */ /* We need recursive (counting) mutexes. */
#define _IO_lock_initializer ... #define _IO_lock_initializer ...
#error libio needs recursive mutexes for _IO_MTSAFE_IO #error libio needs recursive mutexes for _IO_MTSAFE_IO
#define _IO_lock_init(_name) __libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) __libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) __libc_lock_lock_recursive (_name)
#define _IO_lock_unlock(_name) __libc_lock_unlock_recursive (_name)
#define _IO_cleanup_region_start(_fct, _fp) \ #define _IO_cleanup_region_start(_fct, _fp) \
__libc_cleanup_region_start (_fct, _fp) __libc_cleanup_region_start (_fct, _fp)
@ -35,14 +40,6 @@ __libc_lock_define (typedef, _IO_lock_t)
__libc_cleanup_region_start (_fct, NULL) __libc_cleanup_region_start (_fct, NULL)
#define _IO_cleanup_region_end(_doit) \ #define _IO_cleanup_region_end(_doit) \
__libc_cleanup_region_end (_doit) __libc_cleanup_region_end (_doit)
#define _IO_lock_init(_name) \
__libc_lock_init_recursive (_name)
#define _IO_lock_fini(_name) \
__libc_lock_fini_recursive (_name)
#define _IO_lock_lock(_name) \
__libc_lock_lock (_name)
#define _IO_lock_unlock(_name) \
__libc_lock_unlock (_name)
#endif /* bits/stdio-lock.h */ #endif /* bits/stdio-lock.h */

View File

@ -31,6 +31,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <link.h> #include <link.h>
#include <dl-lookupcfg.h> #include <dl-lookupcfg.h>
#include <bits/libc-lock.h>
__BEGIN_DECLS __BEGIN_DECLS
@ -229,6 +230,16 @@ extern struct r_search_path_elem *_dl_init_all_dirs;
extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */ extern int _dl_sysdep_open_zero_fill (void); /* dl-sysdep.c */
/* During the program run we must not modify the global data of
loaded shared object simultanously in two threads. Therefore we
protect `_dl_open' and `_dl_close' in dl-close.c.
This must be a recursive lock since the initializer function of
the loaded object might as well require a call to this function.
At this time it is not anymore a problem to modify the tables. */
__libc_lock_define_recursive (extern, _dl_load_lock)
/* Write message on the debug file descriptor. The parameters are /* Write message on the debug file descriptor. The parameters are
interpreted as for a `printf' call. All the lines start with a interpreted as for a `printf' call. All the lines start with a
tag showing the PID. */ tag showing the PID. */