Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rich@annexia.org>
To: Jeremy Yallop <yallop@gmail.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] OCaml max_int and min_int in C
Date: Mon, 18 Jul 2016 10:04:59 +0100	[thread overview]
Message-ID: <20160718090459.GD27249@annexia.org> (raw)
In-Reply-To: <CAAxsn=ELkz5r6EPfKFfZVxi2PX40o9NXMy8bZM6FOaAJQQfDkQ@mail.gmail.com>

On Mon, Jul 18, 2016 at 09:59:40AM +0100, Jeremy Yallop wrote:
> On 18 July 2016 at 09:43, Richard W.M. Jones <rich@annexia.org> wrote:
> > We need to check that an integer being returned from some C bindings
> > isn't larger or smaller than Pervasives.max_int / min_int.  Are there
> > C macros or constants containing these bounds?  Obviously we can
> > define our own but it seems better to use ones from OCaml if they
> > exist.
> 
> There are Max_long and Min_long:
> 
>    https://github.com/ocaml/ocaml/blob/ebbe205d/byterun/caml/mlvalues.h#L75-L76
> 
> Here's an example of Max_long being used to check that the return
> value of lseek fits in an OCaml int:
> 
>    https://github.com/ocaml/ocaml/blob/ebbe205d/otherlibs/unix/lseek.c#L46-L50

So there is!  I was grepping for MAX & INT, not Max and long :-/

Thanks,

Rich.

      reply	other threads:[~2016-07-18  9:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18  8:43 Richard W.M. Jones
2016-07-18  8:59 ` Jeremy Yallop
2016-07-18  9:04   ` Richard W.M. Jones [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160718090459.GD27249@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    --cc=yallop@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox