diff options
author | Roland McGrath <roland@gnu.org> | 1996-07-09 11:09:08 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-07-09 11:09:08 +0000 |
commit | 3dbe15814da9f55274105b9b305941e573499576 (patch) | |
tree | ecf16ade1932d33b5a96e9831545af9bb9ddda89 | |
parent | d33f2ad4ab849eeffb2c3d19f1e81beed0592646 (diff) | |
download | glibc-3dbe15814da9f55274105b9b305941e573499576.zip glibc-3dbe15814da9f55274105b9b305941e573499576.tar.gz glibc-3dbe15814da9f55274105b9b305941e573499576.tar.bz2 |
Tue Jul 9 06:19:29 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* sysdeps/generic/machine-gmon.h [NO_UNDERSCORES]: Declare _mcount
before using it in lhs of weak_alias.
* nss/getXXent_r.c (setup): New function, broken out of SETFUNC_NAME.
Call __nss_lookup when not setting STARTP.
(SETFUNC_NAME, ENDFUNC_NAME, REENTRANT_GETNAME): Call it to set up for
function-calling loop.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | nss/getXXent_r.c | 75 | ||||
-rw-r--r-- | sysdeps/generic/machine-gmon.h | 9 |
3 files changed, 53 insertions, 41 deletions
@@ -1,3 +1,13 @@ +Tue Jul 9 06:19:29 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> + + * sysdeps/generic/machine-gmon.h [NO_UNDERSCORES]: Declare _mcount + before using it in lhs of weak_alias. + + * nss/getXXent_r.c (setup): New function, broken out of SETFUNC_NAME. + Call __nss_lookup when not setting STARTP. + (SETFUNC_NAME, ENDFUNC_NAME, REENTRANT_GETNAME): Call it to set up for + function-calling loop. + Tue Jul 9 00:14:52 1996 Michael I. Bushnell p/BSG <mib@gnu.ai.mit.edu> * sysdeps/mach/hurd/ioctls.h (MDMBUF, ECHO, TOSTOP, FLUSHO, diff --git a/nss/getXXent_r.c b/nss/getXXent_r.c index 07e5759..b6c73f3 100644 --- a/nss/getXXent_r.c +++ b/nss/getXXent_r.c @@ -99,7 +99,32 @@ __libc_lock_define_initialized (static, lock); /* The lookup function for the first entry of this service. */ extern int DB_LOOKUP_FCT (service_user **nip, const char *name, void **fctp); - +/* Set up NIP to run through the services. If ALL is zero, use NIP's + current location if it's not nil. Return nonzero if there are no + services (left). */ +static enum nss_status +setup (void **fctp, int all) +{ + int no_more; + if (startp == NULL) + { + no_more = DB_LOOKUP_FCT (&nip, SETFUNC_NAME_STRING, fctp); + startp = no_more ? (service_user *) -1 : nip; + } + else if (startp == (service_user *) -1) + /* No services at all. */ + return 1; + else + { + if (all || !nip) + /* Reset to the beginning of the service list. */ + nip = startp; + /* Look up the first function. */ + no_more = __nss_lookup (&nip, SETFUNC_NAME_STRING, fctp); + } + return no_more; +} + void SETFUNC_NAME (STAYOPEN) { @@ -116,15 +141,8 @@ SETFUNC_NAME (STAYOPEN) __libc_lock_lock (lock); - if (startp == NULL) - { - no_more = DB_LOOKUP_FCT (&nip, SETFUNC_NAME_STRING, (void **) &fct); - startp = no_more == 0 ? (service_user *) -1 : nip; - } - else - no_more = (nip = startp) != (service_user *) -1; - /* Cycle through all the services and run their setXXent functions. */ + no_more = setup ((void **) &fct, 1); while (! no_more) { /* Ignore status, we force check in __NSS_NEXT. */ @@ -153,16 +171,9 @@ ENDFUNC_NAME (void) __libc_lock_lock (lock); - if (startp == NULL) - { - no_more = DB_LOOKUP_FCT (&nip, SETFUNC_NAME_STRING, (void **) &fct); - startp = no_more == 0 ? (service_user *) -1 : nip; - } - else - no_more = (nip = startp) != (service_user *) -1; - /* Cycle through all the services and run their endXXent functions. */ - while (no_more == 0) + no_more = setup ((void **) &fct, 1); + while (! no_more) { /* Ignore status, we force check in __NSS_NEXT. */ (void) (*fct) (); @@ -179,7 +190,7 @@ REENTRANT_GETNAME (LOOKUP_TYPE *result, char *buffer, int buflen H_ERRNO_PARM) { get_function fct; int no_more; - enum nss_status status = NSS_STATUS_NOTFOUND; + enum nss_status status; #ifdef NEED__RES if ((_res.options & RES_INIT) == 0 && res_init () == -1) @@ -189,26 +200,16 @@ REENTRANT_GETNAME (LOOKUP_TYPE *result, char *buffer, int buflen H_ERRNO_PARM) } #endif /* need _res */ - __libc_lock_lock (lock); + /* Initialize status to return if no more functions are found. */ + status = NSS_STATUS_NOTFOUND; - if (nip) - /* Continuing a walk-through started before. */ - no_more = 0; - else - { - if (startp == NULL) - { - no_more = DB_LOOKUP_FCT (&nip, SETFUNC_NAME_STRING, (void **) &fct); - startp = no_more == 0 ? (service_user *) -1 : nip; - } - else - no_more = (nip = startp) != (service_user *) -1; - - if (no_more != 0) - status = NSS_STATUS_UNAVAIL; - } + __libc_lock_lock (lock); - while (no_more == 0) + /* Run through available functions, starting with the same function last + run. We will repeat each function as long as it succeeds, and then go + on to the next service action. */ + no_more = setup ((void **) &fct, 0); + while (! no_more) { status = (*fct) (result, buffer, buflen H_ERRNO_VAR); diff --git a/sysdeps/generic/machine-gmon.h b/sysdeps/generic/machine-gmon.h index 3c6fb68..80ee97f 100644 --- a/sysdeps/generic/machine-gmon.h +++ b/sysdeps/generic/machine-gmon.h @@ -31,6 +31,11 @@ Cambridge, MA 02139, USA. */ /* The asm symbols for C functions are `_function'. The canonical name for the counter function is `mcount', no _. */ void _mcount (void) asm ("mcount"); +#else +/* The canonical name for the function is `_mcount' in both C and asm, + but some old asm code might assume it's `mcount'. */ +void _mcount (void); +weak_alias (_mcount, mcount) #endif #define _MCOUNT_DECL(frompc, selfpc) \ @@ -42,7 +47,3 @@ void _mcount (void) \ mcount_internal ((u_long) __builtin_return_address (0), \ (u_long) __builtin_return_address (1)); \ } - -#ifdef NO_UNDERSCORES -weak_alias (_mcount, mcount) -#endif |