From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 288E3BC76 for ; Fri, 3 Aug 2007 17:58:09 +0200 (CEST) Received: from hu-out-0506.google.com (hu-out-0506.google.com [72.14.214.232]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l73FIT8F013847 for ; Fri, 3 Aug 2007 17:18:29 +0200 Received: by hu-out-0506.google.com with SMTP id 16so632479hue for ; Fri, 03 Aug 2007 08:18:29 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:date:to:cc:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=oGNDkjCpsJcBPppFdgFkD2b5nLUqAZG89Cdb5OdmDyQGpVv9Wc7wb+nlT8UjDxBiJB+tjRFNWnfgwetgGL/LKp14bCUxP8XSY83xC/CpH9wONbVk5wLGSvxekqvv7nfJWZvI/v9Di2Co5x7ecWnayvdRPzCO9xpgDpLz9lT2its= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:to:cc:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent:from; b=c6/B4aC7Yadps13ATckM4cr0zK9umtdEO+aXdFnLWD6sN66YcISmF+REqufIScG6ihGJstsoE3P5rSuGDCGk7MmkOc6Z7npTaJVqcVXPDTPaPdWLHvRH52teEcVjumBeDYbGJYUBjb3VdRBxXOy82zBYyTsAUC6velc7Qt70Y2o= Received: by 10.86.70.8 with SMTP id s8mr2311721fga.1186154308844; Fri, 03 Aug 2007 08:18:28 -0700 (PDT) Received: from localhost ( [82.122.232.94]) by mx.google.com with ESMTPS id 13sm6538510fks.2007.08.03.08.18.23 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Aug 2007 08:18:24 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Fri, 03 Aug 2007 17:18:11 +0200 Date: Fri, 3 Aug 2007 17:18:11 +0200 To: Eric Merritt Cc: caml-list@inria.fr Subject: Re: [Caml-list] getting the system architecture Message-ID: <20070803151811.GA5501@jiyu.gnu> Mail-Followup-To: Julien Moutinho , Eric Merritt , caml-list@inria.fr References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.16 (2007-06-11) From: Julien Moutinho X-j-chkmail-Score: MSGID : 46B34745.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 46B34745.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 grepping:01 ocaml:01 runtime:01 uname:01 camlp:01 camlprim:01 camlparam:01 struct:01 uname:01 failwith:01 camlreturn:01 endline:01 gcc:01 ocamlopt:01 On Thu, Aug 02, 2007 at 04:09:15PM -0700, Eric Merritt wrote: > Is there anyway to get the system architecture natively in ocaml? I > found Sys.os_type but have yet to find anything comparable for the > architecture. Grepping at the Ocaml sources I see a few uses of , but none of them deals with the ``machine'' field. Apparently, they never need a runtime check of the arch. > The alternative is to build out a function to get this > info in C but I would rather not complicate my build I don't know exactly how portable you want to be, but you can also try to launch uname -m or this awful config/gnu/config.guess either in a sub-process or in a ./configure coupled with a camlp4 definition. > (or code in C ;) % cat c_arch.c #include #include #include CAMLprim value arch_get(value unit) { CAMLparam0(); /* ``unit'' is not used */ struct utsname utsbuf; if (uname( &utsbuf )) failwith( "Arch.get" ); CAMLreturn(copy_string( utsbuf.machine )); } % cat arch.ml external get : unit -> string = "arch_get" % cat test.ml print_endline (Arch.get ()) % gcc -c c_arch.c % ar rc libarch.a c_arch.o % ocamlopt -c arch.ml % ocamlopt -a -o arch.cmxa -cclib -larch arch.cmx % ocamlopt -c test.ml % ocamlopt -o test.opt -I . arch.cmxa test.cmx % ./test.opt i686 Hope this helps a bit.