From patchwork Fri Jun 18 17:15:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: M X-Patchwork-Id: 30416 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3B32127BC81; Fri, 18 Jun 2021 18:21:15 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A85DB27BC78 for ; Fri, 18 Jun 2021 18:21:14 +0100 (BST) Received: from localhost ([::1]:50012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luIB7-0008Bq-PT for patchwork@mira.cbaines.net; Fri, 18 Jun 2021 13:21:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luIA0-0007ar-7A for guix-patches@gnu.org; Fri, 18 Jun 2021 13:20:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luI9z-00047B-WF for guix-patches@gnu.org; Fri, 18 Jun 2021 13:20:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1luI9z-0004rg-Ru for guix-patches@gnu.org; Fri, 18 Jun 2021 13:20:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49025] [PATCH v3 core-updates 02/37] utils: Define a target-x86-32? and target-x86-64? predicate. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 18 Jun 2021 17:20:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49025 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49025@debbugs.gnu.org Cc: othacehe@gnu.org, Maxime Devos Received: via spool by 49025-submit@debbugs.gnu.org id=B49025.162403675618314 (code B ref 49025); Fri, 18 Jun 2021 17:20:03 +0000 Received: (at 49025) by debbugs.gnu.org; 18 Jun 2021 17:19:16 +0000 Received: from localhost ([127.0.0.1]:57994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luI9D-0004lC-Jn for submit@debbugs.gnu.org; Fri, 18 Jun 2021 13:19:15 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:34838) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luI96-0004j5-7Z for 49025@debbugs.gnu.org; Fri, 18 Jun 2021 13:19:09 -0400 Received: from localhost.localdomain ([213.119.219.214]) by andre.telenet-ops.be with bizsmtp id JhK5250094e8Tal01hK6b2; Fri, 18 Jun 2021 19:19:06 +0200 From: Maxime Devos Date: Fri, 18 Jun 2021 19:15:56 +0200 Message-Id: <20210618171631.20534-2-maximedevos@telenet.be> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210618171631.20534-1-maximedevos@telenet.be> References: <20210618171631.20534-1-maximedevos@telenet.be> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1624036746; bh=lf5YV93HuGoFIHD1h6x01QuYB2H0sCsCvf+MhMqf3Ic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:Reply-To; b=n9k7sEeAp6hkSj1w0Lsr3bVGtuDnfO1pijnnZNRf/T4QHS+FcvQ+zuCJzjAjDuFJk 0WHzhAWKTVp8G+oeHcNGLHIdfcA4XyIl+ATXuzl/gyjigsgqDxyAuy2XMVSN4c3Hys UjM3H2DQJU6y55zGB04CW8NyppM7TtQ4AefQSAd001e0IwSysuhVW1kqSuM5HE65gy Mf5WbFh5WdzlSXTEpUg9+cdepIV7TI4wa/v8BBXmnNAdI4jOgzf2+tdKxgyL/vvy3I PtX8MiwwQQWySvygzhxR8/dtIaa7wYZ3/ngn4yGvcukx19MyVsjq6tlHWXvpPTEaJQ SvVR1sHdQ2nfA== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: 49025@debbugs.gnu.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/utils.scm (target-x86-32?, target-x86-64?): New predicates. * tests/utils.scm ("target-x86-32?", "target-x86-64?"): New tests. --- guix/utils.scm | 20 ++++++++++++++++++++ tests/utils.scm | 23 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/guix/utils.scm b/guix/utils.scm index 4ff2602e23..2256ea2ca6 100644 --- a/guix/utils.scm +++ b/guix/utils.scm @@ -84,6 +84,8 @@ package-name->name+version target-linux? target-mingw? + target-x86-32? + target-x86-64? target-arm32? target-aarch64? target-arm? @@ -553,6 +555,24 @@ a character other than '@'." (and target (string-suffix? "-mingw32" target))) +(define* (target-x86-32? #:optional (target (or (%current-target-system) + (%current-system)))) + "Is the architecture of TARGET a variant of Intel's 32-bit architecture +(IA32)?" + ;; Intel also has a 16-bit architecture in the iN86 series, i286 + ;; (see, e.g. https://en.wikipedia.org/wiki/Intel/808286) so this + ;; procedure is not named target-x86?. + (or (string-prefix? "i386-" target) + (string-prefix? "i486-" target) + (string-prefix? "i586-" target) + (string-prefix? "i686-" target))) + +(define* (target-x86-64? #:optional (target (or (%current-target-system) + (%current-system)))) + "Is the architecture of TARGET a variant of Intel/AMD's 64-bit +architecture (x86_64)?" + (string-prefix? "x86_64-" target)) + (define* (target-arm32? #:optional (target (or (%current-target-system) (%current-system)))) (string-prefix? "arm" target)) diff --git a/tests/utils.scm b/tests/utils.scm index 80a0e669a4..92439b5587 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -306,6 +306,29 @@ skip these tests." '("i686-linux-gnu" "i686-pc-gnu" "i686-w64-mingw32"))) +(test-equal "target-x86-32?" + '(#f #f #f #t #t #t #t #f) + ;; These are (according to Wikipedia) two RISC architectures + ;; by Intel and presumably not compatible with the x86-32 series. + (map target-x86-32? + '("i860-gnu" "i960-gnu" + ;; This is a 16-bit architecture + "i286-gnu" + ;; These are part of the x86-32 series. + "i386-gnu" "i486-gnu" "i586-gnu" "i686-gnu" + ;; Maybe this one will exist some day, but not yet. + "i786-gnu"))) + +(test-equal "target-x86-64?" + '(#t #f #f #f) + (map target-x86-64? + `("x86_64-linux-gnu" "i386-linux-gnu" + ;; Just because it includes "64" doesn't make it 64-bit. + "aarch64-linux-gnu" + ;; Note that (expt 2 109) in decimal notation starts with 64. + ;; However, it isn't 32-bit. + ,(format #f "x86_~a-linux-gnu" (expt 2 109))))) + (test-end) (false-if-exception (delete-file temp-file))