Discussion:
libosmocore: to talloc or not to talloc
Jan Engelhardt
2014-10-04 09:10:20 UTC
Permalink
Changes to previous submission:

- split out the implicit declaration patch (p3 -> p3,p1)
- edit libosmocore.pc to include Requires: pkgconfig. (in p3)
- add (p5) as an optional commit to completely remove the bundled copy

The antisymmetry of osmo_config_list_parse is a matter for a
subsequent submission.
===
The following changes since commit c60de4f35f3f73f3d79b4ff61d0a20b92f818702:

build: fix linker error with kasumi_test (2014-10-03 08:48:31 +0200)

are available in the git repository at:

git://git.inai.de/libosmocore HEAD

for you to fetch changes up to a962cd7b62b92a0acc49591d9b3af2b46e023850:

build: remove bundled copy of talloc (2014-10-04 11:06:44 +0200)

----------------------------------------------------------------
Jan Engelhardt (5):
build: resolve compiler warning about implicit delcaration
build: resolve link failure in libosmogsm when --disable-talloc is used
build: allow using a system-provided talloc properly
build: default to system-provided talloc
build: remove bundled copy of talloc

Makefile.am | 2 +
configure.ac | 9 +-
include/Makefile.am | 4 -
include/osmocom/core/strrb.h | 2 +-
include/osmocom/core/talloc.h | 189 -------------------------------------
include/osmocom/core/utils.h | 2 +-
include/osmocom/ctrl/control_cmd.h | 2 +-
libosmocore.pc.in | 2 +-
src/Makefile.am | 10 +-
src/ctrl/control_cmd.c | 2 +-
src/ctrl/control_if.c | 2 +-
src/gb/common_vty.c | 2 +-
src/gb/gprs_bssgp.c | 2 +-
src/gb/gprs_bssgp_bss.c | 2 +-
src/gb/gprs_bssgp_util.c | 2 +-
src/gb/gprs_bssgp_vty.c | 2 +-
src/gb/gprs_ns.c | 2 +-
src/gb/gprs_ns_frgre.c | 2 +-
src/gb/gprs_ns_vty.c | 2 +-
src/gsm/Makefile.am | 5 +-
src/gsm/ipa.c | 2 +-
src/gsm/lapd_core.c | 2 +-
src/gsmtap_util.c | 2 +-
src/logging.c | 2 +-
src/logging_syslog.c | 2 +-
src/msgb.c | 2 +-
src/msgfile.c | 2 +-
src/rate_ctr.c | 2 +-
src/signal.c | 2 +-
src/statistics.c | 2 +-
src/talloc.c | 2 +-
src/vty/buffer.c | 2 +-
src/vty/command.c | 2 +-
src/vty/logging_vty.c | 2 +-
src/vty/telnet_interface.c | 2 +-
src/vty/utils.c | 2 +-
src/vty/vector.c | 2 +-
src/vty/vty.c | 2 +-
tests/Makefile.am | 12 +--
tests/gb/bssgp_fc_test.c | 2 +-
tests/gb/gprs_ns_test.c | 2 +-
tests/msgfile/msgfile_test.c | 1 +
tests/strrb/strrb_test.c | 2 +-
tests/timer/timer_test.c | 2 +-
tests/vty/vty_test.c | 2 +-
45 files changed, 53 insertions(+), 253 deletions(-)
delete mode 100644 include/osmocom/core/talloc.h
Jan Engelhardt
2014-10-04 09:10:22 UTC
Permalink
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(+)

diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index 828aa50..b0cdea2 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -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_LIBADD += -ltalloc
+endif

EXTRA_DIST = libosmogsm.map
--
2.0.0
Jan Engelhardt
2014-10-04 09:10:23 UTC
Permalink
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 +
Makefile.am | 2 ++
configure.ac | 16 +++++++++++++++-
include/Makefile.am | 3 ++-
include/osmocom/core/talloc.h.in | 6 ++++++
include/osmocom/core/{talloc.h => talloc_int.h} | 0
libosmocore.pc.in | 2 +-
src/Makefile.am | 5 +++--
src/gsm/Makefile.am | 8 +++-----
tests/Makefile.am | 12 ++++++------
10 files changed, 39 insertions(+), 16 deletions(-)
create mode 100644 include/osmocom/core/talloc.h.in
rename include/osmocom/core/{talloc.h => talloc_int.h} (100%)

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/Makefile.am b/Makefile.am
index faf7a83..5144c87 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,6 +6,8 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libosmocore.pc libosmocodec.pc libosmovty.pc libosmogsm.pc \
libosmogb.pc libosmoctrl.pc

+$(pkgconfig_DATA): $(top_builddir)/config.status
+
BUILT_SOURCES = $(top_srcdir)/.version
$(top_srcdir)/.version:
echo $(VERSION) > $@-t && mv $@-t $@
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 c59f9b2..4d59a72 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -89,8 +89,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
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 <osmocom/core/talloc_int.h>
+#else
+#include <talloc.h>
+#endif
diff --git a/include/osmocom/core/talloc.h b/include/osmocom/core/talloc_int.h
similarity index 100%
rename from include/osmocom/core/talloc.h
rename to include/osmocom/core/talloc_int.h
diff --git a/libosmocore.pc.in b/libosmocore.pc.in
index 7c29869..25832f6 100644
--- a/libosmocore.pc.in
+++ b/libosmocore.pc.in
@@ -8,4 +8,4 @@ Description: C Utility Library
Version: @VERSION@
Libs: -L${libdir} -losmocore
Cflags: -I${includedir}/
-
+ at ***@Requires: talloc
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.
--
2.0.0
Jan Engelhardt
2014-10-04 09:10:25 UTC
Permalink
Mailing list discussion showed that the bundled talloc idea was
not so good after all.
---
.gitignore | 1 -
configure.ac | 23 +----
include/Makefile.am | 5 -
include/osmocom/core/strrb.h | 2 +-
include/osmocom/core/talloc.h.in | 6 --
include/osmocom/core/talloc_int.h | 189 -------------------------------------
include/osmocom/core/utils.h | 2 +-
include/osmocom/ctrl/control_cmd.h | 2 +-
libosmocore.pc.in | 2 +-
src/Makefile.am | 5 -
src/ctrl/control_cmd.c | 2 +-
src/ctrl/control_if.c | 2 +-
src/gb/common_vty.c | 2 +-
src/gb/gprs_bssgp.c | 2 +-
src/gb/gprs_bssgp_bss.c | 2 +-
src/gb/gprs_bssgp_util.c | 2 +-
src/gb/gprs_bssgp_vty.c | 2 +-
src/gb/gprs_ns.c | 2 +-
src/gb/gprs_ns_frgre.c | 2 +-
src/gb/gprs_ns_vty.c | 2 +-
src/gsm/ipa.c | 2 +-
src/gsm/lapd_core.c | 2 +-
src/gsmtap_util.c | 2 +-
src/logging.c | 2 +-
src/logging_syslog.c | 2 +-
src/msgb.c | 2 +-
src/msgfile.c | 2 +-
src/rate_ctr.c | 2 +-
src/signal.c | 2 +-
src/statistics.c | 2 +-
src/talloc.c | 2 +-
src/vty/buffer.c | 2 +-
src/vty/command.c | 2 +-
src/vty/logging_vty.c | 2 +-
src/vty/telnet_interface.c | 2 +-
src/vty/utils.c | 2 +-
src/vty/vector.c | 2 +-
src/vty/vty.c | 2 +-
tests/gb/bssgp_fc_test.c | 2 +-
tests/gb/gprs_ns_test.c | 2 +-
tests/msgfile/msgfile_test.c | 2 +-
tests/strrb/strrb_test.c | 2 +-
tests/timer/timer_test.c | 2 +-
tests/vty/vty_test.c | 2 +-
44 files changed, 39 insertions(+), 266 deletions(-)
delete mode 100644 include/osmocom/core/talloc.h.in
delete mode 100644 include/osmocom/core/talloc_int.h

diff --git a/.gitignore b/.gitignore
index 30707a6..1299028 100644
--- a/.gitignore
+++ b/.gitignore
@@ -92,7 +92,6 @@ 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 f12675a..68ef830 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,26 +82,7 @@ CHECK_TM_INCLUDES_TM_GMTOFF
dnl Generate the output
AC_CONFIG_HEADER(config.h)

