npth.git
4 months agow32: Fix memory leak for npth_create. master
NIIBE Yutaka [Thu, 30 Nov 2017 02:14:23 +0000 (11:14 +0900)]
w32: Fix memory leak for npth_create.

* w32/npth.c (npth_create): Free ATTR when allocated.
(npth_attr_destroy): Clear.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
10 months agoPost release updates
Werner Koch [Fri, 2 Jun 2017 08:46:03 +0000 (10:46 +0200)]
Post release updates

--

10 months agoRelease 1.5 npth-1.5
Werner Koch [Fri, 2 Jun 2017 08:39:54 +0000 (10:39 +0200)]
Release 1.5

* configure.ac: Set LT version to C1/A1/R1.

10 months agoFix busy_wait_for.
NIIBE Yutaka [Thu, 1 Jun 2017 02:49:16 +0000 (11:49 +0900)]
Fix busy_wait_for.

* src/npth.c (busy_wait_for): Remove comparison negation.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
11 months agoPost release updates
Werner Koch [Tue, 16 May 2017 07:50:19 +0000 (09:50 +0200)]
Post release updates

--

11 months agoRelease 1.4 npth-1.4
Werner Koch [Tue, 16 May 2017 07:43:43 +0000 (09:43 +0200)]
Release 1.4

* configure.ac: Set LT version to C1/A1/R0.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agoChange license to LPGLv2+
Werner Koch [Tue, 16 May 2017 07:34:50 +0000 (09:34 +0200)]
Change license to LPGLv2+

--

We relax the license so that the software can be used by more
projects.  - wk (g10 Code CEO)

The software was written by g10 Code employees or contractors
with two minor external patches:

 commit a49a061c65fb3a6d9c58add4dc55435f0c4353a2
 Author:     Jim Meyering <meyering@fb.com>
 AuthorDate: Fri Jun 5 08:03:00 2015 -0700

 configure.ac: improve check for clock_gettime library

 * configure.ac: When using AC_SEARCH_LIBS, handle the case in which
 that function returns "none required". Also, save and restore LIBS
 around the check, and properly m4-quote the first argument to
 AC_DEFINE. Finally, also set and AC_SUBST LIB_CLOCK_GETTIME.  This
 added code is very similar to that provided in gnulib's
 clock-time.m4.
 * tests/Makefile.am (LDADD): Append $(LIB_CLOCK_GETTIME).

and

 commit 95754492a41c8284264476f05e3fe3c50c3b4aa9
 Author:     Ben Kibbey <bjk@luxsci.net>
 AuthorDate: Mon Nov 19 23:04:07 2012 -0500

 Build fix for NetBSD.

 * src/npth.c (npth_setname_np): conditional check for __NetBSD__ and
 adapt correct parameters.

11 months agoAdd function npth_is_protected.
Werner Koch [Tue, 16 May 2017 07:02:05 +0000 (09:02 +0200)]
Add function npth_is_protected.

* src/npth.c (got_sceptre): New.
(enter_npth, leave_npth): Set.
(npth_is_protected): New.
* w32/npth.c: (got_sceptre): New.
(enter_npth, leave_npth): Set.
(npth_is_protected): New.
* w32/npth.def, src/libnpth.vers: Add new function.

Signed-off-by: Werner Koch <wk@gnupg.org>
12 months agow32: Change the condition for struct timespec.
NIIBE Yutaka [Thu, 20 Apr 2017 07:31:27 +0000 (16:31 +0900)]
w32: Change the condition for struct timespec.

* w32/npth.h: Fix the ifdef case.

--

GnuPG-bug-id: 2202
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
12 months agoconfigure: Add tweak for FreeBSD.
NIIBE Yutaka [Wed, 5 Apr 2017 06:31:11 +0000 (15:31 +0900)]
configure: Add tweak for FreeBSD.

* configure: On FreeBSD, we use -lpthread.

--

GnuPG-bug-id: 2886
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
12 months agoconfigure: Add tweak for DragonFlyBSD.
NIIBE Yutaka [Wed, 5 Apr 2017 05:39:56 +0000 (14:39 +0900)]
configure: Add tweak for DragonFlyBSD.

* configure.ac: On DragonFlyBSD, we use -lpthread.

--

GnuPG-bug-id: 2886
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
12 months agoconfigure: Add tweak for NetBSD.
NIIBE Yutaka [Wed, 5 Apr 2017 02:54:09 +0000 (11:54 +0900)]
configure: Add tweak for NetBSD.

* configure.ac: On NetBSD, we use -lpthread.

--

We have detection of pthread library in the autoconf archive,
but it's overkill.

GnuPG-bug-id: 2998
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
16 months agoUse unnamed semaphore of Grand Central Dispatch for macOS.
NIIBE Yutaka [Tue, 29 Nov 2016 02:21:15 +0000 (11:21 +0900)]
Use unnamed semaphore of Grand Central Dispatch for macOS.

