Bruno Haible [Wed, 3 Jul 2019 17:25:09 +0000 (19:25 +0200)]
mbrtowc: Fix invalid use of mbtowc() on MSVC.
* lib/mbrtowc.c: Include glthread/lock.h.
(mbtowc_lock): New variable.
(mbrtowc): Treat UTF-8 encoding without locking. For the other
encodings, explicitly reset the internal state of mbtowc, and protect
this through a lock.
* modules/mbrtowc (Depends-on): Add lock.
Bruno Haible [Tue, 2 Jul 2019 18:43:00 +0000 (20:43 +0200)]
getcwd: Fix crash when invoked with size = 0 on MSVC.
* lib/getcwd.c: Include msvc-inval.h.
(getcwd_nothrow): New function/macro.
(getcwd_system): New macro.
(__getcwd): Use it instead of getcwd.
* modules/getcwd (Depends-on): Add msvc-inval.
* doc/posix-functions/getcwd.texi: Mention the MSVC issue.
Bruno Haible [Sun, 30 Jun 2019 13:08:05 +0000 (15:08 +0200)]
inet_ntop, inet_pton: Forward-compatibility with newer Windows versions.
* m4/inet_ntop.m4 (gl_FUNC_INET_NTOP): On native Windows, set
REPLACE_INET_NTOP to 1 always.
* m4/inet_pton.m4 (gl_FUNC_INET_PTON): On native Windows, set
REPLACE_INET_PTON to 1 always.
Paul Eggert [Wed, 26 Jun 2019 19:46:32 +0000 (12:46 -0700)]
strverscmp: sync from glibc
* lib/strverscmp.c: Sync from glibc, except use UTF-8 encoding in
comments, include libc-config.h, define __strverscmp to be
strverscmp, and don’t assume types line uint8_t and int8_t that
that C99 doesn’t guarantee.
[!_LIBC]: Include libc-config.h; define __strverscmp.
Include stdint.h.
(__strverscmp): Assume C99. Use uint_least8_t
and int_least8_t instead of unsigned char and signed char.
* modules/strverscmp (Depends-on): Add libc-config, stdint.
Paul Eggert [Mon, 24 Jun 2019 18:54:00 +0000 (11:54 -0700)]
unistd: stddef.h and sys/types.h namespace cleanup
* lib/unistd.in.h [__GLIBC__]:
Do not include stddef.h or sys/types.h.
[!__GLIBC__]: Always include sys/types.h, since unistd.h is
supposed to declare off_t and ssize_t. Problem found when looking
at why @GNULIB_PWRITE@ was different from the newly-added
@GNULIB_COPY_FILE_RANGE@ with respect to ssize_t.
Akim Demaille [Sat, 22 Jun 2019 06:37:31 +0000 (08:37 +0200)]
argmatch: put all the docs member last.
Reported by Bruno Haible.
* lib/argmatch.h (argmatch_##Name##_group_type): Put the args
member before the docs done.
* doc/argmatch.texi, tests/test-argmatch.c: Adjust.
Bruno Haible [Fri, 21 Jun 2019 02:35:41 +0000 (04:35 +0200)]
threads-h: Define 'thread_local' if and only it actually works.
* m4/threads.m4 (gl_THREAD_LOCAL_DEFINITION): New macro.
(gl_THREADS_H): Define _Thread_local to __thread also for ARM C, IBM C,
Oracle Solaris Studio C. Compile a simple program, to see whether
_Thread_local basically works. Set HAVE_THREAD_LOCAL and LIBTHREADLOCAL.
(gl_THREADS_H_DEFAULTS): Initialize HAVE_THREAD_LOCAL.
* lib/threads.in.h (thread_local): Undefine if it does not work.
* modules/threads-h (Makefile.am): Substitute HAVE_THREAD_LOCAL.
(Link): Mention LIBTHREADLOCAL.
* tests/test-threads.c: Don't check that thread_local is defined.
* tests/test-thread_local.c: New file.
* modules/threads-h-tests (Files): Add it and macros.h.
(Depends-on): Add thrd and stdint.
(configure.ac): Test whether 'alarm' is declared.
(Makefile.am): Arrange to build and link test-thread_local.
* doc/posix-headers/threads.texi: Mention the platforms that don't
support 'thread_local'.
Bruno Haible [Thu, 20 Jun 2019 02:38:06 +0000 (04:38 +0200)]
mtx: Add tests.
* tests/test-mtx.c: New file, based on tests/test-lock.c.
* tests/test-call_once.c: New file, based on tests/test-once.c.
* modules/mtx-tests: New file.
Bruno Haible [Thu, 20 Jun 2019 02:37:23 +0000 (04:37 +0200)]
thrd: Add tests.
* tests/test-thrd_create.c: New file, based on
tests/test-thread_create.c.
* tests/test-thrd_current.c: New file, based on
tests/test-thread_self.c.
* modules/thrd-tests: New file.
Bruno Haible [Thu, 20 Jun 2019 02:26:31 +0000 (04:26 +0200)]
thrd: New module.
* lib/thrd.c: New file.
* m4/thrd.m4: New file.
* modules/thrd: New file.
* doc/posix-functions/thrd_current.texi: Mention the new module.
* doc/posix-functions/thrd_detach.texi: Likewise.
* doc/posix-functions/thrd_equal.texi: Likewise.
* doc/posix-functions/thrd_exit.texi: Likewise.
* doc/posix-functions/thrd_sleep.texi: Likewise.
* doc/posix-functions/thrd_yield.texi: Likewise.
* doc/posix-functions/thrd_create.texi: Mention the new module and the
AIX bug.
* doc/posix-functions/thrd_join.texi: Mention the new module and the
AIX and Solaris bugs.
Bruno Haible [Thu, 20 Jun 2019 02:17:30 +0000 (04:17 +0200)]
threads-h: New module.
* lib/threads.in.h: New file.
* m4/threads.m4: New file.
* m4/yield.m4 (gl_YIELD): Update comment.
* modules/threads-h: New file.
* modules/yields (configure.ac): Use AC_REQUIRE.
* doc/posix-headers/threads.texi: Mention the new module and the AIX
bugs.
Bruno Haible [Thu, 20 Jun 2019 02:15:30 +0000 (04:15 +0200)]
windows-tls: New module.
* lib/windows-tls.h: New file, based on lib/glthread/tls.h.
* lib/windows-tls.c: New file, based on lib/glthread/tls.h.
* lib/glthread/tls.h: Include windows-tls.h.
(gl_tls_key_t): Define using glwthread_tls_key_t.
* modules/windows-tls: New file.
* modules/tls (Depends-on): Add windows-tls.
Bruno Haible [Thu, 20 Jun 2019 02:12:41 +0000 (04:12 +0200)]
windows-timedrecmutex: New module.
* lib/windows-timedrecmutex.h: New file, based on windows-recmutex.h.
* lib/windows-timedrecmutex.c: New file, based on windows-recmutex.c.
* modules/windows-timedrecmutex: New file.
Bruno Haible [Thu, 20 Jun 2019 02:11:57 +0000 (04:11 +0200)]
windows-timedmutex: New module.
* lib/windows-timedmutex.h: New file, based on windows-mutex.h.
* lib/windows-timedmutex.c: New file, based on windows-mutex.c.
* modules/windows-timedmutex: New file.
Bruno Haible [Thu, 20 Jun 2019 02:08:16 +0000 (04:08 +0200)]
windows-mutex: New module.
* lib/windows-mutex.h: New file, extracted from lib/glthread/lock.h.
* lib/windows-mutex.c: New file, extracted from lib/glthread/lock.c.
* lib/windows-spinlock.h: New file, extracted from lib/glthread/lock.h.
* lib/glthread/lock.h: Include windows-spinlock.h, windows-mutex.h.
(gl_spinlock_t): Remove type.
(gl_lock_t): Define using glwthread_mutex_t.
(gl_lock_initializer): Define using GLWTHREAD_MUTEX_INIT.
(glthread_lock_init): Define using glwthread_mutex_init.
(glthread_lock_lock): Define using glwthread_mutex_lock.
(glthread_lock_unlock): Define using glwthread_mutex_unlock.
(glthread_lock_destroy): Define using glwthread_mutex_destroy.
(glthread_lock_init_func, glthread_lock_lock_func,
glthread_lock_unlock_func, glthread_lock_destroy_func): Remove
declarations.
Use glwthread_spinlock_t instead of gl_spinlock_t.
(gl_rwlock_initializer, gl_recursive_lock_initializer): Define using
GLWTHREAD_SPINLOCK_INIT.
* lib/glthread/lock.c (glthread_lock_init_func, glthread_lock_lock_func,
glthread_lock_unlock_func, glthread_lock_destroy_func): Remove
functions.
* lib/glthread/cond.h: Use glwthread_spinlock_t instead of
gl_spinlock_t.
* modules/windows-mutex: New file.
* modules/lock (Depends-on): Add windows-mutex.
Bruno Haible [Thu, 20 Jun 2019 02:04:08 +0000 (04:04 +0200)]
lock, cond: Avoid possible counter wraparound on Windows.
* lib/glthread/lock.c (glthread_lock_lock_func): Leave the 'started'
field of the guard unchanged if it was already positive.
(glthread_rwlock_rdlock_func): Likewise.
(glthread_rwlock_wrlock_func): Likewise.
(glthread_recursive_lock_lock_func): Likewise.
* lib/glthread/cond.c (glthread_cond_wait_func): Likewise.
(glthread_cond_timedwait_func): Likewise.
Bruno Haible [Thu, 20 Jun 2019 02:02:52 +0000 (04:02 +0200)]
pthread_mutex_timedlock: New module.
* lib/pthread.in.h (pthread_mutex_timedlock): New dummy function and
new declaration.
* lib/pthread_mutex_timedlock.c: New file.
* m4/pthread_mutex_timedlock.m4: New file.
* m4/pthread.m4 (gl_PTHREAD_CHECK): Don't call AC_LIBOBJ here. Test
whether pthread_mutex_timedlock is declared.
(gl_PTHREAD_MODULE_INDICATOR): New macro.
(gl_PTHREAD_DEFAULTS): Initialize GNULIB_PTHREAD_MUTEX_TIMEDLOCK,
HAVE_PTHREAD_MUTEX_TIMEDLOCK.
* modules/pthread (configure.ac): Call AC_LIBOBJ here.
(Makefile.am): Substitute GNULIB_PTHREAD_MUTEX_TIMEDLOCK,
HAVE_PTHREAD_MUTEX_TIMEDLOCK.
* modules/pthread_mutex_timedlock: New file.
* doc/posix-functions/pthread_mutex_timedlock.texi: Mention the new
module.
* m4/threadlib.m4 (gl_THREADLIB_BODY): Test for <threads.h>.
* lib/glthread/thread.h (c11_threads_in_use): New macro.
(pthread_in_use, pth_in_use, thread_in_use): Use it.
* lib/glthread/lock.h (c11_threads_in_use): New macro.
(pthread_in_use, pth_in_use, thread_in_use): Use it.
* lib/glthread/cond.h (c11_threads_in_use): New macro.
(pthread_in_use, pth_in_use, thread_in_use): Use it.
* lib/glthread/tls.h (c11_threads_in_use): New macro.
(pthread_in_use, pth_in_use, thread_in_use): Use it.
Bruno Haible [Thu, 20 Jun 2019 01:53:51 +0000 (03:53 +0200)]
tls tests: Small improvements.
* tests/test-tls.c: Include <stdint.h>.
(worker_thread): Avoid gcc warning on 64-bit mingw.
(test_tls): Pass a different id to each thread.
* modules/tls-tests (Depends-on): Add stdint.
Bruno Haible [Wed, 19 Jun 2019 10:06:23 +0000 (12:06 +0200)]
Reorder pieces of header in perl scripts.
The desired order is
- Prologue part 1 (2 lines with #!)
- Program short description
- Copyright and license notice
- Written-by notice
- Program short description (optional)
- Program long description (optional)
- Prologue part 2
- Time stamp
- Code
Reported by Paul Eggert.
* build-aux/announce-gen: Reorder header.
* build-aux/gitlog-to-changelog: Likewise.
* build-aux/useless-if-before-free: Likewise.
* build-aux/prefix-gnulib-mk: Add copyright notice and short
description.
* build-aux/update-copyright: Likewise. Add short description. Bump
time-stamp-line-limit to 200.