├── THANKS ├── versioninfo.rc.in ├── AUTHORS ├── README ├── TODO ├── m4 ├── ltversion.m4 ├── gpg-error.m4 ├── ltsugar.m4 ├── lt~obsolete.m4 └── ltoptions.m4 ├── utils.h ├── w32-io.h ├── NEWS ├── README.SVN ├── libw32pth.def ├── Makefile.am ├── pth-config.in ├── compile ├── autogen.sh ├── configure.ac ├── debug.h ├── ChangeLog ├── pth.h ├── missing ├── INSTALL ├── install-sh ├── depcomp ├── COPYING.LESSER └── w32-io.c /THANKS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /versioninfo.rc.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gpg/w32pth/master/versioninfo.rc.in -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Program: W32PTH 2 | Maintainer: Werner Koch 3 | Bug reports: (public mailing list) 4 | Security related bug reports: 5 | License: LGPLv2+ 6 | 7 | 8 | g10 Code GmbH 9 | Design and most stuff. 10 | 11 | Ralf S. Engelschall 12 | Orignal GNU Pth implementation. 13 | (Some parts of pth.h have been taken from there). 14 | 15 | 16 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | W32PTH 2 | An emulation of PTH for MS Windows 3 | ------------------------------------ 4 | 5 | This is an emulation of GNU PTH for MS Windows (W32). It works by 6 | blocking all threads when outside of one of the pth functions and 7 | using standard W32 threads and suncronization mechanisms to emulate 8 | the behaviour of PTH. 9 | 10 | It is currently limited to what GnuPG 2.0 requires. 11 | 12 | 13 | Missing stuff: 14 | 15 | PTH_MODE_STATIC is known but ignored. 16 | PTH_MODE_REUSE 17 | PTH_MODE_CHAIN 18 | 19 | rwlock - currently just a mutex 20 | 21 | as well as many more things. 22 | 23 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * pth_waitpid should be implemented for dirmngr, at least for the 2 | non-blocking case. 3 | 4 | * The whole wait stuff needs to be cleaned up. In particular, it is 5 | vital that it is clarified which events get reset before pth_wait 6 | returns and which are not. Tentatively I think that none should be 7 | reset when returning from pth_wait, but we need to verify that this is 8 | correct for the signal events. 9 | 10 | * Speaking of signals, that needs to be properly implemented and 11 | tested. 12 | 13 | * We can support static initializers for mutexes, because we can check 14 | the initialization flag (or some other marker, like invalid handle) 15 | before we call enter_pth. 16 | 17 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3012 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3012]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6' 20 | macro_revision='1.3012' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /utils.h: -------------------------------------------------------------------------------- 1 | /* utils.h - Internal definitions. 2 | * Copyright (C) 2010 g10 Code GmbH 3 | * 4 | * This file is part of W32PTH. 5 | * 6 | * W32PTH is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation; either version 2.1 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * W32PTH is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this program; if not, see . 18 | */ 19 | 20 | #ifndef UTILS_H 21 | #define UTILS_H 22 | 23 | #ifdef HAVE_W32CE_SYSTEM 24 | # include /* Required for gpg_err_set_errno(). */ 25 | #endif 26 | 27 | 28 | static inline void 29 | set_errno (int value) 30 | { 31 | #ifdef HAVE_W32CE_SYSTEM 32 | gpg_err_set_errno (value); 33 | #else 34 | errno = value; 35 | #endif 36 | } 37 | 38 | #define DIM(v) (sizeof(v)/sizeof((v)[0])) 39 | #define DIMof(type,member) DIM(((type *)0)->member) 40 | 41 | 42 | /*-- w32-pth.c --*/ 43 | void *_pth_malloc (size_t n); 44 | void *_pth_calloc (size_t n, size_t m); 45 | void _pth_free (void *p); 46 | 47 | 48 | #endif /*UTILS_H*/ 49 | -------------------------------------------------------------------------------- /w32-io.h: -------------------------------------------------------------------------------- 1 | /* w32-io.h - interface to debugging functions 2 | Copyright (C) 2002, 2004, 2005, 2007 g10 Code GmbH 3 | 4 | This file is part of GPGME. 5 | 6 | GPGME is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of 9 | the License, or (at your option) any later version. 10 | 11 | GPGME is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 | 02111-1307, USA. */ 20 | 21 | #ifndef W32_IO_H 22 | #define W32_IO_H 23 | 24 | /* Actually in w32-pth.c */ 25 | void *pth_malloc (size_t n); 26 | void *pth_calloc (size_t n, size_t m); 27 | void _pth_free (void *p); 28 | 29 | 30 | /* w32-io.c */ 31 | void _pth_sema_subsystem_init (void); 32 | 33 | /* For select. */ 34 | HANDLE _pth_get_reader_ev (int fd); 35 | HANDLE _pth_get_writer_ev (int fd); 36 | 37 | int _pth_io_read (int fd, void *buffer, size_t count); 38 | int _pth_io_write (int fd, const void *buffer, size_t count); 39 | 40 | 41 | #endif /* W32_IO_H */ 42 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Noteworthy changes in version 2.0.5 (2013-04-23) 2 | ------------------------------------------------ 3 | 4 | * Fix regression in W32 timer handling introduced by 2.0.3. 5 | 6 | * Switch to i686-w64-mingw32 as default toolchain. 7 | 8 | 9 | Noteworthy changes in version 2.0.4 (2010-08-02) 10 | ------------------------------------------------ 11 | 12 | * Bug fix: Export pth_enter and pth_leave. 13 | 14 | 15 | Noteworthy changes in version 2.0.3 (2010-07-30) 16 | ------------------------------------------------ 17 | 18 | * Support WindowsCE. 19 | 20 | * New functions pth_enter and pth_leave. 21 | 22 | 23 | Noteworthy changes in version 2.0.2 (2008-10-17) 24 | ------------------------------------------------ 25 | 26 | * Support pipes created with non-standard extensions pth_pipe and 27 | closed with pth_close. 28 | 29 | * Allow destruction of mutexes with non-standard extension 30 | pth_mutex_destroy. 31 | 32 | * Support pth_usleep. 33 | 34 | * Bug fixes. 35 | 36 | * New non-standard fucntion pth_thread_id. 37 | 38 | * Add PTH_HANDLE_EVENT. 39 | 40 | 41 | Noteworthy changes in version 2.0.1 (2007-08-16) 42 | ------------------------------------------------ 43 | 44 | * Fixes. Better support for select. 45 | 46 | 47 | Noteworthy changes in version 2.0.0 (2007-07-05) 48 | ------------------------------------------------ 49 | 50 | * First release. We need to use this unusually high version number 51 | to indicate the version of Pth we are emulating. 52 | 53 | 54 | Copyright 2007, 2008 g10 Code GmbH 55 | 56 | This file is free software; as a special exception the author gives 57 | unlimited permission to copy and/or distribute it, with or without 58 | modifications, as long as this notice is preserved. 59 | 60 | This file is distributed in the hope that it will be useful, but 61 | WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 62 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 63 | -------------------------------------------------------------------------------- /README.SVN: -------------------------------------------------------------------------------- 1 | If you are building from CVS, run the script 2 | 3 | ./autogen.sh 4 | 5 | first, to make sure that you have all the necessary maintainer tools 6 | are installed and to build the actual configuration files. Then run 7 | 8 | ./configure --enable-maintainer-mode 9 | 10 | followed by the usual make. 11 | 12 | If autogen.sh complains about insufficient versions of the required 13 | tools, or the tools are not installed, you may use environment 14 | variables to override the default tool names: 15 | 16 | AUTOMAKE_SUFFIX is used as a suffix for all tools from the automake 17 | package. For example 18 | AUTOMAKE_SUFFIX="-1.7" ./autogen.sh 19 | uses "automake-1.7" and "aclocal-1.7. 20 | AUTOMAKE_PREFIX is used as a prefix for all tools from the automake 21 | page and may be combined with AUTOMAKE_SUFFIX. e.g.: 22 | AUTOMAKE_PREFIX=/usr/foo/bin ./autogen.sh 23 | uses "automake" and "aclocal" in the /usr/foo/bin 24 | directory. 25 | AUTOCONF_SUFFIX is used as a suffix for all tools from the automake 26 | package 27 | AUTOCONF_PREFIX is used as a prefix for all tools from the automake 28 | package 29 | GETTEXT_SUFFIX is used as a suffix for all tools from the gettext 30 | package 31 | GETTEXT_PREFIX is used as a prefix for all tools from the gettext 32 | package 33 | 34 | It is also possible to use the variable name AUTOMAKE, AUTOCONF, 35 | ACLOCAL, AUTOHEADER, GETTEXT and MSGMERGE to directly specify the name 36 | of the programs to run. It is however better to use the suffix and 37 | prefix forms as described above because that does not require 38 | knowledge about the actual tools used by autgen.sh. 39 | 40 | 41 | Please don't use autopoint, libtoolize or autoreconf unless you are 42 | the current maintainer and want to update the standard configuration 43 | files. All those files should be in the CVS and only updated manually 44 | if the maintainer decides that newer versions are required. The 45 | maintainer should also make sure that the required version of automake 46 | et al. are properly indicated at the top of configure.ac and take care 47 | to copy the files and not merely use symlinks. 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /libw32pth.def: -------------------------------------------------------------------------------- 1 | ;; libw32pth.def - Exported symbols for W32PTH -*- asm -*- 2 | ;; Copyright (C) 2007 g10 Code GmbH 3 | ;; 4 | ;; This file is part of W32PTH. 5 | ;; 6 | ;; W32PTH is free software; you can redistribute it and/or modify it 7 | ;; under the terms of the GNU Lesser General Public License as 8 | ;; published by the Free Software Foundation; either version 2.1 of 9 | ;; the License, or (at your option) any later version. 10 | ;; W32PTH is distributed in the hope that it will be useful, but 11 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | ;; Lesser General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU Lesser General Public 16 | ;; License along with this program; if not, write to the Free Software 17 | ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 | ;; 02110-1301, USA. 19 | 20 | 21 | EXPORTS 22 | pth_init @1 23 | pth_kill @2 24 | pth_ctrl @3 25 | 26 | pth_read_ev @4 27 | pth_read @5 28 | pth_write_ev @6 29 | pth_write @7 30 | pth_accept_ev @8 31 | pth_accept @9 32 | pth_connect @10 33 | pth_select @11 34 | 35 | pth_mutex_release @12 36 | pth_mutex_acquire @13 37 | pth_mutex_init @14 38 | 39 | pth_attr_new @15 40 | pth_attr_destroy @16 41 | pth_attr_set @17 42 | 43 | pth_spawn @18 44 | pth_self @19 45 | pth_join @20 46 | pth_abort @21 47 | pth_exit @22 48 | pth_waitpid @23 49 | pth_wait @24 50 | 51 | pth_sleep @25 52 | pth_timeout @26 53 | 54 | pth_event_isolate @27 55 | pth_event_free @28 56 | pth_event_status @29 57 | pth_event_occurred @30 58 | pth_event_concat @31 59 | pth_event @32 60 | 61 | pth_select_ev @33 62 | pth_sigmask @34 63 | 64 | pth_rwlock_release @35 65 | pth_rwlock_acquire @36 66 | pth_rwlock_init @37 67 | 68 | pth_yield @38 69 | 70 | pth_pipe @39 71 | pth_close @40 72 | pth_mutex_destroy @41 73 | 74 | pth_usleep @42 75 | pth_thread_id @43 76 | 77 | pth_cancel @44 78 | 79 | pth_enter @45 80 | pth_leave @46 81 | 82 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # Makefile.am - Makefile for W32PTH 2 | # Copyright (C) 2007, 2008 g10 Code GmbH 3 | # 4 | # This file is part of W32PTH. 5 | # 6 | # W32PTH is free software; you can redistribute it and/or modify it 7 | # under the terms of the GNU LEsser General Public License as 8 | # published by the Free Software Foundation; either version 2.1 of the 9 | # License, or (at your option) any later version. 10 | # 11 | # W32PTH is distributed in the hope that it will be useful, but 12 | # WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | # Lesser General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU Lesser General Public 17 | # License along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | # 02110-1301, USA. 20 | 21 | ## Process this file with automake to produce Makefile.in 22 | 23 | ACLOCAL_AMFLAGS = -I m4 24 | AUTOMAKE_OPTIONS = no-dist-gzip dist-bzip2 25 | DISTCHECK_CONFIGURE_FLAGS = --host=i686-w64-mingw32 26 | 27 | EXTRA_DIST = autogen.sh pth-config.in libw32pth.def 28 | 29 | bin_SCRIPTS = pth-config 30 | include_HEADERS = pth.h 31 | lib_LTLIBRARIES = libw32pth.la 32 | 33 | RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ 34 | $(libgpg_error_la_CPPFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) 35 | LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE) 36 | 37 | SUFFIXES: .rc .lo 38 | 39 | .rc.lo: 40 | $(LTRCCOMPILE) -i $< -o $@ 41 | 42 | w32pth_res = versioninfo.lo 43 | no_undefined = -no-undefined 44 | export_symbols = -export-symbols $(srcdir)/libw32pth.def 45 | 46 | install-def-file: 47 | $(INSTALL) $(srcdir)/libw32pth.def $(DESTDIR)$(libdir)/libw32pth.def 48 | 49 | uninstall-def-file: 50 | -rm $(DESTDIR)$(libdir)/libw32pth.def 51 | 52 | # Note that the GPG_ERROR_CFLAGS are only required for W32CE and not 53 | # defined on plain Windows. 54 | libw32pth_la_CFLAGS = $(GPG_ERROR_CFLAGS) 55 | libw32pth_la_LDFLAGS = $(no_undefined) $(export_symbols) \ 56 | -version-info \ 57 | @W32PTH_LT_CURRENT@:@W32PTH_LT_REVISION@:@W32PTH_LT_AGE@ 58 | libw32pth_la_DEPENDENCIES = $(w32pth_res) libw32pth.def 59 | libw32pth_la_LIBADD = $(w32pth_res) @LTLIBOBJS@ $(NETLIBS) $(GPG_ERROR_LIBS) 60 | libw32pth_la_SOURCES = pth.h debug.h w32-pth.c w32-io.h w32-io.c utils.h 61 | 62 | 63 | install-data-local: install-def-file 64 | 65 | uninstall-local: uninstall-def-file 66 | 67 | dist-hook: 68 | @set -e; echo "$(VERSION)" > $(distdir)/VERSION 69 | 70 | -------------------------------------------------------------------------------- /m4/gpg-error.m4: -------------------------------------------------------------------------------- 1 | # gpg-error.m4 - autoconf macro to detect libgpg-error. 2 | # Copyright (C) 2002, 2003, 2004 g10 Code GmbH 3 | # 4 | # This file is free software; as a special exception the author gives 5 | # unlimited permission to copy and/or distribute it, with or without 6 | # modifications, as long as this notice is preserved. 7 | # 8 | # This file is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 10 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION, 13 | dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) 14 | dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS 15 | dnl 16 | AC_DEFUN([AM_PATH_GPG_ERROR], 17 | [ AC_ARG_WITH(gpg-error-prefix, 18 | AC_HELP_STRING([--with-gpg-error-prefix=PFX], 19 | [prefix where GPG Error is installed (optional)]), 20 | gpg_error_config_prefix="$withval", gpg_error_config_prefix="") 21 | if test x$gpg_error_config_prefix != x ; then 22 | if test x${GPG_ERROR_CONFIG+set} != xset ; then 23 | GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config 24 | fi 25 | fi 26 | 27 | AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no) 28 | min_gpg_error_version=ifelse([$1], ,0.0,$1) 29 | AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version) 30 | ok=no 31 | if test "$GPG_ERROR_CONFIG" != "no" ; then 32 | req_major=`echo $min_gpg_error_version | \ 33 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` 34 | req_minor=`echo $min_gpg_error_version | \ 35 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` 36 | gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version` 37 | major=`echo $gpg_error_config_version | \ 38 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` 39 | minor=`echo $gpg_error_config_version | \ 40 | sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` 41 | if test "$major" -gt "$req_major"; then 42 | ok=yes 43 | else 44 | if test "$major" -eq "$req_major"; then 45 | if test "$minor" -ge "$req_minor"; then 46 | ok=yes 47 | fi 48 | fi 49 | fi 50 | fi 51 | if test $ok = yes; then 52 | GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags` 53 | GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs` 54 | AC_MSG_RESULT([yes ($gpg_error_config_version)]) 55 | ifelse([$2], , :, [$2]) 56 | else 57 | GPG_ERROR_CFLAGS="" 58 | GPG_ERROR_LIBS="" 59 | AC_MSG_RESULT(no) 60 | ifelse([$3], , :, [$3]) 61 | fi 62 | AC_SUBST(GPG_ERROR_CFLAGS) 63 | AC_SUBST(GPG_ERROR_LIBS) 64 | ]) 65 | 66 | -------------------------------------------------------------------------------- /pth-config.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2007 g10 Code GmbH 3 | # 4 | # This file is free software; as a special exception the author gives 5 | # unlimited permission to copy and/or distribute it, with or without 6 | # modifications, as long as this notice is preserved. 7 | # 8 | # This file is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 10 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | 12 | PGM=pth-config 13 | libs="@W32PTH_CONFIG_LIBS@" 14 | cflags="@W32PTH_CONFIG_CFLAGS@" 15 | prefix=@prefix@ 16 | exec_prefix=@exec_prefix@ 17 | api_version="@W32PTH_CONFIG_API_VERSION@" 18 | 19 | includes="" 20 | libdirs="" 21 | exec_prefix_set=no 22 | echo_libs=no 23 | echo_ldflags=no 24 | echo_cflags=no 25 | echo_prefix=no 26 | echo_exec_prefix=no 27 | echo_api_version=no 28 | # Note: --all is currently a dummy. 29 | echo_all=no 30 | 31 | usage() 32 | { 33 | cat <&2 50 | fi 51 | 52 | while test $# -gt 0; do 53 | case "$1" in 54 | -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; 55 | *) optarg= ;; 56 | esac 57 | 58 | case $1 in 59 | --prefix=*) 60 | prefix=$optarg 61 | if test $exec_prefix_set = no ; then 62 | exec_prefix=$optarg 63 | fi 64 | ;; 65 | --prefix) 66 | echo_prefix=yes 67 | ;; 68 | --exec-prefix=*) 69 | exec_prefix=$optarg 70 | exec_prefix_set=yes 71 | ;; 72 | --exec-prefix) 73 | echo_exec_prefix=yes 74 | ;; 75 | --version) 76 | echo "W32 PTH @VERSION@" 77 | exit 0 78 | ;; 79 | --api-version) 80 | echo_api_version=yes 81 | ;; 82 | --cflags) 83 | echo_cflags=yes 84 | ;; 85 | --ldflags) 86 | echo_ldflags=yes 87 | ;; 88 | --libs) 89 | echo_libs=yes 90 | ;; 91 | --all) 92 | echo_all=yes 93 | ;; 94 | *) 95 | usage 1 1>&2 96 | ;; 97 | esac 98 | shift 99 | done 100 | 101 | if test "$echo_prefix" = "yes"; then 102 | echo $prefix 103 | fi 104 | 105 | if test "$echo_exec_prefix" = "yes"; then 106 | echo $exec_prefix 107 | fi 108 | 109 | if test "$echo_api_version" = "yes"; then 110 | echo "$api_version" 111 | fi 112 | 113 | if test "$echo_cflags" = "yes"; then 114 | includes="" 115 | if test "@includedir@" != "/usr/include" ; then 116 | includes="-I@includedir@" 117 | fi 118 | tmp="" 119 | for i in $includes $cflags; do 120 | if echo "$tmp" | fgrep -v -- "$i" >/dev/null; then 121 | tmp="$tmp $i" 122 | fi 123 | done 124 | echo $tmp 125 | fi 126 | 127 | if test "$echo_ldflags" = "yes"; then 128 | libdirs="" 129 | if test "@libdir@" != "/usr/lib" ; then 130 | libdirs="-L@libdir@" 131 | fi 132 | tmp="" 133 | for i in $libdirs; do 134 | if echo "$tmp" | fgrep -v -- "$i" >/dev/null; then 135 | tmp="$tmp $i" 136 | fi 137 | done 138 | echo $tmp 139 | fi 140 | 141 | if test "$echo_libs" = "yes"; then 142 | libdirs="" 143 | if test "@libdir@" != "/usr/lib" ; then 144 | libdirs="-L@libdir@" 145 | fi 146 | tmp="" 147 | for i in $libs; do 148 | if echo "$tmp" | fgrep -v -- "$i" >/dev/null; then 149 | tmp="$tmp $i" 150 | fi 151 | done 152 | echo $tmp 153 | fi 154 | -------------------------------------------------------------------------------- /compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand `-c -o'. 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software 7 | # Foundation, Inc. 8 | # Written by Tom Tromey . 9 | # 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | # This file is maintained in Automake, please report 29 | # bugs to or send patches to 30 | # . 31 | 32 | case $1 in 33 | '') 34 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 35 | exit 1; 36 | ;; 37 | -h | --h*) 38 | cat <<\EOF 39 | Usage: compile [--help] [--version] PROGRAM [ARGS] 40 | 41 | Wrapper for compilers which do not understand `-c -o'. 42 | Remove `-o dest.o' from ARGS, run PROGRAM with the remaining 43 | arguments, and rename the output as expected. 44 | 45 | If you are trying to build a whole package this is not the 46 | right script to run: please start by reading the file `INSTALL'. 47 | 48 | Report bugs to . 49 | EOF 50 | exit $? 51 | ;; 52 | -v | --v*) 53 | echo "compile $scriptversion" 54 | exit $? 55 | ;; 56 | esac 57 | 58 | ofile= 59 | cfile= 60 | eat= 61 | 62 | for arg 63 | do 64 | if test -n "$eat"; then 65 | eat= 66 | else 67 | case $1 in 68 | -o) 69 | # configure might choose to run compile as `compile cc -o foo foo.c'. 70 | # So we strip `-o arg' only if arg is an object. 71 | eat=1 72 | case $2 in 73 | *.o | *.obj) 74 | ofile=$2 75 | ;; 76 | *) 77 | set x "$@" -o "$2" 78 | shift 79 | ;; 80 | esac 81 | ;; 82 | *.c) 83 | cfile=$1 84 | set x "$@" "$1" 85 | shift 86 | ;; 87 | *) 88 | set x "$@" "$1" 89 | shift 90 | ;; 91 | esac 92 | fi 93 | shift 94 | done 95 | 96 | if test -z "$ofile" || test -z "$cfile"; then 97 | # If no `-o' option was seen then we might have been invoked from a 98 | # pattern rule where we don't need one. That is ok -- this is a 99 | # normal compilation that the losing compiler can handle. If no 100 | # `.c' file was seen then we are probably linking. That is also 101 | # ok. 102 | exec "$@" 103 | fi 104 | 105 | # Name of file we expect compiler to create. 106 | cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 107 | 108 | # Create the lock directory. 109 | # Note: use `[/\\:.-]' here to ensure that we don't use the same name 110 | # that we are using for the .o file. Also, base the name on the expected 111 | # object file name, since that is what matters with a parallel build. 112 | lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 113 | while true; do 114 | if mkdir "$lockdir" >/dev/null 2>&1; then 115 | break 116 | fi 117 | sleep 1 118 | done 119 | # FIXME: race condition here if user kills between mkdir and trap. 120 | trap "rmdir '$lockdir'; exit 1" 1 2 15 121 | 122 | # Run the compile. 123 | "$@" 124 | ret=$? 125 | 126 | if test -f "$cofile"; then 127 | mv "$cofile" "$ofile" 128 | elif test -f "${cofile}bj"; then 129 | mv "${cofile}bj" "$ofile" 130 | fi 131 | 132 | rmdir "$lockdir" 133 | exit $ret 134 | 135 | # Local Variables: 136 | # mode: shell-script 137 | # sh-indentation: 2 138 | # eval: (add-hook 'write-file-hooks 'time-stamp) 139 | # time-stamp-start: "scriptversion=" 140 | # time-stamp-format: "%:y-%02m-%02d.%02H" 141 | # time-stamp-time-zone: "UTC" 142 | # time-stamp-end: "; # UTC" 143 | # End: 144 | -------------------------------------------------------------------------------- /m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltsugar.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 14 | 15 | 16 | # lt_join(SEP, ARG1, [ARG2...]) 17 | # ----------------------------- 18 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 19 | # associated separator. 20 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 21 | # versions in m4sugar had bugs. 22 | m4_define([lt_join], 23 | [m4_if([$#], [1], [], 24 | [$#], [2], [[$2]], 25 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 26 | m4_define([_lt_join], 27 | [m4_if([$#$2], [2], [], 28 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 29 | 30 | 31 | # lt_car(LIST) 32 | # lt_cdr(LIST) 33 | # ------------ 34 | # Manipulate m4 lists. 35 | # These macros are necessary as long as will still need to support 36 | # Autoconf-2.59 which quotes differently. 37 | m4_define([lt_car], [[$1]]) 38 | m4_define([lt_cdr], 39 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 40 | [$#], 1, [], 41 | [m4_dquote(m4_shift($@))])]) 42 | m4_define([lt_unquote], $1) 43 | 44 | 45 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 46 | # ------------------------------------------ 47 | # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. 48 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 49 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 50 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 51 | # than defined and empty). 52 | # 53 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 54 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 55 | m4_define([lt_append], 56 | [m4_define([$1], 57 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 58 | 59 | 60 | 61 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 62 | # ---------------------------------------------------------- 63 | # Produce a SEP delimited list of all paired combinations of elements of 64 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 65 | # has the form PREFIXmINFIXSUFFIXn. 66 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 67 | m4_define([lt_combine], 68 | [m4_if(m4_eval([$# > 3]), [1], 69 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 70 | [[m4_foreach([_Lt_prefix], [$2], 71 | [m4_foreach([_Lt_suffix], 72 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 73 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 74 | 75 | 76 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 77 | # ----------------------------------------------------------------------- 78 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 79 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 80 | m4_define([lt_if_append_uniq], 81 | [m4_ifdef([$1], 82 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 83 | [lt_append([$1], [$2], [$3])$4], 84 | [$5])], 85 | [lt_append([$1], [$2], [$3])$4])]) 86 | 87 | 88 | # lt_dict_add(DICT, KEY, VALUE) 89 | # ----------------------------- 90 | m4_define([lt_dict_add], 91 | [m4_define([$1($2)], [$3])]) 92 | 93 | 94 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 95 | # -------------------------------------------- 96 | m4_define([lt_dict_add_subkey], 97 | [m4_define([$1($2:$3)], [$4])]) 98 | 99 | 100 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 101 | # ---------------------------------- 102 | m4_define([lt_dict_fetch], 103 | [m4_ifval([$3], 104 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 105 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 106 | 107 | 108 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 109 | # ----------------------------------------------------------------- 110 | m4_define([lt_if_dict_fetch], 111 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 112 | [$5], 113 | [$6])]) 114 | 115 | 116 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 117 | # -------------------------------------------------------------- 118 | m4_define([lt_dict_filter], 119 | [m4_if([$5], [], [], 120 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 121 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 122 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 123 | ]) 124 | -------------------------------------------------------------------------------- /m4/lt~obsolete.m4: -------------------------------------------------------------------------------- 1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004. 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 4 lt~obsolete.m4 11 | 12 | # These exist entirely to fool aclocal when bootstrapping libtool. 13 | # 14 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) 15 | # which have later been changed to m4_define as they aren't part of the 16 | # exported API, or moved to Autoconf or Automake where they belong. 17 | # 18 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 19 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 20 | # using a macro with the same name in our local m4/libtool.m4 it'll 21 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define 22 | # and doesn't know about Autoconf macros at all.) 23 | # 24 | # So we provide this file, which has a silly filename so it's always 25 | # included after everything else. This provides aclocal with the 26 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 27 | # because those macros already exist, or will be overwritten later. 28 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 29 | # 30 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 31 | # Yes, that means every name once taken will need to remain here until 32 | # we give up compatibility with versions before 1.7, at which point 33 | # we need to keep only those names which we still refer to. 34 | 35 | # This is to help aclocal find these macros, as it can't see m4_define. 36 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 37 | 38 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 39 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 40 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 41 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 42 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 43 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 44 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 45 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 46 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 47 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 48 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 49 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 50 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 51 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 52 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 53 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 54 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 55 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 56 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 57 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 58 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 59 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 60 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 61 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 62 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 63 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 64 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 65 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 66 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 67 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 68 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 69 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 70 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 71 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 72 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 73 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 74 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 75 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 76 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 77 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 78 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 79 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 80 | m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) 81 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 82 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 83 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 84 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 85 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 86 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 87 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 88 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 89 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 90 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 91 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 92 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 93 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Run this to generate all the initial makefiles, etc. 3 | # 4 | # Copyright (C) 2003 g10 Code GmbH 5 | # 6 | # This file is free software; as a special exception the author gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | # 10 | # This program is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 12 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | configure_ac="configure.ac" 15 | 16 | cvtver () { 17 | awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}' 18 | } 19 | 20 | check_version () { 21 | if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then 22 | return 0 23 | fi 24 | echo "**Error**: "\`$1\'" not installed or too old." >&2 25 | echo ' Version '$3' or newer is required.' >&2 26 | [ -n "$4" ] && echo ' Note that this is part of '\`$4\''.' >&2 27 | DIE="yes" 28 | return 1 29 | } 30 | 31 | DIE=no 32 | FORCE= 33 | if test x"$1" = x"--force"; then 34 | FORCE=" --force" 35 | shift 36 | fi 37 | 38 | # Begin list of optional variables sourced from ~/.gnupg-autogen.rc 39 | w32_toolprefixes= 40 | w32_extraoptions= 41 | w32ce_toolprefixes= 42 | w32ce_extraoptions= 43 | amd64_toolprefixes= 44 | # End list of optional variables sourced from ~/.gnupg-autogen.rc 45 | # What follows are variables which are sourced but default to 46 | # environment variables or lacking them hardcoded values. 47 | #w32root= 48 | #w32ce_root= 49 | #amd64root= 50 | 51 | if [ -f "$HOME/.gnupg-autogen.rc" ]; then 52 | echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" 53 | . "$HOME/.gnupg-autogen.rc" 54 | fi 55 | 56 | # Convenience option to use certain configure options for some hosts. 57 | myhost="" 58 | myhostsub="" 59 | case "$1" in 60 | --build-w32) 61 | myhost="w32" 62 | ;; 63 | --build-w32ce) 64 | myhost="w32" 65 | myhostsub="ce" 66 | ;; 67 | --build*) 68 | echo "**Error**: invalid build option $1" >&2 69 | exit 1 70 | ;; 71 | *) 72 | ;; 73 | esac 74 | 75 | 76 | 77 | # ***** W32 build script ******* 78 | # Used to cross-compile for Windows. 79 | if [ "$myhost" = "w32" ]; then 80 | tmp=`dirname $0` 81 | tsdir=`cd "$tmp"; pwd` 82 | shift 83 | if [ ! -f $tsdir/config.guess ]; then 84 | echo "$tsdir/config.guess not found" >&2 85 | exit 1 86 | fi 87 | build=`$tsdir/config.guess` 88 | 89 | case $myhostsub in 90 | ce) 91 | w32root="$w32ce_root" 92 | [ -z "$w32root" ] && w32root="$HOME/w32ce_root" 93 | toolprefixes="arm-mingw32ce" 94 | extra_options="--with-gpg-error-prefix=${w32root}" 95 | ;; 96 | *) 97 | [ -z "$w32root" ] && w32root="$HOME/w32root" 98 | toolprefixes="i686-w64-mingw32 i586-mingw32msvc i386-mingw32msvc" 99 | extra_options="" 100 | ;; 101 | esac 102 | echo "Using $w32root as standard install directory" >&2 103 | 104 | crossbindir= 105 | for host in $toolprefixes; do 106 | if ${host}-gcc --version >/dev/null 2>&1 ; then 107 | crossbindir=/usr/${host}/bin 108 | conf_CC="CC=${host}-gcc" 109 | break; 110 | fi 111 | done 112 | if [ -z "$crossbindir" ]; then 113 | echo "Cross compiler kit not installed" >&2 114 | if [ -z "$sub" ]; then 115 | echo "Under Debian GNU/Linux, you may install it using" >&2 116 | echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 117 | fi 118 | echo "Stop." >&2 119 | exit 1 120 | fi 121 | 122 | 123 | if [ -f "$tsdir/config.log" ]; then 124 | if ! head $tsdir/config.log | grep "$host" >/dev/null; then 125 | echo "Pease run a 'make distclean' first" >&2 126 | exit 1 127 | fi 128 | fi 129 | 130 | $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ 131 | --host=${host} --build=${build} ${extra_options} "$@" 132 | 133 | exit $? 134 | fi 135 | # ***** end W32 build script ******* 136 | 137 | 138 | 139 | # Grep the required versions from configure.ac 140 | autoconf_vers=`sed -n '/^AC_PREREQ(/ { 141 | s/^.*(\(.*\))/\1/p 142 | q 143 | }' ${configure_ac}` 144 | autoconf_vers_num=`echo "$autoconf_vers" | cvtver` 145 | 146 | automake_vers=`sed -n '/^min_automake_version=/ { 147 | s/^.*="\(.*\)"/\1/p 148 | q 149 | }' ${configure_ac}` 150 | automake_vers_num=`echo "$automake_vers" | cvtver` 151 | 152 | #gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { 153 | #s/^.*(\(.*\))/\1/p 154 | #q 155 | #}' ${configure_ac}` 156 | #gettext_vers_num=`echo "$gettext_vers" | cvtver` 157 | 158 | 159 | if [ -z "$autoconf_vers" -o -z "$automake_vers" ] 160 | then 161 | echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 162 | exit 1 163 | fi 164 | 165 | # Allow to override the default tool names 166 | AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} 167 | AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} 168 | 169 | AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} 170 | ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} 171 | 172 | #GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} 173 | #MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} 174 | 175 | if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then 176 | check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf 177 | fi 178 | if check_version $AUTOMAKE $automake_vers_num $automake_vers; then 179 | check_version $ACLOCAL $automake_vers_num $autoconf_vers automake 180 | fi 181 | #if check_version $GETTEXT $gettext_vers_num $gettext_vers; then 182 | # check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext 183 | #fi 184 | 185 | if test "$DIE" = "yes"; then 186 | cat </dev/null \ 33 | || echo 'Revision: 0')|sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)])) 34 | m4_define([git_revision], m4_esyscmd([git branch -v 2>/dev/null \ 35 | | awk '/^\* / {printf "%s",$3}'])) 36 | AC_INIT([w32pth], 37 | [my_version[]m4_if(my_issvn,[yes], 38 | [m4_if(git_revision,[],[-svn[]svn_revision],[-git[]git_revision])])], 39 | [gnupg-devel@gnupg.org]) 40 | 41 | # LT Version numbers: Remember to change them just *before* a release. 42 | # (Interfaces removed: CURRENT++, AGE=0, REVISION=0) 43 | # (Interfaces added: CURRENT++, AGE++, REVISION=0) 44 | # (No interfaces changed: REVISION++) 45 | # Please remember to document interface changes in the NEWS file. 46 | W32PTH_LT_CURRENT=2 47 | W32PTH_LT_AGE=2 48 | W32PTH_LT_REVISION=2 49 | #------------------- 50 | # If the API is changed in an incompatible way: increment the next counter. 51 | W32PTH_CONFIG_API_VERSION=1 52 | 53 | NEED_GPG_ERROR_VERSION=1.8 54 | 55 | m4_define([git_brevis],m4_esyscmd(printf "%u" 0x[]m4_substr(git_revision,0,4))) 56 | BUILD_REVISION=m4_if(git_revision,[],[svn_revision],[git_brevis]) 57 | PACKAGE=$PACKAGE_NAME 58 | VERSION=$PACKAGE_VERSION 59 | 60 | AC_CONFIG_SRCDIR([w32-pth.c]) 61 | AC_CANONICAL_TARGET 62 | AM_INIT_AUTOMAKE($PACKAGE, $VERSION) 63 | AM_CONFIG_HEADER(config.h) 64 | AC_CONFIG_MACRO_DIR([m4]) 65 | #AB_INIT 66 | 67 | AC_GNU_SOURCE 68 | 69 | 70 | AM_MAINTAINER_MODE 71 | 72 | 73 | AC_SUBST(W32PTH_LT_CURRENT) 74 | AC_SUBST(W32PTH_LT_AGE) 75 | AC_SUBST(W32PTH_LT_REVISION) 76 | AC_SUBST(PACKAGE) 77 | AC_SUBST(VERSION) 78 | AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package]) 79 | AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package]) 80 | 81 | # 82 | # Initialize libtool 83 | # 84 | LT_PREREQ([2.2.6]) 85 | LT_INIT([win32-dll disable-static]) 86 | LT_LANG([Windows Resource]) 87 | 88 | 89 | 90 | # Setup some stuff depending on host/target. 91 | have_w32_system=no 92 | have_w32ce_system=no 93 | case "${host}" in 94 | *-mingw32ce*) 95 | have_w32_system=yes 96 | have_w32ce_system=yes 97 | ;; 98 | *-*-mingw32*) 99 | have_w32_system=yes 100 | ;; 101 | *) 102 | AC_MSG_ERROR([[This package may only be build for W32 systems]]) 103 | ;; 104 | esac 105 | if test "$have_w32_system" = yes; then 106 | AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system]) 107 | if test "$have_w32ce_system" = yes; then 108 | AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE]) 109 | fi 110 | fi 111 | AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes) 112 | AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes) 113 | 114 | 115 | # Checks for programs. 116 | missing_dir=`cd $ac_aux_dir && pwd` 117 | AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) 118 | AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) 119 | AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) 120 | AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) 121 | AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) 122 | AC_PROG_AWK 123 | AC_PROG_CC 124 | AC_PROG_CPP 125 | AM_PROG_CC_C_O 126 | if test "x$ac_cv_prog_cc_c89" = "xno" ; then 127 | AC_MSG_ERROR([[No C-89 compiler found]]) 128 | fi 129 | AC_PROG_INSTALL 130 | AC_PROG_LN_S 131 | AC_PROG_MAKE_SET 132 | AC_C_INLINE 133 | 134 | 135 | if test "$GCC" = yes; then 136 | CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" 137 | 138 | AC_MSG_CHECKING([if gcc supports -Wpointer-arith]) 139 | _gcc_cflags_save=$CFLAGS 140 | CFLAGS="-Wpointer-arith" 141 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no) 142 | AC_MSG_RESULT($_gcc_wopt) 143 | CFLAGS=$_gcc_cflags_save; 144 | if test x"$_gcc_wopt" = xyes ; then 145 | CFLAGS="$CFLAGS -Wpointer-arith" 146 | fi 147 | 148 | AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign]) 149 | _gcc_cflags_save=$CFLAGS 150 | CFLAGS="-Wno-pointer-sign" 151 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no) 152 | AC_MSG_RESULT($_gcc_psign) 153 | CFLAGS=$_gcc_cflags_save; 154 | if test x"$_gcc_psign" = xyes ; then 155 | CFLAGS="$CFLAGS -Wno-pointer-sign" 156 | fi 157 | 158 | fi 159 | 160 | # 161 | # On W32CE we need gpg-error because this provides our errno.h replacement. 162 | # 163 | if test "$have_w32ce_system" = yes; then 164 | AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION") 165 | if test "x$GPG_ERROR_LIBS" = "x"; then 166 | AC_MSG_ERROR([libgpg-error is needed for Windows CE. 167 | See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .]) 168 | fi 169 | fi 170 | 171 | AH_BOTTOM([ 172 | /* Under WindowsCE we need gpg-error's strerror macro. */ 173 | #define GPG_ERR_ENABLE_ERRNO_MACROS 1 174 | ]) 175 | 176 | 177 | # 178 | # Set NETLIBS 179 | # 180 | if test "$have_w32ce_system" = yes; then 181 | NETLIBS="-lws2 $NETLIBS" 182 | else 183 | NETLIBS="-lws2_32 $NETLIBS" 184 | fi 185 | AC_SUBST(NETLIBS) 186 | 187 | 188 | # Checks for header files. 189 | AC_HEADER_STDC 190 | AC_CHECK_HEADERS([string.h signal.h]) 191 | 192 | # Checks for typedefs, structures, and compiler characteristics. 193 | AC_C_CONST 194 | 195 | AC_C_BIGENDIAN 196 | 197 | AC_CHECK_SIZEOF(unsigned int) 198 | AC_CHECK_SIZEOF(unsigned long) 199 | AC_CHECK_SIZEOF(long long) 200 | 201 | # To be used in pth-config 202 | W32PTH_CONFIG_LIBS="-lw32pth" 203 | W32PTH_CONFIG_CFLAGS="" 204 | AC_SUBST(W32PTH_CONFIG_LIBS) 205 | AC_SUBST(W32PTH_CONFIG_CFLAGS) 206 | AC_SUBST(W32PTH_CONFIG_API_VERSION) 207 | 208 | # The Makefiles need to know about cross compiling 209 | AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes) 210 | 211 | # Generate extended version information for W32. 212 | if test "$have_w32_system" = yes; then 213 | BUILD_TIMESTAMP=`date --iso-8601=minutes` 214 | changequote(,)dnl 215 | BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` 216 | changequote([,])dnl 217 | BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}" 218 | fi 219 | AC_SUBST(BUILD_REVISION) 220 | AC_SUBST(BUILD_TIMESTAMP) 221 | AC_SUBST(BUILD_FILEVERSION) 222 | AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION", 223 | [Subversion revision used to build this package]) 224 | 225 | 226 | AC_CONFIG_FILES([ 227 | Makefile 228 | versioninfo.rc 229 | pth-config 230 | ]) 231 | AC_OUTPUT 232 | 233 | 234 | echo " 235 | W32PTH v${VERSION} has been configured as follows: 236 | 237 | Platform: $host 238 | 239 | " 240 | 241 | -------------------------------------------------------------------------------- /debug.h: -------------------------------------------------------------------------------- 1 | /* debug.h - interface to debugging functions 2 | Copyright (C) 2002, 2004, 2005, 2007, 2008 g10 Code GmbH 3 | 4 | This file is part of PTH. 5 | 6 | PTH is free software; you can redistribute it and/or modify it 7 | under the terms of the GNU Lesser General Public License as 8 | published by the Free Software Foundation; either version 2.1 of 9 | the License, or (at your option) any later version. 10 | 11 | PTH is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this program; if not, write to the Free Software 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 19 | 02111-1307, USA. */ 20 | 21 | #ifndef DEBUG_H 22 | #define DEBUG_H 23 | 24 | #include 25 | 26 | 27 | /* Keeps the current debug level. Define marcos to test them. */ 28 | extern int debug_level; 29 | #ifdef HAVE_W32CE_SYSTEM 30 | extern HANDLE dbghd; 31 | #else 32 | extern FILE *dbgfp; 33 | #endif 34 | #define DBG_ERROR (debug_level >= 1) 35 | #define DBG_INFO (debug_level >= 2) 36 | #define DBG_CALLS (debug_level >= 3) 37 | 38 | #define DEBUG_ERROR 1 39 | #define DEBUG_INFO 2 40 | #define DEBUG_CALLS 3 41 | 42 | 43 | /* Indirect stringification, requires __STDC__ to work. */ 44 | #define STRINGIFY(v) #v 45 | #define XSTRINGIFY(v) STRINGIFY(v) 46 | 47 | /* Log the formatted string FORMAT at debug level LEVEL or higher. */ 48 | void _pth_debug (int level, const char *format, ...); 49 | 50 | 51 | /* Trace support. */ 52 | 53 | /* FIXME: For now. */ 54 | #define _pth_debug_trace() 1 55 | 56 | #define _TRACE(lvl, name, tag) \ 57 | int _pth_trace_level = lvl; \ 58 | const char *const _pth_trace_func = name; \ 59 | const char *const _pth_trace_tagname = STRINGIFY (tag); \ 60 | void *_pth_trace_tag = (void *) tag 61 | 62 | #define TRACE_BEG(lvl, name, tag) \ 63 | _TRACE (lvl, name, tag); \ 64 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): enter\n", \ 65 | _pth_trace_func, _pth_trace_tagname, \ 66 | _pth_trace_tag), 0 67 | #define TRACE_BEG0(lvl, name, tag, fmt) \ 68 | _TRACE (lvl, name, tag); \ 69 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ 70 | _pth_trace_func, _pth_trace_tagname, \ 71 | _pth_trace_tag), 0 72 | #define TRACE_BEG1(lvl, name, tag, fmt, arg1) \ 73 | _TRACE (lvl, name, tag); \ 74 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ 75 | _pth_trace_func, _pth_trace_tagname, \ 76 | _pth_trace_tag, arg1), 0 77 | #define TRACE_BEG2(lvl, name, tag, fmt, arg1, arg2) \ 78 | _TRACE (lvl, name, tag); \ 79 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ 80 | _pth_trace_func, _pth_trace_tagname, \ 81 | _pth_trace_tag, arg1, arg2), 0 82 | #define TRACE_BEG3(lvl, name, tag, fmt, arg1, arg2, arg3) \ 83 | _TRACE (lvl, name, tag); \ 84 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ 85 | _pth_trace_func, _pth_trace_tagname, \ 86 | _pth_trace_tag, arg1, arg2, arg3), 0 87 | #define TRACE_BEG4(lvl, name, tag, fmt, arg1, arg2, arg3, arg4) \ 88 | _TRACE (lvl, name, tag); \ 89 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): enter: " fmt "\n", \ 90 | _pth_trace_func, _pth_trace_tagname, \ 91 | _pth_trace_tag, arg1, arg2, arg3, arg4), 0 92 | 93 | #define TRACE(lvl, name, tag) \ 94 | _pth_debug (lvl, "%s (%s=0x%x): call\n", \ 95 | name, STRINGIFY (tag), (void *) tag), 0 96 | #define TRACE0(lvl, name, tag, fmt) \ 97 | _pth_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ 98 | name, STRINGIFY (tag), (void *) tag), 0 99 | #define TRACE1(lvl, name, tag, fmt, arg1) \ 100 | _pth_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ 101 | name, STRINGIFY (tag), (void *) tag, arg1), 0 102 | #define TRACE2(lvl, name, tag, fmt, arg1, arg2) \ 103 | _pth_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ 104 | name, STRINGIFY (tag), (void *) tag, arg1, arg2), 0 105 | #define TRACE3(lvl, name, tag, fmt, arg1, arg2, arg3) \ 106 | _pth_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ 107 | name, STRINGIFY (tag), (void *) tag, arg1, arg2, \ 108 | arg3), 0 109 | #define TRACE6(lvl, name, tag, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ 110 | _pth_debug (lvl, "%s (%s=0x%x): call: " fmt "\n", \ 111 | name, STRINGIFY (tag), (void *) tag, arg1, arg2, arg3, \ 112 | arg4, arg5, arg6), 0 113 | 114 | #define TRACE_ERR(err) \ 115 | err == 0 ? (TRACE_SUC ()) : \ 116 | (_pth_debug (_pth_trace_level, "%s (%s=0x%x): error: %s <%s>\n", \ 117 | _pth_trace_func, _pth_trace_tagname, \ 118 | _pth_trace_tag, pth_strerror (err), \ 119 | pth_strsource (err)), (err)) 120 | /* The cast to void suppresses GCC warnings. */ 121 | #define TRACE_SYSRES(res) \ 122 | res >= 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \ 123 | (_pth_debug (_pth_trace_level, "%s (%s=0x%x): error: %s\n", \ 124 | _pth_trace_func, _pth_trace_tagname, \ 125 | _pth_trace_tag, strerror (errno)), (res)) 126 | #define TRACE_SYSERR(res) \ 127 | res == 0 ? ((void) (TRACE_SUC1 ("result=%i", res)), (res)) : \ 128 | (_pth_debug (_pth_trace_level, "%s (%s=0x%x): error: %s\n", \ 129 | _pth_trace_func, _pth_trace_tagname, \ 130 | _pth_trace_tag, strerror (res)), (res)) 131 | 132 | #define TRACE_SUC() \ 133 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): leave\n", \ 134 | _pth_trace_func, _pth_trace_tagname, \ 135 | _pth_trace_tag), 0 136 | #define TRACE_SUC0(fmt) \ 137 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ 138 | _pth_trace_func, _pth_trace_tagname, \ 139 | _pth_trace_tag), 0 140 | #define TRACE_SUC1(fmt, arg1) \ 141 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ 142 | _pth_trace_func, _pth_trace_tagname, \ 143 | _pth_trace_tag, arg1), 0 144 | #define TRACE_SUC2(fmt, arg1, arg2) \ 145 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ 146 | _pth_trace_func, _pth_trace_tagname, \ 147 | _pth_trace_tag, arg1, arg2), 0 148 | #define TRACE_SUC5(fmt, arg1, arg2, arg3, arg4, arg5) \ 149 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): leave: " fmt "\n", \ 150 | _pth_trace_func, _pth_trace_tagname, \ 151 | _pth_trace_tag, arg1, arg2, arg3, arg4, arg5), 0 152 | 153 | #define TRACE_LOG(fmt) \ 154 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ 155 | _pth_trace_func, _pth_trace_tagname, \ 156 | _pth_trace_tag), 0 157 | #define TRACE_LOG1(fmt, arg1) \ 158 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ 159 | _pth_trace_func, _pth_trace_tagname, \ 160 | _pth_trace_tag, arg1), 0 161 | #define TRACE_LOG2(fmt, arg1, arg2) \ 162 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ 163 | _pth_trace_func, _pth_trace_tagname, \ 164 | _pth_trace_tag, arg1, arg2), 0 165 | #define TRACE_LOG3(fmt, arg1, arg2, arg3) \ 166 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ 167 | _pth_trace_func, _pth_trace_tagname, \ 168 | _pth_trace_tag, arg1, arg2, arg3), 0 169 | #define TRACE_LOG4(fmt, arg1, arg2, arg3, arg4) \ 170 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ 171 | _pth_trace_func, _pth_trace_tagname, \ 172 | _pth_trace_tag, arg1, arg2, arg3, arg4), 0 173 | #define TRACE_LOG6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \ 174 | _pth_debug (_pth_trace_level, "%s (%s=0x%x): check: " fmt "\n", \ 175 | _pth_trace_func, _pth_trace_tagname, \ 176 | _pth_trace_tag, arg1, arg2, arg3, arg4, arg5, \ 177 | arg6), 0 178 | 179 | #define TRACE_LOGBUF(buf, len) \ 180 | _pth_debug_buffer (_pth_trace_level, "%s (%s=0x%x): check: %s", \ 181 | _pth_trace_func, _pth_trace_tagname, \ 182 | _pth_trace_tag, buf, len) 183 | 184 | #define TRACE_SEQ(hlp,fmt) \ 185 | _pth_debug_begin (&(hlp), _pth_trace_level, \ 186 | "%s (%s=0x%x): check: " fmt, \ 187 | _pth_trace_func, _pth_trace_tagname, \ 188 | _pth_trace_tag) 189 | #define TRACE_ADD0(hlp,fmt) \ 190 | _pth_debug_add (&(hlp), fmt) 191 | #define TRACE_ADD1(hlp,fmt,a) \ 192 | _pth_debug_add (&(hlp), fmt, (a)) 193 | #define TRACE_ADD2(hlp,fmt,a,b) \ 194 | _pth_debug_add (&(hlp), fmt, (a), (b)) 195 | #define TRACE_ADD3(hlp,fmt,a,b,c) \ 196 | _pth_debug_add (&(hlp), fmt, (a), (b), (c)) 197 | #define TRACE_END(hlp,fmt) \ 198 | _pth_debug_add (&(hlp), fmt); \ 199 | _pth_debug_end (&(hlp)) 200 | #define TRACE_ENABLED(hlp) (!!(hlp)) 201 | 202 | #endif /* DEBUG_H */ 203 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2011-01-03 Werner Koch 2 | 3 | * configure.ac: Support git revision numbers. 4 | 5 | 2010-12-02 Marcus Brinkmann 6 | 7 | * w32-pth.c (w32ce_timer_thread): Oops. (Fix last change.) 8 | 9 | 2010-12-01 Marcus Brinkmann 10 | 11 | * w32-pth.c (w32ce_timer_thread): Use earliest timer, not latest. 12 | 13 | 2010-11-26 Werner Koch 14 | 15 | * w32-pth.c: Repalce all fprintf to DBGFP my _pth-debug calls. 16 | (pth_init): Ignore a debug-level of 0. 17 | (pth_init) [W32CE]: Open the GPG2 device. 18 | (log_get_prefix): Remove. Change all callers. 19 | (do_pth_write): Instrument with trace calls. 20 | * w32-io.c (_pth_debug) [W32CE]: Use the GPG2 device. 21 | * debug.h (dbghd) [W32CE]: New. 22 | 23 | 2010-09-01 Marcus Brinkmann 24 | 25 | * configure.ac: Define GPG_ERR_ENABLE_ERRNO_MACROS. 26 | 27 | 2010-08-06 Werner Koch 28 | 29 | * w32-pth.c (set_timer): Fix timer setting on plain windows. 30 | Fixes regression introduced on 2010-02-25. 31 | 32 | 2010-08-02 Werner Koch 33 | 34 | Release 2.0.4. 35 | 36 | * configure.ac: Set LT version to C2/A2/R1. 37 | 38 | * libw32pth.def (pth_enter, pth_leave): New. 39 | 40 | 2010-07-30 Werner Koch 41 | 42 | Release 2.0.3. 43 | 44 | * configure.ac: Set LT version to C2/A2/R0. 45 | 46 | 2010-07-21 Werner Koch 47 | 48 | * w32-pth.c (enter_leave_api_sentinel): New. 49 | (pth_enter, pth_leave): New. 50 | 51 | 2010-04-19 Werner Koch 52 | 53 | * w32-pth.c (is_socket_2): New. 54 | (do_pth_read, do_pth_write): Use is_socket_2. 55 | 56 | * w32-io.c (is_socket): New. 57 | (reader, writer): Use is_socket. 58 | 59 | 2010-04-08 Werner Koch 60 | 61 | * w32-io.c (reader, writer) [W32CE]: Take care of 62 | ERROR_PIPE_NOT_CONNECTED. 63 | 64 | 2010-03-23 Werner Koch 65 | 66 | * w32-io.c (create_pipe) [W32CE]: Change to new driver semantics. 67 | 68 | 2010-02-26 Werner Koch 69 | 70 | * w32-pth.c (w32ce_timer_thread): Take care of an empty timer 71 | list. 72 | 73 | 2010-02-25 Werner Koch 74 | 75 | * utils.h: New. 76 | (set_errno): New. Always use it to change ERRNO. 77 | * w32-io.c (pth_pipe) [W32CE]: Take care of handles being global. 78 | (create_pipe): New. Taken from libassuan. 79 | (pth_pipe): Use it. 80 | 81 | * w32-pth.c: Include utils.h. 82 | [!HAVE_SIGNAL_H]: Don't include signal.h. 83 | (w32_read_registry, getenv) [W32CE]: New. 84 | (destroy_timer): New. 85 | (do_pth_event_free): Use it instead of a CloseHandle. 86 | (w32ce_timer_thread): New. 87 | (create_timer) [W32CE]: Add CE implementation. 88 | (do_pth_wait) : Move timer setting to ... 89 | (set_timer): New. Add code for W32CE. 90 | (w32_strerror, wsa_strerror) [W32CE]: Do not use FormatMessage. 91 | (create_event) [W32CE]: Don't set to synchronize. 92 | 93 | * Makefile.am (libw32pth_la_LIBADD): Use NETLIBS. 94 | * configure.ac [W32CE]: Require gpg-error. 95 | (NETLIBS): New. 96 | * configure.ac: Test for signal.h. 97 | 98 | 2010-02-24 Werner Koch 99 | 100 | * ltmain.sh (wrappers_required): Don't set for mingw32ce. 101 | * ltmain.sh: Updated. 102 | 103 | * autogen.sh: Modernized. 104 | 105 | 2009-12-08 Marcus Brinkmann 106 | 107 | * libw32pth.def: Add pth_cancel. 108 | 109 | Update to libtool 2.2.6a. 110 | * configure.ac: Invoke AC_CONFIG_MACRO_DIR. 111 | (AC_LIBTOOL_WIN32_DLL, AC_LIBTOOL_RC): Replace by ... 112 | (LT_PREREQ, LT_INIT, LT_LANG): ... these. 113 | * config.guess, config.sub, install-sh, ltmain.sh: 114 | Updated to libtool 2.2.6a. 115 | * m4/libtool.m4, m4/ltoptions.m4, m4/ltsugar.m4, m4/ltversion.m4, 116 | m4/lt~obsolete.m4: New files from libtool 2.2.6a. 117 | * Makefile.am (LTRCCOMPILE): Refactor with ... 118 | (RCCOMPILE): ... this new macro. Add $(w32pth_la_CPPFLAGS). 119 | (SUFFIXES): Add .lo. 120 | (.rc.o): Change to ... 121 | (.rc.lo): ... this implicit rule. 122 | (w32pth_res_ldflag): Removed. 123 | (w32pth_res): Use libtool object file name here. 124 | (install-def-file): Fix typo. 125 | (w32pth_la_LDFLAGS): Remove w32pth_res_ldflag usage. 126 | (w32pth_la_LIBADD): Add w32pth_res. 127 | * depcomp, compile, INSTALL, missing: Update from automake 1.10. 128 | 129 | 2008-10-17 Marcus Brinkmann 130 | 131 | Released 2.0.2. 132 | 133 | * configure.ac (W32PTH_LT_CURRENT, W32PTH_LT_AGE): Bump. 134 | (W32PTH_LT_REVISION): Reset. 135 | 136 | 2008-10-15 Werner Koch 137 | 138 | * w32-pth.c (thread_counter): New. 139 | (pth_ctrl): Return thread counters. 140 | (launch_thread, pth_cancel, pth_abort): Track number of threads. 141 | (pth_init): Set counter to 1. 142 | 143 | * w32-pth.c (map_w32_to_errno): Return EPIPE. 144 | (do_pth_write): Fix bogus error checking for WriteFile. 145 | 146 | 2008-10-13 Werner Koch 147 | 148 | * pth.h (PTH_EVENT_HANDLE): New. Note that this was orginally 149 | implemented on 2007-11-20 but accidently not commited and thus 150 | later lost. 151 | * w32-pth.c (do_pth_event_body, do_pth_wait): Implement this event. 152 | (do_pth_event_free): Do not close HD for a handle event. 153 | 154 | 2008-05-27 Werner Koch 155 | 156 | * w32-pth.c (_pth_malloc, _pth_calloc, _pth_free): New. Always 157 | use these wrappers to be prepared to change the allocators. 158 | 159 | 2008-05-26 Werner Koch 160 | 161 | * w32-io.c (_pth_debug): Print tick, process and thread id. 162 | * w32-pth.c (enter_pth, leave_pth): Use debug function. 163 | 164 | * w32-pth.c (pth_thread_id): New. 165 | 166 | * libw32pth.def (pth_thread_id): New. 167 | 168 | 2008-03-25 Marcus Brinkmann 169 | 170 | * debug.h (DEBUG_INFO, DEBUG_CALLS): New macros. 171 | * w32-io.c (pth_pipe): Fix debug trace message. 172 | * w32-pth.c (fd_is_socket, do_pth_read, do_pth_write): Test for 173 | pipes first. 174 | (do_pth_event_body): Print spec debug in hex. 175 | (do_pth_wait): Use new debug interface, which uses EV as a tag. 176 | Catch unhandled event type. 177 | 178 | 2008-03-21 Marcus Brinkmann 179 | 180 | * pth.h (pth_usleep): New prototype. 181 | * w32-pth.c (pth_usleep): New function. 182 | * libw32pth.def: Add pth_usleep. 183 | 184 | * pth.h (pth_mutex_destroy): New prototype. 185 | * w32-pth.c (pth_mutex_destroy): New function. 186 | * libw32pth.def: Add pth_mutex_destroy. 187 | 188 | 2008-02-15 Marcus Brinkmann 189 | 190 | * w32-pth.c (map_wsa_to_errno, map_w32_to_errno): New functions. 191 | (do_pth_read, do_pth_write): Use these to set errno. 192 | 193 | 2008-02-12 Marcus Brinkmann 194 | 195 | * Makefile.in: Removed. 196 | * w32-pth.c (NO_PTH_MODE_STATIC): New macro. Use it everywhere 197 | where we have to release event resources. 198 | (spawn_helper_thread, wait_fd_thread, wait_for_fd): Removed. 199 | (do_pth_wait): Use WSAEventSelect for sockets. 200 | 201 | * Makefile.am (libw32pth_la_SOURCES): Add debug.h, w32-io.h and 202 | w32-io.c. 203 | * libw32pth.def: Add pth_pipe, pth_close. 204 | * pth.h (pth_pipe, pth_close): New prototypes. 205 | * debug.h, w32-io.h, w32-io.c: New files. 206 | * w32-pth.c: Include "debug.h" and "w32-io.h". 207 | (debug_level, dbgfp): Make non-static. 208 | (DBG_ERROR, DBG_INFO, DBG_CALLS): Moved to debug.h. 209 | (fd_is_socket): New function. 210 | (pth_init): Call _pth_sema_subsystem_init. 211 | (do_pth_read): New function, supports pipes. 212 | (pth_read_ev): Implement it. 213 | (pth_read): Use do_pth_read. 214 | (do_pth_write): New function, supports pipes. 215 | (pth_write_ev): Implement it. 216 | (pth_write): Use do_pth_write. 217 | (do_pth_wait): Support pipes. Use actual events waited upon when 218 | gathering the results. Use R instead of EV in build_fdarray 219 | invocation. Do not reset the event for pipes. Add lengthy note 220 | about remaining issues. 221 | (do_pth_event_body): Fix type in va_arg invocation. 222 | 223 | 2007-08-16 Werner Koch 224 | 225 | Released 2.0.1. 226 | 227 | * configure.ac: Bump LT version to C0/A0/R1. 228 | 229 | 2007-08-13 Werner Koch 230 | 231 | * w32-pth.c (pth_init): Allow setting of a debug file. 232 | 233 | 2007-07-27 Marcus Brinkmann 234 | 235 | * w32-pth.c (pth_select): Reimplement in terms of pth_select_ev. 236 | 237 | 2007-07-26 Marcus Brinkmann 238 | 239 | * libw32pth.def: Add pth_rwlock_init, pth_rwlock_acquire, 240 | pth_rwlock_release, and pth_yield. 241 | * pth.h (pth_yield): New prototype. 242 | * w32-pth.c (pth_yield): New function. 243 | 244 | 2007-07-20 Marcus Brinkmann 245 | 246 | * pth.h (PTH_RWLOCK_RD, PTH_RWLOCK_RW): New symbols. 247 | (pth_rwlock_t): New type. 248 | * w32-pth.c (pth_rwlock_init, pth_rwlock_acquire, 249 | (pth_rwlock_release): New functions. 250 | 251 | 2007-07-05 Werner Koch 252 | 253 | Released 2.0.0 (first release). 254 | 255 | 2007-07-04 Werner Koch 256 | 257 | * w32-pth.c: Major rewrite of the event stuff. 258 | 259 | 2007-07-03 Werner Koch 260 | 261 | * Makefile.am (libw32pth_la_LIBADD): Use ws2_32 instead of wsock32. 262 | 263 | 2007-06-29 Werner Koch 264 | 265 | * w32-pth.c (pth_event_add): Remove. 266 | (pth_event_concat): Correctly implement as a ring. 267 | (do_pth_wait): Fixed bug which let us wait only on the first 268 | event. More or less rewrote it. 269 | (do_pth_event_occurred): Removed and repalced by direct call to 270 | the STATUS field of the event. 271 | (pth_event_status): Changed implementation to accommodate the 272 | changed do_pth_wait. 273 | (pth_event_status): Ditto. 274 | 275 | 2007-06-28 Werner Koch 276 | 277 | * w32-pth.c (sig_handler): Ignore the logoff and close event. 278 | (do_pth_event_body): Properly ignore the static mode. 279 | (do_pth_event_body): Implement PTH_EVENT_SELECT. 280 | (wait_select_thread): New. 281 | (pth_select_ev): Support ev_extra. 282 | 283 | 2007-06-25 Werner Koch 284 | 285 | * w32-pth.c (pth_mutex_init): Remove superfluous free. 286 | 287 | 2007-06-15 Werner Koch 288 | 289 | * autogen.sh: Use = and not == in test to be POSIXly correct. 290 | 291 | 2007-05-30 Werner Koch 292 | 293 | Package created. 294 | * w32-pth.c, w32-pth.h: Taken from GnuPG 2.0.4 295 | 296 | 297 | Copyright 2007, 2010 g10 Code GmbH 298 | 299 | This file is free software; as a special exception the author gives 300 | unlimited permission to copy and/or distribute it, with or without 301 | modifications, as long as this notice is preserved. 302 | 303 | This file is distributed in the hope that it will be useful, but 304 | WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 305 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 306 | -------------------------------------------------------------------------------- /pth.h: -------------------------------------------------------------------------------- 1 | /* pth.h - GNU Pth emulation for W32 (MS Windows). 2 | * Copyright (c) 1999-2003 Ralf S. Engelschall 3 | * Copyright (C) 2004, 2006, 2007, 2008, 2010 g10 Code GmbH 4 | * 5 | * This file is part of W32PTH. 6 | * 7 | * W32PTH is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as 9 | * published by the Free Software Foundation; either version 2.1 of 10 | * the License, or (at your option) any later version. 11 | * 12 | * W32PTh is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this program; if not, see . 19 | * 20 | * ------------------------------------------------------------------ 21 | * This code is based on Ralf Engelschall's GNU Pth, a non-preemptive 22 | * thread scheduling library which can be found at 23 | * http://www.gnu.org/software/pth/. 24 | */ 25 | 26 | #ifndef _W32_PTH_H 27 | #define _W32_PTH_H 28 | 29 | #ifdef _PTH_H_ 30 | #error w32pth conflict. A vanilla pth.h has already been included. 31 | #endif 32 | 33 | #include /* Newer mingw version require this to be 34 | included before windows.h. */ 35 | 36 | /* #include /\* We need this for sockaddr et al. FIXME: too */ 37 | /* heavyweight - may be we should factor such */ 38 | /* code out to a second header and adjust all */ 39 | /* user files to include it only if required. *\/ */ 40 | 41 | /* Mingw64 defines sigset_t only of _POSIX is defined. We don't want 42 | to do define this macro because we are a public header. Thus we 43 | use a bit of mingw64 internal knowledge to declare sigset_t. */ 44 | #include 45 | #if __MINGW64_VERSION_MAJOR >= 2 && !defined(_POSIX) 46 | typedef _sigset_t sigset_t; 47 | #endif /* mingw64 >= 2 */ 48 | 49 | 50 | #ifndef W32_PTH_HANDLE_INTERNAL 51 | #define W32_PTH_HANDLE_INTERNAL int 52 | #endif 53 | 54 | /* These are needed for pipe support. Sigh. */ 55 | int pth_pipe (int filedes[2], int inherit_idx); 56 | int pth_close (int fd); 57 | 58 | 59 | /* We need to define value for the how argument of pth_sigmask. This 60 | is required because Mingw does not yet define sigprocmask. We use 61 | an enum to error out if Mingw eventually defines them. Also define 62 | the sigset_t. */ 63 | #ifdef __MINGW32__ 64 | enum 65 | { 66 | SIG_BLOCK = 0, 67 | SIG_UNBLOCK = 1, 68 | SIG_SETMASK = 2 69 | }; 70 | #endif /*__MINGW32__*/ 71 | 72 | /* Filedescriptor blocking modes. */ 73 | enum 74 | { 75 | PTH_FDMODE_ERROR = -1, 76 | PTH_FDMODE_POLL = 0, 77 | PTH_FDMODE_BLOCK, 78 | PTH_FDMODE_NONBLOCK 79 | }; 80 | 81 | 82 | /* Mutex values. */ 83 | #define PTH_MUTEX_INITIALIZED (1<<0) 84 | #define PTH_MUTEX_LOCKED (1<<1) 85 | 86 | /* Note: We can't do static initialization, thus we don't define the 87 | initializer PTH_MUTEX_INIT. */ 88 | 89 | /* Read-write lock values. */ 90 | enum 91 | { 92 | PTH_RWLOCK_RD, 93 | PTH_RWLOCK_RW 94 | }; 95 | 96 | /* Note: We can't do static initialization, thus we don't define the 97 | initializer PTH_RWLOCK_INIT. */ 98 | 99 | 100 | #define PTH_KEY_INIT (1<<0) 101 | 102 | 103 | /* Event subject classes. */ 104 | #define PTH_EVENT_FD (1<<1) 105 | #define PTH_EVENT_SELECT (1<<2) 106 | #define PTH_EVENT_SIGS (1<<3) 107 | #define PTH_EVENT_TIME (1<<4) 108 | #define PTH_EVENT_MSG (1<<5) 109 | #define PTH_EVENT_MUTEX (1<<6) 110 | #define PTH_EVENT_COND (1<<7) 111 | #define PTH_EVENT_TID (1<<8) 112 | #define PTH_EVENT_FUNC (1<<9) 113 | #define PTH_EVENT_HANDLE (1<<10) /* A generic waitable W32 HANDLE. */ 114 | 115 | /* Event occurrence restrictions. */ 116 | #define PTH_UNTIL_OCCURRED (1<<11) 117 | #define PTH_UNTIL_FD_READABLE (1<<12) 118 | #define PTH_UNTIL_FD_WRITEABLE (1<<13) 119 | #define PTH_UNTIL_FD_EXCEPTION (1<<14) 120 | #define PTH_UNTIL_TID_NEW (1<<15) 121 | #define PTH_UNTIL_TID_READY (1<<16) 122 | #define PTH_UNTIL_TID_WAITING (1<<17) 123 | #define PTH_UNTIL_TID_DEAD (1<<18) 124 | 125 | 126 | /* Event structure handling modes. */ 127 | #define PTH_MODE_REUSE (1<<20) 128 | #define PTH_MODE_CHAIN (1<<21) 129 | #define PTH_MODE_STATIC (1<<22) 130 | 131 | 132 | /* Attribute commands for pth_attr_get and pth_attr_set(). */ 133 | enum 134 | { 135 | PTH_ATTR_PRIO, /* RW [int] Priority of thread. */ 136 | PTH_ATTR_NAME, /* RW [char *] Name of thread. */ 137 | PTH_ATTR_JOINABLE, /* RW [int] Thread detachment type. */ 138 | PTH_ATTR_CANCEL_STATE, /* RW [unsigned int] Thread cancellation state.*/ 139 | PTH_ATTR_STACK_SIZE, /* RW [unsigned int] Stack size. */ 140 | PTH_ATTR_STACK_ADDR, /* RW [char *] Stack lower address. */ 141 | PTH_ATTR_DISPATCHES, /* RO [int] Total number of 142 | thread dispatches. */ 143 | PTH_ATTR_TIME_SPAWN, /* RO [pth_time_t] Time thread was spawned. */ 144 | PTH_ATTR_TIME_LAST, /* RO [pth_time_t] Time thread was 145 | last dispatched. */ 146 | PTH_ATTR_TIME_RAN, /* RO [pth_time_t] Time thread was running. */ 147 | PTH_ATTR_START_FUNC, /* RO [void *(*)(void *)] Thread start function.*/ 148 | PTH_ATTR_START_ARG, /* RO [void *] Thread start argument. */ 149 | PTH_ATTR_STATE, /* RO [pth_state_t] Scheduling state. */ 150 | PTH_ATTR_EVENTS, /* RO [pth_event_t] Events the thread 151 | is waiting for. */ 152 | PTH_ATTR_BOUND /* RO [int] Whether object is 153 | bound to thread. */ 154 | }; 155 | 156 | 157 | 158 | /* Queries for pth_ctrl(). */ 159 | #define PTH_CTRL_GETAVLOAD (1<<1) 160 | #define PTH_CTRL_GETPRIO (1<<2) 161 | #define PTH_CTRL_GETNAME (1<<3) 162 | #define PTH_CTRL_GETTHREADS_NEW (1<<4) 163 | #define PTH_CTRL_GETTHREADS_READY (1<<5) 164 | #define PTH_CTRL_GETTHREADS_RUNNING (1<<6) 165 | #define PTH_CTRL_GETTHREADS_WAITING (1<<7) 166 | #define PTH_CTRL_GETTHREADS_SUSPENDED (1<<8) 167 | #define PTH_CTRL_GETTHREADS_DEAD (1<<9) 168 | #define PTH_CTRL_DUMPSTATE (1<<10) 169 | 170 | #define PTH_CTRL_GETTHREADS ( PTH_CTRL_GETTHREADS_NEW \ 171 | | PTH_CTRL_GETTHREADS_READY \ 172 | | PTH_CTRL_GETTHREADS_RUNNING \ 173 | | PTH_CTRL_GETTHREADS_WAITING \ 174 | | PTH_CTRL_GETTHREADS_SUSPENDED \ 175 | | PTH_CTRL_GETTHREADS_DEAD ) 176 | 177 | 178 | /* Event status codes. */ 179 | typedef enum 180 | { 181 | PTH_STATUS_PENDING, 182 | PTH_STATUS_OCCURRED, 183 | PTH_STATUS_FAILED 184 | } 185 | pth_status_t; 186 | 187 | 188 | /* Event deallocation types. */ 189 | enum 190 | { 191 | PTH_FREE_THIS, 192 | PTH_FREE_ALL 193 | }; 194 | 195 | 196 | /* The Pth thread handle object. */ 197 | typedef void *pth_t; 198 | 199 | 200 | /* The Mutex object. */ 201 | typedef W32_PTH_HANDLE_INTERNAL pth_mutex_t; 202 | 203 | /* The read-write lock object. */ 204 | typedef W32_PTH_HANDLE_INTERNAL pth_rwlock_t; 205 | 206 | 207 | /* The Event object. */ 208 | struct pth_event_s; 209 | typedef struct pth_event_s *pth_event_t; 210 | 211 | 212 | /* The Attribute object. */ 213 | struct pth_attr_s; 214 | typedef struct pth_attr_s *pth_attr_t; 215 | 216 | 217 | /* The Key object. */ 218 | typedef int pth_key_t; 219 | 220 | 221 | /* The Pth time object. */ 222 | typedef struct timeval pth_time_t; 223 | 224 | 225 | /* Function prototypes. */ 226 | int pth_init (void); 227 | int pth_kill (void); 228 | long pth_ctrl (unsigned long query, ...); 229 | 230 | int pth_read_ev (int fd, void *buffer, size_t size, pth_event_t ev); 231 | int pth_read (int fd, void *buffer, size_t size); 232 | int pth_write_ev (int fd, const void *buffer, size_t size, pth_event_t ev); 233 | int pth_write (int fd, const void *buffer, size_t size); 234 | 235 | int pth_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, 236 | const struct timeval *timeout); 237 | int pth_select_ev (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, 238 | const struct timeval * timeout, pth_event_t ev_extra); 239 | 240 | int pth_accept (int fd, struct sockaddr *addr, int *addrlen); 241 | int pth_accept_ev (int fd, struct sockaddr *addr, int *addrlen, 242 | pth_event_t hd); 243 | 244 | int pth_connect (int fd, struct sockaddr *name, int namelen); 245 | 246 | 247 | int pth_mutex_release (pth_mutex_t *hd); 248 | int pth_mutex_acquire(pth_mutex_t *hd, int try_only, pth_event_t ev_extra); 249 | int pth_mutex_init (pth_mutex_t *hd); 250 | /* We need this under windows, otherwise we would leak handles. */ 251 | int pth_mutex_destroy (pth_mutex_t *hd); 252 | 253 | int pth_rwlock_init (pth_rwlock_t *rwlock); 254 | int pth_rwlock_acquire (pth_rwlock_t *rwlock, int op, int try, pth_event_t ev); 255 | int pth_rwlock_release (pth_rwlock_t *rwlock); 256 | 257 | 258 | pth_attr_t pth_attr_new (void); 259 | int pth_attr_destroy (pth_attr_t hd); 260 | int pth_attr_set (pth_attr_t hd, int field, ...); 261 | 262 | pth_t pth_spawn (pth_attr_t hd, void *(*func)(void *), void *arg); 263 | pth_t pth_self (void); 264 | int pth_join (pth_t hd, void **value); 265 | int pth_abort (pth_t hd); 266 | void pth_exit (void *value); 267 | 268 | unsigned int pth_waitpid (unsigned int, int *status, int options); 269 | int pth_wait (pth_event_t hd); 270 | 271 | int pth_sleep (int n); 272 | int pth_usleep (unsigned int usec); 273 | pth_time_t pth_timeout (long sec, long usec); 274 | 275 | 276 | 277 | pth_event_t pth_event_isolate (pth_event_t hd); 278 | int pth_event_free (pth_event_t hd, int mode); 279 | int pth_event_status (pth_event_t hd); 280 | int pth_event_occurred (pth_event_t hd); 281 | pth_event_t pth_event_concat (pth_event_t ev, ...); 282 | pth_event_t pth_event (unsigned long spec, ...); 283 | 284 | 285 | int pth_sigmask (int how, const sigset_t *set, sigset_t *old); 286 | 287 | int pth_yield (pth_t tid); 288 | 289 | void pth_enter (void); 290 | void pth_leave (void); 291 | 292 | 293 | /* Special W32 function to cope with the problem that pth_self returns 294 | just a pseudo handle which is not very useful for debugging. */ 295 | unsigned long pth_thread_id (void); 296 | #define PTH_HAVE_PTH_THREAD_ID 1 297 | 298 | 299 | /*-- pth_util.c --*/ 300 | 301 | /* void sigemptyset (struct sigset_s * ss); */ 302 | 303 | /* int sigaddset (struct sigset_s * ss, int signo); */ 304 | 305 | 306 | 307 | #endif /*_W32_PTH_H*/ 308 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 7 | # 2008, 2009 Free Software Foundation, Inc. 8 | # Originally by Fran,cois Pinard , 1996. 9 | 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | if test $# -eq 0; then 29 | echo 1>&2 "Try \`$0 --help' for more information" 30 | exit 1 31 | fi 32 | 33 | run=: 34 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 35 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 36 | 37 | # In the cases where this matters, `missing' is being run in the 38 | # srcdir already. 39 | if test -f configure.ac; then 40 | configure_ac=configure.ac 41 | else 42 | configure_ac=configure.in 43 | fi 44 | 45 | msg="missing on your system" 46 | 47 | case $1 in 48 | --run) 49 | # Try to run requested program, and just exit if it succeeds. 50 | run= 51 | shift 52 | "$@" && exit 0 53 | # Exit code 63 means version mismatch. This often happens 54 | # when the user try to use an ancient version of a tool on 55 | # a file that requires a minimum version. In this case we 56 | # we should proceed has if the program had been absent, or 57 | # if --run hadn't been passed. 58 | if test $? = 63; then 59 | run=: 60 | msg="probably too old" 61 | fi 62 | ;; 63 | 64 | -h|--h|--he|--hel|--help) 65 | echo "\ 66 | $0 [OPTION]... PROGRAM [ARGUMENT]... 67 | 68 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 69 | error status if there is no known handling for PROGRAM. 70 | 71 | Options: 72 | -h, --help display this help and exit 73 | -v, --version output version information and exit 74 | --run try to run the given command, and emulate it if it fails 75 | 76 | Supported PROGRAM values: 77 | aclocal touch file \`aclocal.m4' 78 | autoconf touch file \`configure' 79 | autoheader touch file \`config.h.in' 80 | autom4te touch the output file, or create a stub one 81 | automake touch all \`Makefile.in' files 82 | bison create \`y.tab.[ch]', if possible, from existing .[ch] 83 | flex create \`lex.yy.c', if possible, from existing .c 84 | help2man touch the output file 85 | lex create \`lex.yy.c', if possible, from existing .c 86 | makeinfo touch the output file 87 | tar try tar, gnutar, gtar, then tar without non-portable flags 88 | yacc create \`y.tab.[ch]', if possible, from existing .[ch] 89 | 90 | Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and 91 | \`g' are ignored when checking the name. 92 | 93 | Send bug reports to ." 94 | exit $? 95 | ;; 96 | 97 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 98 | echo "missing $scriptversion (GNU Automake)" 99 | exit $? 100 | ;; 101 | 102 | -*) 103 | echo 1>&2 "$0: Unknown \`$1' option" 104 | echo 1>&2 "Try \`$0 --help' for more information" 105 | exit 1 106 | ;; 107 | 108 | esac 109 | 110 | # normalize program name to check for. 111 | program=`echo "$1" | sed ' 112 | s/^gnu-//; t 113 | s/^gnu//; t 114 | s/^g//; t'` 115 | 116 | # Now exit if we have it, but it failed. Also exit now if we 117 | # don't have it and --version was passed (most likely to detect 118 | # the program). This is about non-GNU programs, so use $1 not 119 | # $program. 120 | case $1 in 121 | lex*|yacc*) 122 | # Not GNU programs, they don't have --version. 123 | ;; 124 | 125 | tar*) 126 | if test -n "$run"; then 127 | echo 1>&2 "ERROR: \`tar' requires --run" 128 | exit 1 129 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 130 | exit 1 131 | fi 132 | ;; 133 | 134 | *) 135 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 136 | # We have it, but it failed. 137 | exit 1 138 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 139 | # Could not run --version or --help. This is probably someone 140 | # running `$TOOL --version' or `$TOOL --help' to check whether 141 | # $TOOL exists and not knowing $TOOL uses missing. 142 | exit 1 143 | fi 144 | ;; 145 | esac 146 | 147 | # If it does not exist, or fails to run (possibly an outdated version), 148 | # try to emulate it. 149 | case $program in 150 | aclocal*) 151 | echo 1>&2 "\ 152 | WARNING: \`$1' is $msg. You should only need it if 153 | you modified \`acinclude.m4' or \`${configure_ac}'. You might want 154 | to install the \`Automake' and \`Perl' packages. Grab them from 155 | any GNU archive site." 156 | touch aclocal.m4 157 | ;; 158 | 159 | autoconf*) 160 | echo 1>&2 "\ 161 | WARNING: \`$1' is $msg. You should only need it if 162 | you modified \`${configure_ac}'. You might want to install the 163 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 164 | archive site." 165 | touch configure 166 | ;; 167 | 168 | autoheader*) 169 | echo 1>&2 "\ 170 | WARNING: \`$1' is $msg. You should only need it if 171 | you modified \`acconfig.h' or \`${configure_ac}'. You might want 172 | to install the \`Autoconf' and \`GNU m4' packages. Grab them 173 | from any GNU archive site." 174 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 175 | test -z "$files" && files="config.h" 176 | touch_files= 177 | for f in $files; do 178 | case $f in 179 | *:*) touch_files="$touch_files "`echo "$f" | 180 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 181 | *) touch_files="$touch_files $f.in";; 182 | esac 183 | done 184 | touch $touch_files 185 | ;; 186 | 187 | automake*) 188 | echo 1>&2 "\ 189 | WARNING: \`$1' is $msg. You should only need it if 190 | you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 191 | You might want to install the \`Automake' and \`Perl' packages. 192 | Grab them from any GNU archive site." 193 | find . -type f -name Makefile.am -print | 194 | sed 's/\.am$/.in/' | 195 | while read f; do touch "$f"; done 196 | ;; 197 | 198 | autom4te*) 199 | echo 1>&2 "\ 200 | WARNING: \`$1' is needed, but is $msg. 201 | You might have modified some files without having the 202 | proper tools for further handling them. 203 | You can get \`$1' as part of \`Autoconf' from any GNU 204 | archive site." 205 | 206 | file=`echo "$*" | sed -n "$sed_output"` 207 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 208 | if test -f "$file"; then 209 | touch $file 210 | else 211 | test -z "$file" || exec >$file 212 | echo "#! /bin/sh" 213 | echo "# Created by GNU Automake missing as a replacement of" 214 | echo "# $ $@" 215 | echo "exit 0" 216 | chmod +x $file 217 | exit 1 218 | fi 219 | ;; 220 | 221 | bison*|yacc*) 222 | echo 1>&2 "\ 223 | WARNING: \`$1' $msg. You should only need it if 224 | you modified a \`.y' file. You may need the \`Bison' package 225 | in order for those modifications to take effect. You can get 226 | \`Bison' from any GNU archive site." 227 | rm -f y.tab.c y.tab.h 228 | if test $# -ne 1; then 229 | eval LASTARG="\${$#}" 230 | case $LASTARG in 231 | *.y) 232 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 233 | if test -f "$SRCFILE"; then 234 | cp "$SRCFILE" y.tab.c 235 | fi 236 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 237 | if test -f "$SRCFILE"; then 238 | cp "$SRCFILE" y.tab.h 239 | fi 240 | ;; 241 | esac 242 | fi 243 | if test ! -f y.tab.h; then 244 | echo >y.tab.h 245 | fi 246 | if test ! -f y.tab.c; then 247 | echo 'main() { return 0; }' >y.tab.c 248 | fi 249 | ;; 250 | 251 | lex*|flex*) 252 | echo 1>&2 "\ 253 | WARNING: \`$1' is $msg. You should only need it if 254 | you modified a \`.l' file. You may need the \`Flex' package 255 | in order for those modifications to take effect. You can get 256 | \`Flex' from any GNU archive site." 257 | rm -f lex.yy.c 258 | if test $# -ne 1; then 259 | eval LASTARG="\${$#}" 260 | case $LASTARG in 261 | *.l) 262 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 263 | if test -f "$SRCFILE"; then 264 | cp "$SRCFILE" lex.yy.c 265 | fi 266 | ;; 267 | esac 268 | fi 269 | if test ! -f lex.yy.c; then 270 | echo 'main() { return 0; }' >lex.yy.c 271 | fi 272 | ;; 273 | 274 | help2man*) 275 | echo 1>&2 "\ 276 | WARNING: \`$1' is $msg. You should only need it if 277 | you modified a dependency of a manual page. You may need the 278 | \`Help2man' package in order for those modifications to take 279 | effect. You can get \`Help2man' from any GNU archive site." 280 | 281 | file=`echo "$*" | sed -n "$sed_output"` 282 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 283 | if test -f "$file"; then 284 | touch $file 285 | else 286 | test -z "$file" || exec >$file 287 | echo ".ab help2man is required to generate this page" 288 | exit $? 289 | fi 290 | ;; 291 | 292 | makeinfo*) 293 | echo 1>&2 "\ 294 | WARNING: \`$1' is $msg. You should only need it if 295 | you modified a \`.texi' or \`.texinfo' file, or any other file 296 | indirectly affecting the aspect of the manual. The spurious 297 | call might also be the consequence of using a buggy \`make' (AIX, 298 | DU, IRIX). You might want to install the \`Texinfo' package or 299 | the \`GNU make' package. Grab either from any GNU archive site." 300 | # The file to touch is that specified with -o ... 301 | file=`echo "$*" | sed -n "$sed_output"` 302 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 303 | if test -z "$file"; then 304 | # ... or it is the one specified with @setfilename ... 305 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 306 | file=`sed -n ' 307 | /^@setfilename/{ 308 | s/.* \([^ ]*\) *$/\1/ 309 | p 310 | q 311 | }' $infile` 312 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 313 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 314 | fi 315 | # If the file does not exist, the user really needs makeinfo; 316 | # let's fail without touching anything. 317 | test -f $file || exit 1 318 | touch $file 319 | ;; 320 | 321 | tar*) 322 | shift 323 | 324 | # We have already tried tar in the generic part. 325 | # Look for gnutar/gtar before invocation to avoid ugly error 326 | # messages. 327 | if (gnutar --version > /dev/null 2>&1); then 328 | gnutar "$@" && exit 0 329 | fi 330 | if (gtar --version > /dev/null 2>&1); then 331 | gtar "$@" && exit 0 332 | fi 333 | firstarg="$1" 334 | if shift; then 335 | case $firstarg in 336 | *o*) 337 | firstarg=`echo "$firstarg" | sed s/o//` 338 | tar "$firstarg" "$@" && exit 0 339 | ;; 340 | esac 341 | case $firstarg in 342 | *h*) 343 | firstarg=`echo "$firstarg" | sed s/h//` 344 | tar "$firstarg" "$@" && exit 0 345 | ;; 346 | esac 347 | fi 348 | 349 | echo 1>&2 "\ 350 | WARNING: I can't seem to be able to run \`tar' with the given arguments. 351 | You may want to install GNU tar or Free paxutils, or check the 352 | command line arguments." 353 | exit 1 354 | ;; 355 | 356 | *) 357 | echo 1>&2 "\ 358 | WARNING: \`$1' is needed, and is $msg. 359 | You might have modified some files without having the 360 | proper tools for further handling them. Check the \`README' file, 361 | it often tells you about the needed prerequisites for installing 362 | this package. You may also peek at any GNU archive site, in case 363 | some other package would contain this missing \`$1' program." 364 | exit 1 365 | ;; 366 | esac 367 | 368 | exit 0 369 | 370 | # Local variables: 371 | # eval: (add-hook 'write-file-hooks 'time-stamp) 372 | # time-stamp-start: "scriptversion=" 373 | # time-stamp-format: "%:y-%02m-%02d.%02H" 374 | # time-stamp-time-zone: "UTC" 375 | # time-stamp-end: "; # UTC" 376 | # End: 377 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 5 | 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 6 | 7 | This file is free documentation; the Free Software Foundation gives 8 | unlimited permission to copy, distribute and modify it. 9 | 10 | Basic Installation 11 | ================== 12 | 13 | Briefly, the shell commands `./configure; make; make install' should 14 | configure, build, and install this package. The following 15 | more-detailed instructions are generic; see the `README' file for 16 | instructions specific to this package. 17 | 18 | The `configure' shell script attempts to guess correct values for 19 | various system-dependent variables used during compilation. It uses 20 | those values to create a `Makefile' in each directory of the package. 21 | It may also create one or more `.h' files containing system-dependent 22 | definitions. Finally, it creates a shell script `config.status' that 23 | you can run in the future to recreate the current configuration, and a 24 | file `config.log' containing compiler output (useful mainly for 25 | debugging `configure'). 26 | 27 | It can also use an optional file (typically called `config.cache' 28 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 29 | the results of its tests to speed up reconfiguring. Caching is 30 | disabled by default to prevent problems with accidental use of stale 31 | cache files. 32 | 33 | If you need to do unusual things to compile the package, please try 34 | to figure out how `configure' could check whether to do them, and mail 35 | diffs or instructions to the address given in the `README' so they can 36 | be considered for the next release. If you are using the cache, and at 37 | some point `config.cache' contains results you don't want to keep, you 38 | may remove or edit it. 39 | 40 | The file `configure.ac' (or `configure.in') is used to create 41 | `configure' by a program called `autoconf'. You need `configure.ac' if 42 | you want to change it or regenerate `configure' using a newer version 43 | of `autoconf'. 44 | 45 | The simplest way to compile this package is: 46 | 47 | 1. `cd' to the directory containing the package's source code and type 48 | `./configure' to configure the package for your system. 49 | 50 | Running `configure' might take a while. While running, it prints 51 | some messages telling which features it is checking for. 52 | 53 | 2. Type `make' to compile the package. 54 | 55 | 3. Optionally, type `make check' to run any self-tests that come with 56 | the package. 57 | 58 | 4. Type `make install' to install the programs and any data files and 59 | documentation. 60 | 61 | 5. You can remove the program binaries and object files from the 62 | source code directory by typing `make clean'. To also remove the 63 | files that `configure' created (so you can compile the package for 64 | a different kind of computer), type `make distclean'. There is 65 | also a `make maintainer-clean' target, but that is intended mainly 66 | for the package's developers. If you use it, you may have to get 67 | all sorts of other programs in order to regenerate files that came 68 | with the distribution. 69 | 70 | 6. Often, you can also type `make uninstall' to remove the installed 71 | files again. 72 | 73 | Compilers and Options 74 | ===================== 75 | 76 | Some systems require unusual options for compilation or linking that 77 | the `configure' script does not know about. Run `./configure --help' 78 | for details on some of the pertinent environment variables. 79 | 80 | You can give `configure' initial values for configuration parameters 81 | by setting variables in the command line or in the environment. Here 82 | is an example: 83 | 84 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 85 | 86 | *Note Defining Variables::, for more details. 87 | 88 | Compiling For Multiple Architectures 89 | ==================================== 90 | 91 | You can compile the package for more than one kind of computer at the 92 | same time, by placing the object files for each architecture in their 93 | own directory. To do this, you can use GNU `make'. `cd' to the 94 | directory where you want the object files and executables to go and run 95 | the `configure' script. `configure' automatically checks for the 96 | source code in the directory that `configure' is in and in `..'. 97 | 98 | With a non-GNU `make', it is safer to compile the package for one 99 | architecture at a time in the source code directory. After you have 100 | installed the package for one architecture, use `make distclean' before 101 | reconfiguring for another architecture. 102 | 103 | On MacOS X 10.5 and later systems, you can create libraries and 104 | executables that work on multiple system types--known as "fat" or 105 | "universal" binaries--by specifying multiple `-arch' options to the 106 | compiler but only a single `-arch' option to the preprocessor. Like 107 | this: 108 | 109 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 110 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 111 | CPP="gcc -E" CXXCPP="g++ -E" 112 | 113 | This is not guaranteed to produce working output in all cases, you 114 | may have to build one architecture at a time and combine the results 115 | using the `lipo' tool if you have problems. 116 | 117 | Installation Names 118 | ================== 119 | 120 | By default, `make install' installs the package's commands under 121 | `/usr/local/bin', include files under `/usr/local/include', etc. You 122 | can specify an installation prefix other than `/usr/local' by giving 123 | `configure' the option `--prefix=PREFIX'. 124 | 125 | You can specify separate installation prefixes for 126 | architecture-specific files and architecture-independent files. If you 127 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 128 | PREFIX as the prefix for installing programs and libraries. 129 | Documentation and other data files still use the regular prefix. 130 | 131 | In addition, if you use an unusual directory layout you can give 132 | options like `--bindir=DIR' to specify different values for particular 133 | kinds of files. Run `configure --help' for a list of the directories 134 | you can set and what kinds of files go in them. 135 | 136 | If the package supports it, you can cause programs to be installed 137 | with an extra prefix or suffix on their names by giving `configure' the 138 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 139 | 140 | Optional Features 141 | ================= 142 | 143 | Some packages pay attention to `--enable-FEATURE' options to 144 | `configure', where FEATURE indicates an optional part of the package. 145 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 146 | is something like `gnu-as' or `x' (for the X Window System). The 147 | `README' should mention any `--enable-' and `--with-' options that the 148 | package recognizes. 149 | 150 | For packages that use the X Window System, `configure' can usually 151 | find the X include and library files automatically, but if it doesn't, 152 | you can use the `configure' options `--x-includes=DIR' and 153 | `--x-libraries=DIR' to specify their locations. 154 | 155 | Particular systems 156 | ================== 157 | 158 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU 159 | CC is not installed, it is recommended to use the following options in 160 | order to use an ANSI C compiler: 161 | 162 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 163 | 164 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 165 | 166 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 167 | parse its `' header file. The option `-nodtk' can be used as 168 | a workaround. If GNU CC is not installed, it is therefore recommended 169 | to try 170 | 171 | ./configure CC="cc" 172 | 173 | and if that doesn't work, try 174 | 175 | ./configure CC="cc -nodtk" 176 | 177 | On Solaris, don't put `/usr/ucb' early in your `PATH'. This 178 | directory contains several dysfunctional programs; working variants of 179 | these programs are available in `/usr/bin'. So, if you need `/usr/ucb' 180 | in your `PATH', put it _after_ `/usr/bin'. 181 | 182 | On Haiku, software installed for all users goes in `/boot/common', 183 | not `/usr/local'. It is recommended to use the following options: 184 | 185 | ./configure --prefix=/boot/common 186 | 187 | Specifying the System Type 188 | ========================== 189 | 190 | There may be some features `configure' cannot figure out 191 | automatically, but needs to determine by the type of machine the package 192 | will run on. Usually, assuming the package is built to be run on the 193 | _same_ architectures, `configure' can figure that out, but if it prints 194 | a message saying it cannot guess the machine type, give it the 195 | `--build=TYPE' option. TYPE can either be a short name for the system 196 | type, such as `sun4', or a canonical name which has the form: 197 | 198 | CPU-COMPANY-SYSTEM 199 | 200 | where SYSTEM can have one of these forms: 201 | 202 | OS 203 | KERNEL-OS 204 | 205 | See the file `config.sub' for the possible values of each field. If 206 | `config.sub' isn't included in this package, then this package doesn't 207 | need to know the machine type. 208 | 209 | If you are _building_ compiler tools for cross-compiling, you should 210 | use the option `--target=TYPE' to select the type of system they will 211 | produce code for. 212 | 213 | If you want to _use_ a cross compiler, that generates code for a 214 | platform different from the build platform, you should specify the 215 | "host" platform (i.e., that on which the generated programs will 216 | eventually be run) with `--host=TYPE'. 217 | 218 | Sharing Defaults 219 | ================ 220 | 221 | If you want to set default values for `configure' scripts to share, 222 | you can create a site shell script called `config.site' that gives 223 | default values for variables like `CC', `cache_file', and `prefix'. 224 | `configure' looks for `PREFIX/share/config.site' if it exists, then 225 | `PREFIX/etc/config.site' if it exists. Or, you can set the 226 | `CONFIG_SITE' environment variable to the location of the site script. 227 | A warning: not all `configure' scripts look for a site script. 228 | 229 | Defining Variables 230 | ================== 231 | 232 | Variables not defined in a site shell script can be set in the 233 | environment passed to `configure'. However, some packages may run 234 | configure again during the build, and the customized values of these 235 | variables may be lost. In order to avoid this problem, you should set 236 | them in the `configure' command line, using `VAR=value'. For example: 237 | 238 | ./configure CC=/usr/local2/bin/gcc 239 | 240 | causes the specified `gcc' to be used as the C compiler (unless it is 241 | overridden in the site shell script). 242 | 243 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to 244 | an Autoconf bug. Until the bug is fixed you can use this workaround: 245 | 246 | CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash 247 | 248 | `configure' Invocation 249 | ====================== 250 | 251 | `configure' recognizes the following options to control how it 252 | operates. 253 | 254 | `--help' 255 | `-h' 256 | Print a summary of all of the options to `configure', and exit. 257 | 258 | `--help=short' 259 | `--help=recursive' 260 | Print a summary of the options unique to this package's 261 | `configure', and exit. The `short' variant lists options used 262 | only in the top level, while the `recursive' variant lists options 263 | also present in any nested packages. 264 | 265 | `--version' 266 | `-V' 267 | Print the version of Autoconf used to generate the `configure' 268 | script, and exit. 269 | 270 | `--cache-file=FILE' 271 | Enable the cache: use and save the results of the tests in FILE, 272 | traditionally `config.cache'. FILE defaults to `/dev/null' to 273 | disable caching. 274 | 275 | `--config-cache' 276 | `-C' 277 | Alias for `--cache-file=config.cache'. 278 | 279 | `--quiet' 280 | `--silent' 281 | `-q' 282 | Do not print messages saying which checks are being made. To 283 | suppress all normal output, redirect it to `/dev/null' (any error 284 | messages will still be shown). 285 | 286 | `--srcdir=DIR' 287 | Look for the package's source code in directory DIR. Usually 288 | `configure' can determine that directory automatically. 289 | 290 | `--prefix=DIR' 291 | Use DIR as the installation prefix. *Note Installation Names:: 292 | for more details, including other options available for fine-tuning 293 | the installation locations. 294 | 295 | `--no-create' 296 | `-n' 297 | Run the configure checks, but stop before creating any output 298 | files. 299 | 300 | `configure' also accepts some other, not widely useful, options. Run 301 | `configure --help' for more details. 302 | 303 | -------------------------------------------------------------------------------- /m4/ltoptions.m4: -------------------------------------------------------------------------------- 1 | # Helper functions for option handling. -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. 4 | # Written by Gary V. Vaughan, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # serial 6 ltoptions.m4 11 | 12 | # This is to help aclocal find these macros, as it can't see m4_define. 13 | AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) 14 | 15 | 16 | # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) 17 | # ------------------------------------------ 18 | m4_define([_LT_MANGLE_OPTION], 19 | [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) 20 | 21 | 22 | # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) 23 | # --------------------------------------- 24 | # Set option OPTION-NAME for macro MACRO-NAME, and if there is a 25 | # matching handler defined, dispatch to it. Other OPTION-NAMEs are 26 | # saved as a flag. 27 | m4_define([_LT_SET_OPTION], 28 | [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl 29 | m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), 30 | _LT_MANGLE_DEFUN([$1], [$2]), 31 | [m4_warning([Unknown $1 option `$2'])])[]dnl 32 | ]) 33 | 34 | 35 | # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) 36 | # ------------------------------------------------------------ 37 | # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. 38 | m4_define([_LT_IF_OPTION], 39 | [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) 40 | 41 | 42 | # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) 43 | # ------------------------------------------------------- 44 | # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME 45 | # are set. 46 | m4_define([_LT_UNLESS_OPTIONS], 47 | [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), 48 | [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), 49 | [m4_define([$0_found])])])[]dnl 50 | m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 51 | ])[]dnl 52 | ]) 53 | 54 | 55 | # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) 56 | # ---------------------------------------- 57 | # OPTION-LIST is a space-separated list of Libtool options associated 58 | # with MACRO-NAME. If any OPTION has a matching handler declared with 59 | # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about 60 | # the unknown option and exit. 61 | m4_defun([_LT_SET_OPTIONS], 62 | [# Set options 63 | m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), 64 | [_LT_SET_OPTION([$1], _LT_Option)]) 65 | 66 | m4_if([$1],[LT_INIT],[ 67 | dnl 68 | dnl Simply set some default values (i.e off) if boolean options were not 69 | dnl specified: 70 | _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no 71 | ]) 72 | _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no 73 | ]) 74 | dnl 75 | dnl If no reference was made to various pairs of opposing options, then 76 | dnl we run the default mode handler for the pair. For example, if neither 77 | dnl `shared' nor `disable-shared' was passed, we enable building of shared 78 | dnl archives by default: 79 | _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) 80 | _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) 81 | _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) 82 | _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], 83 | [_LT_ENABLE_FAST_INSTALL]) 84 | ]) 85 | ])# _LT_SET_OPTIONS 86 | 87 | 88 | ## --------------------------------- ## 89 | ## Macros to handle LT_INIT options. ## 90 | ## --------------------------------- ## 91 | 92 | # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) 93 | # ----------------------------------------- 94 | m4_define([_LT_MANGLE_DEFUN], 95 | [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) 96 | 97 | 98 | # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) 99 | # ----------------------------------------------- 100 | m4_define([LT_OPTION_DEFINE], 101 | [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl 102 | ])# LT_OPTION_DEFINE 103 | 104 | 105 | # dlopen 106 | # ------ 107 | LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes 108 | ]) 109 | 110 | AU_DEFUN([AC_LIBTOOL_DLOPEN], 111 | [_LT_SET_OPTION([LT_INIT], [dlopen]) 112 | AC_DIAGNOSE([obsolete], 113 | [$0: Remove this warning and the call to _LT_SET_OPTION when you 114 | put the `dlopen' option into LT_INIT's first parameter.]) 115 | ]) 116 | 117 | dnl aclocal-1.4 backwards compatibility: 118 | dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) 119 | 120 | 121 | # win32-dll 122 | # --------- 123 | # Declare package support for building win32 dll's. 124 | LT_OPTION_DEFINE([LT_INIT], [win32-dll], 125 | [enable_win32_dll=yes 126 | 127 | case $host in 128 | *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) 129 | AC_CHECK_TOOL(AS, as, false) 130 | AC_CHECK_TOOL(DLLTOOL, dlltool, false) 131 | AC_CHECK_TOOL(OBJDUMP, objdump, false) 132 | ;; 133 | esac 134 | 135 | test -z "$AS" && AS=as 136 | _LT_DECL([], [AS], [0], [Assembler program])dnl 137 | 138 | test -z "$DLLTOOL" && DLLTOOL=dlltool 139 | _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl 140 | 141 | test -z "$OBJDUMP" && OBJDUMP=objdump 142 | _LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl 143 | ])# win32-dll 144 | 145 | AU_DEFUN([AC_LIBTOOL_WIN32_DLL], 146 | [AC_REQUIRE([AC_CANONICAL_HOST])dnl 147 | _LT_SET_OPTION([LT_INIT], [win32-dll]) 148 | AC_DIAGNOSE([obsolete], 149 | [$0: Remove this warning and the call to _LT_SET_OPTION when you 150 | put the `win32-dll' option into LT_INIT's first parameter.]) 151 | ]) 152 | 153 | dnl aclocal-1.4 backwards compatibility: 154 | dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) 155 | 156 | 157 | # _LT_ENABLE_SHARED([DEFAULT]) 158 | # ---------------------------- 159 | # implement the --enable-shared flag, and supports the `shared' and 160 | # `disable-shared' LT_INIT options. 161 | # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 162 | m4_define([_LT_ENABLE_SHARED], 163 | [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl 164 | AC_ARG_ENABLE([shared], 165 | [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], 166 | [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], 167 | [p=${PACKAGE-default} 168 | case $enableval in 169 | yes) enable_shared=yes ;; 170 | no) enable_shared=no ;; 171 | *) 172 | enable_shared=no 173 | # Look at the argument we got. We use all the common list separators. 174 | lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 175 | for pkg in $enableval; do 176 | IFS="$lt_save_ifs" 177 | if test "X$pkg" = "X$p"; then 178 | enable_shared=yes 179 | fi 180 | done 181 | IFS="$lt_save_ifs" 182 | ;; 183 | esac], 184 | [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) 185 | 186 | _LT_DECL([build_libtool_libs], [enable_shared], [0], 187 | [Whether or not to build shared libraries]) 188 | ])# _LT_ENABLE_SHARED 189 | 190 | LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) 191 | LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) 192 | 193 | # Old names: 194 | AC_DEFUN([AC_ENABLE_SHARED], 195 | [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) 196 | ]) 197 | 198 | AC_DEFUN([AC_DISABLE_SHARED], 199 | [_LT_SET_OPTION([LT_INIT], [disable-shared]) 200 | ]) 201 | 202 | AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) 203 | AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) 204 | 205 | dnl aclocal-1.4 backwards compatibility: 206 | dnl AC_DEFUN([AM_ENABLE_SHARED], []) 207 | dnl AC_DEFUN([AM_DISABLE_SHARED], []) 208 | 209 | 210 | 211 | # _LT_ENABLE_STATIC([DEFAULT]) 212 | # ---------------------------- 213 | # implement the --enable-static flag, and support the `static' and 214 | # `disable-static' LT_INIT options. 215 | # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 216 | m4_define([_LT_ENABLE_STATIC], 217 | [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl 218 | AC_ARG_ENABLE([static], 219 | [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], 220 | [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], 221 | [p=${PACKAGE-default} 222 | case $enableval in 223 | yes) enable_static=yes ;; 224 | no) enable_static=no ;; 225 | *) 226 | enable_static=no 227 | # Look at the argument we got. We use all the common list separators. 228 | lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 229 | for pkg in $enableval; do 230 | IFS="$lt_save_ifs" 231 | if test "X$pkg" = "X$p"; then 232 | enable_static=yes 233 | fi 234 | done 235 | IFS="$lt_save_ifs" 236 | ;; 237 | esac], 238 | [enable_static=]_LT_ENABLE_STATIC_DEFAULT) 239 | 240 | _LT_DECL([build_old_libs], [enable_static], [0], 241 | [Whether or not to build static libraries]) 242 | ])# _LT_ENABLE_STATIC 243 | 244 | LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) 245 | LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) 246 | 247 | # Old names: 248 | AC_DEFUN([AC_ENABLE_STATIC], 249 | [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) 250 | ]) 251 | 252 | AC_DEFUN([AC_DISABLE_STATIC], 253 | [_LT_SET_OPTION([LT_INIT], [disable-static]) 254 | ]) 255 | 256 | AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) 257 | AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) 258 | 259 | dnl aclocal-1.4 backwards compatibility: 260 | dnl AC_DEFUN([AM_ENABLE_STATIC], []) 261 | dnl AC_DEFUN([AM_DISABLE_STATIC], []) 262 | 263 | 264 | 265 | # _LT_ENABLE_FAST_INSTALL([DEFAULT]) 266 | # ---------------------------------- 267 | # implement the --enable-fast-install flag, and support the `fast-install' 268 | # and `disable-fast-install' LT_INIT options. 269 | # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. 270 | m4_define([_LT_ENABLE_FAST_INSTALL], 271 | [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl 272 | AC_ARG_ENABLE([fast-install], 273 | [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], 274 | [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], 275 | [p=${PACKAGE-default} 276 | case $enableval in 277 | yes) enable_fast_install=yes ;; 278 | no) enable_fast_install=no ;; 279 | *) 280 | enable_fast_install=no 281 | # Look at the argument we got. We use all the common list separators. 282 | lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," 283 | for pkg in $enableval; do 284 | IFS="$lt_save_ifs" 285 | if test "X$pkg" = "X$p"; then 286 | enable_fast_install=yes 287 | fi 288 | done 289 | IFS="$lt_save_ifs" 290 | ;; 291 | esac], 292 | [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) 293 | 294 | _LT_DECL([fast_install], [enable_fast_install], [0], 295 | [Whether or not to optimize for fast installation])dnl 296 | ])# _LT_ENABLE_FAST_INSTALL 297 | 298 | LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) 299 | LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) 300 | 301 | # Old names: 302 | AU_DEFUN([AC_ENABLE_FAST_INSTALL], 303 | [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) 304 | AC_DIAGNOSE([obsolete], 305 | [$0: Remove this warning and the call to _LT_SET_OPTION when you put 306 | the `fast-install' option into LT_INIT's first parameter.]) 307 | ]) 308 | 309 | AU_DEFUN([AC_DISABLE_FAST_INSTALL], 310 | [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) 311 | AC_DIAGNOSE([obsolete], 312 | [$0: Remove this warning and the call to _LT_SET_OPTION when you put 313 | the `disable-fast-install' option into LT_INIT's first parameter.]) 314 | ]) 315 | 316 | dnl aclocal-1.4 backwards compatibility: 317 | dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) 318 | dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) 319 | 320 | 321 | # _LT_WITH_PIC([MODE]) 322 | # -------------------- 323 | # implement the --with-pic flag, and support the `pic-only' and `no-pic' 324 | # LT_INIT options. 325 | # MODE is either `yes' or `no'. If omitted, it defaults to `both'. 326 | m4_define([_LT_WITH_PIC], 327 | [AC_ARG_WITH([pic], 328 | [AS_HELP_STRING([--with-pic], 329 | [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], 330 | [pic_mode="$withval"], 331 | [pic_mode=default]) 332 | 333 | test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) 334 | 335 | _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl 336 | ])# _LT_WITH_PIC 337 | 338 | LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) 339 | LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) 340 | 341 | # Old name: 342 | AU_DEFUN([AC_LIBTOOL_PICMODE], 343 | [_LT_SET_OPTION([LT_INIT], [pic-only]) 344 | AC_DIAGNOSE([obsolete], 345 | [$0: Remove this warning and the call to _LT_SET_OPTION when you 346 | put the `pic-only' option into LT_INIT's first parameter.]) 347 | ]) 348 | 349 | dnl aclocal-1.4 backwards compatibility: 350 | dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) 351 | 352 | ## ----------------- ## 353 | ## LTDL_INIT Options ## 354 | ## ----------------- ## 355 | 356 | m4_define([_LTDL_MODE], []) 357 | LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], 358 | [m4_define([_LTDL_MODE], [nonrecursive])]) 359 | LT_OPTION_DEFINE([LTDL_INIT], [recursive], 360 | [m4_define([_LTDL_MODE], [recursive])]) 361 | LT_OPTION_DEFINE([LTDL_INIT], [subproject], 362 | [m4_define([_LTDL_MODE], [subproject])]) 363 | 364 | m4_define([_LTDL_TYPE], []) 365 | LT_OPTION_DEFINE([LTDL_INIT], [installable], 366 | [m4_define([_LTDL_TYPE], [installable])]) 367 | LT_OPTION_DEFINE([LTDL_INIT], [convenience], 368 | [m4_define([_LTDL_TYPE], [convenience])]) 369 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # `make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | shift;; 160 | 161 | -T) no_target_directory=true;; 162 | 163 | --version) echo "$0 $scriptversion"; exit $?;; 164 | 165 | --) shift 166 | break;; 167 | 168 | -*) echo "$0: invalid option: $1" >&2 169 | exit 1;; 170 | 171 | *) break;; 172 | esac 173 | shift 174 | done 175 | 176 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177 | # When -d is used, all remaining arguments are directories to create. 178 | # When -t is used, the destination is already specified. 179 | # Otherwise, the last argument is the destination. Remove it from $@. 180 | for arg 181 | do 182 | if test -n "$dst_arg"; then 183 | # $@ is not empty: it contains at least $arg. 184 | set fnord "$@" "$dst_arg" 185 | shift # fnord 186 | fi 187 | shift # arg 188 | dst_arg=$arg 189 | done 190 | fi 191 | 192 | if test $# -eq 0; then 193 | if test -z "$dir_arg"; then 194 | echo "$0: no input file specified." >&2 195 | exit 1 196 | fi 197 | # It's OK to call `install-sh -d' without argument. 198 | # This can happen when creating conditional directories. 199 | exit 0 200 | fi 201 | 202 | if test -z "$dir_arg"; then 203 | trap '(exit $?); exit' 1 2 13 15 204 | 205 | # Set umask so as not to create temps with too-generous modes. 206 | # However, 'strip' requires both read and write access to temps. 207 | case $mode in 208 | # Optimize common cases. 209 | *644) cp_umask=133;; 210 | *755) cp_umask=22;; 211 | 212 | *[0-7]) 213 | if test -z "$stripcmd"; then 214 | u_plus_rw= 215 | else 216 | u_plus_rw='% 200' 217 | fi 218 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 219 | *) 220 | if test -z "$stripcmd"; then 221 | u_plus_rw= 222 | else 223 | u_plus_rw=,u+rw 224 | fi 225 | cp_umask=$mode$u_plus_rw;; 226 | esac 227 | fi 228 | 229 | for src 230 | do 231 | # Protect names starting with `-'. 232 | case $src in 233 | -*) src=./$src;; 234 | esac 235 | 236 | if test -n "$dir_arg"; then 237 | dst=$src 238 | dstdir=$dst 239 | test -d "$dstdir" 240 | dstdir_status=$? 241 | else 242 | 243 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 244 | # might cause directories to be created, which would be especially bad 245 | # if $src (and thus $dsttmp) contains '*'. 246 | if test ! -f "$src" && test ! -d "$src"; then 247 | echo "$0: $src does not exist." >&2 248 | exit 1 249 | fi 250 | 251 | if test -z "$dst_arg"; then 252 | echo "$0: no destination specified." >&2 253 | exit 1 254 | fi 255 | 256 | dst=$dst_arg 257 | # Protect names starting with `-'. 258 | case $dst in 259 | -*) dst=./$dst;; 260 | esac 261 | 262 | # If destination is a directory, append the input filename; won't work 263 | # if double slashes aren't ignored. 264 | if test -d "$dst"; then 265 | if test -n "$no_target_directory"; then 266 | echo "$0: $dst_arg: Is a directory" >&2 267 | exit 1 268 | fi 269 | dstdir=$dst 270 | dst=$dstdir/`basename "$src"` 271 | dstdir_status=0 272 | else 273 | # Prefer dirname, but fall back on a substitute if dirname fails. 274 | dstdir=` 275 | (dirname "$dst") 2>/dev/null || 276 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 277 | X"$dst" : 'X\(//\)[^/]' \| \ 278 | X"$dst" : 'X\(//\)$' \| \ 279 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 280 | echo X"$dst" | 281 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 282 | s//\1/ 283 | q 284 | } 285 | /^X\(\/\/\)[^/].*/{ 286 | s//\1/ 287 | q 288 | } 289 | /^X\(\/\/\)$/{ 290 | s//\1/ 291 | q 292 | } 293 | /^X\(\/\).*/{ 294 | s//\1/ 295 | q 296 | } 297 | s/.*/./; q' 298 | ` 299 | 300 | test -d "$dstdir" 301 | dstdir_status=$? 302 | fi 303 | fi 304 | 305 | obsolete_mkdir_used=false 306 | 307 | if test $dstdir_status != 0; then 308 | case $posix_mkdir in 309 | '') 310 | # Create intermediate dirs using mode 755 as modified by the umask. 311 | # This is like FreeBSD 'install' as of 1997-10-28. 312 | umask=`umask` 313 | case $stripcmd.$umask in 314 | # Optimize common cases. 315 | *[2367][2367]) mkdir_umask=$umask;; 316 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 317 | 318 | *[0-7]) 319 | mkdir_umask=`expr $umask + 22 \ 320 | - $umask % 100 % 40 + $umask % 20 \ 321 | - $umask % 10 % 4 + $umask % 2 322 | `;; 323 | *) mkdir_umask=$umask,go-w;; 324 | esac 325 | 326 | # With -d, create the new directory with the user-specified mode. 327 | # Otherwise, rely on $mkdir_umask. 328 | if test -n "$dir_arg"; then 329 | mkdir_mode=-m$mode 330 | else 331 | mkdir_mode= 332 | fi 333 | 334 | posix_mkdir=false 335 | case $umask in 336 | *[123567][0-7][0-7]) 337 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 338 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 339 | ;; 340 | *) 341 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 342 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 343 | 344 | if (umask $mkdir_umask && 345 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 346 | then 347 | if test -z "$dir_arg" || { 348 | # Check for POSIX incompatibilities with -m. 349 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 350 | # other-writeable bit of parent directory when it shouldn't. 351 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 352 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 353 | case $ls_ld_tmpdir in 354 | d????-?r-*) different_mode=700;; 355 | d????-?--*) different_mode=755;; 356 | *) false;; 357 | esac && 358 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 359 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 360 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 361 | } 362 | } 363 | then posix_mkdir=: 364 | fi 365 | rmdir "$tmpdir/d" "$tmpdir" 366 | else 367 | # Remove any dirs left behind by ancient mkdir implementations. 368 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 369 | fi 370 | trap '' 0;; 371 | esac;; 372 | esac 373 | 374 | if 375 | $posix_mkdir && ( 376 | umask $mkdir_umask && 377 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 378 | ) 379 | then : 380 | else 381 | 382 | # The umask is ridiculous, or mkdir does not conform to POSIX, 383 | # or it failed possibly due to a race condition. Create the 384 | # directory the slow way, step by step, checking for races as we go. 385 | 386 | case $dstdir in 387 | /*) prefix='/';; 388 | -*) prefix='./';; 389 | *) prefix='';; 390 | esac 391 | 392 | eval "$initialize_posix_glob" 393 | 394 | oIFS=$IFS 395 | IFS=/ 396 | $posix_glob set -f 397 | set fnord $dstdir 398 | shift 399 | $posix_glob set +f 400 | IFS=$oIFS 401 | 402 | prefixes= 403 | 404 | for d 405 | do 406 | test -z "$d" && continue 407 | 408 | prefix=$prefix$d 409 | if test -d "$prefix"; then 410 | prefixes= 411 | else 412 | if $posix_mkdir; then 413 | (umask=$mkdir_umask && 414 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 415 | # Don't fail if two instances are running concurrently. 416 | test -d "$prefix" || exit 1 417 | else 418 | case $prefix in 419 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 420 | *) qprefix=$prefix;; 421 | esac 422 | prefixes="$prefixes '$qprefix'" 423 | fi 424 | fi 425 | prefix=$prefix/ 426 | done 427 | 428 | if test -n "$prefixes"; then 429 | # Don't fail if two instances are running concurrently. 430 | (umask $mkdir_umask && 431 | eval "\$doit_exec \$mkdirprog $prefixes") || 432 | test -d "$dstdir" || exit 1 433 | obsolete_mkdir_used=true 434 | fi 435 | fi 436 | fi 437 | 438 | if test -n "$dir_arg"; then 439 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 440 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 441 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 442 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 443 | else 444 | 445 | # Make a couple of temp file names in the proper directory. 446 | dsttmp=$dstdir/_inst.$$_ 447 | rmtmp=$dstdir/_rm.$$_ 448 | 449 | # Trap to clean up those temp files at exit. 450 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 451 | 452 | # Copy the file name to the temp name. 453 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 454 | 455 | # and set any options; do chmod last to preserve setuid bits. 456 | # 457 | # If any of these fail, we abort the whole thing. If we want to 458 | # ignore errors from any of these, just make sure not to ignore 459 | # errors from the above "$doit $cpprog $src $dsttmp" command. 460 | # 461 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 462 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 463 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 464 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 465 | 466 | # If -C, don't bother to copy if it wouldn't change the file. 467 | if $copy_on_change && 468 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 469 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 470 | 471 | eval "$initialize_posix_glob" && 472 | $posix_glob set -f && 473 | set X $old && old=:$2:$4:$5:$6 && 474 | set X $new && new=:$2:$4:$5:$6 && 475 | $posix_glob set +f && 476 | 477 | test "$old" = "$new" && 478 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 479 | then 480 | rm -f "$dsttmp" 481 | else 482 | # Rename the file to the real destination. 483 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 484 | 485 | # The rename failed, perhaps because mv can't rename something else 486 | # to itself, or perhaps because mv is so ancient that it does not 487 | # support -f. 488 | { 489 | # Now remove or move aside any old file at destination location. 490 | # We try this two ways since rm can't unlink itself on some 491 | # systems and the destination file might be busy for other 492 | # reasons. In this case, the final cleanup might fail but the new 493 | # file should still install successfully. 494 | { 495 | test ! -f "$dst" || 496 | $doit $rmcmd -f "$dst" 2>/dev/null || 497 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 498 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 499 | } || 500 | { echo "$0: cannot unlink or rename $dst" >&2 501 | (exit 1); exit 1 502 | } 503 | } && 504 | 505 | # Now rename the file to the real destination. 506 | $doit $mvcmd "$dsttmp" "$dst" 507 | } 508 | fi || exit 1 509 | 510 | trap '' 0 511 | fi 512 | done 513 | 514 | # Local variables: 515 | # eval: (add-hook 'write-file-hooks 'time-stamp) 516 | # time-stamp-start: "scriptversion=" 517 | # time-stamp-format: "%:y-%02m-%02d.%02H" 518 | # time-stamp-time-zone: "UTC" 519 | # time-stamp-end: "; # UTC" 520 | # End: 521 | -------------------------------------------------------------------------------- /depcomp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # depcomp - compile a program generating dependencies as side-effects 3 | 4 | scriptversion=2009-04-28.21; # UTC 5 | 6 | # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free 7 | # Software Foundation, Inc. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # Originally written by Alexandre Oliva . 28 | 29 | case $1 in 30 | '') 31 | echo "$0: No command. Try \`$0 --help' for more information." 1>&2 32 | exit 1; 33 | ;; 34 | -h | --h*) 35 | cat <<\EOF 36 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] 37 | 38 | Run PROGRAMS ARGS to compile a file, generating dependencies 39 | as side-effects. 40 | 41 | Environment variables: 42 | depmode Dependency tracking mode. 43 | source Source file read by `PROGRAMS ARGS'. 44 | object Object file output by `PROGRAMS ARGS'. 45 | DEPDIR directory where to store dependencies. 46 | depfile Dependency file to output. 47 | tmpdepfile Temporary file to use when outputing dependencies. 48 | libtool Whether libtool is used (yes/no). 49 | 50 | Report bugs to . 51 | EOF 52 | exit $? 53 | ;; 54 | -v | --v*) 55 | echo "depcomp $scriptversion" 56 | exit $? 57 | ;; 58 | esac 59 | 60 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then 61 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 62 | exit 1 63 | fi 64 | 65 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 66 | depfile=${depfile-`echo "$object" | 67 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 68 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 69 | 70 | rm -f "$tmpdepfile" 71 | 72 | # Some modes work just like other modes, but use different flags. We 73 | # parameterize here, but still list the modes in the big case below, 74 | # to make depend.m4 easier to write. Note that we *cannot* use a case 75 | # here, because this file can only contain one case statement. 76 | if test "$depmode" = hp; then 77 | # HP compiler uses -M and no extra arg. 78 | gccflag=-M 79 | depmode=gcc 80 | fi 81 | 82 | if test "$depmode" = dashXmstdout; then 83 | # This is just like dashmstdout with a different argument. 84 | dashmflag=-xM 85 | depmode=dashmstdout 86 | fi 87 | 88 | cygpath_u="cygpath -u -f -" 89 | if test "$depmode" = msvcmsys; then 90 | # This is just like msvisualcpp but w/o cygpath translation. 91 | # Just convert the backslash-escaped backslashes to single forward 92 | # slashes to satisfy depend.m4 93 | cygpath_u="sed s,\\\\\\\\,/,g" 94 | depmode=msvisualcpp 95 | fi 96 | 97 | case "$depmode" in 98 | gcc3) 99 | ## gcc 3 implements dependency tracking that does exactly what 100 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like 101 | ## it if -MD -MP comes after the -MF stuff. Hmm. 102 | ## Unfortunately, FreeBSD c89 acceptance of flags depends upon 103 | ## the command line argument order; so add the flags where they 104 | ## appear in depend2.am. Note that the slowdown incurred here 105 | ## affects only configure: in makefiles, %FASTDEP% shortcuts this. 106 | for arg 107 | do 108 | case $arg in 109 | -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 110 | *) set fnord "$@" "$arg" ;; 111 | esac 112 | shift # fnord 113 | shift # $arg 114 | done 115 | "$@" 116 | stat=$? 117 | if test $stat -eq 0; then : 118 | else 119 | rm -f "$tmpdepfile" 120 | exit $stat 121 | fi 122 | mv "$tmpdepfile" "$depfile" 123 | ;; 124 | 125 | gcc) 126 | ## There are various ways to get dependency output from gcc. Here's 127 | ## why we pick this rather obscure method: 128 | ## - Don't want to use -MD because we'd like the dependencies to end 129 | ## up in a subdir. Having to rename by hand is ugly. 130 | ## (We might end up doing this anyway to support other compilers.) 131 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 132 | ## -MM, not -M (despite what the docs say). 133 | ## - Using -M directly means running the compiler twice (even worse 134 | ## than renaming). 135 | if test -z "$gccflag"; then 136 | gccflag=-MD, 137 | fi 138 | "$@" -Wp,"$gccflag$tmpdepfile" 139 | stat=$? 140 | if test $stat -eq 0; then : 141 | else 142 | rm -f "$tmpdepfile" 143 | exit $stat 144 | fi 145 | rm -f "$depfile" 146 | echo "$object : \\" > "$depfile" 147 | alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz 148 | ## The second -e expression handles DOS-style file names with drive letters. 149 | sed -e 's/^[^:]*: / /' \ 150 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 151 | ## This next piece of magic avoids the `deleted header file' problem. 152 | ## The problem is that when a header file which appears in a .P file 153 | ## is deleted, the dependency causes make to die (because there is 154 | ## typically no way to rebuild the header). We avoid this by adding 155 | ## dummy dependencies for each header file. Too bad gcc doesn't do 156 | ## this for us directly. 157 | tr ' ' ' 158 | ' < "$tmpdepfile" | 159 | ## Some versions of gcc put a space before the `:'. On the theory 160 | ## that the space means something, we add a space to the output as 161 | ## well. 162 | ## Some versions of the HPUX 10.20 sed can't process this invocation 163 | ## correctly. Breaking it into two sed invocations is a workaround. 164 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 165 | rm -f "$tmpdepfile" 166 | ;; 167 | 168 | hp) 169 | # This case exists only to let depend.m4 do its work. It works by 170 | # looking at the text of this script. This case will never be run, 171 | # since it is checked for above. 172 | exit 1 173 | ;; 174 | 175 | sgi) 176 | if test "$libtool" = yes; then 177 | "$@" "-Wp,-MDupdate,$tmpdepfile" 178 | else 179 | "$@" -MDupdate "$tmpdepfile" 180 | fi 181 | stat=$? 182 | if test $stat -eq 0; then : 183 | else 184 | rm -f "$tmpdepfile" 185 | exit $stat 186 | fi 187 | rm -f "$depfile" 188 | 189 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 190 | echo "$object : \\" > "$depfile" 191 | 192 | # Clip off the initial element (the dependent). Don't try to be 193 | # clever and replace this with sed code, as IRIX sed won't handle 194 | # lines with more than a fixed number of characters (4096 in 195 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 196 | # the IRIX cc adds comments like `#:fec' to the end of the 197 | # dependency line. 198 | tr ' ' ' 199 | ' < "$tmpdepfile" \ 200 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ 201 | tr ' 202 | ' ' ' >> "$depfile" 203 | echo >> "$depfile" 204 | 205 | # The second pass generates a dummy entry for each header file. 206 | tr ' ' ' 207 | ' < "$tmpdepfile" \ 208 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 209 | >> "$depfile" 210 | else 211 | # The sourcefile does not contain any dependencies, so just 212 | # store a dummy comment line, to avoid errors with the Makefile 213 | # "include basename.Plo" scheme. 214 | echo "#dummy" > "$depfile" 215 | fi 216 | rm -f "$tmpdepfile" 217 | ;; 218 | 219 | aix) 220 | # The C for AIX Compiler uses -M and outputs the dependencies 221 | # in a .u file. In older versions, this file always lives in the 222 | # current directory. Also, the AIX compiler puts `$object:' at the 223 | # start of each line; $object doesn't have directory information. 224 | # Version 6 uses the directory in both cases. 225 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 226 | test "x$dir" = "x$object" && dir= 227 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 228 | if test "$libtool" = yes; then 229 | tmpdepfile1=$dir$base.u 230 | tmpdepfile2=$base.u 231 | tmpdepfile3=$dir.libs/$base.u 232 | "$@" -Wc,-M 233 | else 234 | tmpdepfile1=$dir$base.u 235 | tmpdepfile2=$dir$base.u 236 | tmpdepfile3=$dir$base.u 237 | "$@" -M 238 | fi 239 | stat=$? 240 | 241 | if test $stat -eq 0; then : 242 | else 243 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 244 | exit $stat 245 | fi 246 | 247 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 248 | do 249 | test -f "$tmpdepfile" && break 250 | done 251 | if test -f "$tmpdepfile"; then 252 | # Each line is of the form `foo.o: dependent.h'. 253 | # Do two passes, one to just change these to 254 | # `$object: dependent.h' and one to simply `dependent.h:'. 255 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 256 | # That's a tab and a space in the []. 257 | sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 258 | else 259 | # The sourcefile does not contain any dependencies, so just 260 | # store a dummy comment line, to avoid errors with the Makefile 261 | # "include basename.Plo" scheme. 262 | echo "#dummy" > "$depfile" 263 | fi 264 | rm -f "$tmpdepfile" 265 | ;; 266 | 267 | icc) 268 | # Intel's C compiler understands `-MD -MF file'. However on 269 | # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c 270 | # ICC 7.0 will fill foo.d with something like 271 | # foo.o: sub/foo.c 272 | # foo.o: sub/foo.h 273 | # which is wrong. We want: 274 | # sub/foo.o: sub/foo.c 275 | # sub/foo.o: sub/foo.h 276 | # sub/foo.c: 277 | # sub/foo.h: 278 | # ICC 7.1 will output 279 | # foo.o: sub/foo.c sub/foo.h 280 | # and will wrap long lines using \ : 281 | # foo.o: sub/foo.c ... \ 282 | # sub/foo.h ... \ 283 | # ... 284 | 285 | "$@" -MD -MF "$tmpdepfile" 286 | stat=$? 287 | if test $stat -eq 0; then : 288 | else 289 | rm -f "$tmpdepfile" 290 | exit $stat 291 | fi 292 | rm -f "$depfile" 293 | # Each line is of the form `foo.o: dependent.h', 294 | # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 295 | # Do two passes, one to just change these to 296 | # `$object: dependent.h' and one to simply `dependent.h:'. 297 | sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 298 | # Some versions of the HPUX 10.20 sed can't process this invocation 299 | # correctly. Breaking it into two sed invocations is a workaround. 300 | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | 301 | sed -e 's/$/ :/' >> "$depfile" 302 | rm -f "$tmpdepfile" 303 | ;; 304 | 305 | hp2) 306 | # The "hp" stanza above does not work with aCC (C++) and HP's ia64 307 | # compilers, which have integrated preprocessors. The correct option 308 | # to use with these is +Maked; it writes dependencies to a file named 309 | # 'foo.d', which lands next to the object file, wherever that 310 | # happens to be. 311 | # Much of this is similar to the tru64 case; see comments there. 312 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 313 | test "x$dir" = "x$object" && dir= 314 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 315 | if test "$libtool" = yes; then 316 | tmpdepfile1=$dir$base.d 317 | tmpdepfile2=$dir.libs/$base.d 318 | "$@" -Wc,+Maked 319 | else 320 | tmpdepfile1=$dir$base.d 321 | tmpdepfile2=$dir$base.d 322 | "$@" +Maked 323 | fi 324 | stat=$? 325 | if test $stat -eq 0; then : 326 | else 327 | rm -f "$tmpdepfile1" "$tmpdepfile2" 328 | exit $stat 329 | fi 330 | 331 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 332 | do 333 | test -f "$tmpdepfile" && break 334 | done 335 | if test -f "$tmpdepfile"; then 336 | sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" 337 | # Add `dependent.h:' lines. 338 | sed -ne '2,${ 339 | s/^ *// 340 | s/ \\*$// 341 | s/$/:/ 342 | p 343 | }' "$tmpdepfile" >> "$depfile" 344 | else 345 | echo "#dummy" > "$depfile" 346 | fi 347 | rm -f "$tmpdepfile" "$tmpdepfile2" 348 | ;; 349 | 350 | tru64) 351 | # The Tru64 compiler uses -MD to generate dependencies as a side 352 | # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. 353 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 354 | # dependencies in `foo.d' instead, so we check for that too. 355 | # Subdirectories are respected. 356 | dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` 357 | test "x$dir" = "x$object" && dir= 358 | base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` 359 | 360 | if test "$libtool" = yes; then 361 | # With Tru64 cc, shared objects can also be used to make a 362 | # static library. This mechanism is used in libtool 1.4 series to 363 | # handle both shared and static libraries in a single compilation. 364 | # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. 365 | # 366 | # With libtool 1.5 this exception was removed, and libtool now 367 | # generates 2 separate objects for the 2 libraries. These two 368 | # compilations output dependencies in $dir.libs/$base.o.d and 369 | # in $dir$base.o.d. We have to check for both files, because 370 | # one of the two compilations can be disabled. We should prefer 371 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 372 | # automatically cleaned when .libs/ is deleted, while ignoring 373 | # the former would cause a distcleancheck panic. 374 | tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 375 | tmpdepfile2=$dir$base.o.d # libtool 1.5 376 | tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 377 | tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 378 | "$@" -Wc,-MD 379 | else 380 | tmpdepfile1=$dir$base.o.d 381 | tmpdepfile2=$dir$base.d 382 | tmpdepfile3=$dir$base.d 383 | tmpdepfile4=$dir$base.d 384 | "$@" -MD 385 | fi 386 | 387 | stat=$? 388 | if test $stat -eq 0; then : 389 | else 390 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 391 | exit $stat 392 | fi 393 | 394 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" 395 | do 396 | test -f "$tmpdepfile" && break 397 | done 398 | if test -f "$tmpdepfile"; then 399 | sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" 400 | # That's a tab and a space in the []. 401 | sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" 402 | else 403 | echo "#dummy" > "$depfile" 404 | fi 405 | rm -f "$tmpdepfile" 406 | ;; 407 | 408 | #nosideeffect) 409 | # This comment above is used by automake to tell side-effect 410 | # dependency tracking mechanisms from slower ones. 411 | 412 | dashmstdout) 413 | # Important note: in order to support this mode, a compiler *must* 414 | # always write the preprocessed file to stdout, regardless of -o. 415 | "$@" || exit $? 416 | 417 | # Remove the call to Libtool. 418 | if test "$libtool" = yes; then 419 | while test "X$1" != 'X--mode=compile'; do 420 | shift 421 | done 422 | shift 423 | fi 424 | 425 | # Remove `-o $object'. 426 | IFS=" " 427 | for arg 428 | do 429 | case $arg in 430 | -o) 431 | shift 432 | ;; 433 | $object) 434 | shift 435 | ;; 436 | *) 437 | set fnord "$@" "$arg" 438 | shift # fnord 439 | shift # $arg 440 | ;; 441 | esac 442 | done 443 | 444 | test -z "$dashmflag" && dashmflag=-M 445 | # Require at least two characters before searching for `:' 446 | # in the target name. This is to cope with DOS-style filenames: 447 | # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. 448 | "$@" $dashmflag | 449 | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" 450 | rm -f "$depfile" 451 | cat < "$tmpdepfile" > "$depfile" 452 | tr ' ' ' 453 | ' < "$tmpdepfile" | \ 454 | ## Some versions of the HPUX 10.20 sed can't process this invocation 455 | ## correctly. Breaking it into two sed invocations is a workaround. 456 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 457 | rm -f "$tmpdepfile" 458 | ;; 459 | 460 | dashXmstdout) 461 | # This case only exists to satisfy depend.m4. It is never actually 462 | # run, as this mode is specially recognized in the preamble. 463 | exit 1 464 | ;; 465 | 466 | makedepend) 467 | "$@" || exit $? 468 | # Remove any Libtool call 469 | if test "$libtool" = yes; then 470 | while test "X$1" != 'X--mode=compile'; do 471 | shift 472 | done 473 | shift 474 | fi 475 | # X makedepend 476 | shift 477 | cleared=no eat=no 478 | for arg 479 | do 480 | case $cleared in 481 | no) 482 | set ""; shift 483 | cleared=yes ;; 484 | esac 485 | if test $eat = yes; then 486 | eat=no 487 | continue 488 | fi 489 | case "$arg" in 490 | -D*|-I*) 491 | set fnord "$@" "$arg"; shift ;; 492 | # Strip any option that makedepend may not understand. Remove 493 | # the object too, otherwise makedepend will parse it as a source file. 494 | -arch) 495 | eat=yes ;; 496 | -*|$object) 497 | ;; 498 | *) 499 | set fnord "$@" "$arg"; shift ;; 500 | esac 501 | done 502 | obj_suffix=`echo "$object" | sed 's/^.*\././'` 503 | touch "$tmpdepfile" 504 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 505 | rm -f "$depfile" 506 | cat < "$tmpdepfile" > "$depfile" 507 | sed '1,2d' "$tmpdepfile" | tr ' ' ' 508 | ' | \ 509 | ## Some versions of the HPUX 10.20 sed can't process this invocation 510 | ## correctly. Breaking it into two sed invocations is a workaround. 511 | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" 512 | rm -f "$tmpdepfile" "$tmpdepfile".bak 513 | ;; 514 | 515 | cpp) 516 | # Important note: in order to support this mode, a compiler *must* 517 | # always write the preprocessed file to stdout. 518 | "$@" || exit $? 519 | 520 | # Remove the call to Libtool. 521 | if test "$libtool" = yes; then 522 | while test "X$1" != 'X--mode=compile'; do 523 | shift 524 | done 525 | shift 526 | fi 527 | 528 | # Remove `-o $object'. 529 | IFS=" " 530 | for arg 531 | do 532 | case $arg in 533 | -o) 534 | shift 535 | ;; 536 | $object) 537 | shift 538 | ;; 539 | *) 540 | set fnord "$@" "$arg" 541 | shift # fnord 542 | shift # $arg 543 | ;; 544 | esac 545 | done 546 | 547 | "$@" -E | 548 | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 549 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | 550 | sed '$ s: \\$::' > "$tmpdepfile" 551 | rm -f "$depfile" 552 | echo "$object : \\" > "$depfile" 553 | cat < "$tmpdepfile" >> "$depfile" 554 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 555 | rm -f "$tmpdepfile" 556 | ;; 557 | 558 | msvisualcpp) 559 | # Important note: in order to support this mode, a compiler *must* 560 | # always write the preprocessed file to stdout. 561 | "$@" || exit $? 562 | 563 | # Remove the call to Libtool. 564 | if test "$libtool" = yes; then 565 | while test "X$1" != 'X--mode=compile'; do 566 | shift 567 | done 568 | shift 569 | fi 570 | 571 | IFS=" " 572 | for arg 573 | do 574 | case "$arg" in 575 | -o) 576 | shift 577 | ;; 578 | $object) 579 | shift 580 | ;; 581 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 582 | set fnord "$@" 583 | shift 584 | shift 585 | ;; 586 | *) 587 | set fnord "$@" "$arg" 588 | shift 589 | shift 590 | ;; 591 | esac 592 | done 593 | "$@" -E 2>/dev/null | 594 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 595 | rm -f "$depfile" 596 | echo "$object : \\" > "$depfile" 597 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" 598 | echo " " >> "$depfile" 599 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 600 | rm -f "$tmpdepfile" 601 | ;; 602 | 603 | msvcmsys) 604 | # This case exists only to let depend.m4 do its work. It works by 605 | # looking at the text of this script. This case will never be run, 606 | # since it is checked for above. 607 | exit 1 608 | ;; 609 | 610 | none) 611 | exec "$@" 612 | ;; 613 | 614 | *) 615 | echo "Unknown depmode $depmode" 1>&2 616 | exit 1 617 | ;; 618 | esac 619 | 620 | exit 0 621 | 622 | # Local Variables: 623 | # mode: shell-script 624 | # sh-indentation: 2 625 | # eval: (add-hook 'write-file-hooks 'time-stamp) 626 | # time-stamp-start: "scriptversion=" 627 | # time-stamp-format: "%:y-%02m-%02d.%02H" 628 | # time-stamp-time-zone: "UTC" 629 | # time-stamp-end: "; # UTC" 630 | # End: 631 | -------------------------------------------------------------------------------- /COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | 504 | 505 | -------------------------------------------------------------------------------- /w32-io.c: -------------------------------------------------------------------------------- 1 | /* w32-io.c - W32 API I/O functions. 2 | Copyright (C) 2000 Werner Koch (dd9jn) 3 | Copyright (C) 2001, 2002, 2003, 2004, 2007 g10 Code GmbH 4 | 5 | This file is part of PTH. 6 | 7 | PTH is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU Lesser General Public License as 9 | published by the Free Software Foundation; either version 2.1 of 10 | the License, or (at your option) any later version. 11 | 12 | PTH is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 | 02111-1307, USA. */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #ifdef HAVE_W32CE_SYSTEM 33 | # include 34 | # include 35 | # define GPGCEDEV_IOCTL_GET_RVID \ 36 | CTL_CODE (FILE_DEVICE_STREAMS, 2048, METHOD_BUFFERED, FILE_ANY_ACCESS) 37 | # define GPGCEDEV_IOCTL_MAKE_PIPE \ 38 | CTL_CODE (FILE_DEVICE_STREAMS, 2049, METHOD_BUFFERED, FILE_ANY_ACCESS) 39 | 40 | #warning fixme pth_pipe is not correct - only used in dirmngr - remove it? 41 | 42 | #endif /*HAVE_W32CE_SYSTEM*/ 43 | 44 | 45 | #include "utils.h" 46 | #include "debug.h" 47 | #include "w32-io.h" 48 | 49 | 50 | 51 | 52 | struct critsect_s 53 | { 54 | const char *name; 55 | void *priv; 56 | }; 57 | 58 | #define DEFINE_GLOBAL_LOCK(name) \ 59 | struct critsect_s name = { #name, NULL } 60 | #define DEFINE_STATIC_LOCK(name) \ 61 | static struct critsect_s name = { #name, NULL } 62 | 63 | #define DECLARE_LOCK(name) \ 64 | struct critsect_s name 65 | #define INIT_LOCK(a) \ 66 | do \ 67 | { \ 68 | (a).name = #a; \ 69 | (a).priv = NULL; \ 70 | } \ 71 | while (0) 72 | #define DESTROY_LOCK(name) _pth_sema_cs_destroy (&(name)) 73 | 74 | 75 | #define LOCK(name) \ 76 | do \ 77 | { \ 78 | _pth_sema_cs_enter (&(name)); \ 79 | } \ 80 | while (0) 81 | 82 | #define UNLOCK(name) \ 83 | do \ 84 | { \ 85 | _pth_sema_cs_leave (&(name)); \ 86 | } \ 87 | while (0) 88 | 89 | 90 | static void 91 | sema_fatal (const char *text) 92 | { 93 | fprintf (stderr, "sema.c: %s\n", text); 94 | abort (); 95 | } 96 | 97 | 98 | static void 99 | critsect_init (struct critsect_s *s) 100 | { 101 | CRITICAL_SECTION *mp; 102 | static CRITICAL_SECTION init_lock; 103 | static int initialized; 104 | 105 | if (!initialized) { 106 | /* The very first time we call this function, we assume that 107 | only one thread is running, so that we can bootstrap the 108 | semaphore code. */ 109 | InitializeCriticalSection (&init_lock); 110 | initialized = 1; 111 | } 112 | if (!s) 113 | return; /* we just want to initialize ourself */ 114 | 115 | /* first test whether it is really not initialized */ 116 | EnterCriticalSection (&init_lock); 117 | if ( s->priv ) { 118 | LeaveCriticalSection (&init_lock); 119 | return; 120 | } 121 | /* now init it */ 122 | mp = _pth_malloc ( sizeof *mp ); 123 | if (!mp) { 124 | LeaveCriticalSection (&init_lock); 125 | sema_fatal ("out of core while creating critical section lock"); 126 | } 127 | InitializeCriticalSection (mp); 128 | s->priv = mp; 129 | LeaveCriticalSection (&init_lock); 130 | } 131 | 132 | 133 | void 134 | _pth_sema_subsystem_init (void) 135 | { 136 | /* fixme: we should check that there is only one thread running */ 137 | critsect_init (NULL); 138 | } 139 | 140 | 141 | void 142 | _pth_sema_cs_enter ( struct critsect_s *s ) 143 | { 144 | if (!s->priv) 145 | critsect_init (s); 146 | EnterCriticalSection ( (CRITICAL_SECTION*)s->priv ); 147 | } 148 | 149 | void 150 | _pth_sema_cs_leave (struct critsect_s *s) 151 | { 152 | if (!s->priv) 153 | critsect_init (s); 154 | LeaveCriticalSection ((CRITICAL_SECTION*)s->priv); 155 | } 156 | 157 | void 158 | _pth_sema_cs_destroy ( struct critsect_s *s ) 159 | { 160 | if (s && s->priv) { 161 | DeleteCriticalSection ((CRITICAL_SECTION*)s->priv); 162 | _pth_free (s->priv); 163 | s->priv = NULL; 164 | } 165 | } 166 | 167 | 168 | DEFINE_STATIC_LOCK (debug_lock); 169 | 170 | #define DEBUG_SYSIO 2 171 | 172 | /* Log the formatted string FORMAT at debug level LEVEL or higher. */ 173 | void 174 | _pth_debug (int level, const char *format, ...) 175 | { 176 | va_list arg_ptr; 177 | int saved_errno; 178 | 179 | saved_errno = errno; 180 | 181 | if (debug_level < level) 182 | return; 183 | 184 | #ifdef HAVE_W32CE_SYSTEM 185 | if (dbghd) 186 | { 187 | LOCK (debug_lock); 188 | va_start (arg_ptr, format); 189 | { 190 | char buffer[256]; 191 | DWORD n, nwritten; 192 | 193 | _snprintf (buffer, 30, "%lu/w32pth: ", 194 | (unsigned long)GetCurrentThreadId ()); 195 | buffer[29] = 0; 196 | n = strlen (buffer); 197 | _vsnprintf (buffer + n, sizeof buffer - n, format, arg_ptr); 198 | buffer[sizeof buffer - 1] = 0; 199 | n = strlen (buffer); 200 | WriteFile (dbghd, buffer, n, &nwritten, NULL); 201 | } 202 | va_end (arg_ptr); 203 | UNLOCK (debug_lock); 204 | } 205 | #else 206 | va_start (arg_ptr, format); 207 | LOCK (debug_lock); 208 | fprintf (dbgfp, "%05lu/%lu.%lu/w32pth: ", 209 | ((unsigned long)GetTickCount () % 100000), 210 | (unsigned long)GetCurrentProcessId (), 211 | (unsigned long)GetCurrentThreadId ()); 212 | vfprintf (dbgfp, format, arg_ptr); 213 | va_end (arg_ptr); 214 | if(format && *format && format[strlen (format) - 1] != '\n') 215 | putc ('\n', dbgfp); 216 | UNLOCK (debug_lock); 217 | fflush (dbgfp); 218 | #endif 219 | set_errno (saved_errno); 220 | } 221 | 222 | 223 | #define fd_to_handle(a) ((HANDLE)(a)) 224 | #define handle_to_fd(a) ((int)(a)) 225 | #define pid_to_handle(a) ((HANDLE)(a)) 226 | #define handle_to_pid(a) ((int)(a)) 227 | 228 | #define READBUF_SIZE 4096 229 | #define WRITEBUF_SIZE 4096 230 | #define PIPEBUF_SIZE 4096 231 | #define MAX_READERS 40 232 | #define MAX_WRITERS 40 233 | 234 | 235 | 236 | struct reader_context_s 237 | { 238 | HANDLE file_hd; 239 | HANDLE thread_hd; 240 | int refcount; 241 | 242 | DECLARE_LOCK (mutex); 243 | 244 | int stop_me; 245 | int eof; 246 | int eof_shortcut; 247 | int error; 248 | int error_code; 249 | 250 | /* This is manually reset. */ 251 | HANDLE have_data_ev; 252 | /* This is automatically reset. */ 253 | HANDLE have_space_ev; 254 | HANDLE stopped; 255 | size_t readpos, writepos; 256 | char buffer[READBUF_SIZE]; 257 | }; 258 | 259 | 260 | static struct 261 | { 262 | volatile int used; 263 | int fd; 264 | struct reader_context_s *context; 265 | } reader_table[MAX_READERS]; 266 | static int reader_table_size= MAX_READERS; 267 | DEFINE_STATIC_LOCK (reader_table_lock); 268 | 269 | 270 | struct writer_context_s 271 | { 272 | HANDLE file_hd; 273 | HANDLE thread_hd; 274 | int refcount; 275 | 276 | DECLARE_LOCK (mutex); 277 | 278 | int stop_me; 279 | int error; 280 | int error_code; 281 | 282 | /* This is manually reset. */ 283 | HANDLE have_data; 284 | HANDLE is_empty; 285 | HANDLE stopped; 286 | size_t nbytes; 287 | char buffer[WRITEBUF_SIZE]; 288 | }; 289 | 290 | 291 | static struct 292 | { 293 | volatile int used; 294 | int fd; 295 | struct writer_context_s *context; 296 | } writer_table[MAX_WRITERS]; 297 | static int writer_table_size= MAX_WRITERS; 298 | DEFINE_STATIC_LOCK (writer_table_lock); 299 | 300 | 301 | static int 302 | get_desired_thread_priority (void) 303 | { 304 | return THREAD_PRIORITY_HIGHEST; 305 | } 306 | 307 | 308 | static HANDLE 309 | set_synchronize (HANDLE hd) 310 | { 311 | HANDLE new_hd; 312 | 313 | /* For NT we have to set the sync flag. It seems that the only way 314 | to do it is by duplicating the handle. Tsss... */ 315 | if (!DuplicateHandle (GetCurrentProcess (), hd, 316 | GetCurrentProcess (), &new_hd, 317 | EVENT_MODIFY_STATE | SYNCHRONIZE, FALSE, 0)) 318 | { 319 | TRACE1 (DEBUG_SYSIO, "pth:set_synchronize", hd, 320 | "DuplicateHandle failed: ec=%d", (int) GetLastError ()); 321 | /* FIXME: Should translate the error code. */ 322 | set_errno (EIO); 323 | return INVALID_HANDLE_VALUE; 324 | } 325 | 326 | CloseHandle (hd); 327 | return new_hd; 328 | } 329 | 330 | 331 | /* Return true if HD refers to a socket. */ 332 | static int 333 | is_socket (HANDLE hd) 334 | { 335 | #ifdef HAVE_W32CE_SYSTEM 336 | (void)hd; 337 | return 0; 338 | #else 339 | /* We need to figure out whether we are working on a socket or on a 340 | handle. A trivial way would be to check for the return code of 341 | recv and see if it is WSAENOTSOCK. However the recv may block 342 | after the server process died and thus the destroy_reader will 343 | hang. Another option is to use getsockopt to test whether it is 344 | a socket. The bug here is that once a socket with a certain 345 | values has been opened, closed and later a CreatePipe returned 346 | the same value (i.e. handle), getsockopt still believes it is a 347 | socket. What we do now is to use a combination of GetFileType 348 | and GetNamedPipeInfo. The specs say that the latter may be used 349 | on anonymous pipes as well. Note that there are claims that 350 | since winsocket version 2 ReadFile may be used on a socket but 351 | only if it is supported by the service provider. Tests on a 352 | stock XP using a local TCP socket show that it does not work. */ 353 | DWORD dummyflags, dummyoutsize, dummyinsize, dummyinst; 354 | if (GetFileType (hd) == FILE_TYPE_PIPE 355 | && !GetNamedPipeInfo (hd, &dummyflags, &dummyoutsize, 356 | &dummyinsize, &dummyinst)) 357 | return 1; /* Function failed; thus we assume it is a socket. */ 358 | else 359 | return 0; /* Success; this is not a socket. */ 360 | #endif 361 | } 362 | 363 | 364 | static DWORD CALLBACK 365 | reader (void *arg) 366 | { 367 | struct reader_context_s *ctx = arg; 368 | int nbytes; 369 | DWORD nread; 370 | int sock; 371 | TRACE_BEG1 (DEBUG_SYSIO, "pth:reader", ctx->file_hd, 372 | "thread=%p", ctx->thread_hd); 373 | 374 | sock = is_socket (ctx->file_hd); 375 | 376 | for (;;) 377 | { 378 | LOCK (ctx->mutex); 379 | /* Leave a 1 byte gap so that we can see whether it is empty or 380 | full. */ 381 | if ((ctx->writepos + 1) % READBUF_SIZE == ctx->readpos) 382 | { 383 | /* Wait for space. */ 384 | if (!ResetEvent (ctx->have_space_ev)) 385 | TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); 386 | UNLOCK (ctx->mutex); 387 | TRACE_LOG ("waiting for space"); 388 | WaitForSingleObject (ctx->have_space_ev, INFINITE); 389 | TRACE_LOG ("got space"); 390 | LOCK (ctx->mutex); 391 | } 392 | if (ctx->stop_me) 393 | { 394 | UNLOCK (ctx->mutex); 395 | break; 396 | } 397 | nbytes = (ctx->readpos + READBUF_SIZE 398 | - ctx->writepos - 1) % READBUF_SIZE; 399 | if (nbytes > READBUF_SIZE - ctx->writepos) 400 | nbytes = READBUF_SIZE - ctx->writepos; 401 | UNLOCK (ctx->mutex); 402 | 403 | TRACE_LOG2 ("%s %d bytes", sock? "receiving":"reading", nbytes); 404 | 405 | if (sock) 406 | { 407 | int n; 408 | 409 | n = recv ((int)ctx->file_hd, 410 | ctx->buffer + ctx->writepos, nbytes, 0); 411 | if (n < 0) 412 | { 413 | ctx->error_code = (int) WSAGetLastError (); 414 | if (ctx->error_code == ERROR_BROKEN_PIPE) 415 | { 416 | ctx->eof = 1; 417 | TRACE_LOG ("got EOF (broken connection)"); 418 | } 419 | else 420 | { 421 | ctx->error = 1; 422 | TRACE_LOG1 ("recv error: ec=%d", ctx->error_code); 423 | } 424 | break; 425 | } 426 | nread = n; 427 | } 428 | else 429 | { 430 | if (!ReadFile (ctx->file_hd, 431 | ctx->buffer + ctx->writepos, nbytes, &nread, NULL)) 432 | { 433 | ctx->error_code = (int) GetLastError (); 434 | if (ctx->error_code == ERROR_BROKEN_PIPE) 435 | { 436 | ctx->eof = 1; 437 | TRACE_LOG ("got EOF (broken pipe)"); 438 | } 439 | #ifdef HAVE_W32CE_SYSTEM 440 | else if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED 441 | || ctx->error_code == ERROR_BUSY) 442 | { 443 | /* This may happen while one pipe end is still dangling 444 | because the child process has not yet completed the 445 | pipe creation. ERROR_BUSY has been seen as well, it 446 | is propabaly returned by the device manager. */ 447 | ctx->error_code = 0; 448 | Sleep (100); 449 | continue; 450 | } 451 | #endif 452 | else 453 | { 454 | ctx->error = 1; 455 | TRACE_LOG1 ("read error: ec=%d", ctx->error_code); 456 | } 457 | break; 458 | } 459 | } 460 | if (!nread) 461 | { 462 | ctx->eof = 1; 463 | TRACE_LOG ("got eof"); 464 | break; 465 | } 466 | TRACE_LOG1 ("got %u bytes", nread); 467 | 468 | LOCK (ctx->mutex); 469 | if (ctx->stop_me) 470 | { 471 | UNLOCK (ctx->mutex); 472 | break; 473 | } 474 | ctx->writepos = (ctx->writepos + nread) % READBUF_SIZE; 475 | if (!SetEvent (ctx->have_data_ev)) 476 | TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); 477 | UNLOCK (ctx->mutex); 478 | } 479 | /* Indicate that we have an error or EOF. */ 480 | if (!SetEvent (ctx->have_data_ev)) 481 | TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); 482 | SetEvent (ctx->stopped); 483 | 484 | return TRACE_SUC (); 485 | } 486 | 487 | 488 | static struct reader_context_s * 489 | create_reader (HANDLE fd) 490 | { 491 | struct reader_context_s *ctx; 492 | SECURITY_ATTRIBUTES sec_attr; 493 | DWORD tid; 494 | 495 | TRACE_BEG (DEBUG_SYSIO, "pth:create_reader", fd); 496 | 497 | memset (&sec_attr, 0, sizeof sec_attr); 498 | sec_attr.nLength = sizeof sec_attr; 499 | sec_attr.bInheritHandle = FALSE; 500 | 501 | ctx = _pth_calloc (1, sizeof *ctx); 502 | if (!ctx) 503 | { 504 | TRACE_SYSERR (errno); 505 | return NULL; 506 | } 507 | 508 | ctx->file_hd = fd; 509 | ctx->refcount = 1; 510 | ctx->have_data_ev = CreateEvent (&sec_attr, TRUE, FALSE, NULL); 511 | if (ctx->have_data_ev) 512 | ctx->have_space_ev = CreateEvent (&sec_attr, FALSE, TRUE, NULL); 513 | if (ctx->have_space_ev) 514 | ctx->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); 515 | if (!ctx->have_data_ev || !ctx->have_space_ev || !ctx->stopped) 516 | { 517 | TRACE_LOG1 ("CreateEvent failed: ec=%d", (int) GetLastError ()); 518 | if (ctx->have_data_ev) 519 | CloseHandle (ctx->have_data_ev); 520 | if (ctx->have_space_ev) 521 | CloseHandle (ctx->have_space_ev); 522 | if (ctx->stopped) 523 | CloseHandle (ctx->stopped); 524 | _pth_free (ctx); 525 | /* FIXME: Translate the error code. */ 526 | TRACE_SYSERR (EIO); 527 | return NULL; 528 | } 529 | 530 | ctx->have_data_ev = set_synchronize (ctx->have_data_ev); 531 | INIT_LOCK (ctx->mutex); 532 | 533 | ctx->thread_hd = CreateThread (&sec_attr, 0, reader, ctx, 0, &tid); 534 | if (!ctx->thread_hd) 535 | { 536 | TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ()); 537 | DESTROY_LOCK (ctx->mutex); 538 | if (ctx->have_data_ev) 539 | CloseHandle (ctx->have_data_ev); 540 | if (ctx->have_space_ev) 541 | CloseHandle (ctx->have_space_ev); 542 | if (ctx->stopped) 543 | CloseHandle (ctx->stopped); 544 | _pth_free (ctx); 545 | TRACE_SYSERR (EIO); 546 | return NULL; 547 | } 548 | else 549 | { 550 | /* We set the priority of the thread higher because we know that 551 | it only runs for a short time. This greatly helps to 552 | increase the performance of the I/O. */ 553 | SetThreadPriority (ctx->thread_hd, get_desired_thread_priority ()); 554 | } 555 | 556 | TRACE_SUC (); 557 | return ctx; 558 | } 559 | 560 | 561 | static void 562 | destroy_reader (struct reader_context_s *ctx) 563 | { 564 | LOCK (ctx->mutex); 565 | ctx->refcount--; 566 | if (ctx->refcount != 0) 567 | { 568 | UNLOCK (ctx->mutex); 569 | return; 570 | } 571 | ctx->stop_me = 1; 572 | if (ctx->have_space_ev) 573 | SetEvent (ctx->have_space_ev); 574 | UNLOCK (ctx->mutex); 575 | 576 | TRACE1 (DEBUG_SYSIO, "pth:destroy_reader", ctx->file_hd, 577 | "waiting for termination of thread %p", ctx->thread_hd); 578 | WaitForSingleObject (ctx->stopped, INFINITE); 579 | TRACE1 (DEBUG_SYSIO, "pth:destroy_reader", ctx->file_hd, 580 | "thread %p has terminated", ctx->thread_hd); 581 | 582 | if (ctx->stopped) 583 | CloseHandle (ctx->stopped); 584 | if (ctx->have_data_ev) 585 | CloseHandle (ctx->have_data_ev); 586 | if (ctx->have_space_ev) 587 | CloseHandle (ctx->have_space_ev); 588 | CloseHandle (ctx->thread_hd); 589 | DESTROY_LOCK (ctx->mutex); 590 | _pth_free (ctx); 591 | } 592 | 593 | 594 | /* Find a reader context or create a new one. Note that the reader 595 | context will last until a pth_close. */ 596 | static struct reader_context_s * 597 | find_reader (int fd, int start_it) 598 | { 599 | struct reader_context_s *rd = NULL; 600 | int i; 601 | 602 | LOCK (reader_table_lock); 603 | for (i = 0; i < reader_table_size; i++) 604 | if (reader_table[i].used && reader_table[i].fd == fd) 605 | rd = reader_table[i].context; 606 | 607 | if (rd || !start_it) 608 | { 609 | UNLOCK (reader_table_lock); 610 | return rd; 611 | } 612 | 613 | for (i = 0; i < reader_table_size; i++) 614 | if (!reader_table[i].used) 615 | break; 616 | 617 | if (i != reader_table_size) 618 | { 619 | rd = create_reader (fd_to_handle (fd)); 620 | reader_table[i].fd = fd; 621 | reader_table[i].context = rd; 622 | reader_table[i].used = 1; 623 | } 624 | 625 | UNLOCK (reader_table_lock); 626 | return rd; 627 | } 628 | 629 | 630 | static void 631 | kill_reader (int fd) 632 | { 633 | int i; 634 | 635 | LOCK (reader_table_lock); 636 | for (i = 0; i < reader_table_size; i++) 637 | { 638 | if (reader_table[i].used && reader_table[i].fd == fd) 639 | { 640 | destroy_reader (reader_table[i].context); 641 | reader_table[i].context = NULL; 642 | reader_table[i].used = 0; 643 | break; 644 | } 645 | } 646 | UNLOCK (reader_table_lock); 647 | } 648 | 649 | 650 | int 651 | _pth_io_read (int fd, void *buffer, size_t count) 652 | { 653 | int nread; 654 | struct reader_context_s *ctx; 655 | TRACE_BEG2 (DEBUG_SYSIO, "_pth_io_read", fd, 656 | "buffer=%p, count=%u", buffer, count); 657 | 658 | ctx = find_reader (fd, 0); 659 | if (!ctx) 660 | { 661 | set_errno (EBADF); 662 | return TRACE_SYSRES (-1); 663 | } 664 | if (ctx->eof_shortcut) 665 | return TRACE_SYSRES (0); 666 | 667 | LOCK (ctx->mutex); 668 | if (ctx->readpos == ctx->writepos && !ctx->error) 669 | { 670 | /* No data available. */ 671 | UNLOCK (ctx->mutex); 672 | TRACE_LOG1 ("waiting for data from thread %p", ctx->thread_hd); 673 | WaitForSingleObject (ctx->have_data_ev, INFINITE); 674 | TRACE_LOG1 ("data from thread %p available", ctx->thread_hd); 675 | LOCK (ctx->mutex); 676 | } 677 | 678 | if (ctx->readpos == ctx->writepos || ctx->error) 679 | { 680 | UNLOCK (ctx->mutex); 681 | ctx->eof_shortcut = 1; 682 | if (ctx->eof) 683 | return TRACE_SYSRES (0); 684 | if (!ctx->error) 685 | { 686 | TRACE_LOG ("EOF but ctx->eof flag not set"); 687 | return 0; 688 | } 689 | set_errno (ctx->error_code); 690 | return TRACE_SYSRES (-1); 691 | } 692 | 693 | nread = ctx->readpos < ctx->writepos 694 | ? ctx->writepos - ctx->readpos 695 | : READBUF_SIZE - ctx->readpos; 696 | if (nread > count) 697 | nread = count; 698 | memcpy (buffer, ctx->buffer + ctx->readpos, nread); 699 | ctx->readpos = (ctx->readpos + nread) % READBUF_SIZE; 700 | if (ctx->readpos == ctx->writepos && !ctx->eof) 701 | { 702 | if (!ResetEvent (ctx->have_data_ev)) 703 | { 704 | TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); 705 | UNLOCK (ctx->mutex); 706 | /* FIXME: Should translate the error code. */ 707 | set_errno (EIO); 708 | return TRACE_SYSRES (-1); 709 | } 710 | } 711 | if (!SetEvent (ctx->have_space_ev)) 712 | { 713 | TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); 714 | UNLOCK (ctx->mutex); 715 | /* FIXME: Should translate the error code. */ 716 | set_errno (EIO); 717 | return TRACE_SYSRES (-1); 718 | } 719 | UNLOCK (ctx->mutex); 720 | 721 | #if 0 722 | TRACE_LOGBUF (buffer, nread); 723 | #endif 724 | return TRACE_SYSRES (nread); 725 | } 726 | 727 | 728 | /* The writer does use a simple buffering strategy so that we are 729 | informed about write errors as soon as possible (i. e. with the the 730 | next call to the write function. */ 731 | static DWORD CALLBACK 732 | writer (void *arg) 733 | { 734 | struct writer_context_s *ctx = arg; 735 | DWORD nwritten; 736 | int sock; 737 | TRACE_BEG1 (DEBUG_SYSIO, "pth:writer", ctx->file_hd, 738 | "thread=%p", ctx->thread_hd); 739 | 740 | sock = is_socket (ctx->file_hd); 741 | 742 | for (;;) 743 | { 744 | LOCK (ctx->mutex); 745 | if (ctx->stop_me) 746 | { 747 | UNLOCK (ctx->mutex); 748 | break; 749 | } 750 | if (!ctx->nbytes) 751 | { 752 | if (!SetEvent (ctx->is_empty)) 753 | TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); 754 | if (!ResetEvent (ctx->have_data)) 755 | TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); 756 | UNLOCK (ctx->mutex); 757 | TRACE_LOG ("idle"); 758 | WaitForSingleObject (ctx->have_data, INFINITE); 759 | TRACE_LOG ("got data to send"); 760 | LOCK (ctx->mutex); 761 | } 762 | if (ctx->stop_me) 763 | { 764 | UNLOCK (ctx->mutex); 765 | break; 766 | } 767 | UNLOCK (ctx->mutex); 768 | 769 | TRACE_LOG2 ("%s %d bytes", sock?"sending":"writing", ctx->nbytes); 770 | 771 | /* Note that CTX->nbytes is not zero at this point, because 772 | _pth_io_write always writes at least 1 byte before waking 773 | us up, unless CTX->stop_me is true, which we catch above. */ 774 | if (sock) 775 | { 776 | /* We need to try send first because a socket handle can't 777 | be used with WriteFile. */ 778 | int n; 779 | 780 | n = send ((int)ctx->file_hd, 781 | ctx->buffer, ctx->nbytes, 0); 782 | if (n < 0) 783 | { 784 | ctx->error_code = (int) WSAGetLastError (); 785 | ctx->error = 1; 786 | TRACE_LOG1 ("send error: ec=%d", ctx->error_code); 787 | break; 788 | } 789 | nwritten = n; 790 | } 791 | else 792 | { 793 | if (!WriteFile (ctx->file_hd, ctx->buffer, 794 | ctx->nbytes, &nwritten, NULL)) 795 | { 796 | ctx->error_code = (int) GetLastError (); 797 | #ifdef HAVE_W32CE_SYSTEM 798 | if (ctx->error_code == ERROR_PIPE_NOT_CONNECTED 799 | || ctx->error_code == ERROR_BUSY) 800 | { 801 | /* This may happen while one pipe end is still 802 | dangling because the child process has not yet 803 | completed the pipe creation. ERROR_BUSY has been 804 | seen as well, it is propabaly returned by the 805 | device manager. */ 806 | ctx->error_code = 0; 807 | Sleep (100); 808 | continue; 809 | } 810 | #endif 811 | ctx->error = 1; 812 | TRACE_LOG1 ("write error: ec=%d", ctx->error_code); 813 | break; 814 | } 815 | } 816 | TRACE_LOG1 ("wrote %d bytes", (int) nwritten); 817 | 818 | LOCK (ctx->mutex); 819 | ctx->nbytes -= nwritten; 820 | UNLOCK (ctx->mutex); 821 | } 822 | /* Indicate that we have an error. */ 823 | if (!SetEvent (ctx->is_empty)) 824 | TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); 825 | SetEvent (ctx->stopped); 826 | 827 | return TRACE_SUC (); 828 | } 829 | 830 | 831 | static struct writer_context_s * 832 | create_writer (HANDLE fd) 833 | { 834 | struct writer_context_s *ctx; 835 | SECURITY_ATTRIBUTES sec_attr; 836 | DWORD tid; 837 | 838 | TRACE_BEG (DEBUG_SYSIO, "pth:create_writer", fd); 839 | 840 | memset (&sec_attr, 0, sizeof sec_attr); 841 | sec_attr.nLength = sizeof sec_attr; 842 | sec_attr.bInheritHandle = FALSE; 843 | 844 | ctx = _pth_calloc (1, sizeof *ctx); 845 | if (!ctx) 846 | { 847 | TRACE_SYSERR (errno); 848 | return NULL; 849 | } 850 | 851 | ctx->file_hd = fd; 852 | ctx->refcount = 1; 853 | ctx->have_data = CreateEvent (&sec_attr, TRUE, FALSE, NULL); 854 | if (ctx->have_data) 855 | ctx->is_empty = CreateEvent (&sec_attr, TRUE, TRUE, NULL); 856 | if (ctx->is_empty) 857 | ctx->stopped = CreateEvent (&sec_attr, TRUE, FALSE, NULL); 858 | if (!ctx->have_data || !ctx->is_empty || !ctx->stopped) 859 | { 860 | TRACE_LOG1 ("CreateEvent failed: ec=%d", (int) GetLastError ()); 861 | if (ctx->have_data) 862 | CloseHandle (ctx->have_data); 863 | if (ctx->is_empty) 864 | CloseHandle (ctx->is_empty); 865 | if (ctx->stopped) 866 | CloseHandle (ctx->stopped); 867 | _pth_free (ctx); 868 | /* FIXME: Translate the error code. */ 869 | TRACE_SYSERR (EIO); 870 | return NULL; 871 | } 872 | 873 | ctx->is_empty = set_synchronize (ctx->is_empty); 874 | INIT_LOCK (ctx->mutex); 875 | 876 | ctx->thread_hd = CreateThread (&sec_attr, 0, writer, ctx, 0, &tid ); 877 | if (!ctx->thread_hd) 878 | { 879 | TRACE_LOG1 ("CreateThread failed: ec=%d", (int) GetLastError ()); 880 | DESTROY_LOCK (ctx->mutex); 881 | if (ctx->have_data) 882 | CloseHandle (ctx->have_data); 883 | if (ctx->is_empty) 884 | CloseHandle (ctx->is_empty); 885 | if (ctx->stopped) 886 | CloseHandle (ctx->stopped); 887 | _pth_free (ctx); 888 | TRACE_SYSERR (EIO); 889 | return NULL; 890 | } 891 | else 892 | { 893 | /* We set the priority of the thread higher because we know 894 | that it only runs for a short time. This greatly helps to 895 | increase the performance of the I/O. */ 896 | SetThreadPriority (ctx->thread_hd, get_desired_thread_priority ()); 897 | } 898 | 899 | TRACE_SUC (); 900 | return ctx; 901 | } 902 | 903 | static void 904 | destroy_writer (struct writer_context_s *ctx) 905 | { 906 | LOCK (ctx->mutex); 907 | ctx->refcount--; 908 | if (ctx->refcount != 0) 909 | { 910 | UNLOCK (ctx->mutex); 911 | return; 912 | } 913 | ctx->stop_me = 1; 914 | if (ctx->have_data) 915 | SetEvent (ctx->have_data); 916 | UNLOCK (ctx->mutex); 917 | 918 | TRACE1 (DEBUG_SYSIO, "pth:destroy_writer", ctx->file_hd, 919 | "waiting for termination of thread %p", ctx->thread_hd); 920 | WaitForSingleObject (ctx->stopped, INFINITE); 921 | TRACE1 (DEBUG_SYSIO, "pth:destroy_writer", ctx->file_hd, 922 | "thread %p has terminated", ctx->thread_hd); 923 | 924 | if (ctx->stopped) 925 | CloseHandle (ctx->stopped); 926 | if (ctx->have_data) 927 | CloseHandle (ctx->have_data); 928 | if (ctx->is_empty) 929 | CloseHandle (ctx->is_empty); 930 | CloseHandle (ctx->thread_hd); 931 | DESTROY_LOCK (ctx->mutex); 932 | _pth_free (ctx); 933 | } 934 | 935 | 936 | /* Find a writer context or create a new one. Note that the writer 937 | context will last until a _pth_io_close. */ 938 | static struct writer_context_s * 939 | find_writer (int fd, int start_it) 940 | { 941 | struct writer_context_s *wt = NULL; 942 | int i; 943 | 944 | LOCK (writer_table_lock); 945 | for (i = 0; i < writer_table_size; i++) 946 | if (writer_table[i].used && writer_table[i].fd == fd) 947 | wt = writer_table[i].context; 948 | 949 | if (wt || !start_it) 950 | { 951 | UNLOCK (writer_table_lock); 952 | return wt; 953 | } 954 | 955 | for (i = 0; i < writer_table_size; i++) 956 | if (!writer_table[i].used) 957 | break; 958 | 959 | if (i != writer_table_size) 960 | { 961 | wt = create_writer (fd_to_handle (fd)); 962 | writer_table[i].fd = fd; 963 | writer_table[i].context = wt; 964 | writer_table[i].used = 1; 965 | } 966 | 967 | UNLOCK (writer_table_lock); 968 | return wt; 969 | } 970 | 971 | 972 | static void 973 | kill_writer (int fd) 974 | { 975 | int i; 976 | 977 | LOCK (writer_table_lock); 978 | for (i = 0; i < writer_table_size; i++) 979 | { 980 | if (writer_table[i].used && writer_table[i].fd == fd) 981 | { 982 | destroy_writer (writer_table[i].context); 983 | writer_table[i].context = NULL; 984 | writer_table[i].used = 0; 985 | break; 986 | } 987 | } 988 | UNLOCK (writer_table_lock); 989 | } 990 | 991 | 992 | int 993 | _pth_io_write (int fd, const void *buffer, size_t count) 994 | { 995 | struct writer_context_s *ctx; 996 | TRACE_BEG2 (DEBUG_SYSIO, "_pth_io_write", fd, 997 | "buffer=%p, count=%u", buffer, count); 998 | #if 0 999 | TRACE_LOGBUF (buffer, count); 1000 | #endif 1001 | 1002 | if (count == 0) 1003 | return TRACE_SYSRES (0); 1004 | 1005 | ctx = find_writer (fd, 0); 1006 | if (!ctx) 1007 | return TRACE_SYSRES (-1); 1008 | 1009 | LOCK (ctx->mutex); 1010 | if (!ctx->error && ctx->nbytes) 1011 | { 1012 | /* Bytes are pending for send. */ 1013 | 1014 | /* Reset the is_empty event. Better safe than sorry. */ 1015 | if (!ResetEvent (ctx->is_empty)) 1016 | { 1017 | TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); 1018 | UNLOCK (ctx->mutex); 1019 | /* FIXME: Should translate the error code. */ 1020 | set_errno (EIO); 1021 | return TRACE_SYSRES (-1); 1022 | } 1023 | UNLOCK (ctx->mutex); 1024 | TRACE_LOG1 ("waiting for empty buffer in thread %p", ctx->thread_hd); 1025 | WaitForSingleObject (ctx->is_empty, INFINITE); 1026 | TRACE_LOG1 ("thread %p buffer is empty", ctx->thread_hd); 1027 | LOCK (ctx->mutex); 1028 | } 1029 | 1030 | if (ctx->error) 1031 | { 1032 | UNLOCK (ctx->mutex); 1033 | if (ctx->error_code == ERROR_NO_DATA) 1034 | set_errno (EPIPE); 1035 | else 1036 | set_errno (EIO); 1037 | return TRACE_SYSRES (-1); 1038 | } 1039 | 1040 | /* If no error occured, the number of bytes in the buffer must be 1041 | zero. */ 1042 | assert (!ctx->nbytes); 1043 | 1044 | if (count > WRITEBUF_SIZE) 1045 | count = WRITEBUF_SIZE; 1046 | memcpy (ctx->buffer, buffer, count); 1047 | ctx->nbytes = count; 1048 | 1049 | /* We have to reset the is_empty event early, because it is also 1050 | used by the select() implementation to probe the channel. */ 1051 | if (!ResetEvent (ctx->is_empty)) 1052 | { 1053 | TRACE_LOG1 ("ResetEvent failed: ec=%d", (int) GetLastError ()); 1054 | UNLOCK (ctx->mutex); 1055 | /* FIXME: Should translate the error code. */ 1056 | set_errno (EIO); 1057 | return TRACE_SYSRES (-1); 1058 | } 1059 | if (!SetEvent (ctx->have_data)) 1060 | { 1061 | TRACE_LOG1 ("SetEvent failed: ec=%d", (int) GetLastError ()); 1062 | UNLOCK (ctx->mutex); 1063 | /* FIXME: Should translate the error code. */ 1064 | set_errno (EIO); 1065 | return TRACE_SYSRES (-1); 1066 | } 1067 | UNLOCK (ctx->mutex); 1068 | 1069 | return TRACE_SYSRES ((int) count); 1070 | } 1071 | 1072 | 1073 | /* WindowsCE does not provide a pipe feature. However we need 1074 | something like a pipe to convey data between processes and in some 1075 | cases within a process. This replacement is not only used by 1076 | libassuan but exported and thus usable by gnupg and gpgme as well. */ 1077 | static DWORD 1078 | create_pipe (HANDLE *read_hd, HANDLE *write_hd, 1079 | LPSECURITY_ATTRIBUTES sec_attr, DWORD size) 1080 | { 1081 | #ifdef HAVE_W32CE_SYSTEM 1082 | HANDLE hd[2]; 1083 | LONG rvid; 1084 | TRACE_BEG (DEBUG_SYSIO, "pth:create_pipe", read_hd); 1085 | 1086 | *read_hd = *write_hd = INVALID_HANDLE_VALUE; 1087 | 1088 | ActivateDevice (L"Drivers\\GnuPG_Device", 0); 1089 | 1090 | hd[0] = CreateFile (L"GPG1:", GENERIC_READ, 1091 | FILE_SHARE_READ | FILE_SHARE_WRITE, 1092 | NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 1093 | if (hd[0] == INVALID_HANDLE_VALUE) 1094 | { 1095 | DWORD lastrc = GetLastError (); 1096 | TRACE_LOG1 ("CreateFile(\"GPG1:\", READ) failed: %d\n", lastrc); 1097 | SetLastError (lastrc); 1098 | return 0; 1099 | } 1100 | 1101 | if (!DeviceIoControl (hd[0], GPGCEDEV_IOCTL_GET_RVID, 1102 | NULL, 0, &rvid, sizeof rvid, NULL, NULL)) 1103 | { 1104 | DWORD lastrc = GetLastError (); 1105 | TRACE_LOG1 ("GPGCEDEV_IOCTL_GET_RVID failed: %d\n", lastrc); 1106 | CloseHandle (hd[0]); 1107 | SetLastError (lastrc); 1108 | return 0; 1109 | } 1110 | 1111 | hd[1] = CreateFile (L"GPG1:", GENERIC_WRITE, 1112 | FILE_SHARE_READ | FILE_SHARE_WRITE, 1113 | NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL); 1114 | if (hd[1] == INVALID_HANDLE_VALUE) 1115 | { 1116 | DWORD lastrc = GetLastError (); 1117 | TRACE_LOG1 ("CreateFile(\"GPG1:\", WRITE) failed: %d\n", lastrc); 1118 | CloseHandle (hd[0]); 1119 | SetLastError (lastrc); 1120 | return 0; 1121 | } 1122 | 1123 | if (!DeviceIoControl (hd, GPGCEDEV_IOCTL_MAKE_PIPE, 1124 | &rvid, sizeof rvid, NULL, 0, NULL, NULL)) 1125 | { 1126 | DWORD lastrc = GetLastError (); 1127 | TRACE_LOG1 ("GPGCEDEV_IOCTL_MAKE_PIPE failed: %d\n", lastrc); 1128 | CloseHandle (hd[0]); 1129 | CloseHandle (hd[1]); 1130 | SetLastError (lastrc); 1131 | return 0; 1132 | } 1133 | 1134 | *read_hd = hd[0]; 1135 | *write_hd = hd[1]; 1136 | TRACE_SUC (); 1137 | return 1; 1138 | #else /*!HAVE_W32CE_SYSTEM*/ 1139 | return CreatePipe (read_hd, write_hd, sec_attr, size); 1140 | #endif /*!HAVE_W32CE_SYSTEM*/ 1141 | } 1142 | 1143 | int 1144 | pth_pipe (int filedes[2], int inherit_idx) 1145 | { 1146 | HANDLE rh; 1147 | HANDLE wh; 1148 | SECURITY_ATTRIBUTES sec_attr; 1149 | TRACE_BEG2 (DEBUG_SYSIO, "_pth_pipe", filedes, 1150 | "inherit_idx=%i (used for %s)", 1151 | inherit_idx, inherit_idx ? "reading" : "writing"); 1152 | 1153 | memset (&sec_attr, 0, sizeof (sec_attr)); 1154 | sec_attr.nLength = sizeof (sec_attr); 1155 | sec_attr.bInheritHandle = FALSE; 1156 | 1157 | if (!create_pipe (&rh, &wh, &sec_attr, PIPEBUF_SIZE)) 1158 | { 1159 | TRACE_LOG1 ("CreatePipe failed: ec=%d", (int) GetLastError ()); 1160 | /* FIXME: Should translate the error code. */ 1161 | set_errno (EIO); 1162 | return TRACE_SYSRES (-1); 1163 | } 1164 | 1165 | /* Make one end inheritable. */ 1166 | if (inherit_idx == 0) 1167 | { 1168 | /* Under Windows CE < 6 handles are global without a concept of 1169 | inheritable handles. */ 1170 | #ifndef HAVE_W32CE_SYSTEM 1171 | HANDLE hd; 1172 | if (!DuplicateHandle (GetCurrentProcess(), rh, 1173 | GetCurrentProcess(), &hd, 0, 1174 | TRUE, DUPLICATE_SAME_ACCESS)) 1175 | { 1176 | TRACE_LOG1 ("DuplicateHandle failed: ec=%d", 1177 | (int) GetLastError ()); 1178 | CloseHandle (rh); 1179 | CloseHandle (wh); 1180 | /* FIXME: Should translate the error code. */ 1181 | set_errno (EIO); 1182 | return TRACE_SYSRES (-1); 1183 | } 1184 | CloseHandle (rh); 1185 | rh = hd; 1186 | #endif /*!HAVE_W32CE_SYSTEM*/ 1187 | /* Pre-create the writer thread. */ 1188 | find_reader (handle_to_fd (wh), 1); 1189 | } 1190 | else if (inherit_idx == 1) 1191 | { 1192 | #ifndef HAVE_W32CE_SYSTEM 1193 | HANDLE hd; 1194 | if (!DuplicateHandle( GetCurrentProcess(), wh, 1195 | GetCurrentProcess(), &hd, 0, 1196 | TRUE, DUPLICATE_SAME_ACCESS)) 1197 | { 1198 | TRACE_LOG1 ("DuplicateHandle failed: ec=%d", 1199 | (int) GetLastError ()); 1200 | CloseHandle (rh); 1201 | CloseHandle (wh); 1202 | /* FIXME: Should translate the error code. */ 1203 | set_errno (EIO); 1204 | return TRACE_SYSRES (-1); 1205 | } 1206 | CloseHandle (wh); 1207 | wh = hd; 1208 | #endif /*!HAVE_W32CE_SYSTEM*/ 1209 | /* Pre-create the reader thread. */ 1210 | find_reader (handle_to_fd (rh), 1); 1211 | } 1212 | 1213 | filedes[0] = handle_to_fd (rh); 1214 | filedes[1] = handle_to_fd (wh); 1215 | return TRACE_SUC2 ("read=%p, write=%p", rh, wh); 1216 | } 1217 | 1218 | 1219 | int 1220 | pth_close (int fd) 1221 | { 1222 | TRACE_BEG (DEBUG_SYSIO, "pth_close", fd); 1223 | 1224 | if (fd == -1) 1225 | { 1226 | set_errno (EBADF); 1227 | return TRACE_SYSRES (-1); 1228 | } 1229 | 1230 | kill_reader (fd); 1231 | kill_writer (fd); 1232 | 1233 | if (!CloseHandle (fd_to_handle (fd))) 1234 | { 1235 | TRACE_LOG1 ("CloseHandle failed: ec=%d", (int) GetLastError ()); 1236 | /* FIXME: Should translate the error code. */ 1237 | set_errno (EIO); 1238 | return TRACE_SYSRES (-1); 1239 | } 1240 | 1241 | return TRACE_SYSRES (0); 1242 | } 1243 | 1244 | 1245 | HANDLE 1246 | _pth_get_reader_ev (int fd) 1247 | { 1248 | struct reader_context_s *ctx = find_reader (fd, 0); 1249 | 1250 | if (! ctx) 1251 | return INVALID_HANDLE_VALUE; 1252 | 1253 | return ctx->have_data_ev; 1254 | } 1255 | 1256 | 1257 | HANDLE 1258 | _pth_get_writer_ev (int fd) 1259 | { 1260 | struct writer_context_s *ctx = find_writer (fd, 0); 1261 | 1262 | if (! ctx) 1263 | return INVALID_HANDLE_VALUE; 1264 | 1265 | return ctx->is_empty; 1266 | } 1267 | --------------------------------------------------------------------------------