* configure.ac [*-apple-darwin*]: Search dispatch_semaphore_create
and define HAVE_LIB_DISPATCH if found.
* src/npth.c [HAVE_LIB_DISPATCH] (sem_init, sem_post, sem_wait): New.
* src/npth.c (try_sem_open): Remove.
* tests/t-fork.c: Add comments.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
16 months agoPost release updates
Werner Koch [Tue, 22 Nov 2016 10:19:06 +0000 (11:19 +0100)]
Post release updates

--

16 months agoRelease 1.3 npth-1.3
Werner Koch [Tue, 22 Nov 2016 10:12:55 +0000 (11:12 +0100)]
Release 1.3

* configure.ac: Bump LT version to C0/A0/R6.

Signed-off-by: Werner Koch <wk@gnupg.org>
16 months agoBypass npth_unprotect/protect when npth has not yet been initialized.
Werner Koch [Mon, 21 Nov 2016 08:35:26 +0000 (09:35 +0100)]
Bypass npth_unprotect/protect when npth has not yet been initialized.

* src/npth.c (initialized_or_any_threads): New variable.
(npth_init): Set var.
(npth_create): Set var.
(npth_unprotect, npth_protect): Shortcut if not initialized.

* w32/npth.c (initialized_or_any_threads): New variable.
(npth_init): Set var.
(npth_unprotect, npth_protect): Shortcut if not initialized.

Signed-off-by: Werner Koch <wk@gnupg.org>
18 months agosrc: Fix setting thread names on macOS.
Justus Winter [Mon, 10 Oct 2016 08:43:44 +0000 (10:43 +0200)]
src: Fix setting thread names on macOS.

* src/npth.c (npth_setname_np): Support Apple's one-argument form.

Signed-off-by: Justus Winter <justus@gnupg.org>
21 months agobuild: Update config.{guess,sub} to {2016-05-15,2016-06-20}.
Werner Koch [Wed, 13 Jul 2016 17:04:10 +0000 (19:04 +0200)]
build: Update config.{guess,sub} to {2016-05-15,2016-06-20}.

* build-aux/config.guess: Update.
* build-aux/config.sub: Update.

Signed-off-by: Werner Koch <wk@gnupg.org>
21 months agoFix for semaphore access by child.
NIIBE Yutaka [Tue, 5 Jul 2016 08:28:38 +0000 (17:28 +0900)]
Fix for semaphore access by child.

* configure.ac (HAVE_FORK_UNSAFE_SEMAPHORE): New.
* src/npth.c (sem_init): Use NPTH_SEMAPHORE_PSHARED.
* tests/t-fork.c: New.

--

Thanks to Uldis An┼ímits.
GnuPG-bug-id: 2260
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
21 months agow32: Include io.h for read(2) and write(2).
Werner Koch [Sat, 25 Jun 2016 17:22:56 +0000 (19:22 +0200)]
w32: Include io.h for read(2) and write(2).

* w32/npth.c: Include io.h.

Signed-off-by: Werner Koch <wk@gnupg.org>
21 months agoFix problem with regression tests on recent glibc.
Werner Koch [Sat, 25 Jun 2016 17:09:40 +0000 (19:09 +0200)]
Fix problem with regression tests on recent glibc.

* configure.ac: Change pthread test to test pthread_detach
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoImprove debug output.
Werner Koch [Thu, 26 Nov 2015 15:35:36 +0000 (16:35 +0100)]
Improve debug output.

* w32/npth.c (_npth_debug): Print to stderr.
(enter_npth, leave_npth): Include the tid in the debug output.

2 years agoAdd configure option --enable-build-timestamp.
Werner Koch [Tue, 25 Aug 2015 19:23:31 +0000 (21:23 +0200)]
Add configure option --enable-build-timestamp.

* configure.ac (BUILD_TIMESTAMP): Set to "<none>" by default.  Also
with ac_define_unquoted.
--

This is based on
libgpg-error commit d620005fd1a655d591fccb44639e22ea445e4554
but changed to be disabled by default.  Check there for some
background.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoconfigure.ac: improve check for clock_gettime library
Jim Meyering [Fri, 5 Jun 2015 15:03:00 +0000 (08:03 -0700)]
configure.ac: improve check for clock_gettime library

* configure.ac: When using AC_SEARCH_LIBS, handle the case in which
that function returns "none required". Also, save and restore LIBS
around the check, and properly m4-quote the first argument to AC_DEFINE.
Finally, also set and AC_SUBST LIB_CLOCK_GETTIME.
This added code is very similar to that provided in gnulib's
clock-time.m4.
* tests/Makefile.am (LDADD): Append $(LIB_CLOCK_GETTIME).

2 years agonpth-config: supply a library dependency for clock_gettime.
NIIBE Yutaka [Tue, 28 Apr 2015 00:24:14 +0000 (09:24 +0900)]
npth-config: supply a library dependency for clock_gettime.

* configure.ac (clock_gettime): Update config_libs.

--

