Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/include/reentrant.h,v rcsdiff: /ftp/cvs/cvsroot/src/lib/libc/include/reentrant.h,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.14 retrieving revision 1.14.10.1 diff -u -p -r1.14 -r1.14.10.1 --- src/lib/libc/include/reentrant.h 2009/01/11 02:46:28 1.14 +++ src/lib/libc/include/reentrant.h 2012/06/23 22:54:55 1.14.10.1 @@ -1,4 +1,4 @@ -/* $NetBSD: reentrant.h,v 1.14 2009/01/11 02:46:28 christos Exp $ */ +/* $NetBSD: reentrant.h,v 1.14.10.1 2012/06/23 22:54:55 riz Exp $ */ /*- * Copyright (c) 1997, 1998, 2003 The NetBSD Foundation, Inc. @@ -84,8 +84,6 @@ * */ -#ifdef _REENTRANT - /* * Abstract thread interface for thread-safe libraries. These routines * will use stubs in libc if the application is not linked against the @@ -124,6 +122,8 @@ #define once_t pthread_once_t #define ONCE_INITIALIZER PTHREAD_ONCE_INIT +#ifdef _REENTRANT + #ifndef __LIBC_THREAD_STUBS __BEGIN_DECLS @@ -254,7 +254,15 @@ __END_DECLS #define thr_getspecific(k) #define thr_keydelete(k) -#define thr_once(o, f) +static inline int +thr_once(once_t *once_control, void (*routine)(void)) +{ + if (__predict_false(once_control->pto_done == 0)) { + (*routine)(); + once_control->pto_done = 1; + } + return 0; +} #define thr_sigsetmask(f, n, o) #define thr_self() #define thr_errno()