2005-09-12 Marcus Brinkmann <marcus@g10code.de>

* configure.ac (HAVE_PTH): Don't add $PTH_CFLAGS to $CFLAGS here.

gpgme/
2005-09-12  Marcus Brinkmann  <marcus@g10code.de>

	* Makefile.am (libgpgme_la_SOURCES): Set to ath.h and ath.c.
	(ath_pth_src, ath_pthread_src): Removed.
	(w32_o_files): Replace ath-compat.o with ath.o.
	(libgpgme_pth_la_CFLAGS): New variable.
	* ath-compat.c, ath-pthread-compat.c, ath-pth-compat.c: Removed.
	* ath.h (ath_pthread_available, ath_pth_available): Removed.
	(ath_init) [!_ATH_EXT_SYM_PREFIX]: Do not define macro.
	(struct ath_ops, ath_init) [_ATH_COMPAT]: Removed.
	(_ATH_COMPAT): Macro removed.
	* posix-sema.c (_gpgme_sema_subsystem_init): Do not call
	_gpgme_ath_init.
This commit is contained in:
Marcus Brinkmann 2005-09-12 19:14:36 +00:00
parent a02fa90f6b
commit f1eb841d3b
9 changed files with 37 additions and 489 deletions

View File

@ -1,3 +1,7 @@
2005-09-12 Marcus Brinkmann <marcus@g10code.de>
* configure.ac (HAVE_PTH): Don't add $PTH_CFLAGS to $CFLAGS here.
2005-08-26 Werner Koch <wk@g10code.com> 2005-08-26 Werner Koch <wk@g10code.com>
* configure.ac (SEPCONSTANTS): New to define DIRSEP_C et al. * configure.ac (SEPCONSTANTS): New to define DIRSEP_C et al.

22
NEWS
View File

@ -1,12 +1,6 @@
Noteworthy changes in version 1.1.0 (unreleased) Noteworthy changes in version 1.1.0 (unreleased)
------------------------------------------------ ------------------------------------------------
* "./autogen.sh --build-w32" does now build gpgme.dll.
* [W32] The environment variable GPGME_DEBUG now uses a semicolon as
delimiter. The standard install directory is used when locating
gpg or gpgsm before finally falling back to the hardwired name.
* You can now configure the backend engine file name and home * You can now configure the backend engine file name and home
directory to be used, as default and per context. directory to be used, as default and per context.
@ -27,6 +21,22 @@ Noteworthy changes in version 1.1.0 (unreleased)
if available is made available in the new field plaintext_filename if available is made available in the new field plaintext_filename
of the respective result structure. of the respective result structure.
* The code for "automagically detecting the thread library" has been
removed from libgpgme. It is deprecated since version 0.4.3.
Since then, you had to link against libgpgme-pthread for
applications using pthread and libgpgme-pth for applications using
GNU Pth.
The code was removed because it caused compilation problems on
systems where the pthread.h header from GNU Pth is available in
addition to the system header (FreeBSD 6 and later for example).
* "./autogen.sh --build-w32" does now build gpgme.dll.
* [W32] The environment variable GPGME_DEBUG now uses a semicolon as
delimiter. The standard install directory is used when locating
gpg or gpgsm before finally falling back to the hardwired name.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gpgme_set_engine_info NEW gpgme_set_engine_info NEW
gpgme_ctx_get_engine_info NEW gpgme_ctx_get_engine_info NEW

View File

@ -1,3 +1,17 @@
2005-09-12 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (libgpgme_la_SOURCES): Set to ath.h and ath.c.
(ath_pth_src, ath_pthread_src): Removed.
(w32_o_files): Replace ath-compat.o with ath.o.
(libgpgme_pth_la_CFLAGS): New variable.
* ath-compat.c, ath-pthread-compat.c, ath-pth-compat.c: Removed.
* ath.h (ath_pthread_available, ath_pth_available): Removed.
(ath_init) [!_ATH_EXT_SYM_PREFIX]: Do not define macro.
(struct ath_ops, ath_init) [_ATH_COMPAT]: Removed.
(_ATH_COMPAT): Macro removed.
* posix-sema.c (_gpgme_sema_subsystem_init): Do not call
_gpgme_ath_init.
2005-09-12 Marcus Brinkmann <marcus@g10code.de> 2005-09-12 Marcus Brinkmann <marcus@g10code.de>
* keylist.c (release_op_data): Do not free opd->tmp_uid. * keylist.c (release_op_data): Do not free opd->tmp_uid.

View File