For clock_gettime function, npth-config --libs should answer
it's library.  For old glibc, it's in -lrt.

3 years agoPost release updates.
Werner Koch [Sat, 11 Apr 2015 12:03:47 +0000 (14:03 +0200)]
Post release updates.

--

3 years agoRelease 1.2 npth-1.2
Werner Koch [Sat, 11 Apr 2015 11:58:48 +0000 (13:58 +0200)]
Release 1.2

3 years agow32: Use -static-libgcc to avoid linking to libgcc_s_sjlj-1.dll.
Werner Koch [Tue, 3 Feb 2015 14:17:49 +0000 (15:17 +0100)]
w32: Use -static-libgcc to avoid linking to libgcc_s_sjlj-1.dll.

* w32/Makefile.am: Remove non-Windows stuff.
(extra_ltoptions): New.
(libnpth_la_LDFLAGS): Use it.
--

Since gcc 4.8 there is a regression in that plain C programs may link
to libgcc_s.a which has a dependency on libgcc_s_sjlj.dll.  This is
for example triggered by using long long arithmetic on a 32 bit
Windows (e.g symbol __udivdi3).

3 years agoSwitch to automake 1.14.
Werner Koch [Wed, 28 Jan 2015 09:10:47 +0000 (10:10 +0100)]
Switch to automake 1.14.

* Makefile.am (AUTOMAKE_OPTIONS): Move to ...
* configure.ac (AM_INIT_AUTOMAKE): here.  Add serial-tests.
* build-aux/compile: Add.
* build-aux/config.guess, build-aux/config.sub: Update.
* build-aux/depcomp: Update.
* build-aux/missing: Update.

3 years agoDon't get fooled by leave_npth changing ERRNO.
Werner Koch [Thu, 18 Dec 2014 15:54:51 +0000 (16:54 +0100)]
Don't get fooled by leave_npth changing ERRNO.

* src/npth.c: Save ERRNO.
--
GnuPG-bug-id: 1773

Note that there is no need to do that in enter_pth because the specs
for sem_post don't identify EINTR as a possible return value.

3 years agoPost release updates.
Werner Koch [Fri, 31 Oct 2014 06:54:54 +0000 (07:54 +0100)]
Post release updates.

--

3 years agoRelease 1.1. npth-1.1
Werner Koch [Fri, 31 Oct 2014 06:49:44 +0000 (07:49 +0100)]
Release 1.1.

* configure.ac: Set LT version to C0/A0/R4.

3 years agoAllow use on systems which return ENOSYS for sem_init.
Werner Koch [Wed, 29 Oct 2014 11:25:20 +0000 (12:25 +0100)]
Allow use on systems which return ENOSYS for sem_init.

* src/npth.c: Include some more headers.
(sceptre_buffer): New.
(sceptre): Change to a pointer and init to sceptre_buffer.
(enter_npth, leave_npth): Adjust.
(try_sem_open): New.
(npth_init): Check for ENOSYS and use sem_open.
--

This is for example the case on OS X and some AIX versions Thanks to
Patrick Brunschwig for finding this problem and suggesting a solution.

3 years agoPost release updates
Werner Koch [Thu, 18 Sep 2014 06:11:00 +0000 (08:11 +0200)]
Post release updates

--

3 years agoRelease 1.0 npth-1.0
Werner Koch [Thu, 18 Sep 2014 06:06:58 +0000 (08:06 +0200)]
Release 1.0

* configure.ac: Set LT version to C0/A0/R2.

3 years agow32: Remove a debug message.
Werner Koch [Wed, 25 Jun 2014 18:25:28 +0000 (20:25 +0200)]
w32: Remove a debug message.

--

3 years agow32: Fix segv in npth_eselect.
Werner Koch [Wed, 25 Jun 2014 18:25:28 +0000 (20:25 +0200)]
w32: Fix segv in npth_eselect.

* w32/npth.c (npth_eselect): Obvious fix.

3 years agow32: Change an npth_eselect arg to unsigned.
Werner Koch [Wed, 25 Jun 2014 18:25:28 +0000 (20:25 +0200)]
w32: Change an npth_eselect arg to unsigned.

* w32/npth.c (npth_eselect): Change arg EVENTS_SET to unsigned int.
--

We use an unsigned int instead of a signed int for the bit vector for
clarity.

3 years agow32: Let npth_eselect return 0 for timeout. Fix replacement error codes.
Werner Koch [Wed, 25 Jun 2014 18:25:28 +0000 (20:25 +0200)]
w32: Let npth_eselect return 0 for timeout. Fix replacement error codes.

* w32/npth.c (npth_eselect): Remove debug output.  Return 0 for timeout.
* w32/npth.h (ETIMEDOUT, EOPNOTSUPP):  Change to more correct values.

4 years agow32: Make npth_eselect actually work.
Werner Koch [Wed, 19 Feb 2014 19:56:20 +0000 (20:56 +0100)]
w32: Make npth_eselect actually work.

