summaryrefslogtreecommitdiff
path: root/tests/glthread
diff options
context:
space:
mode:
authorStephen Kitt <skitt@debian.org>2016-05-27 10:11:04 +0200
committerManuel A. Fernandez Montecelo <manuel.montezelo@gmail.com>2016-05-27 14:28:33 +0100
commit752fd7247bc223bcea35bd89cf56d1c08ead9ba6 (patch)
treeb4a428f847a963738faaf24c8eff070fdb03a3a5 /tests/glthread
parent9f7d4fa477ff2a51d7c932b13d57ac22dc033105 (diff)
parenta9a31b1de5776a3b08a82101a4fa711294f0dd1d (diff)
Imported Debian patch 0.9.6+really0.9.3-0.1debian/0.9.6+really0.9.3-0.1
Diffstat (limited to 'tests/glthread')
-rw-r--r--tests/glthread/thread.c24
-rw-r--r--tests/glthread/thread.h64
-rw-r--r--tests/glthread/yield.h10
3 files changed, 22 insertions, 76 deletions
diff --git a/tests/glthread/thread.c b/tests/glthread/thread.c
index d3829ce..5237994 100644
--- a/tests/glthread/thread.c
+++ b/tests/glthread/thread.c
@@ -1,5 +1,5 @@
/* Creating and controlling threads.
- Copyright (C) 2005-2015 Free Software Foundation, Inc.
+ Copyright (C) 2005-2010 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
@@ -12,7 +12,8 @@
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 <http://www.gnu.org/licenses/>. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
@@ -21,7 +22,6 @@
#include <config.h>
/* Specification. */
-# define _GLTHREAD_THREAD_INLINE _GL_EXTERN_INLINE
#include "glthread/thread.h"
#include <stdlib.h>
@@ -29,21 +29,7 @@
/* ========================================================================= */
-#if USE_POSIX_THREADS
-
-#include <pthread.h>
-
-#ifdef PTW32_VERSION
-
-const gl_thread_t gl_null_thread /* = { .p = NULL } */;
-
-#endif
-
-#endif
-
-/* ========================================================================= */
-
-#if USE_WINDOWS_THREADS
+#if USE_WIN32_THREADS
#include <process.h>
@@ -86,7 +72,7 @@ struct gl_thread_struct
};
/* Return a real HANDLE object for the current thread. */
-static HANDLE
+static inline HANDLE
get_current_thread_handle (void)
{
HANDLE this_handle;
diff --git a/tests/glthread/thread.h b/tests/glthread/thread.h
index 2817437..d35be0d 100644
--- a/tests/glthread/thread.h
+++ b/tests/glthread/thread.h
@@ -1,5 +1,5 @@
/* Creating and controlling threads.
- Copyright (C) 2005-2015 Free Software Foundation, Inc.
+ Copyright (C) 2005-2010 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
@@ -12,7 +12,8 @@
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 <http://www.gnu.org/licenses/>. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* Written by Bruno Haible <bruno@clisp.org>, 2005.
Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
@@ -46,13 +47,9 @@
current = gl_thread_self ();
extern gl_thread_t gl_thread_self (void);
- Getting a reference to the current thread as a pointer, for debugging:
- ptr = gl_thread_self_pointer ();
- extern void * gl_thread_self_pointer (void);
-
Terminating the current thread:
gl_thread_exit (return_value);
- extern _Noreturn void gl_thread_exit (void *return_value);
+ extern void gl_thread_exit (void *return_value) __attribute__ ((noreturn));
Requesting custom code to be executed at fork() time(not supported on all
platforms):
@@ -74,14 +71,6 @@
#include <errno.h>
#include <stdlib.h>
-#ifndef _GL_INLINE_HEADER_BEGIN
- #error "Please include config.h first."
-#endif
-_GL_INLINE_HEADER_BEGIN
-#ifndef _GLTHREAD_THREAD_INLINE
-# define _GLTHREAD_THREAD_INLINE _GL_INLINE
-#endif
-
/* ========================================================================= */
#if USE_POSIX_THREADS
@@ -123,13 +112,7 @@ extern int glthread_in_use (void);
address of a function in libpthread that we don't use. */
# pragma weak pthread_create
-
-# ifdef __clang__
- /* Without this, clang complains that pthread_sigmask is never declared. */
-# include <signal.h>
-# endif
# pragma weak pthread_sigmask
-
# pragma weak pthread_join
# ifndef pthread_self
# pragma weak pthread_self
@@ -164,20 +147,8 @@ typedef pthread_t gl_thread_t;
(pthread_in_use () ? pthread_sigmask (HOW, SET, OSET) : 0)
# define glthread_join(THREAD, RETVALP) \
(pthread_in_use () ? pthread_join (THREAD, RETVALP) : 0)
-# ifdef PTW32_VERSION
- /* In pthreads-win32, pthread_t is a struct with a pointer field 'p' and
- other fields. */
-# define gl_thread_self() \
- (pthread_in_use () ? pthread_self () : gl_null_thread)
-# define gl_thread_self_pointer() \
- (pthread_in_use () ? pthread_self ().p : NULL)
-extern const gl_thread_t gl_null_thread;
-# else
-# define gl_thread_self() \
- (pthread_in_use () ? pthread_self () : (pthread_t) NULL)
-# define gl_thread_self_pointer() \
- (pthread_in_use () ? (void *) pthread_self () : NULL)
-# endif
+# define gl_thread_self() \
+ (pthread_in_use () ? (void *) pthread_self () : NULL)
# define gl_thread_exit(RETVAL) \
(pthread_in_use () ? pthread_exit (RETVAL) : 0)
@@ -234,9 +205,7 @@ typedef pth_t gl_thread_t;
# define glthread_join(THREAD, RETVALP) \
(pth_in_use () && !pth_join (THREAD, RETVALP) ? errno : 0)
# define gl_thread_self() \
- (pth_in_use () ? (void *) pth_self () : NULL)
-# define gl_thread_self_pointer() \
- gl_thread_self ()
+ (pth_in_use () ? (void *) pth_self () : 0)
# define gl_thread_exit(RETVAL) \
(pth_in_use () ? pth_exit (RETVAL) : 0)
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
@@ -288,9 +257,7 @@ typedef thread_t gl_thread_t;
# define glthread_join(THREAD, RETVALP) \
(thread_in_use () ? thr_join (THREAD, NULL, RETVALP) : 0)
# define gl_thread_self() \
- (thread_in_use () ? (void *) thr_self () : NULL)
-# define gl_thread_self_pointer() \
- gl_thread_self ()
+ (thread_in_use () ? (void *) thr_self () : 0)
# define gl_thread_exit(RETVAL) \
(thread_in_use () ? thr_exit (RETVAL) : 0)
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
@@ -303,9 +270,8 @@ typedef thread_t gl_thread_t;
/* ========================================================================= */
-#if USE_WINDOWS_THREADS
+#if USE_WIN32_THREADS
-# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# ifdef __cplusplus
@@ -332,8 +298,6 @@ typedef struct gl_thread_struct *gl_thread_t;
glthread_join_func (THREAD, RETVALP)
# define gl_thread_self() \
gl_thread_self_func ()
-# define gl_thread_self_pointer() \
- gl_thread_self ()
# define gl_thread_exit(RETVAL) \
gl_thread_exit_func (RETVAL)
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
@@ -350,7 +314,7 @@ extern int gl_thread_exit_func (void *retval);
/* ========================================================================= */
-#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS)
/* Provide dummy implementation if threads are not supported. */
@@ -358,9 +322,7 @@ typedef int gl_thread_t;
# define glthread_create(THREADP, FUNC, ARG) ENOSYS
# define glthread_sigmask(HOW, SET, OSET) 0
# define glthread_join(THREAD, RETVALP) 0
-# define gl_thread_self() 0
-# define gl_thread_self_pointer() \
- ((void *) gl_thread_self ())
+# define gl_thread_self() NULL
# define gl_thread_exit(RETVAL) 0
# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0
@@ -374,7 +336,7 @@ typedef int gl_thread_t;
extern "C" {
#endif
-_GLTHREAD_THREAD_INLINE gl_thread_t
+static inline gl_thread_t
gl_thread_create (void *(*func) (void *arg), void *arg)
{
gl_thread_t thread;
@@ -411,6 +373,4 @@ gl_thread_create (void *(*func) (void *arg), void *arg)
}
#endif
-_GL_INLINE_HEADER_END
-
#endif /* _GLTHREAD_THREAD_H */
diff --git a/tests/glthread/yield.h b/tests/glthread/yield.h
index b18db5b..df61ac4 100644
--- a/tests/glthread/yield.h
+++ b/tests/glthread/yield.h
@@ -1,5 +1,5 @@
/* Yielding the processor to other threads and processes.
- Copyright (C) 2005-2015 Free Software Foundation, Inc.
+ Copyright (C) 2005-2010 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
@@ -12,7 +12,8 @@
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 <http://www.gnu.org/licenses/>. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/* This file contains a primitive for yielding the processor to other threads.
extern void gl_thread_yield (void);
@@ -88,9 +89,8 @@ extern "C" {
/* ========================================================================= */
-#if USE_WINDOWS_THREADS
+#if USE_WIN32_THREADS
-# define WIN32_LEAN_AND_MEAN /* avoid including junk */
# include <windows.h>
# ifdef __cplusplus
@@ -108,7 +108,7 @@ extern "C" {
/* ========================================================================= */
-#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
+#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WIN32_THREADS)
/* Provide dummy implementation if threads are not supported. */