Commit Graph

529 Commits (f6279a64b5f8812fed05e8bfeaa9bffcf7b6933f)

Author SHA1 Message Date
Nicolás Ojeda Bär 8806ddcbba
Unix.setsid: guard against errors (#9958)
The return value of `setsid()` was not checked for errors.
2020-10-05 19:20:30 +02:00
Florian Angeletti d0e983e2aa
Merge pull request #9745 from johnwhitington/trunk
Unify labeled and unlabeled Standard Library module interfaces
2020-09-15 11:07:25 +02:00
Xavier Leroy ba0a9c2ce8
Export, document, and use Unix._exit (#9914)
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.
2020-09-14 19:03:42 +02:00
John Whitington cd920ab553 Remove false self-references 2020-09-11 18:11:54 +01:00
David Allsopp 0d91bef985
Eliminate CAMLprim/CAMLexport in socketaddr.h (#9900)
* Merge {win32,}unix/socketaddr.h so that unix/socketaddr.h can be used from win32unix/ as well.
* Update socket-related files in win32unix/
2020-09-11 16:35:31 +02:00
John Whitington c3f6cd7ff7 Merge remote-tracking branch 'upstream/trunk' into trunk 2020-09-11 14:14:38 +01:00
David Allsopp 28789cd045
Merge pull request #9904 from dra27/unix-io-prims
Declare primitives used by unix in io.h
2020-09-11 09:35:31 +01:00
John Whitington fc101ae849 Rename tools/unlabel --> tools/sync_stdlib_docs 2020-09-10 19:17:43 +01:00
David Allsopp 435babd6f8 Declare primitives used by unix in io.h 2020-09-10 16:34:24 +01:00
David Allsopp 83f0dda553 Don't use CAMLextern in C files 2020-09-10 13:55:38 +01:00
Yishuai Li 63c7071a34
Add Unix.SO_REUSEPORT (#9869)
Support the SO_REUSEPORT socket option.

Closes: #3512
2020-09-02 10:52:04 +02:00
David Allsopp 79ee88c270 tools/unlabel 2020-08-07 15:04:22 +01:00
David Allsopp bd2f72d647 unixLabels.cmi must be pre-processed 2020-08-07 12:00:38 +01:00
David Allsopp 2271e9c0f5 Final nits 2020-08-07 11:51:26 +01:00
John Whitington 7bb80d434e "final" fixes 2020-08-06 14:18:18 +01:00
John Whitington 53f753d772 remove double @sinces 2020-08-03 15:26:44 +01:00
John Whitington 0af3a1a805 Small fixes from @dra27's comments 2020-08-03 12:46:16 +01:00
John Whitington 7a22c2b1e4 Remove unneeded comment, typo 2020-08-01 13:54:36 +01:00
John Whitington 1c258b463f Fix label warnings 2020-07-31 15:51:11 +01:00
John Whitington 0e2a4a6ea7 Better, simpler, removal of unix type aliases 2020-07-30 19:07:03 +01:00
John Whitington 6e0557f6d7 Labeled and unlabeled @sinces automatically 2020-07-30 17:21:22 +01:00
John Whitington 0fbeee11be Fix smaller review comments from @dra27 2020-07-30 13:26:20 +01:00
John Whitington 85491c8867 Tildes back in labeled modules 2020-07-29 14:58:01 +01:00
John Whitington f32c4df6df {!Unix.xxx} changed to {!xxx} in docstrings 2020-07-23 18:55:57 +01:00
David Allsopp 9a7a17c012 Add Sys.mkdir 2020-07-21 14:15:40 +01:00
Stephen Dolan 5b4b834578
Ensure signals are handled before Unix.{kill,sigprocmask} return (#9802) 2020-07-30 14:30:42 +01:00
Stephen Dolan 15b9d006a4 Avoid polling in caml_leave_blocking_section
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.
2020-07-28 10:54:54 +01:00
John Whitington db432875c9 Fixes per check-typo failure 2020-07-18 09:25:43 +01:00
John Whitington 84414661c1 Unify unixLabels.mli / unix.mli via tools/unlabel 2020-07-17 17:26:28 +01:00
Stephen Dolan a8e2f2b170
Unbox result of Unix.gettimeofday in unix and win32unix (#9561)
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
2020-06-02 11:05:57 +02:00
Xavier Leroy 3e8272fe7c Reimplement Unix.command like Unix.create_process
Avoid calling Unix.fork and use the new "spawn" primitive, for efficiency
and for improved compatibility with threads and Multicore OCaml.
2020-05-19 19:21:18 +02:00
Xavier Leroy ba528fe713 Reimplement Unix.create_process in C, using posix_spawn if possible
Unix.create_process was implemented in OCaml, using Unix.fork
and Unix.execvp.  This commit reimplements it in C, for several reasons:
- The implementation can take advantage of posix_spawn, if available,
  which is usually faster than fork + exec.
- The implementation is more atomic w.r.t. threading.
- Multicore OCaml will probably prohibit Unix.fork in multithreaded
  programs.
2020-05-19 19:21:18 +02:00
Xavier Leroy e4d64486cf Reimplement execvpe emulation in C
The `execvpe` function is not always provided by C standard libraries.

PR #1414 implemented an emulation of `execvpe` in terms of `execve`
written in OCaml.  This commit reimplements the emulation of `execvpe`
in C, so that it can be called from C.  It implements exactly the same
algorithm, with one small change detailed next.

Small change: error ENAMETOOLONG stops the search instead of
continuing with the next entry in PATH.  This seems more secure.
2020-05-19 19:20:26 +02:00
Nicolás Ojeda Bär d18d552fdc
Add Unix.is_inet6_addr (#9575)
Closes: #4535
Closes: #6105
2020-05-18 09:32:00 +02:00
Xavier Leroy c17f6c2956
Protect against bad rounding of mtime / atime / ctime stats (#9505)
Some file systems maintain time stamps with sub-second resolution, up
to nanosecond resolution.  When converting from a "(seconds, nanoseconds)"
timestamp to a floating-point timestamp, rounding to nearest can produce
"seconds + 1" as a result, i.e. the integer part of the FP timestamp
is not equal to "seconds".  As described in #9490, this is a problem
in some cases.

This commit implements a more careful conversion of "(seconds,
nanoseconds)" pairs to FP timestamps so that the integer part of the
FP result is always "seconds".

Both the otherlibs/unix and the otherlibs/win32unix implementations are affected
and corrected.

Closes: #9490
2020-05-13 18:43:46 +02:00
David Allsopp ac2a9dd188 Cease committing C dependendency information
When building for the first time, the only requirement is that generated
header files have been built (jumptbl.h, version.h and opnames.h).
Detailed dependency information is only required when headers have been
edited.

COMPUTE_DEPS in Makefile.config controls whether C dependency
information should be generated on a per-file basis. This variable is
controlled by a new --disable-dependency-generation in configure which
is enabled for Git checkouts and disabled for tarballs (i.e. releases).

The Microsoft C compiler (cl) cannot generate dependencies in a
consistent way which we can consume, so for a Git checkout configure
searches for an additional C compiler in order to compute dependencies.
This is obviously not required for a user-build.

As a result, the MSVC port can now safely run make alldepend, since only
OCaml dependency information is committed to the repo after this change.

CI does not need to waste time testing the dependency information,
because it only tests a single build. A single Travis job has been added
which tests the build system code to generate the dependency information
(and provides a single `make -j` run in CI, although Inria's CI also
tests parallel building continuously).
2020-04-17 14:11:22 +01:00
Enguerrand Decorne b7f0494df5 Rewrite the instrumented runtime to store traces in the CTF format.
The instrumentation code in the instrumented runtime was replaced
with new APIs to gather runtime statistics and output them in a new format
(Common Trace Format).
This commit also exposes new functions in the Gc module to pause or resume
instrumentation during a program execution (Gc.eventlog_pause and
Gc.eventlog_resume).
2020-04-30 10:32:01 +02:00
Damien Doligez e92d13c986 last commit before branching 4.11 2020-04-22 17:28:08 +02:00
zapashcanon 058e089a21
fix msg_flag type doc comment 2020-03-19 22:15:52 +01:00
zapashcanon 16e40ae01f
fix sockaddr type doc comment 2020-03-19 22:14:41 +01:00
Gabriel Scherer 4e6e912328
Merge pull request #9203 from xavierleroy/portability-fixes
Minor portability and standard-conformance issues in the runtime system
2019-12-23 12:02:48 +01:00
Xavier Leroy 0e1c30e042 Do not use h_addr to access struct hostent
A long time ago, an Internet hostname had only one IP address and
struct hostent had a member named h_addr pointing to one IP address.

Shortly after, the struct member h_addr became h_addr_list,
a NULL-terminated array of pointers to IP addresses, and many
standard headers contained `#define h_addr h_addr_list[0]`
for backward compatibility purposes.

In 2019, everyone has h_addr_list, and the #define h_addr is not mandated
by POSIX nor the Single Unix Specification.  Hence, in strict
standard-conformance mode, h_addr is not there.

This commit makes sure h_addr_list is used everywhere and unconditionally.
2019-12-22 17:43:33 +01:00
Jacques-Henri Jourdan 7dbbfce890 New ephemeron-free API for Memprof.
The user can register several callbacks, which are called for various
events during the block's lifetime. We need to maintain a data
structure for tracked blocks in the runtime. When using threads,
callbacks can be called concurrently in a reentrant way, so the
functions manipulating this data structure need to be reentrant.
2019-12-21 10:21:48 +01:00
Brian Wignall 2cd1db7ae9 Fix some spelling typos 2019-11-29 10:17:38 -05:00
Florian Angeletti cf5cca65a1 make alldepend 2019-10-18 18:24:08 +02:00
Jacques-Henri Jourdan c0dbbfdd71 Memprof: stop using C global roots, and use our own root system.
Registering and unregistering global C roots was time consuming.
2019-08-27 19:05:03 +02:00
Xavier Leroy a8daa89500 Add Filename.quote_command function (#1492)
MPR#7672: add a Filename.quote_command function

This function takes care of quoting the command and its arguments
so that they are correctly parsed by the system shell
(/bin/sh for Unix, cmd.exe for Win32).

Redirections for std input (< file) and std output (> file) and
std error (2> file) can also be specified as optional arguments.
A 2>&1 redirection is used if stdout and stderr are redirected to the
same file.

The result is a string that can be passed directly to Sys.command or
to the Unix functions that expect shell command lines.
2019-06-25 14:21:58 +02:00
Jacques-Henri Jourdan 052a950dea Statistical memory profiling of blocks allocated in the major heap. 2019-05-09 16:40:45 +02:00
Nicolás Ojeda Bär ea6573fda1
Implement Unix.truncate and Unix.ftruncate on Windows (#2023) 2019-05-05 09:57:48 +02:00
Damien Doligez 822557f278 fix buggy assertion 2019-04-01 16:22:48 +02:00