-AC_ARG_ENABLE([internal-talloc],
- [AS_HELP_STRING(
- [--enable-internal-talloc],
- [Disable using bundled talloc memory allocator]
- )],
- [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
- ],
- [
- TALLOC_CFLAGS=""
- TALLOC_LIBS=""
- OSMOCORE_INTERNAL_TALLOC=1
- AC_SUBST([TALLOC_CFLAGS])
- AC_SUBST([TALLOC_LIBS])
- ])
-AC_SUBST([OSMOCORE_INTERNAL_TALLOC])
+PKG_CHECK_MODULES([TALLOC], [talloc])

AC_ARG_ENABLE(plugin,
[AS_HELP_STRING(
@@ -186,7 +167,6 @@ then
AM_CONDITIONAL(ENABLE_MSGFILE, false)
AM_CONDITIONAL(ENABLE_SERIAL, false)
AM_CONDITIONAL(ENABLE_VTY, 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])
@@ -201,7 +181,6 @@ 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 d8af474..858140c 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -89,11 +89,6 @@ if ENABLE_PLUGIN
nobase_include_HEADERS += osmocom/core/plugin.h
endif

-nobase_nodist_include_HEADERS = osmocom/core/talloc.h
-if INTERNAL_TALLOC
-nobase_include_HEADERS += osmocom/core/talloc_int.h
-endif
-
if ENABLE_MSGFILE
nobase_include_HEADERS += osmocom/core/msgfile.h
endif
diff --git a/include/osmocom/core/strrb.h b/include/osmocom/core/strrb.h
index c563d1b..2c7cfb2 100644
--- a/include/osmocom/core/strrb.h
+++ b/include/osmocom/core/strrb.h
@@ -31,7 +31,7 @@
#include <stdbool.h>
#include <stdint.h>

-#include <osmocom/core/talloc.h>
+#include <talloc.h>

/*! \brief A structure representing an osmocom string ringbuffer */

diff --git a/include/osmocom/core/talloc.h.in b/include/osmocom/core/talloc.h.in
deleted file mode 100644
index edbbb63..0000000
--- a/include/osmocom/core/talloc.h.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-#if @OSMOCORE_INTERNAL_TALLOC@
-#include <osmocom/core/talloc_int.h>
-#else
-#include <talloc.h>
-#endif
diff --git a/include/osmocom/core/talloc_int.h b/include/osmocom/core/talloc_int.h
deleted file mode 100644
index dde102b..0000000
--- a/include/osmocom/core/talloc_int.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));
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 373522a..b627c7b 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -1,7 +1,7 @@
#pragma once

#include <osmocom/core/backtrace.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>

