This commit adds a new thread-related module Semaphore, implementing
counting semaphores and binary semaphores.
The two kinds of semaphores are presented as two different
abstract types in two sub-modules, Counting and Binary.
- Mutex.lock raises Sys_error if the mutex is already locked by the
calling thread.
- Mutex.unlock raises Sys_error if the mutex is unlocked or locked
by another thread.
Add the corresponding tests.
Co-authored-by: David Allsopp <david.allsopp@metastack.com>
This is a wrapper around the _exit system call. It has been implemented
in otherlibs/unix/exit.c for a long time but never exported.
This commit exports and documents it as `Unix._exit`.
The Unix implementation of `establish_server` is changed to use `_exit`
and to have gender-neutral comments.
A test was added to check that OCaml finalization actions are not performed.
With this commit, it becomes possible to provide C compiler and preprocessor
flags to use in addition to those defined by the build system.
As required by the GNU coding standards, the flags can be provided
either at configure or at make invocation.
The provided CFLAGS and CPPFLAGS will also be taken into account
when C code is compiled by ocamlc/ocamlopt.
This commit removes the explicit reference to CFLAGS in the
configuration for the xlc compiler, since it is not necessary any longer.
To preserve behaviour, explicit polls are added:
- in caml_raise, to raise the right exception when as system
call is interrupted by a signal.
- in sigprocmask, to ensure that signals are handled as soon
as they are unmasked.
Now that programs are built with their $(EXE) suffix, their installation
rules can be simplified a bit because most of the programs get installed
under the name they have been built with.
This commit touches neither boot/ocamlc nor boot/ocamllex
It has the side-effect of fixing the cleanup rules which did not use the
$(EXE) extension when removing a file although it was produced with the
$(EXE) extension.
This patch makes Unix.time and Unix.gettimeofday be unboxed and @noalloc, which makes them about 20% faster (as measured by a stupid benchmark that does them many times in a loop).
This removes the fallback and error-handling paths from gettimeofday. Neither is needed according to Single Unix Specification and POSIX.
Fixes: #7446