diff options
author | NIIBE Yutaka <[email protected]> | 2022-04-05 05:42:59 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2022-04-05 05:42:59 +0000 |
commit | a36d71a8e33e817b1cc2fde5d0fd476ddc6ac560 (patch) | |
tree | 7aa12d0fcdced0062f11dba3c53935c4ab22fbdb /src/assuan-support.c | |
parent | core: Don't keep using deprecated ath_ API. (diff) | |
download | gpgme-a36d71a8e33e817b1cc2fde5d0fd476ddc6ac560.tar.gz gpgme-a36d71a8e33e817b1cc2fde5d0fd476ddc6ac560.zip |
core: Don't use internal __assuan functions.
* configure.ac (nanosleep): Detect.
* src/assuan-support.c: Don't use __assuan_usleep.
(my_socketpair): Don't use __assuan_socketpair.
--
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'src/assuan-support.c')
-rw-r--r-- | src/assuan-support.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/assuan-support.c b/src/assuan-support.c index 7f5b5da9..0bc003b9 100644 --- a/src/assuan-support.c +++ b/src/assuan-support.c @@ -30,7 +30,11 @@ #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +#endif #ifndef HAVE_W32_SYSTEM +#include <unistd.h> #include <sys/wait.h> #endif @@ -68,8 +72,28 @@ _gpgme_assuan_log_cb (assuan_context_t ctx, void *hook, static void my_usleep (assuan_context_t ctx, unsigned int usec) { - /* FIXME: Add to ath. */ - __assuan_usleep (ctx, usec); + (void)ctx; + + if (!usec) + return; + +#ifdef HAVE_W32_SYSTEM + Sleep (usec / 1000); +#else +# ifdef HAVE_NANOSLEEP + { + struct timespec req; + struct timespec rem; + + req.tv_sec = usec / 1000000; + req.tv_nsec = (usec % 1000000) * 1000; + while (nanosleep (&req, &rem) < 0 && errno == EINTR) + req = rem; + } +# else + usleep (usec); +# endif +#endif } @@ -312,8 +336,8 @@ static int my_socketpair (assuan_context_t ctx, int namespace, int style, int protocol, assuan_fd_t filedes[2]) { -#ifdef HAVE_W32_SYSTEM (void)ctx; +#ifdef HAVE_W32_SYSTEM (void)namespace; (void)style; (void)protocol; @@ -322,7 +346,7 @@ my_socketpair (assuan_context_t ctx, int namespace, int style, return -1; #else /* FIXME: Debug output missing. */ - return __assuan_socketpair (ctx, namespace, style, protocol, filedes); + return socketpair (namespace, style, protocol, filedes); #endif } |