/*! \defgroup utils General-purpose utility functions
* @{
diff --git a/include/osmocom/ctrl/control_cmd.h b/include/osmocom/ctrl/control_cmd.h
index 8f2eaa2..c5b7162 100644
--- a/include/osmocom/ctrl/control_cmd.h
+++ b/include/osmocom/ctrl/control_cmd.h
@@ -1,7 +1,7 @@
#pragma once

#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/logging.h>

diff --git a/libosmocore.pc.in b/libosmocore.pc.in
index 2ec6a74..7a9b925 100644
--- a/libosmocore.pc.in
+++ b/libosmocore.pc.in
@@ -8,4 +8,4 @@ Description: C Utility Library
Version: @VERSION@
Libs: -L${libdir} -losmocore
Cflags: -I${includedir}/
- at ***@Requires: talloc
+Requires: talloc
diff --git a/src/Makefile.am b/src/Makefile.am
index 4a6ba5c..8050ad0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,12 +26,7 @@ libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) $(LIBRARY_DL) -no-undefined
else
libosmocore_la_LDFLAGS = -version-info $(LIBVERSION) -no-undefined
endif
-
-if INTERNAL_TALLOC
-libosmocore_la_SOURCES += talloc.c
-else
libosmocore_la_LIBADD += $(TALLOC_LIBS)
-endif

if ENABLE_MSGFILE
libosmocore_la_SOURCES += msgfile.c
diff --git a/src/ctrl/control_cmd.c b/src/ctrl/control_cmd.c
index 4e156b8..4d47145 100644
--- a/src/ctrl/control_cmd.c
+++ b/src/ctrl/control_cmd.c
@@ -32,7 +32,7 @@
#include <osmocom/ctrl/control_cmd.h>

#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>

#include <osmocom/vty/command.h>
#include <osmocom/vty/vector.h>
diff --git a/src/ctrl/control_if.c b/src/ctrl/control_if.c
index c20c1e0..364a092 100644
--- a/src/ctrl/control_if.c
+++ b/src/ctrl/control_if.c
@@ -46,7 +46,7 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/select.h>
#include <osmocom/core/statistics.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/socket.h>

#include <osmocom/gsm/protocol/ipaccess.h>
diff --git a/src/gb/common_vty.c b/src/gb/common_vty.c
index 0bd0b6c..030b2a6 100644
--- a/src/gb/common_vty.c
+++ b/src/gb/common_vty.c
@@ -21,7 +21,7 @@
#include <stdlib.h>
#include <string.h>

-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/logging.h>

#include <osmocom/vty/telnet_interface.h>
diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index 0e9fd38..b002286 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -29,7 +29,7 @@

#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/rate_ctr.h>

#include <osmocom/gprs/gprs_bssgp.h>
diff --git a/src/gb/gprs_bssgp_bss.c b/src/gb/gprs_bssgp_bss.c
index 7d4c07c..5094e76 100644
--- a/src/gb/gprs_bssgp_bss.c
+++ b/src/gb/gprs_bssgp_bss.c
@@ -27,7 +27,7 @@
#include <osmocom/core/msgb.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/gprs/gprs_bssgp_bss.h>
#include <osmocom/gprs/gprs_ns.h>
diff --git a/src/gb/gprs_bssgp_util.c b/src/gb/gprs_bssgp_util.c
index 604764c..0e534df 100644
--- a/src/gb/gprs_bssgp_util.c
+++ b/src/gb/gprs_bssgp_util.c
@@ -26,7 +26,7 @@

#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/gprs/gprs_ns.h>

diff --git a/src/gb/gprs_bssgp_vty.c b/src/gb/gprs_bssgp_vty.c
index d8e1d32..0a2b05b 100644
--- a/src/gb/gprs_bssgp_vty.c
+++ b/src/gb/gprs_bssgp_vty.c
@@ -28,7 +28,7 @@

#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gprs/gprs_ns.h>
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index ee2d7ec..0f27710 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -72,7 +72,7 @@

#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/socket.h>
diff --git a/src/gb/gprs_ns_frgre.c b/src/gb/gprs_ns_frgre.c
index 57cf65e..9b7e92e 100644
--- a/src/gb/gprs_ns_frgre.c
+++ b/src/gb/gprs_ns_frgre.c
@@ -33,7 +33,7 @@

#include <osmocom/core/select.h>
#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/socket.h>
#include <osmocom/gprs/gprs_ns.h>

diff --git a/src/gb/gprs_ns_vty.c b/src/gb/gprs_ns_vty.c
index 4fa60ad..d4b7812 100644
--- a/src/gb/gprs_ns_vty.c
+++ b/src/gb/gprs_ns_vty.c
@@ -28,7 +28,7 @@

#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gprs/gprs_ns.h>
diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index a49d8ac..77136f1 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -29,7 +29,7 @@
#include <arpa/inet.h>

#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/macaddr.h>
#include <osmocom/core/select.h>
diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c
index 8c5fe9c..d7401de 100644
--- a/src/gsm/lapd_core.c
+++ b/src/gsm/lapd_core.c
@@ -80,7 +80,7 @@
#include <osmocom/core/timer.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/utils.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/gsm/lapd_core.h>

/* TS 04.06 Table 4 / Section 3.8.1 */
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 82690a9..fe9d30b 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -26,7 +26,7 @@
#include <osmocom/core/logging.h>
#include <osmocom/core/gsmtap.h>
#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/socket.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
diff --git a/src/logging.c b/src/logging.c
index f9d789d..d636170 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -40,7 +40,7 @@
#include <time.h>
#include <errno.h>

-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>

diff --git a/src/logging_syslog.c b/src/logging_syslog.c
index 5b0ae5f..202b3d1 100644
--- a/src/logging_syslog.c
+++ b/src/logging_syslog.c
@@ -39,7 +39,7 @@
#include <strings.h>
#endif

