mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
common: Cleanup the use of USE_NPTH and HAVE_NPTH macros.
* configure.ac (HAVE_NPTH): New ac_define. * common/estream.c: Use USE_NPTH instead of HAVE_NPTH. * common/http.c: Ditto. Replace remaining calls to pth by npth calls. (connect_server): Remove useless _(). * common/exechelp-posix.c, common/exechelp-w32.c * common/exechelp-w32ce.c: Use HAVE_PTH to include npth.h. * common/init.c (_init_common_subsystems): Remove call to pth_init. * common/sysutils.c (gnupg_sleep): Use npth_sleep. * scd/ccid-driver.c (my_sleep): Ditto. -- USE_NPTH is used in case were we may build with and without nPth. The missing definition HAVE_NPTH didn't allowed us to build outher sources with nPTh support.
This commit is contained in:
parent
8416c875a7
commit
84289e85c7
@ -162,7 +162,7 @@ typedef void (*func_free_t) (void *mem);
|
|||||||
|
|
||||||
/* Primitive system I/O. */
|
/* Primitive system I/O. */
|
||||||
|
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
# define ESTREAM_SYS_READ do_npth_read
|
# define ESTREAM_SYS_READ do_npth_read
|
||||||
# define ESTREAM_SYS_WRITE do_npth_write
|
# define ESTREAM_SYS_WRITE do_npth_write
|
||||||
# define ESTREAM_SYS_YIELD() npth_usleep (0)
|
# define ESTREAM_SYS_YIELD() npth_usleep (0)
|
||||||
@ -197,7 +197,7 @@ struct estream_internal
|
|||||||
unsigned char buffer[BUFFER_BLOCK_SIZE];
|
unsigned char buffer[BUFFER_BLOCK_SIZE];
|
||||||
unsigned char unread_buffer[BUFFER_UNREAD_SIZE];
|
unsigned char unread_buffer[BUFFER_UNREAD_SIZE];
|
||||||
|
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
npth_mutex_t lock; /* Lock. */
|
npth_mutex_t lock; /* Lock. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ static int custom_std_fds[3];
|
|||||||
static unsigned char custom_std_fds_valid[3];
|
static unsigned char custom_std_fds_valid[3];
|
||||||
|
|
||||||
/* A lock object for the estream list and the custom_std_fds array. */
|
/* A lock object for the estream list and the custom_std_fds array. */
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
static npth_mutex_t estream_list_lock;
|
static npth_mutex_t estream_list_lock;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ map_w32_to_errno (DWORD w32_err)
|
|||||||
static int
|
static int
|
||||||
init_stream_lock (estream_t ES__RESTRICT stream)
|
init_stream_lock (estream_t ES__RESTRICT stream)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!stream->intern->samethread)
|
if (!stream->intern->samethread)
|
||||||
@ -380,7 +380,7 @@ init_stream_lock (estream_t ES__RESTRICT stream)
|
|||||||
static void
|
static void
|
||||||
lock_stream (estream_t ES__RESTRICT stream)
|
lock_stream (estream_t ES__RESTRICT stream)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
if (!stream->intern->samethread)
|
if (!stream->intern->samethread)
|
||||||
{
|
{
|
||||||
dbg_lock_1 ("enter lock_stream for %p\n", stream);
|
dbg_lock_1 ("enter lock_stream for %p\n", stream);
|
||||||
@ -396,7 +396,7 @@ lock_stream (estream_t ES__RESTRICT stream)
|
|||||||
static int
|
static int
|
||||||
trylock_stream (estream_t ES__RESTRICT stream)
|
trylock_stream (estream_t ES__RESTRICT stream)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!stream->intern->samethread)
|
if (!stream->intern->samethread)
|
||||||
@ -418,7 +418,7 @@ trylock_stream (estream_t ES__RESTRICT stream)
|
|||||||
static void
|
static void
|
||||||
unlock_stream (estream_t ES__RESTRICT stream)
|
unlock_stream (estream_t ES__RESTRICT stream)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
if (!stream->intern->samethread)
|
if (!stream->intern->samethread)
|
||||||
{
|
{
|
||||||
dbg_lock_1 ("enter unlock_stream for %p\n", stream);
|
dbg_lock_1 ("enter unlock_stream for %p\n", stream);
|
||||||
@ -434,7 +434,7 @@ unlock_stream (estream_t ES__RESTRICT stream)
|
|||||||
static int
|
static int
|
||||||
init_list_lock (void)
|
init_list_lock (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
dbg_lock_0 ("enter init_list_lock\n");
|
dbg_lock_0 ("enter init_list_lock\n");
|
||||||
@ -450,7 +450,7 @@ init_list_lock (void)
|
|||||||
static void
|
static void
|
||||||
lock_list (void)
|
lock_list (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
dbg_lock_0 ("enter lock_list\n");
|
dbg_lock_0 ("enter lock_list\n");
|
||||||
npth_mutex_lock (&estream_list_lock);
|
npth_mutex_lock (&estream_list_lock);
|
||||||
dbg_lock_0 ("leave lock_list\n");
|
dbg_lock_0 ("leave lock_list\n");
|
||||||
@ -461,7 +461,7 @@ lock_list (void)
|
|||||||
static void
|
static void
|
||||||
unlock_list (void)
|
unlock_list (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
dbg_lock_0 ("enter unlock_list\n");
|
dbg_lock_0 ("enter unlock_list\n");
|
||||||
npth_mutex_unlock (&estream_list_lock);
|
npth_mutex_unlock (&estream_list_lock);
|
||||||
dbg_lock_0 ("leave unlock_list\n");
|
dbg_lock_0 ("leave unlock_list\n");
|
||||||
@ -548,7 +548,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
|
* write, assuming that we do I/O on a plain file where the operation
|
||||||
* can't block. FIXME: Is this still needed for npth?
|
* can't block. FIXME: Is this still needed for npth?
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
static int
|
static int
|
||||||
do_npth_read (int fd, void *buffer, size_t size)
|
do_npth_read (int fd, void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
@ -574,7 +574,7 @@ do_npth_write (int fd, const void *buffer, size_t size)
|
|||||||
return npth_write (fd, buffer, size);
|
return npth_write (fd, buffer, size);
|
||||||
# endif /* !HAVE_W32_SYSTEM*/
|
# endif /* !HAVE_W32_SYSTEM*/
|
||||||
}
|
}
|
||||||
#endif /*HAVE_NPTH*/
|
#endif /*USE_NPTH*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1125,7 +1125,7 @@ es_func_w32_read (void *cookie, void *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
/* Note: Our pth_read actually uses HANDLE!
|
/* Note: Our pth_read actually uses HANDLE!
|
||||||
FIXME: Check whether this is the case for npth. */
|
FIXME: Check whether this is the case for npth. */
|
||||||
bytes_read = npth_read ((int)w32_cookie->hd, buffer, size);
|
bytes_read = npth_read ((int)w32_cookie->hd, buffer, size);
|
||||||
@ -1171,7 +1171,7 @@ es_func_w32_write (void *cookie, const void *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
/* Note: Our pth_write actually uses HANDLE! */
|
/* Note: Our pth_write actually uses HANDLE! */
|
||||||
bytes_written = npth_write ((int)w32_cookie->hd, buffer, size);
|
bytes_written = npth_write ((int)w32_cookie->hd, buffer, size);
|
||||||
#else
|
#else
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#undef USE_NPTH
|
#undef USE_NPTH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_NPTH
|
#ifdef HAVE_NPTH
|
||||||
#include <npth.h>
|
#include <npth.h>
|
||||||
#endif
|
#endif
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#undef USE_NPTH
|
#undef USE_NPTH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_NPTH
|
#ifdef HAVE_NPTH
|
||||||
#include <npth.h>
|
#include <npth.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
#undef USE_NPTH
|
#undef USE_NPTH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_NPTH
|
#ifdef HAVE_NPTH
|
||||||
#include <npth.h>
|
#include <npth.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -74,15 +74,13 @@
|
|||||||
#endif /*!HAVE_W32_SYSTEM*/
|
#endif /*!HAVE_W32_SYSTEM*/
|
||||||
|
|
||||||
#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */
|
#ifdef WITHOUT_NPTH /* Give the Makefile a chance to build without Pth. */
|
||||||
# undef HAVE_NPTH
|
|
||||||
# undef USE_NPTH
|
# undef USE_NPTH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
# include <npth.h>
|
# include <npth.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HTTP_USE_GNUTLS
|
#ifdef HTTP_USE_GNUTLS
|
||||||
# include <gnutls/gnutls.h>
|
# include <gnutls/gnutls.h>
|
||||||
/* For non-understandable reasons GNUTLS dropped the _t suffix from
|
/* For non-understandable reasons GNUTLS dropped the _t suffix from
|
||||||
@ -94,7 +92,7 @@ typedef gnutls_transport_ptr gnutls_transport_ptr_t;
|
|||||||
#endif /*HTTP_USE_GNUTLS*/
|
#endif /*HTTP_USE_GNUTLS*/
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#undef USE_DNS_SRV
|
# undef USE_DNS_SRV
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@ -119,10 +117,10 @@ struct srventry
|
|||||||
#endif/*!USE_DNS_SRV*/
|
#endif/*!USE_DNS_SRV*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
# define my_select(a,b,c,d,e) pth_select ((a), (b), (c), (d), (e))
|
# define my_select(a,b,c,d,e) npth_select ((a), (b), (c), (d), (e))
|
||||||
# define my_connect(a,b,c) pth_connect ((a), (b), (c))
|
# define my_connect(a,b,c) npth_connect ((a), (b), (c))
|
||||||
# define my_accept(a,b,c) pth_accept ((a), (b), (c))
|
# define my_accept(a,b,c) npth_accept ((a), (b), (c))
|
||||||
#else
|
#else
|
||||||
# define my_select(a,b,c,d,e) select ((a), (b), (c), (d), (e))
|
# define my_select(a,b,c,d,e) select ((a), (b), (c), (d), (e))
|
||||||
# define my_connect(a,b,c) connect ((a), (b), (c))
|
# define my_connect(a,b,c) connect ((a), (b), (c))
|
||||||
@ -359,8 +357,9 @@ my_socket_unref (my_socket_t so)
|
|||||||
/* #define my_socket_unref(a) _my_socket_unref ((a),__LINE__) */
|
/* #define my_socket_unref(a) _my_socket_unref ((a),__LINE__) */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* This notification function is called by estream whenever stream is
|
/* This notification function is called by estream whenever stream is
|
||||||
closed. Its purpose is to mark the the closing in the handle so
|
closed. Its purpose is to mark the closing in the handle so
|
||||||
that a http_close won't accidentally close the estream. The function
|
that a http_close won't accidentally close the estream. The function
|
||||||
http_close removes this notification so that it won't be called if
|
http_close removes this notification so that it won't be called if
|
||||||
http_close was used before an es_fclose. */
|
http_close was used before an es_fclose. */
|
||||||
@ -1835,7 +1834,7 @@ connect_server (const char *server, unsigned short port,
|
|||||||
sock = socket (host->h_addrtype, SOCK_STREAM, 0);
|
sock = socket (host->h_addrtype, SOCK_STREAM, 0);
|
||||||
if (sock == -1)
|
if (sock == -1)
|
||||||
{
|
{
|
||||||
log_error (_("error creating socket: %s\n"), strerror (errno));
|
log_error ("error creating socket: %s\n", strerror (errno));
|
||||||
xfree (serverlist);
|
xfree (serverlist);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1879,7 +1878,7 @@ connect_server (const char *server, unsigned short port,
|
|||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
log_error ("can't connect to '%s': %s%sec=%d\n",
|
log_error ("can't connect to '%s': %s%sec=%d\n",
|
||||||
server,
|
server,
|
||||||
hostfound? "":_("host not found"),
|
hostfound? "":"host not found",
|
||||||
hostfound? "":" - ", (int)WSAGetLastError());
|
hostfound? "":" - ", (int)WSAGetLastError());
|
||||||
#else
|
#else
|
||||||
log_error ("can't connect to '%s': %s\n",
|
log_error ("can't connect to '%s': %s\n",
|
||||||
@ -1906,16 +1905,16 @@ write_server (int sock, const char *data, size_t length)
|
|||||||
nleft = length;
|
nleft = length;
|
||||||
while (nleft > 0)
|
while (nleft > 0)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_NPTH)
|
#if defined(HAVE_W32_SYSTEM) && !defined(USE_NPTH)
|
||||||
nwritten = send (sock, data, nleft, 0);
|
nwritten = send (sock, data, nleft, 0);
|
||||||
if ( nwritten == SOCKET_ERROR )
|
if ( nwritten == SOCKET_ERROR )
|
||||||
{
|
{
|
||||||
log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ());
|
log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ());
|
||||||
return gpg_error (GPG_ERR_NETWORK);
|
return gpg_error (GPG_ERR_NETWORK);
|
||||||
}
|
}
|
||||||
#else /*!HAVE_W32_SYSTEM || HAVE_NPTH*/
|
#else /*!HAVE_W32_SYSTEM || USE_NPTH*/
|
||||||
# ifdef HAVE_NPTH
|
# ifdef USE_NPTH
|
||||||
nwritten = pth_write (sock, data, nleft);
|
nwritten = npth_write (sock, data, nleft);
|
||||||
# else
|
# else
|
||||||
nwritten = write (sock, data, nleft);
|
nwritten = write (sock, data, nleft);
|
||||||
# endif
|
# endif
|
||||||
@ -1935,7 +1934,7 @@ write_server (int sock, const char *data, size_t length)
|
|||||||
log_info ("network write failed: %s\n", strerror (errno));
|
log_info ("network write failed: %s\n", strerror (errno));
|
||||||
return gpg_error_from_syserror ();
|
return gpg_error_from_syserror ();
|
||||||
}
|
}
|
||||||
#endif /*!HAVE_W32_SYSTEM || HAVE_NPTH*/
|
#endif /*!HAVE_W32_SYSTEM || USE_NPTH*/
|
||||||
nleft -= nwritten;
|
nleft -= nwritten;
|
||||||
data += nwritten;
|
data += nwritten;
|
||||||
}
|
}
|
||||||
@ -1990,8 +1989,8 @@ cookie_read (void *cookie, void *buffer, size_t size)
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
nread = pth_read (c->sock->fd, buffer, size);
|
nread = npth_read (c->sock->fd, buffer, size);
|
||||||
#elif defined(HAVE_W32_SYSTEM)
|
#elif defined(HAVE_W32_SYSTEM)
|
||||||
/* Under Windows we need to use recv for a socket. */
|
/* Under Windows we need to use recv for a socket. */
|
||||||
nread = recv (c->sock->fd, buffer, size, 0);
|
nread = recv (c->sock->fd, buffer, size, 0);
|
||||||
|
@ -156,18 +156,12 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp)
|
|||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
/* For W32 we need to initialize the socket layer. This is because
|
/* For W32 we need to initialize the socket layer. This is because
|
||||||
we use recv and send in libassuan as well as at some other
|
we use recv and send in libassuan as well as at some other
|
||||||
places. If we are building with PTH we let pth_init do it. We
|
places. */
|
||||||
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_NPTH
|
|
||||||
pth_init ();
|
|
||||||
# else
|
|
||||||
{
|
{
|
||||||
WSADATA wsadat;
|
WSADATA wsadat;
|
||||||
|
|
||||||
WSAStartup (0x202, &wsadat);
|
WSAStartup (0x202, &wsadat);
|
||||||
}
|
}
|
||||||
# endif /*!HAVE_NPTH*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_W32CE_SYSTEM
|
#ifdef HAVE_W32CE_SYSTEM
|
||||||
|
@ -275,18 +275,8 @@ check_permissions(const char *path,int extension,int checkonly)
|
|||||||
void
|
void
|
||||||
gnupg_sleep (unsigned int seconds)
|
gnupg_sleep (unsigned int seconds)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
/* With Pth we force a regular sleep for seconds == 0 so that also
|
npth_sleep (seconds);
|
||||||
the process will give up its timeslot. */
|
|
||||||
if (!seconds)
|
|
||||||
{
|
|
||||||
# ifdef HAVE_W32_SYSTEM
|
|
||||||
Sleep (0);
|
|
||||||
# else
|
|
||||||
sleep (0);
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
pth_sleep (seconds);
|
|
||||||
#else
|
#else
|
||||||
/* Fixme: make sure that a sleep won't wake up to early. */
|
/* Fixme: make sure that a sleep won't wake up to early. */
|
||||||
# ifdef HAVE_W32_SYSTEM
|
# ifdef HAVE_W32_SYSTEM
|
||||||
|
@ -900,9 +900,10 @@ AC_DEFINE_UNQUOTED(SHRED,
|
|||||||
#
|
#
|
||||||
AM_PATH_NPTH("$NEED_NPTH_API:$NEED_NPTH_VERSION",have_npth=yes,have_npth=no)
|
AM_PATH_NPTH("$NEED_NPTH_API:$NEED_NPTH_VERSION",have_npth=yes,have_npth=no)
|
||||||
if test "$have_npth" = "yes"; then
|
if test "$have_npth" = "yes"; then
|
||||||
# We define this macro because some code parts require it.
|
AC_DEFINE(HAVE_NPTH, 1,
|
||||||
AC_DEFINE(USE_NPTH, 1,
|
|
||||||
[Defined if the New Portable Thread Library is available])
|
[Defined if the New Portable Thread Library is available])
|
||||||
|
AC_DEFINE(USE_NPTH, 1,
|
||||||
|
[Defined if support for nPth is requested and nPth is available])
|
||||||
else
|
else
|
||||||
AC_MSG_WARN([[
|
AC_MSG_WARN([[
|
||||||
***
|
***
|
||||||
|
@ -315,18 +315,8 @@ set_msg_len (unsigned char *msg, unsigned int length)
|
|||||||
static void
|
static void
|
||||||
my_sleep (int seconds)
|
my_sleep (int seconds)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_NPTH
|
#ifdef USE_NPTH
|
||||||
/* With Pth we also call the standard sleep(0) so that the process
|
npth_sleep (seconds);
|
||||||
may give up its timeslot. */
|
|
||||||
if (!seconds)
|
|
||||||
{
|
|
||||||
# ifdef HAVE_W32_SYSTEM
|
|
||||||
Sleep (0);
|
|
||||||
# else
|
|
||||||
sleep (0);
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
pth_sleep (seconds);
|
|
||||||
#else
|
#else
|
||||||
# ifdef HAVE_W32_SYSTEM
|
# ifdef HAVE_W32_SYSTEM
|
||||||
Sleep (seconds*1000);
|
Sleep (seconds*1000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user