* w32/npth.c (npth_eselect): Rewrite.
--

It never worked because the result FDSETs were first cleared and then
used to see which fd to check after the WFMO.  The new way better
resembles the way a select is expected to work under Windows (ignoring
the first arg) and will also work if this library is used by
application which have been build with a different FD_SETSIZE.

4 years agow32: Avoid calling FD_ISSET with a NULL fdset.
Werner Koch [Wed, 19 Feb 2014 13:09:20 +0000 (14:09 +0100)]
w32: Avoid calling FD_ISSET with a NULL fdset.

* w32/npth.c (npth_eselect): Check fdset before callig FD_foo.

4 years agoUse the generic autogen.sh script.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
Use the generic autogen.sh script.

* autogen.rc: New.
* Makefile.am (EXTRA_DIST): Add it.
* autogen.sh: Update from GnuPG.

4 years agoMove helper scripts to build-aux.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
Move helper scripts to build-aux.

* config.guess, config.sub, depcomp, install-sh
* ltmain.sh, missing: Move to build-aux/.
* configure.ac (AC_CONFIG_AUX_DIR): New.
(AM_SILENT_RULES): New.

4 years agoFix creation of w32 npth-config tool.
Werner Koch [Thu, 9 Jan 2014 16:41:16 +0000 (17:41 +0100)]
Fix creation of w32 npth-config tool.

* src/npth-config.in: Move to ../.
* src/npth.m4: Move to ../.
* w32/npth-config.in: Remove.
* w32/npth.m4: Remove.
* Makefile.am (EXTRA_DIST): Add npth-config.in and npth.m4.
(bin_SCRIPTS): new.
(m4datadir, m4data_DATA): New.
* configure.ac (AC_CONFIG_FILES): Adjust accordingly.

4 years agoAdd configure option --enable-silent-rules.
Werner Koch [Thu, 9 Jan 2014 14:13:48 +0000 (15:13 +0100)]
Add configure option --enable-silent-rules.

* configure.ac: Add AM_SILENT_RULES.

4 years agoautogen.sh: Change preferences of w32 toolchains
Werner Koch [Thu, 9 Jan 2014 14:10:47 +0000 (15:10 +0100)]
autogen.sh: Change preferences of w32 toolchains

--

4 years agoUpdate libtool to support Android.
Werner Koch [Thu, 9 Jan 2014 14:06:32 +0000 (15:06 +0100)]
Update libtool to support Android.

* m4/libtool.m4: Add "linux*android*" case.  Taken from the
libgpg-error.
--

This is the libgpg-error commit

  commit bf0d67dbfa4161e529781d6dfbfcce7126c3bf22
  Author: David 'Digit' Turner <digit@google.com>
  Date:   Tue Oct 22 14:26:53 2013 +0200

4 years agoUpdate config.{guess.sub} to a decent version (2013-11-29)
Werner Koch [Thu, 9 Jan 2014 14:03:15 +0000 (15:03 +0100)]
Update config.{guess.sub} to a decent version (2013-11-29)

4 years agoAdd hack to have different names for 64 bit Windows DLLs.
Werner Koch [Mon, 17 Jun 2013 14:11:23 +0000 (16:11 +0200)]
Add hack to have different names for 64 bit Windows DLLs.

* ltmain.sh: Prefix the SO number for W64 with a "6".
--

We need to stick to libtool 2.4.2 anyway, thus we take the easy way
and hack libtool instead of adding "-release 6" to the Makefile.  This
also avoids an extra dash before the 6 and thus yields a prettier name
than the one produced by the -release option.  The header files and
def files are supposed to be identical for w32 and w64 thus we don't
need to do any special code for them.

Having a different namespace for 64 bit DLLs is such a good idea that
I hope this or a similar feature will be provided by future libtool
versions.

4 years agoFix libtool 2.4.2 to correctly detect .def files.
Werner Koch [Thu, 18 Apr 2013 12:40:43 +0000 (14:40 +0200)]
Fix libtool 2.4.2 to correctly detect .def files.

* ltmain.sh (sed_uncomment_deffile): New.
(orig_export_symbols): Uncomment def file before testing for EXPORTS.
* m4/libtool.m4: Do the same for the generated code.
--

The old code was not correct in that it only looked at the first line
and puts an EXPORTS keyword in front if missing.  Binutils 2.22
accepted a duplicated EXPORTS keyword but at least 2.23.2 is more
stringent and bails out without this fix.

There is no need to send this upstream.  Upstream's git master has a
lot of changes including a similar fix for this problems.  There are
no signs that a libtool 2.4.3 will be released to fix this problem and
thus we need to stick to our copy of 2.4.2 along with this patch.

Signed-off-by: Werner Koch <wk@gnupg.org>
4 years agoUpdate libtool to Debian's 2.4.2.
Werner Koch [Thu, 9 Jan 2014 13:51:46 +0000 (14:51 +0100)]
Update libtool to Debian's 2.4.2.

