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 2EE5D8179A for ; Sat, 27 Jul 2013 10:54:58 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of monnier.florent@gmail.com) identity=pra; client-ip=74.125.82.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of monnier.florent@gmail.com designates 74.125.82.51 as permitted sender) identity=mailfrom; client-ip=74.125.82.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="monnier.florent@gmail.com"; 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@mail-wg0-f51.google.com) identity=helo; client-ip=74.125.82.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="monnier.florent@gmail.com"; x-sender="postmaster@mail-wg0-f51.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuoBALqK81FKfVIzk2dsb2JhbABagztQvVyBDggWDgEBAQEHCwsJFAQkgiQBAQQBQAEbDw4BAwELBgULAzgiAREBBQEOAQ0GiBABAwkGDJsujE+Cf4QrChknDWSHdAEFDI4yCoE1B4MWbwOXX4Epjj4WKYQ8OoEsCRc X-IPAS-Result: AuoBALqK81FKfVIzk2dsb2JhbABagztQvVyBDggWDgEBAQEHCwsJFAQkgiQBAQQBQAEbDw4BAwELBgULAzgiAREBBQEOAQ0GiBABAwkGDJsujE+Cf4QrChknDWSHdAEFDI4yCoE1B4MWbwOXX4Epjj4WKYQ8OoEsCRc X-IronPort-AV: E=Sophos;i="4.89,756,1367964000"; d="scan'208";a="27506445" Received: from mail-wg0-f51.google.com ([74.125.82.51]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Jul 2013 10:54:43 +0200 Received: by mail-wg0-f51.google.com with SMTP id e12so1562851wgh.18 for ; Sat, 27 Jul 2013 01:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=JbIW3pAWNA87o/LUB1mB2N9BlT1axk+SqywBzUJnqRs=; b=EiS0o33EfbbqWKr5qLy8h8NxwLz1VAyqFC7voC/7ZBBchZsAbl00brnrnFUDauFcFo wpi7IGBiK3CQWZ290kz3Ecw89aJ65BzJenS068vUkZhl/EykTuEKtURQJUe0i3UXmL9R dnn+ir+SPx4hvhmHRNc0Q4sJHV2uBLwtrQUft7SvGX2HE/W3WDB23pYw9zqFLvPCDzAc QjYN1mvwgAI5UdfHek5WB/07NctThSS/PmjdPiSu4hQE5iX9SITCtKJG0FsMPKbQFQwL R2FYkjm0foMWBJqLkonS85jKRp1WTfAoOx45JTK2/wzWSOE8N9c/+zd7HeqVYWa2MD2H +fdg== MIME-Version: 1.0 X-Received: by 10.180.73.68 with SMTP id j4mr1527058wiv.10.1374915283336; Sat, 27 Jul 2013 01:54:43 -0700 (PDT) Received: by 10.194.80.36 with HTTP; Sat, 27 Jul 2013 01:54:43 -0700 (PDT) In-Reply-To: References: Date: Sat, 27 Jul 2013 10:54:43 +0200 Message-ID: From: Florent Monnier To: David Allsopp Cc: "caml-list@inria.fr" Content-Type: text/plain; charset=ISO-8859-1 X-Validation-by: monnier.florent@gmail.com Subject: Re: [Caml-list] Re: portable truncate Hi David, 2013/07/27, David Allsopp wrote: [...] >> 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) We are then in a RTFM vs. WTFM situation :o) We may then take this opportunity to import an up to date information on ocaml.org >> 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. Except that MinGW comes with Cygwin, and so is also automatically updated from its package management. As a result it may not be that obvious for beginners and non-experts if it's not written and explained explicitly. Also on ocaml.org this ocaml variant is called: "Cygwin-based native Win32 port" Which also doesn't help to know if mingw variant should be considered as a cygwin variant or a win32 variant. > 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 did similar searches yesterday and already tried _chsize in MyUnix like this: #define ftruncate _chsize But it does not work. The file is not truncated, and _chsize returns -1 which is the error code. > 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". Anyway, MinGW has to use the OS, but is not a product from MS. I believe that we can do a good use of this "feature". > 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... I've made an attempt to compile the ocaml sources under Cygwin using the MinGW toolchain, but I didn't succeeded. I can still alter the unix module as I have shown in the previous email with the module called MyUnix. But if I want to share my code this won't help me much, I should bring the fix upstream. In case I can find a fix (I have good hope, but I'm not sure yet), do you think I should use mantis, or just send a patch to protz ? -- Regards