-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>

diff --git a/src/msgb.c b/src/msgb.c
index b2fe1d2..d169d56 100644
--- a/src/msgb.c
+++ b/src/msgb.c
@@ -31,7 +31,7 @@

#include <osmocom/core/msgb.h>
//#include <openbsc/gsm_data.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
//#include <openbsc/debug.h>

void *tall_msgb_ctx;
diff --git a/src/msgfile.c b/src/msgfile.c
index 1a99184..d4cc567 100644
--- a/src/msgfile.c
+++ b/src/msgfile.c
@@ -22,7 +22,7 @@
*/

#include <osmocom/core/msgfile.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>

#include <sys/stat.h>
#include <fcntl.h>
diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 8a232e8..602e060 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -32,7 +32,7 @@

#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>

diff --git a/src/signal.c b/src/signal.c
index 6384384..68be30f 100644
--- a/src/signal.c
+++ b/src/signal.c
@@ -19,7 +19,7 @@
*/

#include <osmocom/core/signal.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/linuxlist.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/statistics.c b/src/statistics.c
index e28541b..0e559d8 100644
--- a/src/statistics.c
+++ b/src/statistics.c
@@ -23,7 +23,7 @@
#include <string.h>

#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/statistics.h>

static LLIST_HEAD(counters);
diff --git a/src/talloc.c b/src/talloc.c
index d3a0690..b3c0146 100644
--- a/src/talloc.c
+++ b/src/talloc.c
@@ -54,7 +54,7 @@
#define __USE_GNU
#include <string.h>
#undef __USE_GNU
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif /* not _TALLOC_SAMBA3 */

diff --git a/src/vty/buffer.c b/src/vty/buffer.c
index e385f9f..ecfb961 100644
--- a/src/vty/buffer.c
+++ b/src/vty/buffer.c
@@ -28,7 +28,7 @@
#include <stddef.h>
#include <sys/uio.h>

-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/vty/buffer.h>
#include <osmocom/vty/vty.h>

diff --git a/src/vty/command.c b/src/vty/command.c
index 44a1b6c..bf83a74 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -38,7 +38,7 @@ Boston, MA 02111-1307, USA. */
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>

-#include <osmocom/core/talloc.h>
+#include <talloc.h>

/*! \addtogroup command
* @{
diff --git a/src/vty/logging_vty.c b/src/vty/logging_vty.c
index 47877fe..0faa17f 100644
--- a/src/vty/logging_vty.c
+++ b/src/vty/logging_vty.c
@@ -24,7 +24,7 @@

#include "../../config.h"

-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/strrb.h>
diff --git a/src/vty/telnet_interface.c b/src/vty/telnet_interface.c
index 50b08c8..bd4037f 100644
--- a/src/vty/telnet_interface.c
+++ b/src/vty/telnet_interface.c
@@ -28,7 +28,7 @@

#include <osmocom/core/msgb.h>
#include <osmocom/core/socket.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/signal.h>

diff --git a/src/vty/utils.c b/src/vty/utils.c
index d0ad431..d7df523 100644
--- a/src/vty/utils.c
+++ b/src/vty/utils.c
@@ -26,7 +26,7 @@
#include <ctype.h>

#include <osmocom/core/linuxlist.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/core/utils.h>
diff --git a/src/vty/vector.c b/src/vty/vector.c
index 4012f24..6a4f4bd 100644
--- a/src/vty/vector.c
+++ b/src/vty/vector.c
@@ -24,7 +24,7 @@

#include <osmocom/vty/vector.h>
#include <osmocom/vty/vty.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <memory.h>

void *tall_vty_vec_ctx;
diff --git a/src/vty/vty.c b/src/vty/vty.c
index 10a323f..1739d92 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -54,7 +54,7 @@
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/buffer.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>

/* \addtogroup vty
* @{
diff --git a/tests/gb/bssgp_fc_test.c b/tests/gb/bssgp_fc_test.c
index 64e4b4e..bc9ab39 100644
--- a/tests/gb/bssgp_fc_test.c
+++ b/tests/gb/bssgp_fc_test.c
@@ -12,7 +12,7 @@
#include <osmocom/core/application.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/gprs/gprs_bssgp.h>

static unsigned long in_ctr = 1;
diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index c90d752..c51f643 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -20,7 +20,7 @@
#include <osmocom/core/application.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/signal.h>
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gprs/gprs_msgb.h>
diff --git a/tests/msgfile/msgfile_test.c b/tests/msgfile/msgfile_test.c
index 2684b6a..1dd922b 100644
--- a/tests/msgfile/msgfile_test.c
+++ b/tests/msgfile/msgfile_test.c
@@ -20,7 +20,7 @@
*/

