summaryrefslogtreecommitdiff
path: root/src/posix-thread.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2017-11-29 20:22:06 +0100
committerWerner Koch <wk@gnupg.org>2017-11-29 20:22:06 +0100
commitadc786d034b63176b941a1ef8d996acbf8d0ea5d (patch)
treeb19d82491cc7666f18cb44d2f7458f2f28fbe936 /src/posix-thread.c
parent1865c0ba1769b407a3c504f1ab0a4278704a9fc1 (diff)
downloadlibgpg-error-adc786d034b63176b941a1ef8d996acbf8d0ea5d.tar.gz
core: Unify syscall_clamp functions.
* src/estream.c (_gpgrt_set_syscall_clamp) (_gpgrt_get_syscall_clamp): Move to ... * src/syscall-clamp.c: new file. (_gpgrt_pre_syscall, _gpgrt_post_syscall): New. * src/Makefile.am (libgpg_error_la_SOURCES): Add that file. * src/estream.c: Replace the syscall wrapper with the new functions. * src/posix-lock.c: Ditto. * src/w32-lock.c: Ditto. * src/posix-thread.c: Ditto. * src/w32-thread.c: Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'src/posix-thread.c')
-rw-r--r--src/posix-thread.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/src/posix-thread.c b/src/posix-thread.c
index 00a43e2..36c81ba 100644
--- a/src/posix-thread.c
+++ b/src/posix-thread.c
@@ -39,27 +39,10 @@
# include <thread.h>
#endif
-#include "gpg-error.h"
+#include "gpgrt-int.h"
#include "thread.h"
-/*
- * Functions called before and after blocking syscalls.
- * gpgrt_set_syscall_clamp is used to set them.
- */
-static void (*pre_syscall_func)(void);
-static void (*post_syscall_func)(void);
-
-
-/* Helper to set the clamp functions. This is called as a helper from
- * _gpgrt_set_syscall_clamp to keep the function pointers local. */
-void
-_gpgrt_thread_set_syscall_clamp (void (*pre)(void), void (*post)(void))
-{
- pre_syscall_func = pre;
- post_syscall_func = post;
-}
-
gpg_err_code_t
@@ -67,20 +50,16 @@ _gpgrt_yield (void)
{
#if USE_POSIX_THREADS
# ifdef _POSIX_PRIORITY_SCHEDULING
- if (pre_syscall_func)
- pre_syscall_func ();
- sched_yield ();
- if (post_syscall_func)
- post_syscall_func ();
+ _gpgrt_pre_syscall ();
+ sched_yield ();
+ _gpgrt_post_syscall ();
# else
- return GPG_ERR_NOT_SUPPORTED;
+ return GPG_ERR_NOT_SUPPORTED;
# endif
#elif USE_SOLARIS_THREADS
- if (pre_syscall_func)
- pre_syscall_func ();
+ _gpgrt_pre_syscall ();
thr_yield ();
- if (post_syscall_func)
- post_syscall_func ();
+ _gpgrt_post_syscall ();
#else
return GPG_ERR_NOT_SUPPORTED;
#endif