Restore ABI compatibility for talloc.
authorSimo Sorce <idra@samba.org>
Thu, 2 Jul 2009 13:29:20 +0000 (09:29 -0400)
committerSimo Sorce <idra@samba.org>
Fri, 3 Jul 2009 12:45:29 +0000 (08:45 -0400)
lib/talloc/abi_checks.sh
lib/talloc/configure.ac
lib/talloc/talloc.c
lib/talloc/talloc.exports
lib/talloc/talloc.h
lib/talloc/talloc.signatures
source3/configure.in
source4/min_versions.m4

index 432cc87745f6e4979af1f2c8d6d03afc96a956b6..e3d3b042faadf88212c9ca5f0aae5b21a0f2344f 100755 (executable)
@@ -4,15 +4,17 @@ make clean
 
 mkdir abi
 ABI_CHECKS="-aux-info abi/\$@.X"
-make ABI_CHECK="$ABI_CHECKS"
+make ABI_CHECK="$ABI_CHECKS" CC="/usr/bin/gcc"
 
-for i in abi/*.X; do cat $i | grep 'talloc\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' > abi/signatures
+for i in abi/*.X; do cat $i | grep 'talloc\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' | sort > abi/signatures
 
 cat > abi/exports << EOF
 {
     global:
 EOF
 cat abi/signatures | awk -F '(' '{ print $1 }' | awk -F ' ' '{ print "           "$NF";" }' | tr -d '*' | sort >> abi/exports
+# need to manually add talloc free for backward ABI compat
+echo '           talloc_free;' >> abi/exports
 cat >> abi/exports << EOF
 
     local: *;
index d6471a4aa7691f51a74865685649d811a09cfd7f..161f6f79e3d1a3872e875aeae5a2d736eb08dc4e 100644 (file)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.50)
-AC_INIT(talloc, 2.0.0)
+AC_INIT(talloc, 1.4.0)
 AC_CONFIG_SRCDIR([talloc.c])
 AC_SUBST(datarootdir)
 AC_CONFIG_HEADER(config.h)
index a23df38b5654e899d695868a855136c97af56784..8ccebe2e24eb37d4c304dd43b2ff0ce785469821 100644 (file)
@@ -477,7 +477,7 @@ static inline void *_talloc_named_const(const void *context, size_t size, const
   same underlying data, and you want to be able to free the two instances separately,
   and in either order
 */
-void *_talloc_reference(const void *context, const void *ptr, const char *location)
+void *_talloc_reference_loc(const void *context, const void *ptr, const char *location)
 {
        struct talloc_chunk *tc;
        struct talloc_reference_handle *handle;
@@ -499,6 +499,7 @@ void *_talloc_reference(const void *context, const void *ptr, const char *locati
        return handle->ptr;
 }
 
+static void *_talloc_steal_internal(const void *new_ctx, const void *ptr);
 
 /* 
    internal talloc_free call
@@ -613,7 +614,7 @@ static inline int _talloc_free_internal(void *ptr)
    ptr on success, or NULL if it could not be transferred.
    passing NULL as ptr will always return NULL with no side effects.
 */
-void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
+static void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
 {
        struct talloc_chunk *tc, *new_tc;
 
@@ -665,13 +666,12 @@ void *_talloc_steal_internal(const void *new_ctx, const void *ptr)
        return discard_const_p(void, ptr);
 }
 
-
 /* 
    move a lump of memory from one talloc context to another return the
    ptr on success, or NULL if it could not be transferred.
    passing NULL as ptr will always return NULL with no side effects.
 */
-void *_talloc_steal(const void *new_ctx, const void *ptr, const char *location)
+void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location)
 {
        struct talloc_chunk *tc;
 
@@ -683,9 +683,13 @@ void *_talloc_steal(const void *new_ctx, const void *ptr, const char *location)
        
        if (unlikely(tc->refs != NULL) && talloc_parent(ptr) != new_ctx) {
                struct talloc_reference_handle *h;
+#if DEVELOPER
                fprintf(stderr, "ERROR: talloc_steal with references at %s\n", location);
+#endif
                for (h=tc->refs; h; h=h->next) {
+#if DEVELOPER
                        fprintf(stderr, "\treference at %s\n", h->location);
+#endif
                }
                return NULL;
        }
@@ -1054,9 +1058,13 @@ int _talloc_free(void *ptr, const char *location)
        
        if (unlikely(tc->refs != NULL)) {
                struct talloc_reference_handle *h;
+#if DEVELOPER
                fprintf(stderr, "ERROR: talloc_free with references at %s\n", location);
+#endif
                for (h=tc->refs; h; h=h->next) {
+#if DEVELOPER
                        fprintf(stderr, "\treference at %s\n", h->location);
+#endif
                }
                return -1;
        }
@@ -1876,3 +1884,30 @@ int talloc_is_parent(const void *context, const void *ptr)
        }
        return 0;
 }
+
+
+
+
+/* ABI compat functions (do NOT append anything beyond thess functions,
+ * keep them as the last ones in the file) */
+
+static const char *talloc_ABI_compat_location = "Called from compatibility function";
+
+/* ABI compat function (don't use) */
+void *_talloc_reference(const void *context, const void *ptr) {
+       return _talloc_reference_loc(context, ptr, talloc_ABI_compat_location);
+}
+
+/* ABI compat function (don't use) */
+void *_talloc_steal(const void *new_ctx, const void *ptr)
+{
+       return _talloc_steal_internal(new_ctx, ptr);
+}
+
+#undef talloc_free
+int talloc_free(void *ptr)
+{
+       return _talloc_free_internal(ptr);
+}
+
+/* DO NOT APPEND ANYTHING BEYOND THIS POINT */
index b7878453cf85326a05a3b0ce9a69280a3099a06c..2459c4821181169caca2a4d3c817fbb77db8d6ef 100644 (file)
@@ -12,7 +12,7 @@
            talloc_enable_leak_report_full;
            talloc_enable_null_tracking;
            talloc_find_parent_byname;
-           talloc_free;
+           _talloc_free;
            talloc_free_children;
            talloc_get_name;
            talloc_get_size;
@@ -32,6 +32,8 @@
            talloc_realloc_fn;
            _talloc_reference;
            talloc_reference_count;
+           _talloc_reference_loc;
+           talloc_reparent;
            talloc_report;
            talloc_report_depth_cb;
            talloc_report_depth_file;
@@ -42,6 +44,7 @@
            talloc_set_name_const;
            talloc_show_parents;
            _talloc_steal;
+           _talloc_steal_loc;
            talloc_strdup;
            talloc_strdup_append;
            talloc_strdup_append_buffer;
@@ -56,6 +59,7 @@
            talloc_vasprintf_append_buffer;
            _talloc_zero;
            _talloc_zero_array;
+           talloc_free;
 
     local: *;
 };
index 9d1aa0df040a3b189a42966670b05236ed74821d..855f778f8c92893b2045363c6fb848fe97fb0fc8 100644 (file)
@@ -69,15 +69,15 @@ typedef void TALLOC_CTX;
        } 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), __location__); __talloc_steal_ret; })
+#define talloc_steal(ctx, ptr) ({ _TALLOC_TYPEOF(ptr) __talloc_steal_ret = (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__); __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), __location__)
+#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal_loc((ctx),(ptr), __location__)
 #endif
 
-#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr), __location__)
+#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference_loc((ctx),(ptr), __location__)
 #define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr))
 
 /* useful macros for creating type checked pointers */
@@ -126,7 +126,7 @@ 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, const char *location);
+void *_talloc_reference_loc(const void *context, const void *ptr, const char *location);
 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);
@@ -142,8 +142,7 @@ void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
 int _talloc_free(void *ptr, const char *location);
 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, const char *location);
