From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id B1177BC57 for ; Thu, 8 Jul 2010 19:47:00 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgwFALerNUzV+668/2dsb2JhbACTc40vwWSFJQSDeYcC X-IronPort-AV: E=Sophos;i="4.53,559,1272837600"; d="scan'208";a="54727750" Received: from rastageeks.org (HELO mail.rastageeks.org) ([213.251.174.188]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 08 Jul 2010 19:47:00 +0200 Received: from leonard.localnet (unknown [129.81.171.38]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.rastageeks.org (Postfix) with ESMTPSA id 9101742BB9 for ; Thu, 8 Jul 2010 19:56:32 +0200 (CEST) From: Romain Beauxis To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Distinguish between osx and linux programmatically Date: Thu, 8 Jul 2010 12:47:25 -0500 User-Agent: KMail/1.13.3 (Linux/2.6.32-4-amd64; KDE/4.4.4; x86_64; ; ) References: <201007081042.41196.toots@rastageeks.org> <20100708170124.GC16057@annexia.org> In-Reply-To: <20100708170124.GC16057@annexia.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201007081247.25427.toots@rastageeks.org> X-Spam: no; 0.00; uname:01 ocaml:01 stdlib:01 non-unix:01 ocaml:01 uname:01 os-dependent:01 threads:01 unix:01 exception:01 exception:01 caml-list:01 functions:01 posix:01 emulate:01 Le jeudi 8 juillet 2010 12:01:24, Richard Jones a =E9crit : > Actually I misunderstood the link I posted > (http://www.kernel.org/doc/man-pages/online/pages/man2/uname.2.html#NOTES) > thinking it meant that the string fields in the structure could have > variable width. Reading it again, they don't. And they are terminated by a '\0' symbol so we can pass them to=20 ocaml_copy_string... > Nevertheless I still think this is not a useful addition to stdlib, > but for different reasons: >=20 > (1) You'd have to emulate it on non-Unix platforms, but it's unclear > what you'd emulate it with. Windows has a completely different and > much richer concept of OS version. This sort of version probing > complexity doesn't belong in the core library, but in an external "OS > version" library where detection rules can be frequently updated. Well, we already have emulation for many things in OCaml, including much mo= re=20 complex parts of the POSIX/UNIX API, like signals, select, threads etc.. Most of these functions, when not implemented raise a (mostly) undocumented= =20 exception on Windows.. I see no reason why the uname "emulation" could not as well raise an except= ion=20 when it is not implemented (e.g. under Win32). > (2) Your program only ever calls out to uname once. The cost of > running an external program is negligible. In the general case, I prefer to avoid running external programs. This is w= ay=20 to much OS-dependent. A builting alternative, if available, is always bette= r.. Romain