caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Romain Beauxis <romain.beauxis@gmail.com>
To: David Allsopp <dra-news@metastack.com>
Cc: OCaml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Unix.file_descr and unixsupport.h
Date: Tue, 2 Aug 2011 11:58:26 -0500	[thread overview]
Message-ID: <CABWZ6ORyKUMRaU18WsFGC=UejP-5uh3d6BK72hChR7Psu2wtNA@mail.gmail.com> (raw)
In-Reply-To: <000001cc5134$d990da80$8cb28f80$@metastack.com>

Hi!

2011/8/2 David Allsopp <dra-news@metastack.com>:
> OK, some further digging into my problem with ocaml-ssl eventually revealed
> that the problem is the way it handles Unix.file_descr. On Unix, this is
> just an [int] and so ocaml-ssl's stubs treat it as such. Under Windows, it's
> a custom block as file_descr is a C struct containing a lot of information.
>
> unixsupport.h is installed with the other caml headers, although it's not
> referenced by any of them and as far as I can tell isn't referred to in the
> manual. For Unix implementations of OCaml, it's a pretty dull file but the
> Windows version contains a definition for Socket_val which will extract the
> underlying OS handle for a socket from a file_descr.
>
> I've therefore tried inserting #include <caml/unixsupport.h> and changing
> the offending portion of code in ocaml-ssl to this:
>
> #ifdef Socket_val
>  SOCKET socket = Socket_val(socket_);
> #else
>  int socket = Int_val(socket_);
> #endif
>
> But my questions - is this "safe"? Is it likely to continue to work? If not,
> is there - or could there be - some kind of official way to extract file
> descriptors which aims to work in a cross-platform manner?

I think the safest for now is to condition your macros on the OS and
only address WIN32/Unix cases.

I have submitted a bug upstream about this:
  http://caml.inria.fr/mantis/view.php?id=5249

Romain


      reply	other threads:[~2011-08-02 16:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-02 16:54 David Allsopp
2011-08-02 16:58 ` Romain Beauxis [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='CABWZ6ORyKUMRaU18WsFGC=UejP-5uh3d6BK72hChR7Psu2wtNA@mail.gmail.com' \
    --to=romain.beauxis@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.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;
as well as URLs for NNTP newsgroup(s).