From patchwork Tue Apr 5 14:44:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Freyther X-Patchwork-Id: 606495 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 3qfWq85BrMz9t0r for ; Wed, 6 Apr 2016 00:45:08 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 019941C8FB; Tue, 5 Apr 2016 14:45:05 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from gandharva.secretlabs.de (gandharva.secretlabs.de [5.9.72.18]) by lists.osmocom.org (Postfix) with ESMTP id 2F4DC1C8EA for ; Tue, 5 Apr 2016 14:45:04 +0000 (UTC) Received: from localhost.localdomain (ip127-36-210-87.adsl2.static.versatel.nl [87.210.36.127]) by gandharva.secretlabs.de (Postfix) with ESMTPSA id 0715A7438A for ; Tue, 5 Apr 2016 14:45:03 +0000 (UTC) From: Holger Hans Peter Freyther To: openbsc@lists.osmocom.org Subject: [PATCH] misc: Replace libosmocore with talloc Date: Tue, 5 Apr 2016 16:44:50 +0200 Message-Id: <1459867490-66746-1-git-send-email-holger@freyther.de> X-Mailer: git-send-email 2.6.3 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" From: Holger Hans Peter Freyther The libosmocore depedency is used for talloc and OSMO_ASSERT. Reduce the depedencies by using libtalloc directly and replace the ASSERT with a local one (without backtrace support). --- configure.ac | 2 +- include/asn1c/asn_internal.h | 2 +- libasn1c.pc.in | 4 ++-- src/Makefile.am | 4 ++-- src/asn1helpers.c | 20 ++++++++++++-------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index aaa2b5a..dcec465 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ AC_PROG_LIBTOOL AC_CONFIG_MACRO_DIR([m4]) -PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.1.13) +PKG_CHECK_MODULES(LIBTALLOC, talloc) # The following test is taken from WebKit's webkit.m4 saved_CFLAGS="$CFLAGS" diff --git a/include/asn1c/asn_internal.h b/include/asn1c/asn_internal.h index 58b4583..580c2e7 100644 --- a/include/asn1c/asn_internal.h +++ b/include/asn1c/asn_internal.h @@ -15,7 +15,7 @@ #include /* for assert() macro */ #endif -#include +#include #ifdef __cplusplus extern "C" { diff --git a/libasn1c.pc.in b/libasn1c.pc.in index 149fe2d..89ad53a 100644 --- a/libasn1c.pc.in +++ b/libasn1c.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: asn1c runtime library Description: C Utility Library Version: @VERSION@ -Libs: -L${libdir} -lasn1c -lm -Cflags: -I${includedir}/ -I${includedir}/asn1c +Libs: -L${libdir} @LIBTALLOC_LIBS@ -lasn1c -lm +Cflags: -I${includedir}/ -I${includedir}/asn1c @LIBTALLOC_CFLAGS@ diff --git a/src/Makefile.am b/src/Makefile.am index 120d29b..0f05cce 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,13 +4,13 @@ LIBVERSION=1:0:0 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include/asn1c -AM_CFLAGS = -fPIC -Wall $(LIBOSMOCORE_CFLAGS) +AM_CFLAGS = -fPIC -Wall $(LIBTALLOC_CFLAGS) if BUILD_DEBUG AM_CFLAGS += -DEMIT_ASN_DEBUG=1 endif lib_LTLIBRARIES = libasn1c.la -libasn1c_la_LDFLAGS = $(LIBOSMOCORE_LIBS) +libasn1c_la_LDFLAGS = $(LIBTALLOC_LIBS) libasn1c_la_SOURCES = ANY.c constraints.c GeneralizedTime.c NumericString.c T61String.c asn_codecs_prim.c constr_CHOICE.c GeneralString.c ObjectDescriptor.c TeletexString.c asn_SEQUENCE_OF.c constr_SEQUENCE.c GraphicString.c OBJECT_IDENTIFIER.c UniversalString.c asn_SET_OF.c constr_SEQUENCE_OF.c IA5String.c OCTET_STRING.c UTCTime.c ber_decoder.c constr_SET.c INTEGER.c per_decoder.c UTF8String.c ber_tlv_length.c constr_SET_OF.c ISO646String.c per_encoder.c VideotexString.c ber_tlv_tag.c constr_TYPE.c NativeEnumerated.c per_support.c VisibleString.c BIT_STRING.c NativeInteger.c PrintableString.c xer_decoder.c BMPString.c der_encoder.c NativeReal.c REAL.c xer_encoder.c BOOLEAN.c ENUMERATED.c NULL.c RELATIVE-OID.c xer_support.c per_opentype.c asn1helpers .c diff --git a/src/asn1helpers.c b/src/asn1helpers.c index 8ce9bf4..aca5300 100644 --- a/src/asn1helpers.c +++ b/src/asn1helpers.c @@ -22,11 +22,15 @@ #include #include -#include - #include "asn1helpers.h" #include "asn_internal.h" +#define ASN1C_ASSERT(exp) \ + if (!(exp)) { \ + fprintf(stderr, "Assert failed %s %s:%d\n", #exp, __FILE__, __LINE__); \ + abort(); \ + } + void asn1_u32_to_bitstring(BIT_STRING_t *bitstr, uint32_t *buf, uint32_t in) { *buf = htonl(in); @@ -126,39 +130,39 @@ int asn1_strncpy(char *out, const OCTET_STRING_t *in, size_t n) uint32_t asn1str_to_u32(const OCTET_STRING_t *in) { - OSMO_ASSERT(in && in->size == sizeof(uint32_t)); + ASN1C_ASSERT(in && in->size == sizeof(uint32_t)); return ntohl(*(uint32_t *)in->buf); } uint16_t asn1str_to_u16(const OCTET_STRING_t *in) { - OSMO_ASSERT(in && in->size == sizeof(uint16_t)); + ASN1C_ASSERT(in && in->size == sizeof(uint16_t)); return ntohs(*(uint16_t *)in->buf); } uint8_t asn1str_to_u8(const OCTET_STRING_t *in) { - OSMO_ASSERT(in && in->size == sizeof(uint8_t)); + ASN1C_ASSERT(in && in->size == sizeof(uint8_t)); return *(uint8_t *)in->buf; } uint32_t asn1bitstr_to_u32(const BIT_STRING_t *in) { - OSMO_ASSERT(in && in->size == sizeof(uint32_t)); + ASN1C_ASSERT(in && in->size == sizeof(uint32_t)); return ntohl(*(uint32_t *)in->buf); } uint32_t asn1bitstr_to_u28(const BIT_STRING_t *in) { - OSMO_ASSERT(in && in->size == sizeof(uint32_t) && in->bits_unused == 4); + ASN1C_ASSERT(in && in->size == sizeof(uint32_t) && in->bits_unused == 4); return ntohl(*(uint32_t *)in->buf) >> 4; } uint32_t asn1bitstr_to_u24(const BIT_STRING_t *in) { - OSMO_ASSERT(in && in->size == 3); + ASN1C_ASSERT(in && in->size == 3); return ntohl(*(uint32_t *)in->buf) >> 8; }