@ -83,18 +83,7 @@ libgpgme_real_la_SOURCES = \
$(gpgsm_components) sema.h priv-io.h $(system_components) \ $(gpgsm_components) sema.h priv-io.h $(system_components) \
debug.c debug.h gpgme.c version.c error.c debug.c debug.h gpgme.c version.c error.c
# libgpgme_la_SOURCES = ath.h ath.c libgpgme_la_SOURCES = ath.h ath.c
if HAVE_PTH
ath_pth_src = ath-pth-compat.c
else
ath_pth_src =
endif
if HAVE_PTHREAD
ath_pthread_src = ath-pthread-compat.c
else
ath_pthread_src =
endif
libgpgme_la_SOURCES = ath.h ath-compat.c $(ath_pth_src) $(ath_pthread_src)
libgpgme_pthread_la_SOURCES = ath.h ath-pthread.c libgpgme_pthread_la_SOURCES = ath.h ath-pthread.c
libgpgme_pth_la_SOURCES = ath.h ath-pth.c libgpgme_pth_la_SOURCES = ath.h ath-pth.c
@ -114,6 +103,7 @@ libgpgme_pthread_la_DEPENDENCIES = libgpgme-real.la $(assuan_libobjs) \
libgpgme_pthread_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \ libgpgme_pthread_la_LIBADD = libgpgme-real.la $(assuan_libobjs) @LTLIBOBJS@ \
-lpthread @GPG_ERROR_LIBS@ -lpthread @GPG_ERROR_LIBS@
libgpgme_pth_la_CFLAGS = $(AM_CFLAGS) @PTH_CFLAGS@
libgpgme_pth_la_CPPFLAGS = $(AM_CPPFLAGS) @PTH_CPPFLAGS@ libgpgme_pth_la_CPPFLAGS = $(AM_CPPFLAGS) @PTH_CPPFLAGS@
libgpgme_pth_la_LDFLAGS = @PTH_LDFLAGS@ \ libgpgme_pth_la_LDFLAGS = @PTH_LDFLAGS@ \
$(libgpgme_version_script_cmd) -version-info \ $(libgpgme_version_script_cmd) -version-info \
@ -130,7 +120,7 @@ status-table.h : gpgme.h
# able to do this properly; we better use gcc's built in magic. # able to do this properly; we better use gcc's built in magic.
if HAVE_W32_SYSTEM if HAVE_W32_SYSTEM
w32_o_files = ath-compat.o conversion.o data-compat.o data-fd.o \ w32_o_files = ath.o conversion.o data-compat.o data-fd.o \
data-mem.o data-stream.o data-user.o data.o debug.o \ data-mem.o data-stream.o data-user.o data.o debug.o \
decrypt-verify.o decrypt.o delete.o edit.o encrypt-sign.o \ decrypt-verify.o decrypt.o delete.o edit.o encrypt-sign.o \
encrypt.o engine-gpgsm.o engine.o error.o export.o genkey.o \ encrypt.o engine-gpgsm.o engine.o error.o export.o genkey.o \

View File

