From patchwork Thu May 26 19:16:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruben Undheim X-Patchwork-Id: 626846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id 3rFzQm0B9Pz9t4b for ; Fri, 27 May 2016 05:16:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=S+hGbrEb; dkim-atps=neutral Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id DF39E13D3E; Thu, 26 May 2016 19:16:29 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail-lb0-x243.google.com (mail-lb0-x243.google.com [IPv6:2a00:1450:4010:c04::243]) by lists.osmocom.org (Postfix) with ESMTP id E089613D2B for ; Thu, 26 May 2016 19:16:27 +0000 (UTC) Received: by mail-lb0-x243.google.com with SMTP id r5so4895997lbj.3 for ; Thu, 26 May 2016 12:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=aCicEECLx9HidxGAnexjTfPt2F+VAEou8zsxTAfyhg8=; b=S+hGbrEbb5KPBkP8EMTBqZwAUN9vAvbOjzKuZJ0aDNvezUfGwbSaWLnYUUwaNPQtmI fGIXrSLLsmOIP+oYfAi2oxOjo3js4blaVeS7gV5fp8hKQmJUDcBwcARr3woYO2WbTsdL sYKTaFijXW8obO9pcHBm6amZtjWYcRsBMN44BHisio1TyAGjQiW+eCpGnyGyhRfITrh+ H1vv72/g7BbTOs0tbiO4YMU3x0VNybixLGe2r1ScYzwONNzYcS71vUUQcV8ZxF3zh328 ELgIwyMr0oRcj6W2x6NpF3ICvL1YvLvBQZcePpCED0/3elrIdcmSVo9GiXGEuL+bnoH1 mlFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=aCicEECLx9HidxGAnexjTfPt2F+VAEou8zsxTAfyhg8=; b=GOR1dp7sP8BVa/brr/A+xoTrvTEReOgLs8Q1u1YCHnnFs05cTc8ztb/TudPEG9PkmM 5bM8yYBERmdwf3iIqYtsdhZemwRZi0PDq5iucM0WjY3OKyRwO8gw9/sd4CwjJfIUbzxk 0x3jAlikjPBO6ROb5Wi/xrmax9kto4azPV/AGut38G+uIygewwHO5rCT8AyoPzCDFwTy jc4/PQTsQ0RQ5eyhS6jzsyVAl/fAA6qBaOMU6qGPwsLBij7txKhZ/wZ+LnpB4iu11Njy XfKBkysPXUJXNcc2Iuh776J9AbkRHhtgGPXEhwRT9X4H84mmsfyHFH4zssfpdyWZrH2A rmKg== X-Gm-Message-State: ALyK8tI5K3ifee8SU8ilcEaFYVNAn+dgsZmDDOz8Ys24w8jByghjEQcuPzkC7Ri0qwrF9A== X-Received: by 10.112.181.72 with SMTP id du8mr3341365lbc.137.1464290187189; Thu, 26 May 2016 12:16:27 -0700 (PDT) Received: from macbookair ([188.113.84.48]) by smtp.gmail.com with ESMTPSA id 1sm220065ljf.5.2016.05.26.12.16.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 May 2016 12:16:26 -0700 (PDT) Date: Thu, 26 May 2016 21:16:24 +0200 From: Ruben Undheim To: openbsc@lists.osmocom.org Subject: libosmocore: patch for big-endian architectures Message-ID: <20160526191624.GA23739@macbookair> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.0 (2016-04-01) 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: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Hi, One test case fails for openbsc on big-endian architectures. This was traced back to struct erros in libosmocore. Please see patch below: commit fb3d353ab238a2d14cb8e9704995f14a2acd6c1b Author: Ruben Undheim Date: Mon Dec 7 19:34:28 2015 +0100 Patched structs for big-endian architectures I tried 30 seconds to figure out how to use Gerrit, but I couldn't figure out how to login, so I rather just post here. Best regards, Ruben 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 @@ struct gsm48_classmark2 { } __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 @@ struct gsm48_range_1024 { 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 @@ struct gsm48_range_512 { 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 @@ struct gsm48_range_256 { 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 @@ struct gsm48_range_128 { 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 {