#include <osmocom/core/msgfile.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>

#include <stdio.h>

diff --git a/tests/strrb/strrb_test.c b/tests/strrb/strrb_test.c
index 6140ac9..9b8ec34 100644
--- a/tests/strrb/strrb_test.c
+++ b/tests/strrb/strrb_test.c
@@ -21,7 +21,7 @@
#include <string.h>

#include <osmocom/core/strrb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>

diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c
index 6184f66..67a22c7 100644
--- a/tests/timer/timer_test.c
+++ b/tests/timer/timer_test.c
@@ -28,7 +28,7 @@
#include <getopt.h>
#include <unistd.h>

-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/select.h>
#include <osmocom/core/linuxlist.h>
diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c
index 2a7347f..67c8679 100644
--- a/tests/vty/vty_test.c
+++ b/tests/vty/vty_test.c
@@ -25,7 +25,7 @@
#include <sys/un.h>

#include <osmocom/core/application.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/signal.h>
--
2.0.0
Holger Hans Peter Freyther
2014-10-04 09:59:56 UTC
Permalink
Post by Jan Engelhardt
diff --git a/include/osmocom/core/talloc.h.in b/include/osmocom/core/talloc.h.in
deleted file mode 100644
index edbbb63..0000000
--- a/include/osmocom/core/talloc.h.in
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-#include <osmocom/core/talloc_int.h>
-#else
-#include <talloc.h>
-#endif
leave it for a transition period.
Post by Jan Engelhardt
--- a/include/osmocom/ctrl/control_cmd.h
+++ b/include/osmocom/ctrl/control_cmd.h
@@ -1,7 +1,7 @@
#pragma once
#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/logging.h>
In general these blocks are grouped. E.g. from most specific to
general (specially to make sure that a header file can be included
directly). So all of the #include <talloc.h> are at the wrong place
now. Either it is done correctly right now or leave osmocom/core/talloc.h
for a transition period.


thanks for working on it
holger
Jan Engelhardt
2014-10-04 10:11:46 UTC
Permalink
Post by Holger Hans Peter Freyther
Post by Jan Engelhardt
#include <osmocom/core/msgb.h>
-#include <osmocom/core/talloc.h>
+#include <talloc.h>
#include <osmocom/core/write_queue.h>
#include <osmocom/core/logging.h>
In general these blocks are grouped. E.g. from most specific to
general (specially to make sure that a header file can be included
directly). So all of the #include <talloc.h> are at the wrong place
now. Either it is done correctly right now or leave osmocom/core/talloc.h
for a transition period.
Just take the first four then.

Jan Engelhardt
2014-10-04 09:10:21 UTC
Permalink
CC msgfile_test.o
msgfile/msgfile_test.c: In function "main":
msgfile/msgfile_test.c:48:2: warning: implicit declaration of
function "talloc_free" [-Wimplicit-function-declaration]
talloc_free(entries);
^
---
tests/msgfile/msgfile_test.c | 1 +
1 file changed, 1 insertion(+)

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 <osmocom/core/msgfile.h>
+#include <osmocom/core/talloc.h>

#include <stdio.h>
--
2.0.0
Jan Engelhardt
2014-10-04 09:10:24 UTC
Permalink
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 +-
libosmocore.pc.in | 2 +-
src/Makefile.am | 2 +-
4 files changed, 9 insertions(+), 9 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/libosmocore.pc.in b/libosmocore.pc.in
index 25832f6..2ec6a74 100644
--- a/libosmocore.pc.in
+++ b/libosmocore.pc.in
@@ -8,4 +8,4 @@ Description: C Utility Library
Version: @VERSION@
Libs: -L${libdir} -losmocore
Cflags: -I${includedir}/
- at ***@Requires: talloc
+ at ***@Requires: talloc
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
Loading...