Define G_GNUC_INTERNAL for Sun Studio as __hidden. (#342981, Brian
authorMatthias Clasen <mclasen@redhat.com>
Sat, 27 Jan 2007 03:34:48 +0000 (03:34 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 27 Jan 2007 03:34:48 +0000 (03:34 +0000)
2007-01-26  Matthias Clasen <mclasen@redhat.com>

        * configure.in: Define G_GNUC_INTERNAL for Sun Studio
        as __hidden.  (#342981, Brian Cameron)

        * glib/gconvert.c:
        * glib/gutf8.c: Move G_GNUC_INTERNAL uses to the right
        spot.

2

svn path=/trunk/; revision=5317

ChangeLog
configure.in
docs/reference/ChangeLog
docs/reference/glib/tmpl/macros_misc.sgml
glib/gconvert.c
glib/gutf8.c

index aaf6776..4daccd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2007-01-26  Matthias Clasen <mclasen@redhat.com>
 
+       * configure.in: Define G_GNUC_INTERNAL for Sun Studio
+       as __hidden.  (#342981, Brian Cameron)
+
+       * glib/gconvert.c:
+       * glib/gutf8.c: Move G_GNUC_INTERNAL uses to the right
+       spot.  
+
+2007-01-26  Matthias Clasen <mclasen@redhat.com>
+
        * gmem.c:
        * gslice.c:
        * gmessages.c:
index dd35c94..4b478de 100644 (file)
@@ -786,6 +786,15 @@ int main (int argc, char **argv)
 AC_MSG_RESULT($g_have_gnuc_visibility)
 AM_CONDITIONAL(HAVE_GNUC_VISIBILITY, [test x$g_have_gnuc_visibility = xyes])
 
+AC_MSG_CHECKING([whether using Sun Studio C compiler])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__SUNPRO_C) || (__SUNPRO_C >= 0x550)
+#else
+# include "error: this is not Sun Studio."
+#endif
+]], [[]])], [ g_have_sunstudio_visibility=yes ], [ g_have_sunstudio_visibility=no ])
+AC_MSG_RESULT($g_have_sunstudio_visibility)
+AM_CONDITIONAL(HAVE_SUNSTUDIO_VISIBILITY, [test x$g_have_sunstudio_visibility = xyes])
+
 # check for bytesex stuff
 AC_C_BIGENDIAN
 
@@ -2440,10 +2449,16 @@ _______EOF
 #define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
 #endif
 _______EOF
-       else
+        else
+          if test x$g_have_sunstudio_visibility = xyes ; then
+                cat >>$outfile <<_______EOF
+#define G_GNUC_INTERNAL __hidden
+_______EOF
+          else
                cat >>$outfile <<_______EOF
 #define G_GNUC_INTERNAL
 _______EOF
+         fi
        fi
 
 
@@ -2769,6 +2784,7 @@ g_have_iso_cxx_varargs=$g_have_iso_cxx_varargs
 
 g_can_inline=$g_can_inline
 g_have_gnuc_visibility=$g_have_gnuc_visibility
+g_have_sunstudio_visibility=$g_have_sunstudio_visibility
 
 case xyes in
 x$ac_cv_c_bigendian)
index d39d4dd..17ff604 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-26  Matthias Clasen  <mclasen@redhat.com>
+
+       * glib/tmpl/macros_misc.sgml: Document G_GNUC_INTERNAL
+       support for Sun Studio.
+
 2007-01-23  Matthias Clasen  <mclasen@redhat.com>
 
        * gobject/tmpl/objects.sgml: Document 
index 580aebc..e2b954f 100644 (file)
@@ -309,12 +309,29 @@ Since: 2.6
 
 <!-- ##### MACRO G_GNUC_INTERNAL ##### -->
 <para>
-Expands to the GNU C <literal>visibility(hidden)</literal> attribute if the 
-compiler supports it  (currently only <command>gcc</command>). This attribute 
-can be used for marking library functions as being used internally to the lib 
-only, to not create inefficient PLT entries. Note that static functions do not 
-need to be marked as internal in this way. See the GNU C documentation for details. 
+This attribute can be used for marking library functions as being used 
+internally to the library only, which may allow the compiler to handle
+function calls more efficiently. 
+Note that static functions do not need to be marked as internal in this way. 
+See the GNU C documentation for details. 
+</para>
+<para>
+When using a compiler that supports the GNU C hidden visibility attribute, 
+this macro expands to <literal>__attribute__((visibility("hidden")))</literal>.
+When using the Sun Studio compiler, it expands to <literal>__hidden</literal>.
 </para>
+<para>
+Note that for portability, the attribute should be placed before the
+function declaration. While GCC allows the macro after the declaration, 
+Sun Studio does not.
+</para>
+<informalexample><programlisting>
+G_GNUC_INTERNAL
+void _g_log_fallback_handler (const gchar    *log_domain,
+                              GLogLevelFlags  log_level,
+                              const gchar    *message,
+                              gpointer        unused_data);
+</programlisting></informalexample>
 
 Since: 2.6
 
index 4c25674..ab0b18e 100644 (file)
@@ -89,7 +89,8 @@ try_to_aliases (const char **to_aliases,
   return FALSE;
 }
 
-extern const char ** G_GNUC_INTERNAL _g_charset_get_aliases (const char *canonical_name);
+G_GNUC_INTERNAL extern const char ** 
+_g_charset_get_aliases (const char *canonical_name);
 
 /**
  * g_iconv_open:
index 6d98502..87dad3f 100644 (file)
@@ -435,7 +435,7 @@ get_alias_hash (void)
 /* As an abuse of the alias table, the following routines gets
  * the charsets that are aliases for the canonical name.
  */
-const char ** G_GNUC_INTERNAL
+G_GNUC_INTERNAL const char ** 
 _g_charset_get_aliases (const char *canonical_name)
 {
   GHashTable *alias_hash = get_alias_hash ();