caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Adrien Nader <adrien@notk.org>
To: Florent Monnier <monnier.florent@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: portable truncate
Date: Sat, 27 Jul 2013 16:23:20 +0200	[thread overview]
Message-ID: <20130727142320.GA26244@notk.org> (raw)
In-Reply-To: <CAE1DttDN2F2Xea0Rw3fTnJ6YnWypXkOfYWhq9eq3Qv0zU2Vz5Q@mail.gmail.com>

On Sat, Jul 27, 2013, Florent Monnier wrote:
> 2013/07/27, Adrien Nader wrote:
> > On Fri, Jul 26, 2013, Florent Monnier wrote:
> [...]
> >> 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
> >
> > The compiler differs but otherwise the differences are small.
> 
> I have already understood that MinGW will produce a resulting binary
> that equivalently makes use of MS' OS libs. But as far as I have
> understood it also provide an additional layer which goal is to make
> easier to compile something that comes from the Unix world. As a
> result I expected to get a fully functional ocaml Unix module.

It's a very minimal layer. Microsoft CRT cannot be used for things like
printing properly long doubles or similar things. Its math
implementation is also lacking some C99 support (plus it's not that
fast). That's where the mingw CRT will provide you more things. For
others, it's the Microsoft one.

> >                                                               The libc
> > that is used on Windows is Microsoft's (actually called CRT); mingw*
> > provide some additions to that and apparently, ftruncate is provided.
> 
> - truncate()  DOES work on my computer
> - ftruncate() / _chsize()  DOESN'T

That's surprising and you should really try to see which error you get
throw errno. You can also try a tool like FileMonitor (or whatever it's
called nowadays) to see how it fails.

> > In otherlibs/win32unix/unix.ml, you have:
> >   let ftruncate fd len = invalid_arg "Unix.ftruncate not implemented"
> 
> I see,
> I expected that a mingw variant would use "otherlibs/unix/"
> So it seems I was wrong again on that point too.
> 
> > And in unistd.h, you have:
> [...]
> >   __CRT_INLINE int ftruncate(int __fd, off32_t __length)
> >   {
> >     return _chsize (__fd, __length);
> >   }
> [...]
> > Considering this, you should probably make a patch to add a file
> > win32unix/ftruncate.c which use the implementation above and replace the
> > implementation of ftruncate* in win32unix/unix.ml.
> 
> Don't you think that "win32unix/" should remain as is for the MS
> compiler, and that mingw variant should just switch to
> "otherlibs/unix/" ?

No. Mingw is not posix. Just think about fork(): it cannot exist on
Windows currently without resorting to the big layer that Cygwin
provides (along with its performance hit).

Btw, you can have a look at this entry in the Cygwin FAQ to better
understand what "cygwin" means:
  http://cygwin.com/faq.html#faq.api.fork

You can also take a look at the C files in otherlibs/win32unix: there's
quite a lot of work that is done to provide a matching API.

> > I don't know what is the purpose of the __CRT_NO_INLINE define; I've
> > already asked and will propagate the answer when I get it. It would be
> > good to have truncate*() too.
> >
> > (and submit it to the bug tracker :-) )
> 
> I do have only one test machine with Windows Seven Starter to make
> tests. And I do not have the MS' compiler.
> 
> Are there other people arround living in Rennes (the town where I
> live) that would accept to provide me access to other test machines
> under MS/Windows ? Like for example Windows 8 ?
> (So that I could do more serious tests.)

You can use the eval editions that are available on Microsoft's website.
They're time-limited (one month for some) and after that they will
shutdown after 1 hour but that's not an issue for testing, especially
for VMs. There are also ways to extend the original one-month period
that are documented on MSDN.

(you can also reinstall: qemu's cache=unsafe disk parameter makes
installation insanely fast; yypkg's mingw-builds should also make
installation of a build environment much faster)

-- 
Adrien Nader

  reply	other threads:[~2013-07-27 14:23 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
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 [this message]
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=20130727142320.GA26244@notk.org \
    --to=adrien@notk.org \
    --cc=caml-list@inria.fr \
    --cc=monnier.florent@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;
as well as URLs for NNTP newsgroup(s).