npth.git
7 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.

7 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.

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

--

7 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.

7 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.

7 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.

7 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__.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 years agoImplement ability to wait on sockets and events.
Marcus Brinkmann [Thu, 19 Jan 2012 20:13:53 +0000 (21:13 +0100)]
Implement ability to wait on sockets and events.

* w32/npth.c (npth_eselect): New function.
* w32/npth.h (npth_eselect): New declaration.
* w32/npth.def (npth_eselect): New export.

7 years agoRemove libnpth.vers dependency.
Marcus Brinkmann [Thu, 19 Jan 2012 20:12:32 +0000 (21:12 +0100)]
Remove libnpth.vers dependency.

* w32/Makefile.am (libnpth_la_DEPENDENCIES): Remove libnpth.vers.

7 years agoRelease mutex temporarily on instant timeout in npth_cond_timedwait.
Marcus Brinkmann [Thu, 19 Jan 2012 16:31:59 +0000 (17:31 +0100)]
Release mutex temporarily on instant timeout in npth_cond_timedwait.

* w32/npth.c (npth_cond_timedwait): Release mutex temporarily even on
instant timeout.

7 years agoRemove obsolete file.
Marcus Brinkmann [Fri, 13 Jan 2012 00:53:25 +0000 (01:53 +0100)]
Remove obsolete file.

* src/Makefile.am (EXTRA_DIST): Remove npth.def
* src/npth.def: Removed.

7 years agoInitial support for w32.
Marcus Brinkmann [Fri, 13 Jan 2012 00:37:07 +0000 (01:37 +0100)]
Initial support for w32.

* Makefile.am [HAVE_W32_SYSTEM]: Build from w32 directory.
* configure.ac: Don't check for pthread on windows.  Add winsock
library on windows.  Add w32 subdirectory to config files.
* w32/npth.h, w32/npth.c, w32/Makefile.am, w32/npth.def,
w32/npth-config.in, w32/npth.m4: New files.
* tests/Makefile.am: Allow building on w32.

7 years agoAdd missing function npth_system.
Marcus Brinkmann [Fri, 13 Jan 2012 00:27:26 +0000 (01:27 +0100)]
Add missing function npth_system.

* src/npth.c (npth_system): New function.

7 years agoRemove duplicated macro.
Marcus Brinkmann [Wed, 11 Jan 2012 21:35:26 +0000 (22:35 +0100)]
Remove duplicated macro.

* npth.h (PTHREAD_RWLOCK_INITIALIZER): Remove.

7 years agoAdd some missing interfaces.
Marcus Brinkmann [Wed, 11 Jan 2012 21:15:48 +0000 (22:15 +0100)]
Add some missing interfaces.

* npth.h (npth_key_delete, NPTH_ERRORCHECK_MUTEX_INITIALIZER_NP,
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):
New macros.
(NPTH_RWLOCK_INIT): Rename to ...
(NPTH_RWLOCK_INITIALIZER): ... this.

7 years agoFix exclusion logic at thread creation and allow main thread to exit.
Marcus Brinkmann [Fri, 6 Jan 2012 13:03:13 +0000 (14:03 +0100)]
Fix exclusion logic at thread creation and allow main thread to exit.

* libnpth.vers (npth_create, npth_exit): New.
* npth.def (npth_create, npth_exit): Likewise.
* npth.h (npth_create): Change from macro to declaration.
(npth_exit): New declaration.
* npth.c (startup_s): New struct.
(thread_startup, npth_create, npth_exit): New functions.

7 years agoCreate the ChangeLog from the git commit log.
Werner Koch [Tue, 6 Dec 2011 10:37:19 +0000 (11:37 +0100)]
Create the ChangeLog from the git commit log.

* autogen.sh: Install git commit log checker.
* build-aux/git-hooks/commit-msg: New.  Repo only.
* build-aux/git-log-fix: New.  Repo only.
* build-aux/git-log-footer: New.  Repo only.
* build-aux/gitlog-to-changelog: New.  Repo only.
* HACKING: New.
* Makefile.am (gen-Changelog): New rule.
(dist-hook):  Depend on gen-Changelog.
(EXTRA_DIST): Add HACKING.
* ChangeLog: New stub file.

7 years agoMerge branch 'master' of git+ssh://playfair.gnupg.org/git/npth
Marcus Brinkmann [Mon, 7 Nov 2011 16:38:23 +0000 (17:38 +0100)]
Merge branch 'master' of git+ssh://playfair.gnupg.org/git/npth

Conflicts:
ChangeLog

7 years agoLoop over sem_wait until EINTR.
Marcus Brinkmann [Mon, 7 Nov 2011 16:37:52 +0000 (17:37 +0100)]
Loop over sem_wait until EINTR.

7 years agoStraighten out some interface issues.
Marcus Brinkmann [Wed, 26 Oct 2011 19:51:49 +0000 (21:51 +0200)]
Straighten out some interface issues.

7 years agoHave attributes for mutex, rwlock and cond like in pthread.
Marcus Brinkmann [Fri, 7 Oct 2011 19:58:02 +0000 (21:58 +0200)]
Have attributes for mutex, rwlock and cond like in pthread.

7 years agoDelete generated file.
Marcus Brinkmann [Fri, 7 Oct 2011 19:36:26 +0000 (21:36 +0200)]
Delete generated file.

7 years agoMade make distcheck work.
Werner Koch [Thu, 6 Oct 2011 16:47:29 +0000 (18:47 +0200)]
Made make distcheck work.

7 years agoInitial commit.
Marcus Brinkmann [Thu, 6 Oct 2011 15:00:06 +0000 (17:00 +0200)]
Initial commit.

8 years agoStarted nPth project.
Werner Koch [Wed, 23 Feb 2011 18:06:32 +0000 (19:06 +0100)]
Started nPth project.