4 years agow32: Fix build problems with current compilers.
Werner Koch [Thu, 9 Jan 2014 13:39:25 +0000 (14:39 +0100)]
w32: Fix build problems with current compilers.

* configure.ac (NTELIBS): ac_subst for W32.
* w32/npth.h (struct timespec): Do not define for current mingw-w64
versions.

4 years agoConditionalize use of pthread_atfork.
NIIBE Yutaka [Tue, 10 Dec 2013 00:00:37 +0000 (09:00 +0900)]
Conditionalize use of pthread_atfork.

* configure.ac: Add checking pthread_atfork.

* src/npth-sigev.c (npth_sigev_fini): Call pthread_atfork only when
it's available.

--

GnuPG-bug-id: 1576

4 years agoRestore sigmask at fork.
NIIBE Yutaka [Wed, 3 Jul 2013 08:06:49 +0000 (17:06 +0900)]
Restore sigmask at fork.

* src/npth-sigev.c (restore_sigmask_for_child_process): New.
(npth_sigev_fini): Register restore_sigmask_for_child_process.

5 years agoBuild fix for NetBSD.
Ben Kibbey [Tue, 20 Nov 2012 04:04:07 +0000 (23:04 -0500)]
Build fix for NetBSD.

* src/npth.c (npth_setname_np): conditional check for __NetBSD__ and
adapt correct parameters.
--

