Define G_GNUC_INTERNAL for Sun Studio as __hidden. (#342981, Brian

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
This commit is contained in:
Matthias Clasen 2007-01-27 03:34:48 +00:00 committed by Matthias Clasen
parent f90d6d821d
commit df3dd538e5
6 changed files with 56 additions and 8 deletions

View File

@ -1,3 +1,12 @@
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:

View 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)

View 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

View 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

View 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:

View 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 ();