Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all renamed symbols to unixsupport.h #11336

Merged
merged 4 commits into from Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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 @@ -75,20 +75,13 @@ extern SOCKET caml_win32_socket(int domain, int type, int protocol,
#define NO_CRT_FD (-1)

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 @@ -97,12 +90,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 @@ -123,7 +110,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The win32_maperr macri is also defined at line 78.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch - in fact, that macro not being guarded on L78 in the same way as the others means that there was a renaming missing in socket_win32.c (presumably a rebase artefact during the original PR)

#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