Skip to content

Commit

Permalink
Add Windows compatibility definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Jun 20, 2022
1 parent 94ab50d commit de4a88a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Changes
Expand Up @@ -544,7 +544,8 @@ OCaml 4.14.0
WSADuplicateSocket on sockets instead of DuplicateHandle.
(Antonin Décimo, review by Xavier Leroy and Nicolás Ojeda Bär)

* #10926: Ensure all C functions in the Unix library are prefixed with `caml_`.
* #10926, #11336: Ensure all C functions in the Unix library are prefixed with
`caml_`.
(David Allsopp, review by Kate Deplaix, Damien Doligez and Xavier Leroy)

- #10951: Introduce the Thread.Exit exception as an alternative way to
Expand Down
15 changes: 13 additions & 2 deletions otherlibs/unix/unixsupport.h
Expand Up @@ -115,6 +115,14 @@ extern void caml_unix_clear_cloexec(int fd, char * cmdname, value arg);

/* Compatibility definitions for the pre-5.0 names of these functions */
#ifndef CAML_BUILDING_UNIX
#ifdef _WIN32
#define win_alloc_handle caml_win32_alloc_handle
#define win_alloc_socket caml_win32_alloc_socket
#define win_CRT_fd_of_filedescr caml_win32_CRT_fd_of_filedescr
#define win32_socket caml_win32_socket
#define win32_maperr caml_win32_maperr
#endif /* _WIN32 */

#define unix_error_of_code caml_unix_error_of_code
#define code_of_unix_error caml_unix_code_of_unix_error

Expand All @@ -127,10 +135,13 @@ extern void caml_unix_clear_cloexec(int fd, char * cmdname, value arg);
#define unix_cloexec_default caml_unix_cloexec_default
#define unix_cloexec_p caml_unix_cloexec_p

#ifndef _WIN32
#ifdef _WIN32
#define win_set_inherit caml_win32_set_inherit
#define win_set_cloexec caml_win32_set_cloexec
#else
#define unix_set_cloexec caml_unix_set_cloexec
#define unix_clear_cloexec caml_unix_clear_cloexec
#endif /* ! _WIN32 */
#endif /* _WIN32 */
#endif /* CAML_BUILDING_UNIX */

#ifdef __cplusplus
Expand Down

0 comments on commit de4a88a

Please sign in to comment.