From patchwork Fri Apr 25 12:14:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 29063 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 503FA203AC for ; Fri, 25 Apr 2014 12:15:36 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id vb8sf21461047obc.7 for ; Fri, 25 Apr 2014 05:15:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=KWQ8oTMRuXjNy87N5n15lcwMytvM5JvZ10h2uWu8ayA=; b=h5LKViXembbSTL7b4svOGta3fEG1lmSWYQA4UviHzGsjBjNHbL6FJmSW1gy+DCv/sU ovG0djflWqEiPq009xRw3nVn0yBLpDTC7xe1x/5ATOqcSqiOfU6I3SWJGND+bnLbJGzA JOCVuSSSlOS6SJ4RSzM+SZvjih9HnGA0PPjI0y9oUlk+dQ+TlKJh+jIkvWsi02lRNgOd /H1uii/FBDjhx4A/qecpn27m6t7Uy9kDjTleDmXpXEXsYbMdX8aKF31xSPgnOcjyPkXM Oqz64UH1j0M1XVBUFLcP8jhRalm2AU3Eo2M/usfLipZeoqW6UahlfrpVcr13hJAxfdzi DmtQ== X-Gm-Message-State: ALoCoQmjWrrWESgN91WFw3J+oupPdMjGL9FVIbS712+816ujLPTJ0F48QgLdvaPDf7uPRVyOIQnk X-Received: by 10.50.79.197 with SMTP id l5mr2547837igx.0.1398428135537; Fri, 25 Apr 2014 05:15:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.81 with SMTP id r75ls1550163qga.71.gmail; Fri, 25 Apr 2014 05:15:35 -0700 (PDT) X-Received: by 10.220.249.6 with SMTP id mi6mr311611vcb.33.1398428135449; Fri, 25 Apr 2014 05:15:35 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id bp12si1649436veb.189.2014.04.25.05.15.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 05:15:35 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id lf12so2406987vcb.13 for ; Fri, 25 Apr 2014 05:15:35 -0700 (PDT) X-Received: by 10.52.241.106 with SMTP id wh10mr5505312vdc.16.1398428135372; Fri, 25 Apr 2014 05:15:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp92985vcb; Fri, 25 Apr 2014 05:15:35 -0700 (PDT) X-Received: by 10.224.79.194 with SMTP id q2mr10908539qak.57.1398428134940; Fri, 25 Apr 2014 05:15:34 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id v6si3713846qas.68.2014.04.25.05.15.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 25 Apr 2014 05:15:34 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Wdf26-0006g2-9w; Fri, 25 Apr 2014 12:15:10 +0000 Received: from mail-la0-f41.google.com ([209.85.215.41]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Wdf1w-0006aX-Ah for lng-odp@lists.linaro.org; Fri, 25 Apr 2014 12:15:00 +0000 Received: by mail-la0-f41.google.com with SMTP id el20so625570lab.14 for ; Fri, 25 Apr 2014 05:15:18 -0700 (PDT) X-Received: by 10.152.116.99 with SMTP id jv3mr5490011lab.19.1398428118019; Fri, 25 Apr 2014 05:15:18 -0700 (PDT) Received: from localhost (c-853670d5.07-21-73746f28.cust.bredbandsbolaget.se. [213.112.54.133]) by mx.google.com with ESMTPSA id z10sm7971578lbu.1.2014.04.25.05.15.16 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Apr 2014 05:15:16 -0700 (PDT) From: Anders Roxell To: lng-odp@lists.linaro.org Date: Fri, 25 Apr 2014 14:14:34 +0200 Message-Id: <1398428077-32199-2-git-send-email-anders.roxell@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398428077-32199-1-git-send-email-anders.roxell@linaro.org> References: <1398428077-32199-1-git-send-email-anders.roxell@linaro.org> Subject: [lng-odp] [PATCH 1/4] include/odp_byteorder: endianess compatible with -std=c99 X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: anders.roxell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Anders Roxell --- include/odp_byteorder.h | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/include/odp_byteorder.h b/include/odp_byteorder.h index c573bb6..4b35da9 100644 --- a/include/odp_byteorder.h +++ b/include/odp_byteorder.h @@ -22,21 +22,11 @@ extern "C" { #include #include -#ifndef BYTE_ORDER -#error BYTE_ORDER not defined! -#endif - -/** Big endian byte order */ -#define ODP_BIG_ENDIAN BIG_ENDIAN -/** Little endian byte order */ -#define ODP_LITTLE_ENDIAN LITTLE_ENDIAN - -/** Selected byte order */ -#if BYTE_ORDER == LITTLE_ENDIAN -#define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN -#elif BYTE_ORDER == BIG_ENDIAN -#define ODP_BYTE_ORDER ODP_BIG_ENDIAN +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define ODP_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ +#else +#define ODP_BIG_ENDIAN __ORDER_BIG_ENDIAN__ #endif @@ -75,7 +65,7 @@ typedef uint64_t __odp_bitwise uint64be_t; /**< unsigned 64bit big endian */ */ static inline uint16_t odp_be_to_cpu_16(uint16be_t be16) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return __odp_builtin_bswap16((__odp_force uint16_t)be16); #else return (__odp_force uint16_t)be16; @@ -89,7 +79,7 @@ static inline uint16_t odp_be_to_cpu_16(uint16be_t be16) */ static inline uint32_t odp_be_to_cpu_32(uint32be_t be32) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return __builtin_bswap32((__odp_force uint32_t)be32); #else return (__odp_force uint32_t)be32; @@ -103,7 +93,7 @@ static inline uint32_t odp_be_to_cpu_32(uint32be_t be32) */ static inline uint64_t odp_be_to_cpu_64(uint64be_t be64) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return __builtin_bswap64((__odp_force uint64_t)be64); #else return (__odp_force uint64_t)be64; @@ -122,7 +112,7 @@ static inline uint64_t odp_be_to_cpu_64(uint64be_t be64) */ static inline uint16be_t odp_cpu_to_be_16(uint16_t cpu16) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint16be_t)__odp_builtin_bswap16(cpu16); #else return (__odp_force uint16be_t)cpu16; @@ -136,7 +126,7 @@ static inline uint16be_t odp_cpu_to_be_16(uint16_t cpu16) */ static inline uint32be_t odp_cpu_to_be_32(uint32_t cpu32) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint32be_t)__builtin_bswap32(cpu32); #else return (__odp_force uint32be_t)cpu32; @@ -150,7 +140,7 @@ static inline uint32be_t odp_cpu_to_be_32(uint32_t cpu32) */ static inline uint64be_t odp_cpu_to_be_64(uint64_t cpu64) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint64be_t)__builtin_bswap64(cpu64); #else return (__odp_force uint64be_t)cpu64; @@ -169,7 +159,7 @@ static inline uint64be_t odp_cpu_to_be_64(uint64_t cpu64) */ static inline uint16_t odp_le_to_cpu_16(uint16le_t le16) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint16_t)le16; #else return __odp_builtin_bswap16((__odp_force uint16_t)le16); @@ -183,7 +173,7 @@ static inline uint16_t odp_le_to_cpu_16(uint16le_t le16) */ static inline uint32_t odp_le_to_cpu_32(uint32le_t le32) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint32_t)le32; #else return __builtin_bswap32((__odp_force uint32_t)le32); @@ -197,7 +187,7 @@ static inline uint32_t odp_le_to_cpu_32(uint32le_t le32) */ static inline uint64_t odp_le_to_cpu_64(uint64le_t le64) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint64_t)le64; #else return __builtin_bswap64((__odp_force uint64_t)le64); @@ -216,7 +206,7 @@ static inline uint64_t odp_le_to_cpu_64(uint64le_t le64) */ static inline uint16le_t odp_cpu_to_le_16(uint16_t cpu16) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint16le_t)cpu16; #else return (__odp_force uint16le_t)__odp_builtin_bswap16(cpu16); @@ -230,7 +220,7 @@ static inline uint16le_t odp_cpu_to_le_16(uint16_t cpu16) */ static inline uint32le_t odp_cpu_to_le_32(uint32_t cpu32) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint32le_t)cpu32; #else return (__odp_force uint32le_t)__builtin_bswap32(cpu32); @@ -244,7 +234,7 @@ static inline uint32le_t odp_cpu_to_le_32(uint32_t cpu32) */ static inline uint64le_t odp_cpu_to_le_64(uint64_t cpu64) { -#if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN +#if ODP_LITTLE_ENDIAN return (__odp_force uint64le_t)cpu64; #else return (__odp_force uint64le_t)__builtin_bswap64(cpu64);