-void *_talloc_steal_internal(const void *new_ctx, const void *ptr);
+void *_talloc_steal_loc(const void *new_ctx, const void *ptr, const char *location);
 void *talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr);
 void *_talloc_move(const void *new_ctx, const void *pptr);
 size_t talloc_total_size(const void *ptr);
@@ -191,4 +190,7 @@ char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIB
 
 void talloc_set_abort_fn(void (*abort_fn)(const char *reason));
 
+/* for ABI compatibility, never use in new code */
+void *_talloc_reference(const void *context, const void *ptr);
+void *_talloc_steal(const void *new_ctx, const void *ptr);
 #endif
index e2fc8aee438e45fc766c3cce6a3cb26317b0af77..96b71f737ad889451149b8c2137a44bbfc9612f0 100644 (file)
@@ -1,56 +1,59 @@
-void *_talloc (const void *, size_t);
-void *talloc_pool (const void *, size_t);
-void _talloc_set_destructor (const void *, int (*) (void *));
+char *talloc_asprintf_append_buffer (char *, const char *, ...);
+char *talloc_asprintf_append (char *, const char *, ...);
+char *talloc_asprintf (const void *, const char *, ...);
+char *talloc_strdup_append_buffer (char *, const char *);
+char *talloc_strdup_append (char *, const char *);
+char *talloc_strdup (const void *, const char *);
+char *talloc_strndup_append_buffer (char *, const char *, size_t);
+char *talloc_strndup_append (char *, const char *, size_t);
+char *talloc_strndup (const void *, const char *, size_t);
+char *talloc_vasprintf_append_buffer (char *, const char *, va_list);
+char *talloc_vasprintf_append (char *, const char *, va_list);
+char *talloc_vasprintf (const void *, const char *, va_list);
+const char *talloc_get_name (const void *);
+const char *talloc_parent_name (const void *);
+const char *talloc_set_name (const void *, const char *, ...);
+int _talloc_free (void *, const char *);
 int talloc_increase_ref_count (const void *);
-size_t talloc_reference_count (const void *);
-void *_talloc_reference (const void *, const void *);
+int talloc_is_parent (const void *, const void *);
 int talloc_unlink (const void *, void *);
-const char *talloc_set_name (const void *, const char *, ...);
-void talloc_set_name_const (const void *, const char *);
-void *talloc_named (const void *, size_t, const char *, ...);
-void *talloc_named_const (const void *, size_t, const char *);
-const char *talloc_get_name (const void *);
+size_t talloc_get_size (const void *);
+size_t talloc_reference_count (const void *);
+size_t talloc_total_blocks (const void *);
+size_t talloc_total_size (const void *);
+void *_talloc_array (const void *, size_t, unsigned int, const char *);
+void *talloc_autofree_context (void);
 void *talloc_check_name (const void *, const char *);
+void *_talloc (const void *, size_t);
+void talloc_disable_null_tracking (void);
+void talloc_enable_leak_report_full (void);
+void talloc_enable_leak_report (void);
+void talloc_enable_null_tracking (void);
+void *talloc_find_parent_byname (const void *, const char *);
+void talloc_free_children (void *);
 void *_talloc_get_type_abort (const void *, const char *, const char *);
-void *talloc_parent (const void *);
-const char *talloc_parent_name (const void *);
 void *talloc_init (const char *, ...);
-int talloc_free (void *);
-void talloc_free_children (void *);
-void *_talloc_realloc (const void *, void *, size_t, const char *);
-void *_talloc_steal (const void *, const void *);
+void *_talloc_memdup (const void *, const void *, size_t, const char *);
 void *_talloc_move (const void *, const void *);
