Skip to content

Commit

Permalink
ocaml-core_unix: use legacysupport correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 committed Jul 6, 2024
1 parent cb2d20c commit 2394f76
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 50 deletions.
7 changes: 6 additions & 1 deletion ocaml/ocaml-core_unix/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ depends_lib-append port:ocaml-core \
port:ocaml-spawn \
port:ocaml-timezone

# FIXME: review the following.
patch.pre_args-replace -p0 -p1
if {${os.platform} eq "darwin" && ${os.major} < 16} {
patchfiles 0001-time_stamp_counter_stubs.c-add-legacysupport-header-.patch \
0002-core_unix_stubs.c-add-legacysupport-header-for-strnl.patch

post-patch {
reinplace "s|@PREFIX@|${prefix}|g" \
${worksrcpath}/core_unix/src/dune \
${worksrcpath}/time_stamp_counter/src/dune
}
}

ocaml.build_type dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,15 @@ Date: Mon, 21 Nov 2022 01:08:19 +0800
Subject: [PATCH 1/2] time_stamp_counter_stubs.c: add legacysupport header for
clock_gettime

---
time_stamp_counter/src/time_stamp_counter_stubs.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/time_stamp_counter/src/time_stamp_counter_stubs.c b/time_stamp_counter/src/time_stamp_counter_stubs.c
index 5d5ec32..1cf0ee1 100644
--- a/time_stamp_counter/src/time_stamp_counter_stubs.c
+++ b/time_stamp_counter/src/time_stamp_counter_stubs.c
@@ -17,6 +17,11 @@
#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
+
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 101100
+#include <LegacySupport/time.h>
+#endif
#endif

#include "ocaml_utils.h"

--- a/time_stamp_counter/src/dune 2023-04-25 21:12:26.000000000 +0800
+++ b/time_stamp_counter/src/dune 2023-10-25 20:10:11.000000000 +0800
+++ b/time_stamp_counter/src/dune 2024-07-06 22:52:24.000000000 +0800
@@ -1,7 +1,7 @@
(library (name time_stamp_counter) (public_name core_unix.time_stamp_counter)
(preprocess (pps ppx_jane ppx_optcomp)) (preprocessor_deps config.h)
- (c_names time_stamp_counter_stubs)
+ (c_names time_stamp_counter_stubs) (c_library_flags -lMacportsLegacySupport)
(libraries core core_unix ocaml_intrinsics))
- (libraries core core_unix ocaml_intrinsics))
+ (c_names time_stamp_counter_stubs) (c_flags -I@PREFIX@/include/LegacySupport)
+ (c_library_flags -lMacportsLegacySupport) (libraries core core_unix ocaml_intrinsics))

(rule (targets config.h) (deps)
- (action (bash "cp %{lib:jst-config:config.h} %{targets}")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,15 @@ From: barracuda156 <[email protected]>
Date: Mon, 21 Nov 2022 01:13:02 +0800
Subject: [PATCH 2/2] core_unix_stubs.c: add legacysupport header for strnlen

---
core_unix/src/core_unix_stubs.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/core_unix/src/core_unix_stubs.c b/core_unix/src/core_unix_stubs.c
index 4beba77..20976d2 100644
--- a/core_unix/src/core_unix_stubs.c
+++ b/core_unix/src/core_unix_stubs.c
@@ -64,6 +64,13 @@
#include <wordexp.h>
#endif

+#if defined(__APPLE__)
+#include <AvailabilityMacros.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1060
+#include <LegacySupport/string.h>
+#endif
+#endif
+
CAMLprim value core_unix_error_of_code(value code)
{
return unix_error_of_code(Int_val(code));

--- a/core_unix/src/dune 2023-04-25 21:12:26.000000000 +0800
+++ b/core_unix/src/dune 2023-10-25 20:09:45.000000000 +0800
+++ b/core_unix/src/dune 2024-07-06 22:50:49.000000000 +0800
@@ -1,10 +1,10 @@
(library (name core_unix) (public_name core_unix)
(libraries core error_checking_mutex core_kernel.flags sexplib.unix
- signal_unix spawn)
- (c_flags (:standard -D_LARGEFILE64_SOURCE) ())
+ signal_unix spawn) (c_library_flags -lMacportsLegacySupport)
(c_flags (:standard -D_LARGEFILE64_SOURCE) ())
+ (c_flags (:standard -D_LARGEFILE64_SOURCE) -I@PREFIX@/include/LegacySupport ())
(c_names nss_stubs timespec core_unix_stubs core_unix_time_stubs)
(preprocess (pps ppx_jane ppx_optcomp)) (preprocessor_deps config.h))

Expand Down

0 comments on commit 2394f76

Please sign in to comment.