* k5-platform.h (k5_call_init_function) [DELAY_INITIALIZER] [__GNUC__]: Use a
authorKen Raeburn <raeburn@mit.edu>
Wed, 14 Jul 2004 01:33:35 +0000 (01:33 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 14 Jul 2004 01:33:35 +0000 (01:33 +0000)
statement expression so any line number info printed by assertion failures is
useful.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16589 dc483132-0cff-0310-8789-dd5450dbe970

src/include/ChangeLog
src/include/k5-platform.h

index 22915dd2b183b8b90b5bff70e406475a49beeb33..9bceef3ad6db13d4fa68c6c4e6e68b92742769d2 100644 (file)
@@ -1,5 +1,9 @@
 2004-07-13  Ken Raeburn  <raeburn@mit.edu>
 
+       * k5-platform.h (k5_call_init_function) [DELAY_INITIALIZER]
+       [__GNUC__]: Use a statement expression so any line number info
+       printed by assertion failures is useful.
+
        * k5-thread.h (k5_os_mutex_init, k5_os_mutex_destroy): If
        USE_PTHREAD_LOCK_ONLY_IF_LOADED is defined, use pthread_mutex_init
        and _destroy only if pthread support is loaded.
index bf8a584322630547a0001b71d625785cc83b58dc..e0793f6290e2ba2e64e756b2dc717896cead4fdf 100644 (file)
@@ -168,6 +168,18 @@ typedef struct { k5_once_t once; int error, did_run; void (*fn)(void); } k5_init
        static int NAME(void)
 # define CALL_INIT_FUNCTION(NAME)      \
        k5_call_init_function(& JOIN__2(NAME, once))
+# ifdef __GNUC__
+/* Do it in macro form so we get the file/line of the invocation if
+   the assertion fails.  */
+#  define k5_call_init_function(I)                                     \
+       (__extension__ ({                                               \
+               k5_init_t *k5int_i = (I);                               \
+               int k5int_err = k5_once(&k5int_i->once, k5int_i->fn);   \
+               (k5int_err                                              \
+                ? k5int_err                                            \
+                : (assert(k5int_i->did_run != 0), k5int_i->error));    \
+           }))
+# else
 static inline int k5_call_init_function(k5_init_t *i)
 {
     int err;
@@ -177,6 +189,7 @@ static inline int k5_call_init_function(k5_init_t *i)
     assert (i->did_run != 0);
     return i->error;
 }
+# endif
 /* This should be called in finalization only, so we shouldn't have
    multiple active threads mucking around in our library at this
    point.  So ignore the once_t object and just look at the flag.