+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,
/* 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;
+}
+\f
void
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. */
__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) ();
{
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)
}
#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);
/* 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) \
mcount_internal ((u_long) __builtin_return_address (0), \
(u_long) __builtin_return_address (1)); \
}
-
-#ifdef NO_UNDERSCORES
-weak_alias (_mcount, mcount)
-#endif