From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 45F9181799 for ; Sat, 27 Jul 2013 16:23:21 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of adrien@notk.org) identity=pra; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="adrien@notk.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of adrien@notk.org designates 91.121.71.147 as permitted sender) identity=mailfrom; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="adrien@notk.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@nautica.notk.org) identity=helo; client-ip=91.121.71.147; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="adrien@notk.org"; x-sender="postmaster@nautica.notk.org"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AisDAA/X81FbeUeTgWdsb2JhbABbgztKgxW6ToEWFg4BARYmKIIkAQEEASNWEAsYAgIFEw4CAg8FGB0BE4gdCgMFpxqRG4EojSCBNQeCYzNvA5deAYEpkzk6gSw X-IPAS-Result: AisDAA/X81FbeUeTgWdsb2JhbABbgztKgxW6ToEWFg4BARYmKIIkAQEEASNWEAsYAgIFEw4CAg8FGB0BE4gdCgMFpxqRG4EojSCBNQeCYzNvA5deAYEpkzk6gSw X-IronPort-AV: E=Sophos;i="4.89,757,1367964000"; d="scan'208";a="27540592" Received: from nautica.notk.org ([91.121.71.147]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 27 Jul 2013 16:23:20 +0200 Received: by nautica.notk.org (Postfix, from userid 1003) id 8DF7DC01A; Sat, 27 Jul 2013 16:23:20 +0200 (CEST) Date: Sat, 27 Jul 2013 16:23:20 +0200 From: Adrien Nader To: Florent Monnier Cc: caml-list@inria.fr Message-ID: <20130727142320.GA26244@notk.org> References: <20130727083844.GA17235@notk.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Re: [Caml-list] Re: portable truncate 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