Skip to content

Commit

Permalink
Merge pull request #11336 from dra27/unix-header-compat
Browse files Browse the repository at this point in the history
Add all renamed symbols to unixsupport.h

(cherry picked from commit 1916810)
  • Loading branch information
dra27 committed Jul 5, 2022
1 parent c6e8962 commit 4273a04
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
3 changes: 2 additions & 1 deletion Changes
Expand Up @@ -551,7 +551,8 @@ OCaml 4.14.0 (28 March 2022)
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
2 changes: 1 addition & 1 deletion otherlibs/unix/socket_win32.c
Expand Up @@ -57,7 +57,7 @@ SOCKET caml_win32_socket(int domain, int type, int protocol,
return s;

err:
win32_maperr(WSAGetLastError());
caml_win32_maperr(WSAGetLastError());
return INVALID_SOCKET;
}

Expand Down
45 changes: 31 additions & 14 deletions otherlibs/unix/unixsupport.h
Expand Up @@ -87,20 +87,13 @@ extern SOCKET caml_win32_socket(int domain, int type, int protocol,
BOOL inherit);

extern void caml_win32_maperr(DWORD errcode);
#define win32_maperr caml_win32_maperr
#endif /* _WIN32 */

#define Nothing ((value) 0)

extern value caml_unix_error_of_code (int errcode);
extern int caml_unix_code_of_unix_error (value error);

/* Compatibility definitions for the pre-5.0 names of these functions */
#ifndef CAML_BUILDING_UNIX
#define unix_error_of_code caml_unix_error_of_code
#define code_of_unix_error caml_unix_code_of_unix_error
#endif /* CAML_BUILDING_UNIX */

CAMLnoreturn_start
extern void caml_unix_error (int errcode, const char * cmdname, value arg)
CAMLnoreturn_end;
Expand All @@ -109,12 +102,6 @@ CAMLnoreturn_start
extern void caml_uerror (const char * cmdname, value arg)
CAMLnoreturn_end;

/* Compatibility definitions for the pre-5.0 names of these functions */
#ifndef CAML_BUILDING_UNIX
#define uerror caml_uerror
#define unix_error caml_unix_error
#endif /* CAML_BUILDING_UNIX */

extern void caml_unix_check_path(value path, const char * cmdname);

#define UNIX_BUFFER_SIZE 65536
Expand All @@ -135,7 +122,37 @@ extern int caml_win32_set_inherit(HANDLE fd, BOOL inherit);
#else
extern void caml_unix_set_cloexec(int fd, char * cmdname, value arg);
extern void caml_unix_clear_cloexec(int fd, char * cmdname, value arg);
#endif
#endif /* _WIN32 */

/* 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_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

#define uerror caml_uerror
#define unix_error caml_unix_error

#define cstringvect caml_unix_cstringvect
#define cstringvect_free caml_unix_cstringvect_free

#define unix_cloexec_default caml_unix_cloexec_default
#define unix_cloexec_p caml_unix_cloexec_p

#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 /* CAML_BUILDING_UNIX */

#ifdef __cplusplus
}
Expand Down

0 comments on commit 4273a04

Please sign in to comment.