don't always require support library when building with sun cc
authorKen Raeburn <raeburn@mit.edu>
Tue, 7 Jun 2005 06:18:40 +0000 (06:18 +0000)
committerKen Raeburn <raeburn@mit.edu>
Tue, 7 Jun 2005 06:18:40 +0000 (06:18 +0000)
By default, a non-GCC configuration will not optimize during the build.  The
Solaris C compiler will always output functions defined as "inline", at least
when not optimizing, even if they're never used.  With recent changes on the
trunk, k5_call_init_function will cause the support library to be required on
Solaris by every program that includes k5-platform.h.  This patch should fix
that.

* k5-platform.h (MAYBE_DEFINE_CALLINIT_FUNCTION) [DELAY_INITIALIZER]: New
macro.  If not __GNUC__, define k5_call_init_function in the expansion;
otherwise, do nothing.
(MAKE_INIT_FUNCTION) [DELAY_INITIALIZER]: Use it.
(k5_call_init_function): Don't define function form at top level.

ticket: new

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

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

index 217c6a59c562e75435a7331a03517a69f8df8bd8..2551c653618cd60543a75203fc3588180bd40269 100644 (file)
@@ -1,3 +1,11 @@
+2005-06-07  Ken Raeburn  <raeburn@mit.edu>
+
+       * k5-platform.h (MAYBE_DEFINE_CALLINIT_FUNCTION)
+       [DELAY_INITIALIZER]: New macro.  If not __GNUC__, define
+       k5_call_init_function in the expansion; otherwise, do nothing.
+       (MAKE_INIT_FUNCTION) [DELAY_INITIALIZER]: Use it.
+       (k5_call_init_function): Don't define function form at top level.
+
 2005-05-31  Ken Raeburn  <raeburn@mit.edu>
 
        * k5-thread.h (krb5int_pthread_loaded) [HAVE_PRAGMA_WEAK_REF]:
index 8a88cacf318834d9f416b7a3122203f1c39df14e..232e15bea285fde36c8e04af3a37be9ea22d059c 100644 (file)
@@ -196,6 +196,30 @@ typedef struct { k5_once_t once; int error, did_run; void (*fn)(void); } k5_init
 # else
 #  define MAYBE_DUMMY_INIT(NAME)
 # endif
+# 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));    \
+           }))
+#  define MAYBE_DEFINE_CALLINIT_FUNCTION
+# else
+#  define MAYBE_DEFINE_CALLINIT_FUNCTION                       \
+       static inline int k5_call_init_function(k5_init_t *i)   \
+       {                                                       \
+           int err;                                            \
+           err = k5_once(&i->once, i->fn);                     \
+           if (err)                                            \
+               return err;                                     \
+           assert (i->did_run != 0);                           \
+           return i->error;                                    \
+       }
+# endif
 # define MAKE_INIT_FUNCTION(NAME)                              \
        static int NAME(void);                                  \
        MAYBE_DUMMY_INIT(NAME)                                  \
@@ -203,6 +227,7 @@ typedef struct { k5_once_t once; int error, did_run; void (*fn)(void); } k5_init
        static void JOIN__2(NAME, aux) (void);                  \
        static k5_init_t JOIN__2(NAME, once) =                  \
                { K5_ONCE_INIT, 0, 0, JOIN__2(NAME, aux) };     \
+       MAYBE_DEFINE_CALLINIT_FUNCTION                          \
        static void JOIN__2(NAME, aux) (void)                   \
        {                                                       \
            JOIN__2(NAME, once).did_run = 1;                    \
@@ -212,28 +237,6 @@ 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;
-    err = k5_once(&i->once, i->fn);
-    if (err)
-       return err;
-    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.