@ -1,211 +0,0 @@
/* ath.c - self-adapting thread-safeness library
Copyright (C) 2002, 2004 g10 Code GmbH
This file is part of GPGME.
GPGME is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
GPGME is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#ifdef HAVE_SYS_SELECT_H
# include <sys/select.h>
#else
# include <sys/time.h>
#endif
#include <sys/types.h>
#ifndef HAVE_W32_SYSTEM
#include <sys/wait.h>
#endif /*!HAVE_W32_SYSTEM*/
#include "ath.h"
static struct ath_ops *ath_ops;
void
ath_init (void)
{
if (0)
;
#ifdef HAVE_PTHREAD
else if (!ath_ops)
ath_ops = ath_pthread_available ();
#endif
#ifdef HAVE_PTH
else if (!ath_ops)
ath_ops = ath_pth_available ();
#endif
}
int
ath_mutex_init (ath_mutex_t *lock)
{
if (!ath_ops)
return 0;
return ath_ops->mutex_init (lock, 0);
}
int
ath_mutex_destroy (ath_mutex_t *lock)
{
int err;
if (!ath_ops)
return 0;
err = ath_ops->mutex_init (lock, 1);
if (!err)
err = ath_ops->mutex_destroy (*lock);
return err;
}
int
ath_mutex_lock (ath_mutex_t *lock)
{
int err;
if (!ath_ops)
return 0;
err = ath_ops->mutex_init (lock, 1);
if (!err)
err = ath_ops->mutex_lock (*lock);
return err;
}
int
ath_mutex_unlock (ath_mutex_t *lock)
{
int err;
if (!ath_ops)
return 0;
err = ath_ops->mutex_init (lock, 1);
if (!err)
err = ath_ops->mutex_unlock (*lock);
return err;
}
ssize_t
ath_read (int fd, void *buf, size_t nbytes)
{
if (ath_ops && ath_ops->read)
return ath_ops->read (fd, buf, nbytes);
else
return read (fd, buf, nbytes);
}
ssize_t
ath_write (int fd, const void *buf, size_t nbytes)
{
if (ath_ops && ath_ops->write)
return ath_ops->write (fd, buf, nbytes);
else
return write (fd, buf, nbytes);
}
ssize_t
ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout)
{
if (ath_ops && ath_ops->select)
return ath_ops->select (nfd, rset, wset, eset, timeout);
else
#ifdef HAVE_W32_SYSTEM
return -1; /* We don't support this yet. */
#else
return select (nfd, rset, wset, eset, timeout);
#endif
}
ssize_t
ath_waitpid (pid_t pid, int *status, int options)
{
if (ath_ops && ath_ops->waitpid)
return ath_ops->waitpid (pid, status, options);
else
#ifdef HAVE_W32_SYSTEM
return -1; /* We don't support this yet. */
#else
return waitpid (pid, status, options);
#endif
}
int
ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr)
{
if (ath_ops && ath_ops->accept)
return ath_ops->accept (s, addr, length_ptr);
else
#ifdef HAVE_W32_SYSTEM
return -1; /* We don't support this yet. */
#else
return accept (s, addr, length_ptr);
#endif
}
int
ath_connect (int s, const struct sockaddr *addr, socklen_t length)
{
if (ath_ops && ath_ops->connect)
return ath_ops->connect (s, addr, length);
else
#ifdef HAVE_W32_SYSTEM
return -1; /* We don't support this yet. */
#else
return connect (s, addr, length);
#endif
}
int
ath_sendmsg (int s, const struct msghdr *msg, int flags)
{
if (ath_ops && ath_ops->sendmsg)
return ath_ops->sendmsg (s, msg, flags);
else
#ifdef HAVE_W32_SYSTEM
return -1; /* We don't support this yet. */
#else
return sendmsg (s, msg, flags);
#endif
}
int
ath_recvmsg (int s, struct msghdr *msg, int flags)
{
if (ath_ops && ath_ops->recvmsg)
return ath_ops->recvmsg (s, msg, flags);
else
#ifdef HAVE_W32_SYSTEM
return -1; /* We don't support this yet. */
#else
return recvmsg (s, msg, flags);
#endif
}

View File

@ -1,123 +0,0 @@
/* ath-pth.c - Pth module for self-adapting thread-safeness library
Copyright (C) 2002, 2004 g10 Code GmbH
This file is part of GPGME.
GPGME is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
GPGME is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include <stdlib.h>
#include <errno.h>
#include <pth.h>
#include "ath.h"
#pragma weak pth_mutex_init
#pragma weak pth_mutex_acquire
#pragma weak pth_mutex_release
#pragma weak pth_read
#pragma weak pth_write
#pragma weak pth_select
#pragma weak pth_waitpid
#pragma weak pth_accept
#pragma weak pth_connect
/* The lock we take while checking for lazy lock initialization. */
static pth_mutex_t check_init_lock = PTH_MUTEX_INIT;
/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if
it is not already initialized. */
static int
mutex_pth_init (void **priv, int just_check)
{
int err = 0;
if (just_check)
pth_mutex_acquire (&check_init_lock, 0, NULL);
if (!*priv || !just_check)
{
pth_mutex_t *lock = malloc (sizeof (pth_mutex_t));
if (!lock)
err = ENOMEM;
if (!err)
{
err = pth_mutex_init (lock);
if (err == FALSE)
err = errno;
else
err = 0;
if (err)
free (lock);
else
*priv = lock;
}
}
if (just_check)
pth_mutex_release (&check_init_lock);
return err;
}
static int
mutex_pth_destroy (void *priv)
{
free (priv);
return 0;
}
static int
mutex_pth_lock (void *priv)
{
int ret = pth_mutex_acquire ((pth_mutex_t *) priv, 0, NULL);
return ret == FALSE ? errno : 0;
}
static int
mutex_pth_unlock (void *priv)
{
int ret = pth_mutex_release ((pth_mutex_t *) priv);
return ret == FALSE ? errno : 0;
}
static struct ath_ops ath_pth_ops =
{
mutex_pth_init,
mutex_pth_destroy,
mutex_pth_lock,
mutex_pth_unlock,
pth_read,
pth_write,
pth_select,
pth_waitpid,
pth_accept,
pth_connect,
NULL, /* FIXME: When GNU PTh has sendmsg. */
NULL /* FIXME: When GNU PTh has recvmsg. */
};
struct ath_ops *
ath_pth_available (void)
{
if (pth_mutex_init && pth_mutex_acquire && pth_mutex_release
&& pth_read && pth_write && pth_select && pth_waitpid)
return &ath_pth_ops;
else
return 0;
}

