Jan Engelhardt 2015-12-23 18:02:48 +00:00 committed by Git OBS Bridge
parent 62eaf3e2f3
commit 3a49b5c4e9
7 changed files with 18 additions and 707 deletions

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f5e46570cabb48d92a9f3dc75d87c30625104e7ea1b49b9dd9a6020d4499af69
size 391596

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4fcecc0a9a7208bd9a0f25914db3fdf322f4d9385bf0609d85c6042ad268b356
size 396644

View File

@ -8,7 +8,11 @@ Wed Dec 23 17:19:46 UTC 2015 - jengelh@inai.de
* stats/vty: Add stats configuration
* stat/vty: Add vty_out_statistics_full to show all statistics
* stats: Add vty_out_stat_item_group
- Drop osmo-symbols.diff (solved better upstream)
* LaPDm: Refuse SUSPEND/RESUME/RECONNECT in BTS mode
* ns: Force a defined state when sending NS RESET
- Drop osmo-symbols.diff (solved better upstream),
osmo-talloc.diff, osmo-talloc2.diff, osmo-talloc3.diff (solved
upstream)
-------------------------------------------------------------------
Thu Sep 10 21:13:26 UTC 2015 - jengelh@inai.de

View File

@ -17,7 +17,7 @@
Name: libosmocore
Version: 0.9.0
Version: 0.9.0.45
Release: 0
Summary: Open Source Mobile Communications Core Library
License: GPL-2.0 and GPL-2.0+ and LGPL-3.0+ and AGPL-3.0+
@ -25,11 +25,8 @@ Group: Productivity/Telephony/Utilities
Url: http://bb.osmocom.org/trac/wiki/libosmocore
#Git-Clone: git://git.osmocom.org/libosmocore
#Update osmo-version.diff too!
#Snapshot: 0.9.0-45-ga2db75f
Source: %name-%version.tar.xz
Patch1: osmo-talloc.diff
Patch2: osmo-talloc2.diff
Patch3: osmo-talloc3.diff
Patch4: osmo-pkgconfig.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: autoconf
@ -96,14 +93,14 @@ communications.
This subpackage contains libraries and header files for developing
applications that want to make use of libosmocodec.
%package -n libosmocore6
%package -n libosmocore7
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 libosmocore6
%description -n libosmocore7
libosmocore is a library with various utility functions shared
between OpenBSC and OsmocomBB.
@ -112,7 +109,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: libosmocore6 = %version
Requires: libosmocore7 = %version
Requires: libtalloc-devel
%description -n libosmocore-devel
@ -268,7 +265,7 @@ applications that want to make use of libosmovty.
%prep
%setup -qn %name
%patch -P 1 -P 2 -P 3 -P 4 -p1
%patch -P 4 -p1
%build
echo "%version" >.tarball-version
@ -286,8 +283,8 @@ make %{?_smp_mflags} check
%post -n libosmocodec0 -p /sbin/ldconfig
%postun -n libosmocodec0 -p /sbin/ldconfig
%post -n libosmocore6 -p /sbin/ldconfig
%postun -n libosmocore6 -p /sbin/ldconfig
%post -n libosmocore7 -p /sbin/ldconfig
%postun -n libosmocore7 -p /sbin/ldconfig
%post -n libosmoctrl0 -p /sbin/ldconfig
%postun -n libosmoctrl0 -p /sbin/ldconfig
%post -n libosmogb4 -p /sbin/ldconfig
@ -314,9 +311,9 @@ make %{?_smp_mflags} check
%_libdir/libosmocodec.so
%_libdir/pkgconfig/libosmocodec.pc
%files -n libosmocore6
%files -n libosmocore7
%defattr(-,root,root)
%_libdir/libosmocore.so.6*
%_libdir/libosmocore.so.7*
%files -n libosmocore-devel
%defattr(-,root,root)

View File

@ -1,32 +0,0 @@
From c1d2d27e87686969b02f86475fe3fb4967ba5872 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Sun, 17 Feb 2013 20:23:09 +0100
Subject: [PATCH 1/3] build: resolve link failure in libosmogsm when
--disable-talloc is used
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'
collect2: error: ld returned 1 exit status
make[2]: *** [osmo-arfcn] Error 1
---
src/gsm/Makefile.am | 3 +++
1 file changed, 3 insertions(+)
Index: libosmocore/src/gsm/Makefile.am
===================================================================
--- libosmocore.orig/src/gsm/Makefile.am
+++ libosmocore/src/gsm/Makefile.am
@@ -28,5 +28,8 @@ libgsmint_la_LIBADD = ../libosmocore.la
libosmogsm_la_SOURCES =
libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined
libosmogsm_la_LIBADD = libgsmint.la
+if !ENABLE_TALLOC
+libosmogsm_la_LIBADD += $(TALLOC_LIBS)
+endif
EXTRA_DIST = libosmogsm.map

View File

