From patchwork Fri May 27 20:05:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gerrit-no-reply@lists.osmocom.org X-Patchwork-Id: 627337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 3rGcTK26tmz9sBc for ; Sat, 28 May 2016 06:05:57 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 025506308; Fri, 27 May 2016 20:05:52 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from 127.0.1.12 (unknown [127.0.1.12]) by lists.osmocom.org (Postfix) with ESMTPA id B3DA662F9; Fri, 27 May 2016 20:05:50 +0000 (UTC) Date: Fri, 27 May 2016 20:05:50 +0000 From: Ruben Undheim Message-ID: X-Gerrit-MessageType: newchange Subject: [PATCH] libosmocore[master]: Patched structs for big-endian architectures X-Gerrit-Change-Id: I29eafe481e112d18c624b1c83add0d53c354dbe4 X-Gerrit-ChangeURL: X-Gerrit-Commit: fe16f37822d44db49f29fe8ef90292bbc40ee2ea MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/2.12.2-31-gb331dbd-dirty X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Development of OpenBSC, OsmoBSC, OsmoNITB, OsmoCSCN" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ruben.undheim@gmail.com Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Review at https://gerrit.osmocom.org/124 Patched structs for big-endian architectures Change-Id: I29eafe481e112d18c624b1c83add0d53c354dbe4 --- M include/osmocom/gsm/protocol/gsm_04_08.h 1 file changed, 160 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/24/124/1 diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h index 4800b48..0c2fcf2 100644 --- a/include/osmocom/gsm/protocol/gsm_04_08.h +++ b/include/osmocom/gsm/protocol/gsm_04_08.h @@ -4,6 +4,8 @@ #include #include +#include + /* GSM TS 04.08 definitions */ struct gsm_lchan; @@ -42,6 +44,7 @@ } __attribute__ ((packed)); /* Chapter 10.5.2.1b.3 */ +#if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_1024 { uint8_t w1_hi:2, f0:1, @@ -75,8 +78,44 @@ uint8_t w16:6, w15_lo:2; } __attribute__ ((packed)); +#else +struct gsm48_range_1024 { + uint8_t form_id:5, + f0:1, + w1_hi:2; + uint8_t w1_lo; + uint8_t w2_hi; + uint8_t w2_lo:1, + w3_hi:7; + uint8_t w3_lo:2, + w4_hi:6; + uint8_t w4_lo:2, + w5_hi:6; + uint8_t w5_lo:2, + w6_hi:6; + uint8_t w6_lo:2, + w7_hi:6; + uint8_t w7_lo:2, + w8_hi:6; + uint8_t w8_lo:1, + w9:7; + uint8_t w10:7, + w11_hi:1; + uint8_t w11_lo:6, + w12_hi:2; + uint8_t w12_lo:5, + w13_hi:3; + uint8_t w13_lo:4, + w14_hi:4; + uint8_t w14_lo:3, + w15_hi:5; + uint8_t w15_lo:2, + w16:6; +} __attribute__ ((packed)); +#endif /* Chapter 10.5.2.1b.4 */ +#if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_512 { uint8_t orig_arfcn_hi:1, form_id:7; @@ -110,8 +149,44 @@ uint8_t w17:5, w16_lo:3; } __attribute__ ((packed)); +#else +struct gsm48_range_512 { + uint8_t form_id:7, + orig_arfcn_hi:1; + uint8_t orig_arfcn_mid; + uint8_t orig_arfcn_lo:1, + w1_hi:7; + uint8_t w1_lo:2, + w2_hi:6; + uint8_t w2_lo:2, + w3_hi:6; + uint8_t w3_lo:2, + w4_hi:6; + uint8_t w4_lo:1, + w5:7; + uint8_t w6:7, + w7_hi:1; + uint8_t w7_lo:6, + w8_hi:2; + uint8_t w8_lo:4, + w9_hi:4; + uint8_t w9_lo:2, + w10:6; + uint8_t w11:6, + w12_hi:2; + uint8_t w12_lo:4, + w13_hi:4; + uint8_t w13_lo:2, + w14:6; + uint8_t w15:6, + w16_hi:2; + uint8_t w16_lo:3, + w17:5; +} __attribute__ ((packed)); +#endif /* Chapter 10.5.2.1b.5 */ +#if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_256 { uint8_t orig_arfcn_hi:1, form_id:7; @@ -151,8 +226,50 @@ w21:4, w20_lo:3; } __attribute__ ((packed)); +#else +struct gsm48_range_256 { + uint8_t form_id:7, + orig_arfcn_hi:1; + uint8_t orig_arfcn_mid; + uint8_t orig_arfcn_lo:1, + w1_hi:7; + uint8_t w1_lo:1, + w2:7; + uint8_t w3:7, + w4_hi:1; + uint8_t w4_lo:5, + w5_hi:3; + uint8_t w5_lo:3, + w6_hi:5; + uint8_t w6_lo:1, + w7:6, + w8_hi:1; + uint8_t w8_lo:4, + w9_hi:4; + uint8_t w9_lo:1, + w10:5, + w11_hi:2; + uint8_t w11_lo:3, + w12:5; + uint8_t w13:5, + w14_hi:3; + uint8_t w14_lo:2, + w15:5, + w16_hi:1; + uint8_t w16_lo:3, + w17:4, + w18_hi:1; + uint8_t w18_lo:3, + w19:4, + w20_hi:1; + uint8_t w20_lo:3, + w21:4, + spare:1; +} __attribute__ ((packed)); +#endif /* Chapter 10.5.2.1b.6 */ +#if OSMO_IS_LITTLE_ENDIAN == 1 struct gsm48_range_128 { uint8_t orig_arfcn_hi:1, form_id:7; @@ -194,6 +311,49 @@ w27:3, w26_lo:1; } __attribute__ ((packed)); +#else +struct gsm48_range_128 { + uint8_t form_id:7, + orig_arfcn_hi:1; + uint8_t orig_arfcn_mid; + uint8_t orig_arfcn_lo:1, + w1:7; + uint8_t w2:6, + w3_hi:2; + uint8_t w3_lo:4, + w4_hi:4; + uint8_t w4_lo:1, + w5:5, + w6_hi:2; + uint8_t w6_lo:3, + w7:5; + uint8_t w8:4, + w9:4; + uint8_t w10:4, + w11:4; + uint8_t w12:4, + w13:4; + uint8_t w14:4, + w15:4; + uint8_t w16:3, + w17:3, + w18_hi:2; + uint8_t w18_lo:1, + w19:3, + w20:3, + w21_hi:1; + uint8_t w21_lo:2, + w22:3, + w23:3; + uint8_t w24:3, + w25:3, + w26_hi:2; + uint8_t w26_lo:1, + w27:3, + w28:3, + spare:1; +} __attribute__ ((packed)); +#endif /* Chapter 10.5.2.1b.7 */ struct gsm48_var_bit {