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 6F42DBC57 for ; Thu, 8 Jul 2010 20:23:03 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgQDAPCzNUzRVaFEhmdsb2JhbACDHp0LCBUBAQEKCQoHEyKwQTuCDIYGLohTAQEDBQiBHIMKcgSDdA X-IronPort-AV: E=Sophos;i="4.53,559,1272837600"; d="scan'208";a="54729324" Received: from mail-fx0-f68.google.com ([209.85.161.68]) by mail2-smtp-roc.national.inria.fr with ESMTP; 08 Jul 2010 20:23:03 +0200 Received: by fxm15 with SMTP id 15so319188fxm.3 for ; Thu, 08 Jul 2010 11:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:x-mailer:mime-version :content-type:content-transfer-encoding; bh=McH56C0p1QBwsCajbZTxF6a3g7m3zqlPpBrcg8Fo6lI=; b=NHl1rs6qJqCdtayyjpBX4MmTHGnN5rFZU+Yqo6SRZ2cE7HzftX5hpfc95H+qdL1u5L Fovr+EYEIWDeKObttVfO5Rusx2FxjEmttXMor2X1TmWCuTSOA40Yc4dOFBSZ0mZKp+AK T0JDsKol/C9zPwlp46RWXY+D++QaNVPfHASm8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=GTx0feO35HIhx23BUGQkM5CDbS08kC8X/MkqHpsCrZ0EQ/UUfgen44BqDVJ2j0kBte ESIStlrctDtmuFtzyZPu6DbGPvI7nn2SijaBhgazBzHgjX0UbZc1TthwHPQBWhlvizk6 T8lcBn19NP/VnQ3A3RoPpEkj/F+bnkPKczT4o= Received: by 10.86.63.7 with SMTP id l7mr6301757fga.27.1278613382555; Thu, 08 Jul 2010 11:23:02 -0700 (PDT) Received: from debian ([79.114.60.141]) by mx.google.com with ESMTPS id q28sm10174655faa.41.2010.07.08.11.23.01 (version=SSLv3 cipher=RC4-MD5); Thu, 08 Jul 2010 11:23:02 -0700 (PDT) Date: Thu, 8 Jul 2010 21:22:56 +0300 From: =?UTF-8?B?VMO2csO2aw==?= Edwin To: David Allsopp Cc: "oliver@first.in-berlin.de" , "caml-list@yquem.inria.fr" Subject: Re: [Caml-list] Distinguish between osx and linux programmatically Message-ID: <20100708212256.3261bf11@debian> In-Reply-To: References: <20100708114434.GB16057@annexia.org> <201007081042.41196.toots@rastageeks.org> <20100708170124.GC16057@annexia.org> <20100708171743.GA2178@first.in-berlin.de> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; bandel:01 0100,:01 stdlib:01 uname:01 uname:01 stdlib:01 non-unix:01 mingw:01 mingw:01 cygwin:01 cygwin:01 ocaml:01 otherlibs:01 gethostname:01 edwin:98 On Thu, 8 Jul 2010 17:22:15 +0000 David Allsopp wrote: > Oliver Bandel wrote:=20 > > On Thu, Jul 08, 2010 at 06:01:24PM +0100, Richard Jones wrote: > > > On Thu, Jul 08, 2010 at 10:42:40AM -0500, Romain Beauxis wrote: > > > > Le jeudi 8 juillet 2010 06:44:34, Richard Jones a =C3=A9crit : > > > > > Stdlib could bind the uname(2) syscall, but it's legendary in > > > > > its complexity. Seems more likely to cause problems than > > > > > just calling out to the external program. > > > > > > > > I fail to see the complexity.. Where is it ? > > > > > > Actually *I* misunderstood the link I posted > > > (http://www.kernel.org/doc/man-pages/online/pages/man2/uname.2.html#NO > > > TES) thinking it meant that the string fields in the structure > > > could have variable width. Reading it again, they don't. > > > > > > Nevertheless I still think this is not a useful addition to > > > stdlib, but for different reasons: > > > > > > (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. > > [...] > >=20 > >=20 > > $ uname -a > >=20 > > If it's not Unix, what will uname(2) or uname(1) give you? > >=20 > > What will be reported on Windows with MinGW >=20 > C:\Users\DRA>uname -a > windows32 Tenor 2.6.1 7600 i686-pc Intel unknown MinGW >=20 > (using GnuWin32 which is a MinGW build of the Unix tools) >=20 > > or Cygwin? >=20 > DRA@Tenor ~ > $ uname -a > CYGWIN_NT-6.1-WOW64 Tenor 1.7.5(0.225/5/3) 2010-04-12 19:07 i686 > Cygwin >=20 > But of course in both instances that requires uname.exe to be > installed which it won't be on most normal end-user systems. OCaml already calls uname(), and has a configure check for its presence: ./configure: echo "uname() found." ./otherlibs/unix/gethostname.c: uname(&un); I think it would only be a matter of using uname() for something more than just the hostname. Of course finding out the OS version from uname is more complicated (Linux has the kernel's version, and there is no way to find out the distribution, etc.), but a portable program shouldn't care much about the exact OS version, as long as it knows the OS type. Best regards, --Edwin