@ -1,585 +0,0 @@
From 9177b5bee459896aa8e3a33d2e279643dd15db63 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Fri, 3 Oct 2014 12:06:47 +0200
Subject: [PATCH 1/2] build: allow using a system-provided talloc properly
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.
---
.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 +-
9 files changed, 225 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
Index: libosmocore/.gitignore
===================================================================
--- libosmocore.orig/.gitignore
+++ libosmocore/.gitignore
@@ -97,6 +97,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?
Index: libosmocore/configure.ac
===================================================================
--- libosmocore.orig/configure.ac
+++ libosmocore/configure.ac
@@ -97,10 +97,23 @@ AM_CONDITIONAL(ENABLE_PCSC, test "x$enab
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(
@@ -201,6 +214,7 @@ AC_OUTPUT(
libosmoctrl.pc
libosmosim.pc
include/Makefile
+ include/osmocom/core/talloc.h
src/Makefile
src/vty/Makefile
src/codec/Makefile
Index: libosmocore/include/Makefile.am
===================================================================
--- libosmocore.orig/include/Makefile.am
+++ libosmocore/include/Makefile.am
@@ -96,8 +96,9 @@ if ENABLE_PLUGIN
nobase_include_HEADERS += osmocom/core/plugin.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
Index: libosmocore/include/osmocom/core/talloc.h
===================================================================
--- libosmocore.orig/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 <http://www.gnu.org/licenses/>.
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-#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));
Index: libosmocore/include/osmocom/core/talloc.h.in
===================================================================
--- /dev/null
+++ libosmocore/include/osmocom/core/talloc.h.in
@@ -0,0 +1,6 @@
+#pragma once
+#if @OSMOCORE_INTERNAL_TALLOC@
+#include <osmocom/core/talloc_int.h>
+#else
+#include <talloc.h>
+#endif
Index: libosmocore/include/osmocom/core/talloc_int.h
===================================================================
--- /dev/null
+++ libosmocore/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 <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#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));
Index: libosmocore/src/Makefile.am
===================================================================
--- libosmocore.orig/src/Makefile.am
+++ libosmocore/src/Makefile.am
@@ -2,7 +2,8 @@
# Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification
LIBVERSION=6: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
Index: libosmocore/src/gsm/Makefile.am
===================================================================
--- libosmocore.orig/src/gsm/Makefile.am
+++ libosmocore/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
@@ -27,9 +28,6 @@ libgsmint_la_LIBADD = ../libosmocore.la
libosmogsm_la_SOURCES =
libosmogsm_la_LDFLAGS = $(LTLDFLAGS_OSMOGSM) -version-info $(LIBVERSION) -no-undefined
-libosmogsm_la_LIBADD = libgsmint.la
-if !ENABLE_TALLOC
-libosmogsm_la_LIBADD += $(TALLOC_LIBS)
-endif
+libosmogsm_la_LIBADD = libgsmint.la $(TALLOC_LIBS)
EXTRA_DIST = libosmogsm.map
Index: libosmocore/tests/Makefile.am
===================================================================
--- libosmocore.orig/tests/Makefile.am
+++ libosmocore/tests/Makefile.am
@@ -1,4 +1,4 @@
-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
check_PROGRAMS = timer/timer_test sms/sms_test ussd/ussd_test \
@@ -49,7 +49,7 @@ lapd_lapd_test_SOURCES = lapd/lapd_test.
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
@@ -61,7 +61,7 @@ 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
@@ -73,7 +73,7 @@ gb_gprs_bssgp_test_SOURCES = gb/gprs_bss
gb_gprs_bssgp_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(top_builddir)/src/vty/libosmovty.la $(LIBRARY_DL)
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 $(top_builddir)/src/vty/libosmovty.la $(LIBRARY_DL)
+gb_gprs_ns_test_LDADD = $(top_builddir)/src/libosmocore.la $(top_builddir)/src/gb/libosmogb.la $(top_builddir)/src/vty/libosmovty.la $(LIBRARY_DL) $(TALLOC_LIBS)
logging_logging_test_SOURCES = logging/logging_test.c
logging_logging_test_LDADD = $(top_builddir)/src/libosmocore.la
@@ -85,10 +85,10 @@ loggingrb_loggingrb_test_SOURCES = loggi
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.

View File

@ -1,73 +0,0 @@
From d6c1607a724a07416c7d39f9b43f7af7349de666 Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
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(-)
Index: libosmocore/configure.ac
===================================================================
--- libosmocore.orig/configure.ac
+++ libosmocore/configure.ac
@@ -94,14 +94,14 @@ if test "x$enable_pcsc" = "xyes" ; then
fi
AM_CONDITIONAL(ENABLE_PCSC, test "x$enable_pcsc" = "xyes")
-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
@@ -198,7 +198,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])
Index: libosmocore/include/Makefile.am
===================================================================
--- libosmocore.orig/include/Makefile.am
+++ libosmocore/include/Makefile.am
@@ -97,7 +97,7 @@ nobase_include_HEADERS += osmocom/core/p
endif
nobase_nodist_include_HEADERS = osmocom/core/talloc.h
-if ENABLE_TALLOC
+if INTERNAL_TALLOC
nobase_include_HEADERS += osmocom/core/talloc_int.h
endif
Index: libosmocore/src/Makefile.am
===================================================================
--- libosmocore.orig/src/Makefile.am
+++ libosmocore/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)