-size_t talloc_total_size (const void *);
-size_t talloc_total_blocks (const void *);
+void *talloc_named_const (const void *, size_t, const char *);
+void *talloc_named (const void *, size_t, const char *, ...);
+void *talloc_parent (const void *);
+void *talloc_pool (const void *, size_t);
+void *_talloc_realloc_array (const void *, void *, size_t, unsigned int, const char *);
+void *_talloc_realloc (const void *, void *, size_t, const char *);
+void *talloc_realloc_fn (const void *, void *, size_t);
+void *_talloc_reference (const void *, const void *);
+void *_talloc_reference_loc (const void *, const void *, const char *);
+void *talloc_reparent (const void *, const void *, const void *);
+void talloc_report (const void *, FILE *);
 void talloc_report_depth_cb (const void *, int, int, void (*) (const void *, int, int, int, void *), void *);
 void talloc_report_depth_file (const void *, int, int, FILE *);
 void talloc_report_full (const void *, FILE *);
-void talloc_report (const void *, FILE *);
-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 *, size_t, const char *);
-void *_talloc_memdup (const void *, const void *, size_t, const char *);
-void *_talloc_array (const void *, size_t, unsigned int, const char *);
-void *_talloc_zero_array (const void *, size_t, unsigned int, const char *);
-void *_talloc_realloc_array (const void *, void *, size_t, unsigned int, const char *);
-void *talloc_realloc_fn (const void *, void *, size_t);
-void *talloc_autofree_context (void);
-size_t talloc_get_size (const void *);
-void *talloc_find_parent_byname (const void *, const char *);
-void talloc_show_parents (const void *, FILE *);
-int talloc_is_parent (const void *, const void *);
-char *talloc_strdup (const void *, const char *);
-char *talloc_strdup_append (char *, const char *);
-char *talloc_strdup_append_buffer (char *, const char *);
-char *talloc_strndup (const void *, const char *, size_t);
-char *talloc_strndup_append (char *, const char *, size_t);
-char *talloc_strndup_append_buffer (char *, const char *, size_t);
-char *talloc_vasprintf (const void *, const char *, __va_list_tag *);
-char *talloc_vasprintf_append (char *, const char *, __va_list_tag *);
-char *talloc_vasprintf_append_buffer (char *, const char *, __va_list_tag *);
-char *talloc_asprintf (const void *, const char *, ...);
-char *talloc_asprintf_append (char *, const char *, ...);
-char *talloc_asprintf_append_buffer (char *, const char *, ...);
 void talloc_set_abort_fn (void (*) (const char *));
+void _talloc_set_destructor (const void *, int (*) (void *));
+void talloc_set_name_const (const void *, const char *);
+void talloc_show_parents (const void *, FILE *);
+void *_talloc_steal (const void *, const void *);
+void *_talloc_steal_loc (const void *, const void *, const char *);
+void *_talloc_zero_array (const void *, size_t, unsigned int, const char *);
+void *_talloc_zero (const void *, size_t, const char *);
index 7115a3ba4d3ff4a62a965aede5739bc7a8797dab..3a95b6a750f3081c3fb0ac4fa2e1cbd7513203cb 100644 (file)
@@ -4741,7 +4741,7 @@ AC_ARG_ENABLE(external_libtalloc, [AS_HELP_STRING([--enable-external-libtalloc],
 
 if test "x$enable_external_libtalloc" != xno
 then
-       PKG_CHECK_MODULES(LIBTALLOC, talloc >= 2.0.0, 
+       PKG_CHECK_MODULES(LIBTALLOC, talloc >= 1.4.0, 
                [ enable_external_libtalloc=yes ],
                [ if test x$enable_external_libtalloc = xyes; then
                        AC_MSG_ERROR([Unable to find libtalloc])
index ecc8e10ffc334639ed30bf43e4bc98eff5673b8d..1ecc92919db68a53e3d0b666edd1488be7911fa2 100644 (file)
@@ -1,6 +1,6 @@
 # Minimum and exact required versions for various libraries 
 # if we use the ones installed in the system.
 define(TDB_MIN_VERSION,1.1.5)
-define(TALLOC_MIN_VERSION,2.0.0)
+define(TALLOC_MIN_VERSION,1.4.0)
 define(LDB_REQUIRED_VERSION,0.9.6)
 define(TEVENT_REQUIRED_VERSION,0.9.6)