2018-07-24 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+ [BZ #14092]
+ * conform/data/threads.h-data (ONCE_FLAG_INIT): New macro.
+ (once_flag): New type.
+ (call_once): New function.
+ * nptl/Makefile (libpthread-routines): Add call_once object.
+ * nptl/Versions (libphread) [GLIBC_2.28]: Add call_once symbol.
+ * nptl/call_once.c: New file.
+ * sysdeps/nptl/threads.h (ONCE_FLAG_INIT): New define.
+ (once_flag): New type.
+ (call_once): New prototype.
+
[BZ #14092]
* conform/data/threads.h-data (mtx_plain): New constant.
(mtx_recursive): Likewise.
#if defined ISO11
+macro ONCE_FLAG_INIT
+
constant thrd_success
constant thrd_busy
constant thrd_error
type thrd_t
type thrd_start_t
type mtx_t
+type once_flag
function int thrd_create (thrd_t*, thrd_start_t, void*)
function int thrd_equal (thrd_t, thrd_t)
function int mtx_unlock (mtx_t*)
function void mtx_destroy (mtx_t*)
+function void call_once (once_flag*, void (*)(void))
+
#include "time.h-data"
#endif
pthread_setattr_default_np pthread_getattr_default_np \
thrd_create thrd_detach thrd_exit thrd_join \
mtx_destroy mtx_init mtx_lock mtx_timedlock \
- mtx_trylock mtx_unlock
+ mtx_trylock mtx_unlock call_once
# pthread_setuid pthread_seteuid pthread_setreuid \
# pthread_setresuid \
# pthread_setgid pthread_setegid pthread_setregid \
GLIBC_2.28 {
thrd_create; thrd_detach; thrd_exit; thrd_join;
mtx_init; mtx_lock; mtx_timedlock; mtx_trylock; mtx_unlock; mtx_destroy;
+ call_once;
}
GLIBC_PRIVATE {
--- /dev/null
+/* C11 threads call once implementation.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdalign.h>
+
+#include "thrd_priv.h"
+
+void
+call_once (once_flag *flag, void (*func)(void))
+{
+ _Static_assert (sizeof (once_flag) == sizeof (pthread_once_t),
+ "sizeof (once_flag) != sizeof (pthread_once_t)");
+ _Static_assert (alignof (once_flag) == alignof (pthread_once_t),
+ "alignof (once_flag) != alignof (pthread_once_t)");
+ __pthread_once (&flag->__data, func);
+}
mtx_timed = 2
};
+typedef struct
+{
+ int __data __ONCE_ALIGNMENT;
+} once_flag;
+#define ONCE_FLAG_INIT { 0 }
+
typedef union
{
char __size[__SIZEOF_PTHREAD_MUTEX_T];
/* Destroy the mutex object pointed by __MUTEX. */
extern void mtx_destroy (mtx_t *__mutex);
+
+/* Call function __FUNC exactly once, even if invoked from several threads.
+ All calls must be made with the same __FLAGS object. */
+extern void call_once (once_flag *__flag, void (*__func)(void));
+
__END_DECLS
#endif /* _THREADS_H */