Not sure how far back pthread_setname_np() goes on NetBSD. This
function has funny parameters on NetBSD and I *think* this is the
correct
fix (http://www.daemon-systems.org/man/pthread_setname_np.3.html). Fixes
the build anyway.

5 years agoImprove parsing of the GIT revision number.
Werner Koch [Fri, 16 Nov 2012 12:42:44 +0000 (13:42 +0100)]
Improve parsing of the GIT revision number.

* configure.ac (git_revision): Use git rev-parse.

5 years agoFix non-portable use of chmod in autogen.sh.
Werner Koch [Fri, 16 Nov 2012 12:41:49 +0000 (13:41 +0100)]
Fix non-portable use of chmod in autogen.sh.

* autogen.sh: Remove option -c from chmod.

5 years agoMake local variables configure hack more robust
Werner Koch [Wed, 26 Sep 2012 14:38:49 +0000 (16:38 +0200)]
Make local variables configure hack more robust

* configure.ac (emacs_local_vars_begin): Use extra m4 quoting so that
newer Emscasen won't take it up as Local Variables for this file.

5 years agoPost release version bump
Werner Koch [Wed, 8 Aug 2012 04:51:04 +0000 (06:51 +0200)]
Post release version bump

--

5 years agoRelease 0.91 npth-0.91
Werner Koch [Wed, 8 Aug 2012 04:44:18 +0000 (06:44 +0200)]
Release 0.91

* configure.ac: Bump LT version to C0/A0/R2.

5 years agoReally fix the version number parsing.
Werner Koch [Tue, 15 May 2012 15:03:07 +0000 (17:03 +0200)]
Really fix the version number parsing.

* src/npth.m4 (_AM_PATH_NPTH_CONFIG, _AM_PATH_NPTH_CONFIG]: Fix last
fix.  Print detected version number.  Print warning for non-matching
host.
--

Repeat with me:  Before-breakfast-hacking is a bad habit.

5 years agoFix version number parsing in npth.m4.
Werner Koch [Tue, 15 May 2012 07:05:08 +0000 (09:05 +0200)]
Fix version number parsing in npth.m4.

* src/npth.m4: Adjust for n.m style version numbers.

5 years agoProvide gettimeofday fallback for clock_gettime.
Werner Koch [Thu, 10 May 2012 18:28:23 +0000 (20:28 +0200)]
Provide gettimeofday fallback for clock_gettime.

* configure.ac (AC_CHECK_FUNCS): Check for gettimeofday.
* src/npth.c (npth_clock_gettime): Use gettimeofday if clock_gettime
is not available.
--

This should fix the MacOS problem.

5 years agoReturn an error if npth_rwlock_timedwrlock is not supported.
Werner Koch [Thu, 10 May 2012 17:00:35 +0000 (19:00 +0200)]
Return an error if npth_rwlock_timedwrlock is not supported.

* src/npth.c (npth_rwlock_timedwrlock): Return ENOSYS if there is no
way to build it.

5 years agoAvoid compiler warning for debug variable.
Werner Koch [Thu, 10 May 2012 16:59:17 +0000 (18:59 +0200)]
Avoid compiler warning for debug variable.

* src/npth.c (main_thread): Flag as volatile.

5 years agoInclude required headers into pth.h.
Werner Koch [Thu, 10 May 2012 16:47:00 +0000 (18:47 +0200)]
Include required headers into pth.h.

* src/npth.h.in: Include sys/time.h and signal.h.  Include time.h only
if available.
* configure.ac (INSERT_SYS_TIME_H, INSERT_TIME_H, INSERT_SIGNAL_H):
Detect header files and ac_subst snippets.
--

sys/time.h is required for struct timeval and signal.h for sigset_t.
Without that them the regression test fails on IRIX.  Conditional
inclusion of these files might not bee required, but it should not
harm, either.

5 years agoRemove obsolete debug stuff.
Werner Koch [Thu, 10 May 2012 15:03:48 +0000 (17:03 +0200)]
Remove obsolete debug stuff.

* src/npth.c (enter_npth, leave_npth): Remove argument and debug
stuff.
(ENTER, LEAVE): Adjust macros accordingly.
--

The debug calls used c99 style varmarco arguments which is not good
for pre-c99 systems.  The debug stuff is not anymore needed, standard
system trace utilities are better suited for this task.

5 years agoAdd a basic create and join thread test case.
Werner Koch [Thu, 10 May 2012 14:55:48 +0000 (16:55 +0200)]
Add a basic create and join thread test case.

* tests/t-thread.c: New
* tests/t-support.h (opt_verbose):  New.
(fail_msg, info_msg): New.

5 years agoMake npth_setname_np actually work.
Werner Koch [Thu, 10 May 2012 13:31:37 +0000 (15:31 +0200)]
Make npth_setname_np actually work.

* src/npth.c (npth_setname_np): Fix typo in name and test macro.

5 years agoCheck for -lsocket et al.
Werner Koch [Thu, 10 May 2012 07:17:55 +0000 (09:17 +0200)]
Check for -lsocket et al.

* m4/libsocket.m4: New.  Stripped down from gnulib's socketlib.m4.
* tests/Makefile.am (LDADD): Add LIBSOCKET.
* configure.ac (NETLIBS): Remove because it is not used.
(npth_LIBSOCKET): Call.

5 years agoAdd a pselect emulation.
Werner Koch [Wed, 9 May 2012 18:44:12 +0000 (20:44 +0200)]
Add a pselect emulation.

* src/npth.c [!HAVE_PSELECT]: Include signal.h
(npth_pselect) [!HAVE_PSELECT]: Implement a crude pselect emulation
* configure.ac (AC_CHECK_FUNCS): Test for pselect.
--

This is a better than nothing emulation.  OpenBSD applications who
care about race conditions will probably use their own signal detection
via pipe.  This can be implemented on top of this emulation.

5 years agoCleanup the debug code.
Werner Koch [Wed, 9 May 2012 15:10:29 +0000 (17:10 +0200)]
Cleanup the debug code.

Debugging was only used for initial testing and there is no interface
to enable it at runtime.  This change make the code a little bit
cleaner.

5 years agoTake care of possible surprising sem_init implementations.
Werner Koch [Wed, 9 May 2012 15:08:30 +0000 (17:08 +0200)]
Take care of possible surprising sem_init implementations.

* src/npth.c (npth_init): Return an error only for POSIX.1-2008.
--

Although, I doubt that there is a sem_init version which does not
return 0 on success, it is better to avoid such surprises.  Most
callers will not test for the error return anyway.

5 years agoComment cleanups.
Werner Koch [Wed, 9 May 2012 14:25:36 +0000 (16:25 +0200)]
Comment cleanups.

--

5 years agoMake the t-mutex test more robust.
Werner Koch [Wed, 9 May 2012 13:21:34 +0000 (15:21 +0200)]
Make the t-mutex test more robust.

* tests/t-support.h: Simplify.
* tests/t-mutex.c: Include t-support.h.
(main): Check each call and explicitly return 0.

5 years agoLet npth_init actually return an error.
Werner Koch [Wed, 9 May 2012 13:13:10 +0000 (15:13 +0200)]
Let npth_init actually return an error.

* src/npth.c (npth_init): Return ERRNO.

5 years agoProvide a replacement for socklen_t.
Werner Koch [Wed, 9 May 2012 13:01:22 +0000 (15:01 +0200)]
Provide a replacement for socklen_t.

* m4/socklen.m4, m4/sys_socket_h.m4: New.
* configure.ac (INSERT_SOCKLEN_T): New.
* src/npth.h.in (INSERT_SOCKLEN_T): New substitution.
(npth_connect, npth_accept): Use _npth_socklen_t.
--

For example SGI IRIX 6.5 MIPS R10000 does not provide socklen_t.  We
provide the usual fallback to int as figured out by a gnulib test.
Note that _npth_socklen_t is internal to nPth and shall not be used by
applications.

5 years agoDo not use ___FUNCTION__.
Werner Koch [Wed, 9 May 2012 12:31:39 +0000 (14:31 +0200)]
Do not use ___FUNCTION__.

* src/npth.c: Define replacement for __func__.
(ENTER, LEAVE): Use __func__.

5 years agoTweak for building with c99.
Werner Koch [Wed, 9 May 2012 12:05:41 +0000 (14:05 +0200)]
Tweak for building with c99.

* tests/Makefile.am (AM_CPPFLAGS): Add -D_POSIX_C_SOURCE=200112L.

5 years agoAdd unistd.h is available.
Werner Koch [Wed, 9 May 2012 09:09:38 +0000 (11:09 +0200)]
Add unistd.h is available.

* configure.ac (AC_CHECK_HEADERS): Test for unistd.h.
* src/npth.c [HAVE_UNISTD_H]: Include unistd.h.

5 years agoImplement git magic to create beta version numbers.
Werner Koch [Fri, 4 May 2012 13:24:39 +0000 (15:24 +0200)]
Implement git magic to create beta version numbers.

* configure.ac (BUILD_FILEVERSION): Move after detection of W32.
--
Also update the version number for the next release.

5 years agoRelease 0.90. npth-0.90
Werner Koch [Fri, 4 May 2012 12:14:05 +0000 (14:14 +0200)]
Release 0.90.

* configure.ac: Bump LT version to C0/A0/R1.

6 years agoSupport Android API level earlier than 9.
Marcus Brinkmann [Fri, 9 Mar 2012 18:00:21 +0000 (19:00 +0100)]
Support Android API level earlier than 9.

* src/npth.h [__ANDROID__]: Include <android/api-level.h>
(_NPTH_NO_RWLOCK) [__ANDROID__ && __ANDROID_API__ < 9]: Define.
(npth_rwlockattr_t, npth_rwlockattr_init, npth_rwlockattr_destroy,
npth_rwlockattr_gettype_np, npth_rwlockattr_settype_np,
NPTH_RWLOCK_PREFER_READER_NP, NPTH_RWLOCK_PREFER_WRITER_NP,
NPTH_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, NPTH_RWLOCK_DEFAULT_NP,
NPTH_RWLOCK_INITIALIZER, NPTH_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
NPTH_MUTEX_INITIALIZER, npth_rwlock_t, npth_rwlock_init,
npth_rwlock_destroy, npth_rwlock_tryrdlock, npth_rwlock_rdlock,
npth_rwlock_trywrlock, npth_rwlock_timedrdlock, npth_rwlock_wrlock,
npth_rwlock_rdlock, npth_rwlock_timedwrlock, npth_rwlock_unlock
(_NPTH_NO_RWLOCK): Alternative implementation based on mutex.

6 years agoRemove npth_yield.
Marcus Brinkmann [Tue, 28 Feb 2012 16:24:19 +0000 (17:24 +0100)]
Remove npth_yield.

* src/npth.h.in (npth_yield): Macro removed (should have been a
function anyway).
* w32/npth.c (npth_yield): Remove function.
* w32/npth.h (npth_yield): Remove prototype.
* w32/npth.def (npth_yield): Remove symbol export.

6 years agoMake rwlock try and timed functions optional.
Marcus Brinkmann [Tue, 28 Feb 2012 15:52:07 +0000 (16:52 +0100)]
Make rwlock try and timed functions optional.

* configure.ac: Check for pthread_rwlock_rdlock, pthread_rwlock_wrlock,
pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock,
pthread_rwlock_tryrdlock, pthread_rwlock_trywrlock.
* src/npth.c (trylock_func_t): New type.
(busy_wait_for): New function.
(npth_mutex_timedlock) [!HAVE_PTHREAD_MUTEX_TIMEDLOCK]: Reimplement
in terms of busy_wait_for.
(npth_rwlock_rdlock, npth_rwlock_timedrdlock)
[!HAVE_PTHREAD_RWLOCK_TRYRDLOCK]: Skip trylock.
(npth_rwlock_wrlock, npth_rwlock_timedwrlock)
[!HAVE_PTHREAD_RWLOCK_TRYWRLOCK]: Skip trylock call.
(npth_rwlock_timedrdlock) [!HAVE_PTHREAD_RWLOCK_TIMEDRDLOCK]:
Use busy_wait_for.
(npth_rwlock_timedwrlock) [!HAVE_PTHREAD_RWLOCK_TIMEDWRLOCK]:
Use busy_wait_for.

6 years agoAdd generated files src/npth.h and w32/npth-config.
Marcus Brinkmann [Tue, 28 Feb 2012 13:44:37 +0000 (14:44 +0100)]
Add generated files src/npth.h and w32/npth-config.

6 years agoFix include path for non-w32 builds.
Marcus Brinkmann [Wed, 8 Feb 2012 13:39:42 +0000 (14:39 +0100)]
Fix include path for non-w32 builds.

* tests/Makefile.am (AM_CPPFLAGS) [!HAVE_W32_SYSTEM]:
Locate header in build dir, not src.

6 years agoImplement npth_mutex_timedlock for inferior systems.
Marcus Brinkmann [Tue, 31 Jan 2012 14:33:55 +0000 (15:33 +0100)]
Implement npth_mutex_timedlock for inferior systems.

* configure.ac: Check for pthread_mutex_timedlock.
* src/npth.c (BUSY_WAIT_INTERVAL): New macro.
(npth_mutex_timedlock): If pthread_mutex_timedlock is missing,
use a poke-the-stick-at-it strategy.

6 years agoInclude sys/select.h if needed.
Werner Koch [Fri, 27 Jan 2012 18:55:22 +0000 (19:55 +0100)]
Include sys/select.h if needed.

* src/npth.h: Rename to npth.h.in.  Include sys/select.h if
available. Add usual read-only comments.
* configure.ac: Create npth.h.
(INSERT_SYS_SELECT_N): New
(emacs_local_vars_read_only): New vars to support read-only switching.

6 years agoUpdate config.guess and config.sub.
Werner Koch [Fri, 27 Jan 2012 14:20:08 +0000 (15:20 +0100)]
Update config.guess and config.sub.

* config.guess, config.sub: Update to version 2012-01-01.
* autogen.sh: Fix typo.

6 years agoEncapsulate clock_gettime.
Werner Koch [Fri, 27 Jan 2012 14:16:25 +0000 (15:16 +0100)]
Encapsulate clock_gettime.

* src/Makefile.am (libnpth_la_LDFLAGS): Remove -pthread and -lrt.
* src/npth.h (npth_clock_gettime): Turn macro into a function.
* src/npth.c (npth_clock_gettime): New.
* src/libnpth.vers: Add npth_clock_gettime.

6 years agoImprove pthread library detection.
Werner Koch [Fri, 27 Jan 2012 14:12:47 +0000 (15:12 +0100)]
Improve pthread library detection.

* configure.ac: Reorder some code.  Improve pthread test to take libc
in account.  Generate NPTH_CONFIG_LIBS from tests.
* src/npth-config.in: Use NPTH_CONFIG_LIBS.
* w32/npth-config.in: Ditto.
* tests/Makefile.am (AM_CPPFLAGS, AM_LDFLAGS): Don not pass -pthread.

6 years agoRemove unused include files from npth.h.
Werner Koch [Thu, 26 Jan 2012 16:27:37 +0000 (17:27 +0100)]
Remove unused include files from npth.h.

* src/npth.h: Remove unused poll.h and errno.h includes.

6 years agoMake npth_{s,g}etname_np portable.
Werner Koch [Thu, 26 Jan 2012 16:01:28 +0000 (17:01 +0100)]
Make npth_{s,g}etname_np portable.

These functions are usually used for debugging.  On systems where
they are not easy to support they will now simply return ENOSYS.
* configure.ac: Check for pthread_setname_np and pthread_getname_np.
* src/libnpth.vers: Add npth_setname_np and npth_getname_np.
* src/npth.c (npth_setname_np, npth_getname_np): New.
* src/npth.h (npth_setname_np, npth_getname_np): Turn macros into
functions.

6 years agoCheck for the non-portable pthread_tryjoin_np.
Werner Koch [Thu, 26 Jan 2012 10:15:16 +0000 (11:15 +0100)]
Check for the non-portable pthread_tryjoin_np.

* configure.ac: Check for pthread_tryjoin_np.  Also rework the pthread
test to update LIBS
* src/npth.c (npth_join) [HAVE_PTHREAD_TRYJOIN_NP]: Use
pthread_tryjoin_np only if available.

6 years agoFix thread startup.
Marcus Brinkmann [Wed, 25 Jan 2012 15:23:34 +0000 (16:23 +0100)]
Fix thread startup.

* src/npth.c (npth_create): Fix startup data use.

6 years agoInclude stdlib.h for malloc prototypes.
Werner Koch [Wed, 25 Jan 2012 10:50:02 +0000 (11:50 +0100)]
Include stdlib.h for malloc prototypes.

* src/npth.c: Include stdlib.h.

6 years agoRequire gitlog-to-changelog to be installed.
Werner Koch [Tue, 24 Jan 2012 17:53:42 +0000 (18:53 +0100)]
Require gitlog-to-changelog to be installed.

* Makefile.am (gen-ChangeLog): Do no use included gitlog-to-changelog.
Use options --append-dot and --tear-off.
* build-aux/gitlog-to-changelog: Remove from repo.

6 years agoAllow manually unprotect/protect calls.
Marcus Brinkmann [Mon, 23 Jan 2012 22:53:05 +0000 (23:53 +0100)]
Allow manually unprotect/protect calls.

* src/libnpth.vers (npth_unprotect, npth_protect): New symbols.
* src/npth.c (npth_unprotect, npth_protect): New functions.
* src/npth.h (npth_unprotect, npth_protect): New declaration.
* w32/npth.def (npth_unprotect, npth_protect): New exports.
* w32/npth.c (npth_unprotect, npth_protect): New functions.
* w32/npth.h (npth_unprotect, npth_protect): New declaration.

6 years agoAllow no extra events in npth_eselect.
Marcus Brinkmann [Thu, 19 Jan 2012 20:50:59 +0000 (21:50 +0100)]
Allow no extra events in npth_eselect.

* w32/npth.c (npth_eselect): Allow events to be NULL.