caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Florent Monnier <monnier.florent@gmail.com>
To: David Allsopp <dra-news@metastack.com>
Cc: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Re: portable truncate
Date: Sat, 27 Jul 2013 10:54:43 +0200	[thread overview]
Message-ID: <CAE1DttAXkVLFaO-x1WXtp=Xsj5YTGQ2PYDophuwqtCCrFKjC8A@mail.gmail.com> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9CCA8C0C9@Remus.metastack.local>

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

  reply	other threads:[~2013-07-27  8:54 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 [this message]
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='CAE1DttAXkVLFaO-x1WXtp=Xsj5YTGQ2PYDophuwqtCCrFKjC8A@mail.gmail.com' \
    --to=monnier.florent@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).