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 442107F7AF for ; Fri, 9 Oct 2015 14:03:24 +0200 (CEST) IronPort-PHdr: 9a23:z1hVkxVV6S9I/FBPCJYDsKdclBfV8LGtZVwlr6E/grcLSJyIuqrYZheAt8tkgFKBZ4jH8fUM07OQ6PC8HzFYqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7z0psWbSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6Lpyv/JHBK7zeqB9Sb1DEBwnNXo07Yvlr0rtVwyKs0AAX2sflFJoDgzB4Qv/V5H3+n/hqudz0S+yIc37F7U9Qiiv9bwtRBK+23RPDCIw7GyC0p84t6lcuh/0/xE= Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=stefan@the2masters.de; spf=Pass smtp.mailfrom=stefan@the2masters.de; spf=None smtp.helo=postmaster@mail-wi0-f180.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of stefan@the2masters.de) identity=pra; client-ip=209.85.212.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="stefan@the2masters.de"; x-sender="stefan@the2masters.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of stefan@the2masters.de designates 209.85.212.180 as permitted sender) identity=mailfrom; client-ip=209.85.212.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="stefan@the2masters.de"; x-sender="stefan@the2masters.de"; 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-wi0-f180.google.com) identity=helo; client-ip=209.85.212.180; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="stefan@the2masters.de"; x-sender="postmaster@mail-wi0-f180.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BrAADbqxdWlLTUVdFehGi5P4QiAQ2BWoMTggp/AoFJOBQBAQEBAQEBARABAQEBBwsLCR8wgh+CCAEBBBIuAQE4Dz8SNAEFARwZIogMBAGhLoExPjGKWIVWAQWPKgEBAQcCARkGCpB7hC6HQY5WjXSIKQyRJDWBFx8BAYJGIx2BQG+HagEBAQ X-IPAS-Result: A0BrAADbqxdWlLTUVdFehGi5P4QiAQ2BWoMTggp/AoFJOBQBAQEBAQEBARABAQEBBwsLCR8wgh+CCAEBBBIuAQE4Dz8SNAEFARwZIogMBAGhLoExPjGKWIVWAQWPKgEBAQcCARkGCpB7hC6HQY5WjXSIKQyRJDWBFx8BAYJGIx2BQG+HagEBAQ X-IronPort-AV: E=Sophos;i="5.17,657,1437429600"; d="scan'208";a="181942590" Received: from mail-wi0-f180.google.com ([209.85.212.180]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 09 Oct 2015 14:03:23 +0200 Received: by wicge5 with SMTP id ge5so65361301wic.0 for ; Fri, 09 Oct 2015 05:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=the2masters.de; s=mail; h=from:to:subject:date:message-id:in-reply-to:references; bh=6Zme3hQW1ETdWr/mYGVV26xQOANLezuIFy5ZIVO8t1g=; b=tHgCwPjhlYEexqE4oyXQUIwUjPh8G3amDKJxz40fLCKms6Y8HUOe0EtDl7XeCqQZxK K0hYzsR2NSgmaMia6iE+Gf/7uKPNZltNi5F7oAmrYjbN9Jq6BW/KxpzHK1kLljhkQIhb 9iYbApY8FIWQ7f7w174550Ra1YCwgHIRRwV3c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=6Zme3hQW1ETdWr/mYGVV26xQOANLezuIFy5ZIVO8t1g=; b=VhF8x49CbQR75ZlnPQtAHr2YMSCvs93keDawg+A+vvWehDIl0bBhGaFpnW+EZmW3iJ ev880N87uRdAbs//zWtsiImgIBM0boS1UxuwhWDfHkX8Oc6N7YaatSK6PxyU6s8R7plM d+RebZ3lyFUaD0dlFXSE7tcRQXS2GNbNAk/at4Km2LH5lsoYDgyMiurn18vSPPwgxREp n7FyaoJ3v6Kpju2mHPOyoZ6eocFf9tkkfxtqPnmYqtwVmAyNDYdJAav9qa57u5QFtLfk K5BUjdAYShftPzcP5sihIF1v17vGtazPnqwoZmCSvkuUwwOtU3wbHZR+BATw93JjOAYh RXCA== X-Gm-Message-State: ALoCoQkqcNxNkdxbHs4soSfZwozxktRR2MFkIriO7AR0c979uYcCdNtyDrZos/5csy7FQV10bz16 X-Received: by 10.194.178.196 with SMTP id da4mr16355160wjc.41.1444392203415; Fri, 09 Oct 2015 05:03:23 -0700 (PDT) Received: from devel.eslohe.lan (p579F4BD2.dip0.t-ipconnect.de. [87.159.75.210]) by smtp.googlemail.com with ESMTPSA id h7sm1754456wjz.7.2015.10.09.05.03.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Oct 2015 05:03:22 -0700 (PDT) From: Stefan Hellermann To: caml-list@inria.fr Date: Fri, 9 Oct 2015 14:03:13 +0200 Message-Id: <1444392194-18276-2-git-send-email-stefan@the2masters.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444392194-18276-1-git-send-email-stefan@the2masters.de> References: <1444392194-18276-1-git-send-email-stefan@the2masters.de> Subject: [Caml-list] [PATCH 1/2] configure: Check sizes of integers and pointers by using the preprocessor Signed-off-by: Stefan Hellermann --- config/auto-aux/preprocesstest | 22 +++++++++++ config/auto-aux/sizes.c | 85 ++++++++++++++++++++++++++++++------------ configure | 2 +- 3 files changed, 85 insertions(+), 24 deletions(-) create mode 100755 config/auto-aux/preprocesstest diff --git a/config/auto-aux/preprocesstest b/config/auto-aux/preprocesstest new file mode 100755 index 0000000..9c66047 --- /dev/null +++ b/config/auto-aux/preprocesstest @@ -0,0 +1,22 @@ +#!/bin/sh + +######################################################################### +# # +# OCaml # +# # +# Xavier Leroy, projet Cristal, INRIA Rocquencourt # +# # +# Copyright 1995 Institut National de Recherche en Informatique et # +# en Automatique. All rights reserved. This file is distributed # +# under the terms of the GNU Library General Public License, with # +# the special exception on linking described in file ../../LICENSE. # +# # +######################################################################### + +if test "$verbose" = yes; then +echo "preprocesstest: $cc -o tst $* $cclibs" >&2 +$cc -E -P -o tst $* $cclibs || exit 100 +else +$cc -E -P -o tst $* $cclibs 2> /dev/null || exit 100 +fi +tail -n 1 ./tst diff --git a/config/auto-aux/sizes.c b/config/auto-aux/sizes.c index d756952..5290b93 100644 --- a/config/auto-aux/sizes.c +++ b/config/auto-aux/sizes.c @@ -1,25 +1,64 @@ -/***********************************************************************/ -/* */ -/* OCaml */ -/* */ -/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ -/* */ -/* Copyright 1996 Institut National de Recherche en Informatique et */ -/* en Automatique. All rights reserved. This file is distributed */ -/* under the terms of the GNU Library General Public License, with */ -/* the special exception on linking described in file ../../LICENSE. */ -/* */ -/***********************************************************************/ +#include +#include -#include +#if UINT_MAX == 255ULL +#define SIZEOFINT 1 +#elif UINT_MAX == 65535ULL +#define SIZEOFINT 2 +#elif UINT_MAX == 4294967295ULL +#define SIZEOFINT 4 +#elif UINT_MAX == 18446744073709551615ULL +#define SIZEOFINT 8 +#else +#error Cannot evaluate sizeof(int) +#endif -int main(int argc, char **argv) -{ - printf("%d %d %d %d %d\n", - (int) sizeof(int), - (int) sizeof(long), - (int) sizeof(long *), - (int) sizeof(short), - (int) sizeof(long long)); - return 0; -} +#if ULONG_MAX == 255ULL +#define SIZEOFLONG 1 +#elif ULONG_MAX == 65535ULL +#define SIZEOFLONG 2 +#elif ULONG_MAX == 4294967295ULL +#define SIZEOFLONG 4 +#elif ULONG_MAX == 18446744073709551615ULL +#define SIZEOFLONG 8 +#else +#error Cannot evaluate sizeof(long) +#endif + +#if SIZE_MAX == 255ULL +#define SIZEOFPOINTER 1 +#elif SIZE_MAX == 65535ULL +#define SIZEOFPOINTER 2 +#elif SIZE_MAX == 4294967295ULL +#define SIZEOFPOINTER 4 +#elif SIZE_MAX == 18446744073709551615ULL +#define SIZEOFPOINTER 8 +#else +#error Cannot evaluate sizeof(*ptr) +#endif + +#if USHRT_MAX == 255ULL +#define SIZEOFSHORT 1 +#elif USHRT_MAX == 65535ULL +#define SIZEOFSHORT 2 +#elif USHRT_MAX == 4294967295ULL +#define SIZEOFSHORT 4 +#elif USHRT_MAX == 18446744073709551615ULL +#define SIZEOFSHORT 8 +#else +#error Cannot evaluate sizeof(short) +#endif + +#if ULLONG_MAX == 255ULL +#define SIZEOFLONGLONG 1 +#elif ULLONG_MAX == 65535ULL +#define SIZEOFLONGLONG 2 +#elif ULLONG_MAX == 4294967295ULL +#define SIZEOFLONGLONG 4 +#elif ULLONG_MAX == 18446744073709551615ULL +#define SIZEOFLONGLONG 8 +#else +#error Cannot evaluate sizeof(long long) +#endif + +SIZEOFINT SIZEOFLONG SIZEOFPOINTER SIZEOFSHORT SIZEOFLONGLONG diff --git a/configure b/configure index 5596523..e3ea7eb 100755 --- a/configure +++ b/configure @@ -495,7 +495,7 @@ fi # cross-compiler # a 64-bit integer type inf "Checking the sizes of integers and pointers..." -ret=`sh ./runtest sizes.c` +ret=`sh ./preprocesstest sizes.c` # $1 = sizeof(int) # $2 = sizeof(long) # $3 = sizeof(pointers) -- 2.1.4