From 704416a0f835a54eb59c4748d6f38810975bec3cbc8743a167fc5d84a3ef495f Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 18 Feb 2015 17:13:23 +0000 Subject: [PATCH] More architecture exclusions OBS-URL: https://build.opensuse.org/package/show/network:telephony/libosmocore?expand=0&rev=18 --- ...mpiler-warnings-on-implicit-declarat.patch | 28 - libosmocore-0.7.0+git19.tar.xz | 3 + libosmocore-0.7.0.tar.xz | 3 - libosmocore.spec | 35 +- osmo-kasumi.diff | 40 -- osmo-talloc.diff | 16 +- osmo-talloc2.diff | 603 +++++++++++++++++- osmo-talloc3.diff | 76 +++ 8 files changed, 689 insertions(+), 115 deletions(-) delete mode 100644 0001-utils-resolve-compiler-warnings-on-implicit-declarat.patch create mode 100644 libosmocore-0.7.0+git19.tar.xz delete mode 100644 libosmocore-0.7.0.tar.xz delete mode 100644 osmo-kasumi.diff create mode 100644 osmo-talloc3.diff diff --git a/0001-utils-resolve-compiler-warnings-on-implicit-declarat.patch b/0001-utils-resolve-compiler-warnings-on-implicit-declarat.patch deleted file mode 100644 index 977054c..0000000 --- a/0001-utils-resolve-compiler-warnings-on-implicit-declarat.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 02d132264692be5fb72ed9ee119d42ba17ed8164 Mon Sep 17 00:00:00 2001 -From: Jan Engelhardt -Date: Mon, 3 Jun 2013 01:38:57 +0200 -Subject: [PATCH 1/4] utils: resolve compiler warnings on implicit declarations - - CC osmo-auc-gen.o - osmo-auc-gen.c: In function 'main': - osmo-auc-gen.c:216:3: warning: implicit declaration of function - 'time' [-Wimplicit-function-declaration] ---- - utils/osmo-auc-gen.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c -index ee349ae..7809730 100644 ---- a/utils/osmo-auc-gen.c -+++ b/utils/osmo-auc-gen.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #include - #include --- -2.0.0 - diff --git a/libosmocore-0.7.0+git19.tar.xz b/libosmocore-0.7.0+git19.tar.xz new file mode 100644 index 0000000..8f066d6 --- /dev/null +++ b/libosmocore-0.7.0+git19.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09a448707219c412589611819efe24b01c298c23ee15db9a13ae2e8303482bf3 +size 364252 diff --git a/libosmocore-0.7.0.tar.xz b/libosmocore-0.7.0.tar.xz deleted file mode 100644 index bc5f3c1..0000000 --- a/libosmocore-0.7.0.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:125cb5ea2a46f06f0a2e631c3c800e0e45700a91c10731ecac5659b65f37540d -size 363004 diff --git a/libosmocore.spec b/libosmocore.spec index 18c5619..de695e3 100644 --- a/libosmocore.spec +++ b/libosmocore.spec @@ -20,30 +20,29 @@ Name: libosmocore Summary: Open Source Mobile Communications Core Library License: GPL-2.0 and GPL-2.0+ and LGPL-3.0+ and AGPL-3.0+ Group: Productivity/Telephony/Utilities -Version: 0.7.0 +Version: 0.7.0+git19 Release: 0 Url: http://bb.osmocom.org/trac/wiki/libosmocore #Git-Clone: git://git.osmocom.org/libosmocore -#Snapshot: 0.7.0 +#Snapshot: 0.7.0-19-gc60de4f #Update osmo-version.diff too! Source: %name-%version.tar.xz Patch1: osmo-version.diff -Patch2: 0001-utils-resolve-compiler-warnings-on-implicit-declarat.patch Patch3: osmo-talloc.diff Patch4: osmo-talloc2.diff -Patch5: osmo-kasumi.diff +Patch5: osmo-talloc3.diff BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: autoconf BuildRequires: automake >= 1.6 BuildRequires: gcc-c++ BuildRequires: libtalloc-devel BuildRequires: libtool -BuildRequires: pkgconfig +BuildRequires: pkg-config BuildRequires: xz # do not try to build for big-endian archs # as suggested by http://lists.osmocom.org/pipermail/baseband-devel/2015-February/000022.html -ExcludeArch: ppc ppc64 +ExcludeArch: ppc ppc64 ppc64p7 mips mips64 %sparc s390 s390x %description libosmocore is a library with various utility functions that were @@ -97,14 +96,14 @@ communications. This subpackage contains libraries and header files for developing applications that want to make use of libosmocodec. -%package -n libosmocore4 +%package -n libosmocore5 Summary: Osmocom core library License: GPL-2.0 and GPL-2.0+ Group: System/Libraries # crc16.c has GPL2-only clauses, the rest (*.c) is GPL-2.0+ # talloc.c (LGPL-3.0+) is not part of libosmocore.so -%description -n libosmocore4 +%description -n libosmocore5 libosmocore is a library with various utility functions shared between OpenBSC and OsmocomBB. @@ -113,7 +112,7 @@ Summary: Development files for the Osmocom core library License: GPL-2.0 and GPL-2.0+ Group: Development/Libraries/C and C++ # crc16.h has GPL2-only clauses, the rest (*.h) is GPL-2.0+ -Requires: libosmocore4 = %version +Requires: libosmocore5 = %version Requires: libtalloc-devel %description -n libosmocore-devel @@ -238,19 +237,13 @@ communications. This subpackage contains libraries and header files for developing applications that want to make use of libosmovty. -%define use_system_talloc 1 - %prep %setup -qn %name -%patch -P 1 -P 2 -P 3 -P 4 -P 5 -p1 +%patch -P 1 -P 3 -P 4 -P 5 -p1 %build -%if 0%{?use_system_talloc} -echo "#include " >include/osmocom/core/talloc.h -%endif autoreconf -fiv -%configure --enable-shared --disable-static \ - %{?use_system_talloc:--disable-talloc} +%configure --enable-shared --disable-static make %{?_smp_mflags} %install @@ -263,8 +256,8 @@ make %{?_smp_mflags} check %post -n libosmocodec0 -p /sbin/ldconfig %postun -n libosmocodec0 -p /sbin/ldconfig -%post -n libosmocore4 -p /sbin/ldconfig -%postun -n libosmocore4 -p /sbin/ldconfig +%post -n libosmocore5 -p /sbin/ldconfig +%postun -n libosmocore5 -p /sbin/ldconfig %post -n libosmoctrl0 -p /sbin/ldconfig %postun -n libosmoctrl0 -p /sbin/ldconfig %post -n libosmogb3 -p /sbin/ldconfig @@ -289,9 +282,9 @@ make %{?_smp_mflags} check %_libdir/libosmocodec.so %_libdir/pkgconfig/libosmocodec.pc -%files -n libosmocore4 +%files -n libosmocore5 %defattr(-,root,root) -%_libdir/libosmocore.so.4* +%_libdir/libosmocore.so.5* %files -n libosmocore-devel %defattr(-,root,root) diff --git a/osmo-kasumi.diff b/osmo-kasumi.diff deleted file mode 100644 index 8474256..0000000 --- a/osmo-kasumi.diff +++ /dev/null @@ -1,40 +0,0 @@ -From 0929c5b1d3ae71fb600120fd5c60221495b8391c Mon Sep 17 00:00:00 2001 -From: Jan Engelhardt -Date: Thu, 2 Oct 2014 22:22:28 +0200 -Subject: [PATCH] build: fix linker error with kasumi_test - -When the osmocore package is configured with --disable-static, -building of kasumi_test fails. This seems quite legit, given -the function _kasumi_kgcore is not exported. -Don't try to workaround the build system. Include the code. - - CCLD kasumi/kasumi_test -kasumi_test.o: In function `test_expansion': -~tests/kasumi/kasumi_test.c:25: undefined reference to `_kasumi_key_expand' -kasumi_test.o: In function `main': -~tests/kasumi/kasumi_test.c:56: undefined reference to `_kasumi' -~tests/kasumi/kasumi_test.c:100: undefined reference to `_kasumi_key_expand' -~tests/kasumi/kasumi_test.c:112: undefined reference to `_kasumi_kgcore' -[...] ---- - tests/Makefile.am | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/tests/Makefile.am b/tests/Makefile.am -index 8779c4f..3f7db1f 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -20,9 +20,8 @@ utils_utils_test_LDADD = $(top_builddir)/src/libosmocore.la - a5_a5_test_SOURCES = a5/a5_test.c - a5_a5_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la - --kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c -+kasumi_kasumi_test_SOURCES = kasumi/kasumi_test.c ../src/gsm/kasumi.c - kasumi_kasumi_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la --kasumi_kasumi_test_LDFLAGS = -static - - comp128_comp128_test_SOURCES = comp128/comp128_test.c - comp128_comp128_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la --- -2.0.0 - diff --git a/osmo-talloc.diff b/osmo-talloc.diff index 9aef851..1a65f37 100644 --- a/osmo-talloc.diff +++ b/osmo-talloc.diff @@ -1,11 +1,13 @@ -From 69015be0dfe88476d80895aa3261ab64223c664c Mon Sep 17 00:00:00 2001 +From c1d2d27e87686969b02f86475fe3fb4967ba5872 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sun, 17 Feb 2013 20:23:09 +0100 -Subject: [PATCH 2/4] build: resolve link failure in libosmogsm when +Subject: [PATCH 1/3] build: resolve link failure in libosmogsm when --disable-talloc is used -The link stage fails at some point. libosmogsm.so:lapd-core.c uses -talloc_free, but does not link to libtalloc.so. Correct this. +libosmogsm.so:lapd-core.c uses talloc_free unconditionally (like +libosmocore), but in the absence of the builtin talloc, does not link +to libtalloc.so (like libosmocore would). This causes linker failures +when programs using libosmogsm are being built. Correct this issue. CCLD osmo-arfcn ../src/gsm/.libs/libosmogsm.so: undefined reference to `talloc_free' @@ -16,15 +18,15 @@ talloc_free, but does not link to libtalloc.so. Correct this. 1 file changed, 3 insertions(+) diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am -index 46698cd..c471b45 100644 +index 828aa50..b0cdea2 100644 --- a/src/gsm/Makefile.am +++ b/src/gsm/Makefile.am -@@ -23,5 +23,8 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ +@@ -24,5 +24,8 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la +if !ENABLE_TALLOC -+libosmogsm_la_LIBDADD = -ltalloc ++libosmogsm_la_LIBADD += -ltalloc +endif EXTRA_DIST = libosmogsm.map diff --git a/osmo-talloc2.diff b/osmo-talloc2.diff index 2dbca42..8a3a63f 100644 --- a/osmo-talloc2.diff +++ b/osmo-talloc2.diff @@ -1,31 +1,602 @@ -From e539a62cadc2d182ed5fff77da86d8ab727d6dbe Mon Sep 17 00:00:00 2001 +From 9177b5bee459896aa8e3a33d2e279643dd15db63 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt -Date: Sun, 17 Feb 2013 21:13:29 +0100 -Subject: [PATCH 3/4] build: always install our talloc.h +Date: Fri, 3 Oct 2014 12:06:47 +0200 +Subject: [PATCH 1/2] build: allow using a system-provided talloc properly -Next-level packages like libosmo-abis strictly depend on -, therefore always ship this file. When -distributions are using --disable-talloc to use a system talloc -instead of the shipped copy, they will simply have to overwrite -osmocom/core/talloc.h with the single line #include . +When --disable-talloc was given to configure, it would already link +libosmocore.so to libtalloc. Make it use pkg-config to discover +talloc's flags and location, and when the system talloc is used, +make sure to use its API header file too. --- - include/Makefile.am | 2 -- - 1 file changed, 2 deletions(-) + .gitignore | 1 + + configure.ac | 16 +++- + include/Makefile.am | 3 +- + include/osmocom/core/talloc.h | 189 -------------------------------------- + include/osmocom/core/talloc.h.in | 6 ++ + include/osmocom/core/talloc_int.h | 189 ++++++++++++++++++++++++++++++++++++++ + src/Makefile.am | 5 +- + src/gsm/Makefile.am | 8 +- + tests/Makefile.am | 12 +-- + tests/msgfile/msgfile_test.c | 1 + + 10 files changed, 226 insertions(+), 204 deletions(-) + delete mode 100644 include/osmocom/core/talloc.h + create mode 100644 include/osmocom/core/talloc.h.in + create mode 100644 include/osmocom/core/talloc_int.h +diff --git a/.gitignore b/.gitignore +index 1299028..30707a6 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -92,6 +92,7 @@ doc/html.tar + src/crc*gen.c + include/osmocom/core/crc*gen.h + include/osmocom/core/bit*gen.h ++/include/osmocom/core/talloc.h + + # vi files + *.sw? +diff --git a/configure.ac b/configure.ac +index deaa8bf..f0d1206 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -85,10 +85,23 @@ AC_CONFIG_HEADER(config.h) + AC_ARG_ENABLE(talloc, + [AS_HELP_STRING( + [--disable-talloc], +- [Disable building talloc memory allocator] ++ [Disable using bundled talloc memory allocator] + )], + [enable_talloc=$enableval], [enable_talloc="yes"]) + AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) ++AS_IF([test x"$enable_talloc" = xno], ++ [ ++ PKG_CHECK_MODULES([TALLOC], [talloc]) ++ OSMOCORE_INTERNAL_TALLOC=0 ++ ], ++ [ ++ TALLOC_CFLAGS="" ++ TALLOC_LIBS="" ++ OSMOCORE_INTERNAL_TALLOC=1 ++ AC_SUBST([TALLOC_CFLAGS]) ++ AC_SUBST([TALLOC_LIBS]) ++ ]) ++AC_SUBST([OSMOCORE_INTERNAL_TALLOC]) + + AC_ARG_ENABLE(plugin, + [AS_HELP_STRING( +@@ -188,6 +201,7 @@ AC_OUTPUT( + libosmogb.pc + libosmoctrl.pc + include/Makefile ++ include/osmocom/core/talloc.h + src/Makefile + src/vty/Makefile + src/codec/Makefile diff --git a/include/Makefile.am b/include/Makefile.am -index b035906..2db13ae 100644 +index c59f9b2..4d59a72 100644 --- a/include/Makefile.am +++ b/include/Makefile.am -@@ -81,9 +81,7 @@ if ENABLE_PLUGIN +@@ -89,8 +89,9 @@ if ENABLE_PLUGIN nobase_include_HEADERS += osmocom/core/plugin.h endif --if ENABLE_TALLOC - nobase_include_HEADERS += osmocom/core/talloc.h --endif ++nobase_nodist_include_HEADERS = osmocom/core/talloc.h + if ENABLE_TALLOC +-nobase_include_HEADERS += osmocom/core/talloc.h ++nobase_include_HEADERS += osmocom/core/talloc_int.h + endif if ENABLE_MSGFILE - nobase_include_HEADERS += osmocom/core/msgfile.h +diff --git a/include/osmocom/core/talloc.h b/include/osmocom/core/talloc.h +deleted file mode 100644 +index dde102b..0000000 +--- a/include/osmocom/core/talloc.h ++++ /dev/null +@@ -1,189 +0,0 @@ +-#pragma once +-/* +- Unix SMB/CIFS implementation. +- Samba temporary memory allocation functions +- +- Copyright (C) Andrew Tridgell 2004-2005 +- Copyright (C) Stefan Metzmacher 2006 +- +- ** NOTE! The following LGPL license applies to the talloc +- ** library. This does NOT imply that all of Samba is released +- ** under the LGPL +- +- This library is free software; you can redistribute it and/or +- modify it under the terms of the GNU Lesser General Public +- License as published by the Free Software Foundation; either +- version 3 of the License, or (at your option) any later version. +- +- This library is distributed in the hope that it will be useful, +- but WITHOUT ANY WARRANTY; without even the implied warranty of +- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- Lesser General Public License for more details. +- +- You should have received a copy of the GNU Lesser General Public +- License along with this library; if not, see . +-*/ +- +-#include +-#include +-#include +- +-#define HAVE_VA_COPY +- +-/* this is only needed for compatibility with the old talloc */ +-typedef void TALLOC_CTX; +- +-/* +- this uses a little trick to allow __LINE__ to be stringified +-*/ +-#ifndef __location__ +-#define __TALLOC_STRING_LINE1__(s) #s +-#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) +-#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) +-#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ +-#endif +- +-#ifndef TALLOC_DEPRECATED +-#define TALLOC_DEPRECATED 0 +-#endif +- +-#ifndef PRINTF_ATTRIBUTE +-#if (__GNUC__ >= 3) +-/** Use gcc attribute to check printf fns. a1 is the 1-based index of +- * the parameter containing the format, and a2 the index of the first +- * argument. Note that some gcc 2.x versions don't handle this +- * properly **/ +-#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) +-#else +-#define PRINTF_ATTRIBUTE(a1, a2) +-#endif +-#endif +- +-/* try to make talloc_set_destructor() and talloc_steal() type safe, +- if we have a recent gcc */ +-#if (__GNUC__ >= 3) +-#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) +-#define talloc_set_destructor(ptr, function) \ +- do { \ +- int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ +- _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ +- } while(0) +-/* this extremely strange macro is to avoid some braindamaged warning +- stupidity in gcc 4.1.x */ +-#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) +-#else +-#define talloc_set_destructor(ptr, function) \ +- _talloc_set_destructor((ptr), (int (*)(void *))(function)) +-#define _TALLOC_TYPEOF(ptr) void * +-#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) +-#endif +- +-#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) +-#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) +- +-/* useful macros for creating type checked pointers */ +-#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) +-#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) +-#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) +- +-#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) +- +-#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) +-#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) +- +-#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) +-#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) +-#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) +-#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) +-#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx)) +- +-#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) +-#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) +- +-#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) +- +-#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) +-#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) +-#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__) +- +-#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) +- +-#if TALLOC_DEPRECATED +-#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) +-#define talloc_p(ctx, type) talloc(ctx, type) +-#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) +-#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) +-#define talloc_destroy(ctx) talloc_free(ctx) +-#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) +-#endif +- +-#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) +- +-/* The following definitions come from talloc.c */ +-void *_talloc(const void *context, size_t size); +-void *talloc_pool(const void *context, size_t size); +-void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *)); +-int talloc_increase_ref_count(const void *ptr); +-size_t talloc_reference_count(const void *ptr); +-void *_talloc_reference(const void *context, const void *ptr); +-int talloc_unlink(const void *context, void *ptr); +-const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +-void talloc_set_name_const(const void *ptr, const char *name); +-void *talloc_named(const void *context, size_t size, +- const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); +-void *talloc_named_const(const void *context, size_t size, const char *name); +-const char *talloc_get_name(const void *ptr); +-void *talloc_check_name(const void *ptr, const char *name); +-void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location); +-void *talloc_parent(const void *ptr); +-const char *talloc_parent_name(const void *ptr); +-void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); +-int talloc_free(void *ptr); +-void talloc_free_children(void *ptr); +-void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); +-void *_talloc_steal(const void *new_ctx, const void *ptr); +-void *_talloc_move(const void *new_ctx, const void *pptr); +-size_t talloc_total_size(const void *ptr); +-size_t talloc_total_blocks(const void *ptr); +-void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, +- void (*callback)(const void *ptr, +- int depth, int max_depth, +- int is_ref, +- void *private_data), +- void *private_data); +-void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); +-void talloc_report_full(const void *ptr, FILE *f); +-void talloc_report(const void *ptr, FILE *f); +-void talloc_enable_null_tracking(void); +-void talloc_disable_null_tracking(void); +-void talloc_enable_leak_report(void); +-void talloc_enable_leak_report_full(void); +-void *_talloc_zero(const void *ctx, size_t size, const char *name); +-void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); +-void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); +-void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); +-void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); +-void *talloc_realloc_fn(const void *context, void *ptr, size_t size); +-void *talloc_autofree_context(void); +-size_t talloc_get_size(const void *ctx); +-void *talloc_find_parent_byname(const void *ctx, const char *name); +-void talloc_show_parents(const void *context, FILE *file); +-int talloc_is_parent(const void *context, const void *ptr); +- +-char *talloc_strdup(const void *t, const char *p); +-char *talloc_strdup_append(char *s, const char *a); +-char *talloc_strdup_append_buffer(char *s, const char *a); +- +-char *talloc_strndup(const void *t, const char *p, size_t n); +-char *talloc_strndup_append(char *s, const char *a, size_t n); +-char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); +- +-char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +-char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +-char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); +- +-char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +-char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +-char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); +- +-void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); +diff --git a/include/osmocom/core/talloc.h.in b/include/osmocom/core/talloc.h.in +new file mode 100644 +index 0000000..edbbb63 +--- /dev/null ++++ b/include/osmocom/core/talloc.h.in +@@ -0,0 +1,6 @@ ++#pragma once ++#if @OSMOCORE_INTERNAL_TALLOC@ ++#include ++#else ++#include ++#endif +diff --git a/include/osmocom/core/talloc_int.h b/include/osmocom/core/talloc_int.h +new file mode 100644 +index 0000000..dde102b +--- /dev/null ++++ b/include/osmocom/core/talloc_int.h +@@ -0,0 +1,189 @@ ++#pragma once ++/* ++ Unix SMB/CIFS implementation. ++ Samba temporary memory allocation functions ++ ++ Copyright (C) Andrew Tridgell 2004-2005 ++ Copyright (C) Stefan Metzmacher 2006 ++ ++ ** NOTE! The following LGPL license applies to the talloc ++ ** library. This does NOT imply that all of Samba is released ++ ** under the LGPL ++ ++ This library is free software; you can redistribute it and/or ++ modify it under the terms of the GNU Lesser General Public ++ License as published by the Free Software Foundation; either ++ version 3 of the License, or (at your option) any later version. ++ ++ This library is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ Lesser General Public License for more details. ++ ++ You should have received a copy of the GNU Lesser General Public ++ License along with this library; if not, see . ++*/ ++ ++#include ++#include ++#include ++ ++#define HAVE_VA_COPY ++ ++/* this is only needed for compatibility with the old talloc */ ++typedef void TALLOC_CTX; ++ ++/* ++ this uses a little trick to allow __LINE__ to be stringified ++*/ ++#ifndef __location__ ++#define __TALLOC_STRING_LINE1__(s) #s ++#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s) ++#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__) ++#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__ ++#endif ++ ++#ifndef TALLOC_DEPRECATED ++#define TALLOC_DEPRECATED 0 ++#endif ++ ++#ifndef PRINTF_ATTRIBUTE ++#if (__GNUC__ >= 3) ++/** Use gcc attribute to check printf fns. a1 is the 1-based index of ++ * the parameter containing the format, and a2 the index of the first ++ * argument. Note that some gcc 2.x versions don't handle this ++ * properly **/ ++#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2))) ++#else ++#define PRINTF_ATTRIBUTE(a1, a2) ++#endif ++#endif ++ ++/* try to make talloc_set_destructor() and talloc_steal() type safe, ++ if we have a recent gcc */ ++#if (__GNUC__ >= 3) ++#define _TALLOC_TYPEOF(ptr) __typeof__(ptr) ++#define talloc_set_destructor(ptr, function) \ ++ do { \ ++ int (*_talloc_destructor_fn)(_TALLOC_TYPEOF(ptr)) = (function); \ ++ _talloc_set_destructor((ptr), (int (*)(void *))_talloc_destructor_fn); \ ++ } while(0) ++/* this extremely strange macro is to avoid some braindamaged warning ++ stupidity in gcc 4.1.x */ ++#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)); __talloc_steal_ret; }) ++#else ++#define talloc_set_destructor(ptr, function) \ ++ _talloc_set_destructor((ptr), (int (*)(void *))(function)) ++#define _TALLOC_TYPEOF(ptr) void * ++#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr)) ++#endif ++ ++#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr)) ++#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr)) ++ ++/* useful macros for creating type checked pointers */ ++#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type) ++#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) ++#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr))) ++ ++#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__) ++ ++#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type) ++#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__) ++ ++#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type) ++#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type) ++#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__) ++#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count) ++#define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx)) ++ ++#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type) ++#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__) ++ ++#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__) ++ ++#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type) ++#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type) ++#define talloc_get_type_abort(ptr, type) (type *)_talloc_get_type_abort(ptr, #type, __location__) ++ ++#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type) ++ ++#if TALLOC_DEPRECATED ++#define talloc_zero_p(ctx, type) talloc_zero(ctx, type) ++#define talloc_p(ctx, type) talloc(ctx, type) ++#define talloc_array_p(ctx, type, count) talloc_array(ctx, type, count) ++#define talloc_realloc_p(ctx, p, type, count) talloc_realloc(ctx, p, type, count) ++#define talloc_destroy(ctx) talloc_free(ctx) ++#define talloc_append_string(c, s, a) (s?talloc_strdup_append(s,a):talloc_strdup(c, a)) ++#endif ++ ++#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0) ++ ++/* The following definitions come from talloc.c */ ++void *_talloc(const void *context, size_t size); ++void *talloc_pool(const void *context, size_t size); ++void _talloc_set_destructor(const void *ptr, int (*_destructor)(void *)); ++int talloc_increase_ref_count(const void *ptr); ++size_t talloc_reference_count(const void *ptr); ++void *_talloc_reference(const void *context, const void *ptr); ++int talloc_unlink(const void *context, void *ptr); ++const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); ++void talloc_set_name_const(const void *ptr, const char *name); ++void *talloc_named(const void *context, size_t size, ++ const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); ++void *talloc_named_const(const void *context, size_t size, const char *name); ++const char *talloc_get_name(const void *ptr); ++void *talloc_check_name(const void *ptr, const char *name); ++void *_talloc_get_type_abort(const void *ptr, const char *name, const char *location); ++void *talloc_parent(const void *ptr); ++const char *talloc_parent_name(const void *ptr); ++void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2); ++int talloc_free(void *ptr); ++void talloc_free_children(void *ptr); ++void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name); ++void *_talloc_steal(const void *new_ctx, const void *ptr); ++void *_talloc_move(const void *new_ctx, const void *pptr); ++size_t talloc_total_size(const void *ptr); ++size_t talloc_total_blocks(const void *ptr); ++void talloc_report_depth_cb(const void *ptr, int depth, int max_depth, ++ void (*callback)(const void *ptr, ++ int depth, int max_depth, ++ int is_ref, ++ void *private_data), ++ void *private_data); ++void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f); ++void talloc_report_full(const void *ptr, FILE *f); ++void talloc_report(const void *ptr, FILE *f); ++void talloc_enable_null_tracking(void); ++void talloc_disable_null_tracking(void); ++void talloc_enable_leak_report(void); ++void talloc_enable_leak_report_full(void); ++void *_talloc_zero(const void *ctx, size_t size, const char *name); ++void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name); ++void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name); ++void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name); ++void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name); ++void *talloc_realloc_fn(const void *context, void *ptr, size_t size); ++void *talloc_autofree_context(void); ++size_t talloc_get_size(const void *ctx); ++void *talloc_find_parent_byname(const void *ctx, const char *name); ++void talloc_show_parents(const void *context, FILE *file); ++int talloc_is_parent(const void *context, const void *ptr); ++ ++char *talloc_strdup(const void *t, const char *p); ++char *talloc_strdup_append(char *s, const char *a); ++char *talloc_strdup_append_buffer(char *s, const char *a); ++ ++char *talloc_strndup(const void *t, const char *p, size_t n); ++char *talloc_strndup_append(char *s, const char *a, size_t n); ++char *talloc_strndup_append_buffer(char *s, const char *a, size_t n); ++ ++char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); ++char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); ++char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0); ++ ++char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); ++char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); ++char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3); ++ ++void talloc_set_abort_fn(void (*abort_fn)(const char *reason)); +diff --git a/src/Makefile.am b/src/Makefile.am +index 65494a5..3924330 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -2,7 +2,8 @@ + # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification + LIBVERSION=5:0:0 + +-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include ++AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ ++ $(TALLOC_CFLAGS) + AM_CFLAGS = -Wall + + lib_LTLIBRARIES = libosmocore.la +@@ -29,7 +30,7 @@ endif + if ENABLE_TALLOC + libosmocore_la_SOURCES += talloc.c + else +-libosmocore_la_LIBADD += -ltalloc ++libosmocore_la_LIBADD += $(TALLOC_LIBS) + endif + + if ENABLE_MSGFILE +diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am +index b0cdea2..40a1821 100644 +--- a/src/gsm/Makefile.am ++++ b/src/gsm/Makefile.am +@@ -2,7 +2,8 @@ + # Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification + LIBVERSION=6:0:1 + +-AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include ++AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include \ ++ $(TALLOC_CFLAGS) + AM_CFLAGS = -Wall ${GCC_FVISIBILITY_HIDDEN} + + # FIXME: this should eventually go into a milenage/Makefile.am +@@ -23,9 +24,6 @@ libosmogsm_la_SOURCES = a5.c rxlev_stat.c tlv_parser.c comp128.c comp128v23.c \ + milenage/milenage.c gan.c ipa.c + + libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined +-libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la +-if !ENABLE_TALLOC +-libosmogsm_la_LIBADD += -ltalloc +-endif ++libosmogsm_la_LIBADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) + + EXTRA_DIST = libosmogsm.map +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 3f7db1f..9f034c0 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -1,4 +1,4 @@ +-AM_CPPFLAGS = -I$(top_srcdir)/include ++AM_CPPFLAGS = -I$(top_srcdir)/include $(TALLOC_CFLAGS) + AM_CFLAGS = -Wall + + check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \ +@@ -45,7 +45,7 @@ lapd_lapd_test_SOURCES = lapd/lapd_test.c + lapd_lapd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la + + msgfile_msgfile_test_SOURCES = msgfile/msgfile_test.c +-msgfile_msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la ++msgfile_msgfile_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) + + smscb_smscb_test_SOURCES = smscb/smscb_test.c + smscb_smscb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la +@@ -54,13 +54,13 @@ sms_sms_test_SOURCES = sms/sms_test.c + sms_sms_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la + + timer_timer_test_SOURCES = timer/timer_test.c +-timer_timer_test_LDADD = $(top_builddir)/src/libosmocore.la ++timer_timer_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) + + ussd_ussd_test_SOURCES = ussd/ussd_test.c + ussd_ussd_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gsm/libosmogsm.la + + gb_bssgp_fc_test_SOURCES = gb/bssgp_fc_test.c +-gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la ++gb_bssgp_fc_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(TALLOC_LIBS) + + gb_gprs_ns_test_SOURCES = gb/gprs_ns_test.c + gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(LIBRARY_DL) +@@ -75,10 +75,10 @@ loggingrb_loggingrb_test_SOURCES = logging/logging_test.c + loggingrb_loggingrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/vty/libosmovty.la + + strrb_strrb_test_SOURCES = strrb/strrb_test.c +-strrb_strrb_test_LDADD = $(top_builddir)/src/libosmocore.la ++strrb_strrb_test_LDADD = $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) + + vty_vty_test_SOURCES = vty/vty_test.c +-vty_vty_test_LDADD = $(top_builddir)/src/vty/libosmovty.la $(top_builddir)/src/libosmocore.la ++vty_vty_test_LDADD = $(top_builddir)/src/vty/libosmovty.la $(top_builddir)/src/libosmocore.la $(TALLOC_LIBS) + + + # The `:;' works around a Bash 3.2 bug when the output is not writeable. +diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c +index a919694..2684b6a 100644 +--- a/tests/msgfile/msgfile_test.c ++++ b/tests/msgfile/msgfile_test.c +@@ -20,6 +20,7 @@ + */ + + #include ++#include + + #include + -- 2.0.0 diff --git a/osmo-talloc3.diff b/osmo-talloc3.diff new file mode 100644 index 0000000..f945b11 --- /dev/null +++ b/osmo-talloc3.diff @@ -0,0 +1,76 @@ +From d6c1607a724a07416c7d39f9b43f7af7349de666 Mon Sep 17 00:00:00 2001 +From: Jan Engelhardt +Date: Fri, 3 Oct 2014 12:14:17 +0200 +Subject: [PATCH 2/2] build: default to system-provided talloc + +Rename the option --enable-talloc to --enable-internal-talloc, and +then make disable-internal-talloc the default when nothing else is +specified. +--- + configure.ac | 12 ++++++------ + include/Makefile.am | 2 +- + src/Makefile.am | 2 +- + 3 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/configure.ac b/configure.ac +index f0d1206..f12675a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -82,14 +82,14 @@ CHECK_TM_INCLUDES_TM_GMTOFF + dnl Generate the output + AC_CONFIG_HEADER(config.h) + +-AC_ARG_ENABLE(talloc, ++AC_ARG_ENABLE([internal-talloc], + [AS_HELP_STRING( +- [--disable-talloc], ++ [--enable-internal-talloc], + [Disable using bundled talloc memory allocator] + )], +- [enable_talloc=$enableval], [enable_talloc="yes"]) +-AM_CONDITIONAL(ENABLE_TALLOC, [test x"$enable_talloc" = x"yes"]) +-AS_IF([test x"$enable_talloc" = xno], ++ [internal_talloc=$enableval], [internal_talloc="no"]) ++AM_CONDITIONAL([INTERNAL_TALLOC], [test x"$internal_talloc" = x"yes"]) ++AS_IF([test x"$internal_talloc" = xno], + [ + PKG_CHECK_MODULES([TALLOC], [talloc]) + OSMOCORE_INTERNAL_TALLOC=0 +@@ -186,7 +186,7 @@ then + AM_CONDITIONAL(ENABLE_MSGFILE, false) + AM_CONDITIONAL(ENABLE_SERIAL, false) + AM_CONDITIONAL(ENABLE_VTY, false) +- AM_CONDITIONAL(ENABLE_TALLOC, false) ++ AM_CONDITIONAL([INTERNAL_TALLOC], [true]) + AM_CONDITIONAL(ENABLE_UTILITIES, false) + AM_CONDITIONAL(ENABLE_GB, false) + AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort]) +diff --git a/include/Makefile.am b/include/Makefile.am +index 4d59a72..d8af474 100644 +--- a/include/Makefile.am ++++ b/include/Makefile.am +@@ -90,7 +90,7 @@ nobase_include_HEADERS += osmocom/core/plugin.h + endif + + nobase_nodist_include_HEADERS = osmocom/core/talloc.h +-if ENABLE_TALLOC ++if INTERNAL_TALLOC + nobase_include_HEADERS += osmocom/core/talloc_int.h + endif + +diff --git a/src/Makefile.am b/src/Makefile.am +index 3924330..4a6ba5c 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -27,7 +27,7 @@ else + libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined + endif + +-if ENABLE_TALLOC ++if INTERNAL_TALLOC + libosmocore_la_SOURCES += talloc.c + else + libosmocore_la_LIBADD += $(TALLOC_LIBS) +-- +2.0.0 +