caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] Re: portable truncate
Date: Sat, 27 Jul 2013 07:05:49 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9CCA8C0C9@Remus.metastack.local> (raw)
In-Reply-To: <CAE1DttBWpX0ixjPXSFpkJqr8W+zxU1tedGSOJ=i2=z++SvjKVA@mail.gmail.com>

Florent Monnier wrote:
 
> 2013/07/26, Florent Monnier wrote:
> [...]
> > 1) I thought that the module Unix only contains portable things for
> > Windows, so it's not true?
> 
> This page indeed gives a list of unimplemented functions at the end:
> [1] http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual036.html
> 
> but it depends which ocaml variants is used.
> 
> This page above says:
> "The Cygwin port of OCaml fully implements all functions from the Unix
> module.
>  The native Win32 ports implement a subset of them."
> 
> So this page talks about 2 ocaml variants:
> - Cygwin ocaml,
> - and native Win32 ocaml.
> 
> This other page, gives informations for 3 ocanl variants:
> [2] http://caml.inria.fr/ocaml/portability.en.html

That page is slightly out of date as it doesn't refer to the 64 bit MinGW port :o)

> which are
> - native Microsoft
> - native MinGW
> - and Cygwin
> 
> I should probably understand frm this that both "native Microsoft" and
> "native MinGW" are native Win32 ocaml.

Correct

> I made the error to think that native Win32 port only refers to ocaml
> compiled with MSVC, while it seems that it also include protz's ocaml that
> is a MinGW variant.

Native in this context means "not Cygwin", indeed.

> I'm still not sure though that compiling with MSVC or MinGW can be
> considered equivalent.
> And actually they seem not considering this page:
> [2] http://caml.inria.fr/ocaml/portability.en.html

I've done some limited Googling, so may be barking up the wrong tree. I believe that in Microsoft C world, the function ftrunctate is called _chsize (http://msdn.microsoft.com/en-gb/library/aa246710(v=vs.60).aspx) in io.h and that MinGW defined a compatible ftruncate in unistd.h a long time ago. I expect that the reason for not implementing ftruncate in win32unix originally was either that whoever wrote it didn't know about _chsize or at the time it didn't work properly (e.g. on Windows 9x). The Windows API functions SetEndOfFile/SetFileValidData (which actually implement this) look comparatively new (Windows XP+), although Microsoft annoyingly altered the "Minimum supported" sections of MSDN a while ago so "minimum" no longer means "introduced".

Altering unix is relatively easy if you've compiled your own OCaml - edit files in otherlibs/win32unix and use make -f Makefile.nt [opt] to recompile. You can simply copy the replacement files into your ocaml lib directory while experimenting. Patches adding missing functionality to win32unix tend to be accepted quite quickly in my experience...


David


  reply	other threads:[~2013-07-27  7:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 10:35 [Caml-list] " Florent Monnier
2013-07-26 10:46 ` Mihamina Rakotomandimby
2013-07-26 10:48   ` Török Edwin
2013-07-26 10:52 ` Daniel Bünzli
2013-07-26 12:02 ` [Caml-list] " Florent Monnier
2013-07-27  7:05   ` David Allsopp [this message]
2013-07-27  8:54     ` Florent Monnier
2013-07-27  8:38   ` Adrien Nader
2013-07-27  9:05     ` Adrien Nader
2013-07-27 14:11     ` Florent Monnier
2013-07-27 14:23       ` Adrien Nader
2013-07-27 15:34         ` Florent Monnier
2013-07-27 15:43           ` Adrien Nader
2013-07-27 19:45             ` Florent Monnier
2013-07-27 19:53               ` Adrien Nader
2013-07-27 20:03                 ` Török Edwin
     [not found] ` <20130727181711.65d8456f@kiwi.local.tld>
2013-07-27 14:41   ` [Caml-list] " Florent Monnier
2013-07-27 15:26     ` Adrien Nader
2013-07-27 15:40       ` Florent Monnier

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=E51C5B015DBD1348A1D85763337FB6D9CCA8C0C9@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    /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).