* lib/tss.c: New file.
* modules/tss: New file.
* doc/posix-functions/tss_create.texi: Mention the new module.
* doc/posix-functions/tss_set.texi: Likewise.
* doc/posix-functions/tss_get.texi: Likewise.
* doc/posix-functions/tss_delete.texi: Likewise.
+2019-06-20 Bruno Haible <bruno@clisp.org>
+
+ tss: New module.
+ * lib/tss.c: New file.
+ * modules/tss: New file.
+ * doc/posix-functions/tss_create.texi: Mention the new module.
+ * doc/posix-functions/tss_set.texi: Likewise.
+ * doc/posix-functions/tss_get.texi: Likewise.
+ * doc/posix-functions/tss_delete.texi: Likewise.
+
2019-06-20 Bruno Haible <bruno@clisp.org>
cnd: New module.
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
@url{https://www.gnu.org/software/libc/manual/html_node/ISO-C-Thread_002dlocal-Storage.html}.
@end ifnotinfo
-Gnulib module: ---
+Gnulib module: tss
Portability problems fixed by Gnulib:
@itemize
+@item
+This function is missing on many platforms:
+glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
-@item
-This function is missing on many platforms:
-glibc 2.27, Mac OS X 10.5, FreeBSD 9.3, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, OSF/1 5.1, Solaris 11.3, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 9.0.
@end itemize
--- /dev/null
+/* ISO C 11 thread-specific storage in multithreaded situations.
+ Copyright (C) 2005-2019 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005, 2019. */
+
+#include <config.h>
+
+#include <threads.h>
+
+#include <string.h>
+
+#if defined _WIN32 && ! defined __CYGWIN__
+/* Use Windows threads. */
+
+# define WIN32_LEAN_AND_MEAN /* avoid including junk */
+# include <windows.h>
+
+#else
+/* Use POSIX threads. */
+
+# include <pthread.h>
+
+#endif
+
+#if defined _WIN32 && ! defined __CYGWIN__
+/* Use Windows threads. */
+
+int
+tss_create (tss_t *keyp, tss_dtor_t destructor)
+{
+ int err = glwthread_tls_key_create (keyp, destructor);
+ if (err == 0)
+ return thrd_success;
+ else
+ {
+ memset (keyp, '\0', sizeof (tss_t));
+ return thrd_error;
+ }
+}
+
+int
+tss_set (tss_t key, void *value)
+{
+ int err = glwthread_tls_set (key, value);
+ return (err == 0 ? thrd_success : thrd_error);
+}
+
+void *
+tss_get (tss_t key)
+{
+ return glwthread_tls_get (key);
+}
+
+void
+tss_delete (tss_t key)
+{
+ glwthread_tls_key_delete (key);
+}
+
+#else
+/* Use POSIX threads. */
+
+int
+tss_create (tss_t *keyp, tss_dtor_t destructor)
+{
+ int err = pthread_key_create (keyp, destructor);
+ if (err == 0)
+ return thrd_success;
+ else
+ {
+ memset (keyp, '\0', sizeof (tss_t));
+ return thrd_error;
+ }
+}
+
+int
+tss_set (tss_t key, void *value)
+{
+ int err = pthread_setspecific (key, value);
+ return (err == 0 ? thrd_success : thrd_error);
+}
+
+void *
+tss_get (tss_t key)
+{
+ return pthread_getspecific (key);
+}
+
+void
+tss_delete (tss_t key)
+{
+ pthread_key_delete (key);
+}
+
+#endif
--- /dev/null
+Description:
+ISO C 11 thread-specific storage functions.
+
+Files:
+lib/tss.c
+
+Depends-on:
+threads-h
+windows-tls
+
+configure.ac:
+AC_REQUIRE([gl_THREADS_H])
+if test $HAVE_THREADS_H = 0; then
+ AC_LIBOBJ([tss])
+fi
+gl_THREADS_MODULE_INDICATOR([tss])
+
+Makefile.am:
+
+Include:
+<threads.h>
+
+Link:
+$(LTLIBSTDTHREAD) when linking with libtool, $(LIBSTDTHREAD) otherwise
+
+License:
+LGPLv2+
+
+Maintainer:
+all