View File

@ -1,104 +0,0 @@
/* ath-pthread.c - pthread module for self-adapting thread-safeness library
Copyright (C) 2002, 2004 g10 Code GmbH
This file is part of GPGME.
GPGME is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
GPGME is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
#include <stdlib.h>
#include <errno.h>
#include <pthread.h>
#include "ath.h"
/* Need to include pthread_create in our check, as the GNU C library
has the pthread_mutex_* functions in their public interface. */
#pragma weak pthread_create
#pragma weak pthread_mutex_init
#pragma weak pthread_mutex_destroy
#pragma weak pthread_mutex_lock
#pragma weak pthread_mutex_unlock
/* The lock we take while checking for lazy lock initialization. */
static pthread_mutex_t check_init_lock = PTHREAD_MUTEX_INITIALIZER;
/* Initialize the mutex *PRIV. If JUST_CHECK is true, only do this if
it is not already initialized. */
static int
mutex_pthread_init (void **priv, int just_check)
{
int err = 0;
if (just_check)
pthread_mutex_lock (&check_init_lock);
if (!*priv || !just_check)
{
pthread_mutex_t *lock = malloc (sizeof (pthread_mutex_t));
if (!lock)
err = ENOMEM;
if (!err)
{
err = pthread_mutex_init (lock, NULL);
if (err)
free (lock);
else
*priv = lock;
}
}
if (just_check)
pthread_mutex_unlock (&check_init_lock);
return err;
}
static int
mutex_pthread_destroy (void *priv)
{
int err = pthread_mutex_destroy ((pthread_mutex_t *) priv);
free (priv);
return err;
}
static struct ath_ops ath_pthread_ops =
{
mutex_pthread_init,
mutex_pthread_destroy,
(int (*) (void *)) pthread_mutex_lock,
(int (*) (void *)) pthread_mutex_unlock,
NULL, /* read */
NULL, /* write */
NULL, /* select */
NULL, /* waitpid */
NULL, /* accept */
NULL, /* connect */
NULL, /* sendmsg */
NULL /* recvmsg */
};
struct ath_ops *
ath_pthread_available (void)
{
/* Need to include pthread_create in our check, as the GNU C library
has the pthread_mutex_* functions in their public interface. */
if (pthread_create
&& pthread_mutex_init && pthread_mutex_destroy
&& pthread_mutex_lock && pthread_mutex_unlock)
return &ath_pthread_ops;
else
return 0;
}

View File

@ -86,34 +86,4 @@ int ath_connect (int s, const struct sockaddr *addr, socklen_t length);
int ath_sendmsg (int s, const struct msghdr *msg, int flags); int ath_sendmsg (int s, const struct msghdr *msg, int flags);
int ath_recvmsg (int s, struct msghdr *msg, int flags); int ath_recvmsg (int s, struct msghdr *msg, int flags);
#define _ATH_COMPAT
#ifdef _ATH_COMPAT
struct ath_ops
{
int (*mutex_init) (void **priv, int just_check);
int (*mutex_destroy) (void *priv);
int (*mutex_lock) (void *priv);
int (*mutex_unlock) (void *priv);
ssize_t (*read) (int fd, void *buf, size_t nbytes);
ssize_t (*write) (int fd, const void *buf, size_t nbytes);
ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
struct timeval *timeout);
ssize_t (*waitpid) (pid_t pid, int *status, int options);
int (*accept) (int s, struct sockaddr *addr, socklen_t *length_ptr);
int (*connect) (int s, const struct sockaddr *addr, socklen_t length);
int (*sendmsg) (int s, const struct msghdr *msg, int flags);
int (*recvmsg) (int s, struct msghdr *msg, int flags);
};
/* Initialize the any-thread package. */
#define ath_init _ATH_PREFIX(ath_init)
void ath_init (void);
/* Used by ath_pkg_init. */
#define ath_pthread_available _ATH_PREFIX(ath_pthread_available)
struct ath_ops *ath_pthread_available (void);
#define ath_pth_available _ATH_PREFIX(ath_pth_available)
struct ath_ops *ath_pth_available (void);
#endif
#endif /* ATH_H */ #endif /* ATH_H */

View File

@ -40,8 +40,6 @@
void void
_gpgme_sema_subsystem_init () _gpgme_sema_subsystem_init ()
{ {
/* FIXME: we should check that there is only one thread running */
_gpgme_ath_init ();
} }
void void