Re: core on OpenBSD

44 views
Skip to first unread message

Yaron Minsky

unread,
Sep 23, 2014, 12:42:39 PM9/23/14
to Christopher Zimmermann, ocaml...@googlegroups.com, Jeremie Dimino
Redirecting to the ocaml-core mailing list, and looping in Jeremie,
who work on the public release.

y

On Tue, Sep 23, 2014 at 12:16 PM, Christopher Zimmermann
<chris...@gmerlin.de> wrote:
> Hi,
>
> I'm porting core and async to OpenBSD. While doing so I noticed a
> preprocessor warning about the time functions not being available.
> I have no idea where the JSC_POSIX_TIMERS is supposed to come from, but
> OpenBSD does have those functions. Therefore I just addad
> "|| defined(__OpenBSD__)".
> The next part is for avoiding an annoying linker warning on OpenBSD
> suggesting to use stlcpy. Since the same functionality can be
> implemented by strncpy, I did exactly that. Using strlcpy would
> probably break some other unices.
>
>
> Christopher
>
>
> --- lib/unix_stubs.c.orig Tue Aug 12 14:56:26 2014
> +++ lib/unix_stubs.c Tue Sep 23 18:11:00 2014
> @@ -884,7 +884,7 @@ CAMLprim value unix_pselect_stub(
>
> /* Clock functions */
>
> -#ifdef JSC_POSIX_TIMERS
> +#if defined(JSC_POSIX_TIMERS) || defined(__OpenBSD__)
> #define clockid_t_val(v_cl) ((clockid_t) Nativeint_val(v_cl))
>
> CAMLprim value unix_clock_gettime(value v_cl)
> @@ -1038,15 +1038,13 @@ CAMLprim value unix_setrlimit(value v_resource, value
> static struct ifreq build_ifaddr_request(const char *interface)
> {
> struct ifreq ifr;
> + memset(&ifr, 0, sizeof(ifr));
> + ifr.ifr_addr.sa_family = AF_INET;
> + strncpy(ifr.ifr_name, interface, sizeof(ifr.ifr_name));
>
> assert(sizeof(ifr.ifr_name) == IFNAMSIZ);
> - if (strlen(interface) > IFNAMSIZ-1)
> + if (ifr.ifr_name[IFNAMSIZ-1] != '\0')
> caml_failwith("build_ifaddr_request: interface name string too long");
> -
> - memset(&ifr, 0, sizeof(ifr));
> - ifr.ifr_addr.sa_family = AF_INET;
> - /* No overrun possible because ifr.ifr_name is checked above */
> - strcpy(ifr.ifr_name, interface);
>
> return ifr;
> }
>
> --
> http://gmerlin.de
> OpenPGP: http://gmerlin.de/christopher.pub
> F190 D013 8F01 AA53 E080 3F3C F17F B0A1 D44E 4FEE

Jeremie Dimino

unread,
Sep 24, 2014, 9:12:53 AM9/24/14
to Yaron Minsky, Christopher Zimmermann, ocaml...@googlegroups.com
Hi Christopher,

On Tue, Sep 23, 2014 at 5:42 PM, Yaron Minsky <ymi...@janestreet.com> wrote:
> I'm porting core and async to OpenBSD. While doing so I noticed a
> preprocessor warning about the time functions not being available.
> I have no idea where the JSC_POSIX_TIMERS is supposed to come from, but
> OpenBSD does have those functions. Therefore I just addad
> "|| defined(__OpenBSD__)".

JSC_POSIX_TIMERS comes from lib/core_config.h which is generated by ./configure. The macro is set when --enable-posix-timers is passed to ./configure, the default state being detected by the script config/detect.sh.
 
Could you look at config/detect.sh script and see if you can come up with a patch for OpenBSD?

> The next part is for avoiding an annoying linker warning on OpenBSD
> suggesting to use stlcpy. Since the same functionality can be
> implemented by strncpy, I did exactly that. Using strlcpy would
> probably break some other unices.

That seems good to me.
 
--
Jeremie
Reply all
Reply to author
Forward
0 new messages