From: Stéphane Glondu Date: Fri, 28 Jun 2024 05:53:21 +0000 (+0200) Subject: Avoid atomic 64-bit load on Debian armel X-Git-Tag: archive/raspbian/5.2.0-2+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=02fe451b3256f7d4cc4861ee2aa6bb6bbe4c1694;p=ocaml.git Avoid atomic 64-bit load on Debian armel Bug: https://github.com/ocaml/ocaml/issues/13234 Forwarded: https://github.com/ocaml/ocaml/pull/13267 Gbp-Pq: Name 0010-Avoid-atomic-64-bit-load-on-Debian-armel.patch --- diff --git a/otherlibs/runtime_events/runtime_events_consumer.c b/otherlibs/runtime_events/runtime_events_consumer.c index 9df4eb5a..1771df70 100644 --- a/otherlibs/runtime_events/runtime_events_consumer.c +++ b/otherlibs/runtime_events/runtime_events_consumer.c @@ -189,7 +189,16 @@ caml_runtime_events_create_cursor(const char_os* runtime_events_path, int pid, cursor->ring_file_size_bytes = GetFileSize(cursor->ring_file_handle, NULL); #else - ring_fd = open(runtime_events_loc, O_RDONLY, 0); +#if defined(__ARM_ARCH) && __ARM_ARCH <= 5 + /* Atomic 64-bit load requires RW memory on Debian armel. See: + https://github.com/ocaml/ocaml/issues/13234 */ + const int open_flags = O_RDWR; + const int mmap_prot = PROT_READ | PROT_WRITE; +#else + const int open_flags = O_RDONLY; + const int mmap_prot = PROT_READ; +#endif + ring_fd = open(runtime_events_loc, open_flags, 0); if( ring_fd == -1 ) { caml_stat_free(cursor); @@ -210,7 +219,7 @@ caml_runtime_events_create_cursor(const char_os* runtime_events_path, int pid, /* This cast is necessary for compatibility with Illumos' non-POSIX mmap/munmap */ cursor->metadata = (struct runtime_events_metadata_header *) - mmap(NULL, cursor->ring_file_size_bytes, PROT_READ, + mmap(NULL, cursor->ring_file_size_bytes, mmap_prot, MAP_SHARED, ring_fd, 0); if( cursor->metadata == MAP_FAILED ) {