Module Name: src
Committed By: joerg
Date: Sun Jun 3 21:27:30 UTC 2012
Modified Files:
src/lib/libc/include: reentrant.h
Log Message:
Provide a usable thr_once for !_REENTRANT
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/include/reentrant.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/include/reentrant.h
diff -u src/lib/libc/include/reentrant.h:1.14 src/lib/libc/include/reentrant.h:1.15
--- src/lib/libc/include/reentrant.h:1.14 Sun Jan 11 02:46:28 2009
+++ src/lib/libc/include/reentrant.h Sun Jun 3 21:27:30 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: reentrant.h,v 1.14 2009/01/11 02:46:28 christos Exp $ */
+/* $NetBSD: reentrant.h,v 1.15 2012/06/03 21:27:30 joerg 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()