diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Makefile.am | 10 | ||||
-rw-r--r-- | common/estream.c | 29 | ||||
-rw-r--r-- | common/exechelp-posix.c | 36 | ||||
-rw-r--r-- | common/exechelp-w32.c | 10 | ||||
-rw-r--r-- | common/exechelp-w32ce.c | 20 | ||||
-rw-r--r-- | common/http.c | 22 | ||||
-rw-r--r-- | common/init.c | 14 | ||||
-rw-r--r-- | common/sysutils.c | 12 |
8 files changed, 66 insertions, 87 deletions
diff --git a/common/Makefile.am b/common/Makefile.am index bb996bab7..2ff4ade48 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -106,22 +106,22 @@ else common_sources += exechelp-posix.c endif -# Sources only useful without PTH. -without_pth_sources = \ +# Sources only useful without NPTH. +without_npth_sources = \ get-passphrase.c get-passphrase.h -libcommon_a_SOURCES = $(jnlib_sources) $(common_sources) $(without_pth_sources) +libcommon_a_SOURCES = $(jnlib_sources) $(common_sources) $(without_npth_sources) if USE_DNS_SRV libcommon_a_SOURCES += srv.c endif -libcommon_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) -DWITHOUT_GNU_PTH=1 +libcommon_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) -DWITHOUT_NPTH=1 libcommonpth_a_SOURCES = $(jnlib_sources) $(common_sources) if USE_DNS_SRV libcommonpth_a_SOURCES += srv.c endif -libcommonpth_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS) +libcommonpth_a_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) $(NPTH_CFLAGS) if !HAVE_W32CE_SYSTEM libsimple_pwquery_a_SOURCES = \ diff --git a/common/estream.c b/common/estream.c index 6b7bd8b75..81a12428a 100644 --- a/common/estream.c +++ b/common/estream.c @@ -85,13 +85,13 @@ # include <gpg-error.h> /* ERRNO replacement. */ #endif -#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ -# undef HAVE_PTH -# undef USE_GNU_PTH +#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ +# undef HAVE_NPTH +# undef USE_NPTH #endif -#ifdef HAVE_PTH -# include <pth.h> +#ifdef HAVE_NPTH +# include <npth.h> #endif /* This is for the special hack to use estream.c in GnuPG. */ @@ -159,7 +159,7 @@ typedef void (*func_free_t) (void *mem); /* Locking. */ -#ifdef HAVE_PTH +#ifdef HAVE_NPTH typedef pth_mutex_t estream_mutex_t; # define ESTREAM_MUTEX_INITIALIZER PTH_MUTEX_INIT @@ -197,7 +197,7 @@ dummy_mutex_call_int (estream_mutex_t mutex) /* Primitive system I/O. */ -#ifdef HAVE_PTH +#ifdef HAVE_NPTH # define ESTREAM_SYS_READ do_pth_read # define ESTREAM_SYS_WRITE do_pth_write # define ESTREAM_SYS_YIELD() pth_yield (NULL) @@ -450,7 +450,7 @@ do_list_remove (estream_t stream, int with_locked_list) * write, assuming that we do I/O on a plain file where the operation * can't block. */ -#ifdef HAVE_PTH +#ifdef HAVE_NPTH static int do_pth_read (int fd, void *buffer, size_t size) { @@ -476,7 +476,7 @@ do_pth_write (int fd, const void *buffer, size_t size) return pth_write (fd, buffer, size); # endif /* !HAVE_W32_SYSTEM*/ } -#endif /*HAVE_PTH*/ +#endif /*HAVE_NPTH*/ @@ -507,7 +507,7 @@ do_init (void) if (!initialized) { -#ifdef HAVE_PTH +#ifdef HAVE_NPTH if (!pth_init () && errno != EPERM ) return -1; if (pth_mutex_init (&estream_list_lock)) @@ -1033,7 +1033,7 @@ es_func_w32_read (void *cookie, void *buffer, size_t size) { do { -#ifdef HAVE_PTH +#ifdef HAVE_NPTH /* Note: Our pth_read actually uses HANDLE! */ bytes_read = pth_read ((int)w32_cookie->hd, buffer, size); #else @@ -1078,7 +1078,7 @@ es_func_w32_write (void *cookie, const void *buffer, size_t size) { do { -#ifdef HAVE_PTH +#ifdef HAVE_NPTH /* Note: Our pth_write actually uses HANDLE! */ bytes_written = pth_write ((int)w32_cookie->hd, buffer, size); #else @@ -2713,7 +2713,6 @@ es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode) return stream; } - /* This is the same as es_fopenmem but intializes the memory with a copy of (DATA,DATALEN). The stream is initally set to the @@ -2744,10 +2743,6 @@ es_fopenmem_init (size_t memlimit, const char *ES__RESTRICT mode, es_set_indicators (stream, 0, 0); } } - - if (stream) - stream->intern->func_ioctl = es_func_mem_ioctl; - return stream; } diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c index 5479fe3fc..976d0dde5 100644 --- a/common/exechelp-posix.c +++ b/common/exechelp-posix.c @@ -35,13 +35,13 @@ #include <unistd.h> #include <fcntl.h> -#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ -#undef HAVE_PTH -#undef USE_GNU_PTH +#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ +#undef HAVE_NPTH +#undef USE_NPTH #endif -#ifdef USE_GNU_PTH -#include <pth.h> +#ifdef USE_NPTH +#include <npth.h> #endif #include <sys/wait.h> @@ -388,11 +388,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], } -#ifdef USE_GNU_PTH - *pid = pth_fork? pth_fork () : fork (); -#else *pid = fork (); -#endif if (*pid == (pid_t)(-1)) { err = gpg_err_make (errsource, gpg_err_code_from_syserror ()); @@ -454,11 +450,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], { gpg_error_t err; -#ifdef USE_GNU_PTH - *pid = pth_fork? pth_fork () : fork (); -#else *pid = fork (); -#endif if (*pid == (pid_t)(-1)) { err = gpg_error_from_syserror (); @@ -491,16 +483,12 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode) if (pid == (pid_t)(-1)) return gpg_error (GPG_ERR_INV_VALUE); -#ifdef USE_GNU_PTH - if (pth_waitpid) - i = pth_waitpid (pid, &status, hang? 0:WNOHANG); - else +#ifdef USE_NPTH + i = npth_waitpid (pid, &status, hang? 0:WNOHANG); +#else + while ((i=waitpid (pid, &status, hang? 0:WNOHANG)) == (pid_t)(-1) + && errno == EINTR); #endif - { - while ((i=waitpid (pid, &status, hang? 0:WNOHANG)) == (pid_t)(-1) - && errno == EINTR) - ; - } if (i == (pid_t)(-1)) { @@ -569,11 +557,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], if (access (pgmname, X_OK)) return gpg_error_from_syserror (); -#ifdef USE_GNU_PTH - pid = pth_fork? pth_fork () : fork (); -#else pid = fork (); -#endif if (pid == (pid_t)(-1)) { log_error (_("error forking process: %s\n"), strerror (errno)); diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c index a8fbd1587..a25a724a8 100644 --- a/common/exechelp-w32.c +++ b/common/exechelp-w32.c @@ -35,13 +35,13 @@ #include <unistd.h> #include <fcntl.h> -#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ -#undef HAVE_PTH -#undef USE_GNU_PTH +#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ +#undef HAVE_NPTH +#undef USE_NPTH #endif -#ifdef USE_GNU_PTH -#include <pth.h> +#ifdef USE_NPTH +#include <npth.h> #endif #ifdef HAVE_STAT diff --git a/common/exechelp-w32ce.c b/common/exechelp-w32ce.c index 1bc2d6c3a..0583c0b53 100644 --- a/common/exechelp-w32ce.c +++ b/common/exechelp-w32ce.c @@ -35,13 +35,13 @@ #include <unistd.h> #include <fcntl.h> -#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ -#undef HAVE_PTH -#undef USE_GNU_PTH +#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ +#undef HAVE_NPTH +#undef USE_NPTH #endif -#ifdef USE_GNU_PTH -#include <pth.h> +#ifdef USE_NPTH +#include <npth.h> #endif #ifdef HAVE_STAT @@ -73,7 +73,7 @@ #define handle_to_pid(a) ((int)(a)) -#ifdef USE_GNU_PTH +#ifdef USE_NPTH /* The data passed to the feeder_thread. */ struct feeder_thread_parms { @@ -171,9 +171,9 @@ leave: xfree (parm); return NULL; } -#endif /*USE_GNU_PTH*/ +#endif /*USE_NPTH*/ -#ifdef USE_GNU_PTH +#ifdef USE_NPTH static void feeder_onclose_notification (estream_t stream, void *opaque) { @@ -182,7 +182,7 @@ feeder_onclose_notification (estream_t stream, void *opaque) log_debug ("feeder(%p): received onclose note\n", parm->hd); parm->stream_valid = 0; } -#endif /*USE_GNU_PTH*/ +#endif /*USE_NPTH*/ /* Fire up a thread to copy data between STREAM and a pipe's descriptor FD. With DIRECTION set to true the copy takes place @@ -191,7 +191,7 @@ feeder_onclose_notification (estream_t stream, void *opaque) static gpg_error_t start_feeder (estream_t stream, HANDLE hd, int direction) { -#ifdef USE_GNU_PTH +#ifdef USE_NPTH gpg_error_t err; struct feeder_thread_parms *parm; pth_attr_t tattr; diff --git a/common/http.c b/common/http.c index 7df84576f..ac5928bc1 100644 --- a/common/http.c +++ b/common/http.c @@ -59,13 +59,13 @@ # include <netdb.h> #endif /*!HAVE_W32_SYSTEM*/ -#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ -# undef HAVE_PTH -# undef USE_GNU_PTH +#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ +# undef HAVE_NPTH +# undef USE_NPTH #endif -#ifdef HAVE_PTH -# include <pth.h> +#ifdef HAVE_NPTH +# include <npth.h> #endif @@ -105,7 +105,7 @@ struct srventry #endif/*!USE_DNS_SRV*/ -#ifdef HAVE_PTH +#ifdef HAVE_NPTH # define my_select(a,b,c,d,e) pth_select ((a), (b), (c), (d), (e)) # define my_connect(a,b,c) pth_connect ((a), (b), (c)) # define my_accept(a,b,c) pth_accept ((a), (b), (c)) @@ -1887,15 +1887,15 @@ write_server (int sock, const char *data, size_t length) nleft = length; while (nleft > 0) { -#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_PTH) +#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_NPTH) nwritten = send (sock, data, nleft, 0); if ( nwritten == SOCKET_ERROR ) { log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ()); return gpg_error (GPG_ERR_NETWORK); } -#else /*!HAVE_W32_SYSTEM || HAVE_PTH*/ -# ifdef HAVE_PTH +#else /*!HAVE_W32_SYSTEM || HAVE_NPTH*/ +# ifdef HAVE_NPTH nwritten = pth_write (sock, data, nleft); # else nwritten = write (sock, data, nleft); @@ -1916,7 +1916,7 @@ write_server (int sock, const char *data, size_t length) log_info ("network write failed: %s\n", strerror (errno)); return gpg_error_from_syserror (); } -#endif /*!HAVE_W32_SYSTEM || HAVE_PTH*/ +#endif /*!HAVE_W32_SYSTEM || HAVE_NPTH*/ nleft -= nwritten; data += nwritten; } @@ -1971,7 +1971,7 @@ cookie_read (void *cookie, void *buffer, size_t size) { do { -#ifdef HAVE_PTH +#ifdef HAVE_NPTH nread = pth_read (c->sock->fd, buffer, size); #elif defined(HAVE_W32_SYSTEM) /* Under Windows we need to use recv for a socket. */ diff --git a/common/init.c b/common/init.c index bcb0cd4ea..f551416c5 100644 --- a/common/init.c +++ b/common/init.c @@ -19,16 +19,16 @@ #include <config.h> -#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ -#undef HAVE_PTH -#undef USE_GNU_PTH +#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ +#undef HAVE_NPTH +#undef USE_NPTH #endif #ifdef HAVE_W32_SYSTEM #include <windows.h> #endif -#ifdef HAVE_PTH -#include <pth.h> +#ifdef HAVE_NPTH +#include <npth.h> #endif #ifdef HAVE_W32CE_SYSTEM # include <assuan.h> /* For _assuan_w32ce_finish_pipe. */ @@ -87,7 +87,7 @@ init_common_subsystems (int *argcp, char ***argvp) places. If we are building with PTH we let pth_init do it. We can't do much on error so we ignore them. An error would anyway later pop up if one of the socket functions is used. */ -# ifdef HAVE_PTH +# ifdef HAVE_NPTH pth_init (); # else { @@ -95,7 +95,7 @@ init_common_subsystems (int *argcp, char ***argvp) WSAStartup (0x202, &wsadat); } -# endif /*!HAVE_PTH*/ +# endif /*!HAVE_NPTH*/ #endif #ifdef HAVE_W32CE_SYSTEM diff --git a/common/sysutils.c b/common/sysutils.c index 648e70fe6..2c16978f5 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -20,9 +20,9 @@ #include <config.h> -#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ -# undef HAVE_PTH -# undef USE_GNU_PTH +#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */ +# undef HAVE_NPTH +# undef USE_NPTH #endif #include <stdio.h> @@ -46,8 +46,8 @@ # define WINVER 0x0500 /* Required for AllowSetForegroundWindow. */ # include <windows.h> #endif -#ifdef HAVE_PTH -# include <pth.h> +#ifdef HAVE_NPTH +# include <npth.h> #endif #include <fcntl.h> @@ -259,7 +259,7 @@ check_permissions(const char *path,int extension,int checkonly) void gnupg_sleep (unsigned int seconds) { -#ifdef HAVE_PTH +#ifdef HAVE_NPTH /* With Pth we force a regular sleep for seconds == 0 so that also the process will give up its timeslot. */ if (!seconds) |