X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=glib%2Fgtypes.h;h=0e73b40b93999063a9649c66f3dd90f0a78be790;hb=1cbdbef77209fe82239bd10f062425491cf256ae;hp=21b55e7c952aa76e0c8c678bef0de620ca01ff04;hpb=d923d1f03f48fdc22a62362b2f7a4a6ddc4aec1e;p=platform%2Fupstream%2Fglib.git diff --git a/glib/gtypes.h b/glib/gtypes.h index 21b55e7..0e73b40 100644 --- a/glib/gtypes.h +++ b/glib/gtypes.h @@ -12,22 +12,27 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library; if not, see . */ /* * Modified by the GLib Team and others 1997-2000. See the AUTHORS * file for a list of people on the GLib Team. See the ChangeLog * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. + * GLib at ftp://ftp.gtk.org/pub/gtk/. */ #ifndef __G_TYPES_H__ #define __G_TYPES_H__ +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + #include +#include +#include +#include G_BEGIN_DECLS @@ -86,13 +91,42 @@ typedef guint (*GHashFunc) (gconstpointer key); typedef void (*GHFunc) (gpointer key, gpointer value, gpointer user_data); + +/** + * GFreeFunc: + * @data: a data pointer + * + * Declares a type of function which takes an arbitrary + * data pointer argument and has no return value. It is + * not currently used in GLib or GTK+. + */ typedef void (*GFreeFunc) (gpointer data); + +/** + * GTranslateFunc: + * @str: the untranslated string + * @data: user data specified when installing the function, e.g. + * in g_option_group_set_translate_func() + * + * The type of functions which are used to translate user-visible + * strings, for output. + * + * Returns: a translation of the string for the current locale. + * The returned string is owned by GLib and must not be freed. + */ typedef const gchar * (*GTranslateFunc) (const gchar *str, gpointer data); /* Define some mathematical constants that aren't available * symbolically in some strict ISO C implementations. + * + * Note that the large number of digits used in these definitions + * doesn't imply that GLib or current computers in general would be + * able to handle floating point numbers with an accuracy like this. + * It's mostly an exercise in futility and future proofing. For + * extended precision floating point support, look somewhere else + * than GLib. */ #define G_E 2.7182818284590452353602874713526624977572470937000 #define G_LN2 0.69314718055994530941723212145817656807550013436026 @@ -145,10 +179,16 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, /* Arch specific stuff for speed */ #if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) + +# if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3 +# define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((gint32) (val))) +# define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((gint64) (val))) +# endif + # if defined (__i386__) # define GUINT16_SWAP_LE_BE_IA32(val) \ - (__extension__ \ - ({ register guint16 __v, __x = ((guint16) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint16 __v, __x = ((guint16) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -161,8 +201,8 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, && !defined (__pentium__) && !defined (__i686__) \ && !defined (__pentiumpro__) && !defined (__pentium4__) # define GUINT32_SWAP_LE_BE_IA32(val) \ - (__extension__ \ - ({ register guint32 __v, __x = ((guint32) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -175,8 +215,8 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, __v; })) # else /* 486 and higher has bswap */ # define GUINT32_SWAP_LE_BE_IA32(val) \ - (__extension__ \ - ({ register guint32 __v, __x = ((guint32) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -186,7 +226,7 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, __v; })) # endif /* processor specific 32-bit stuff */ # define GUINT64_SWAP_LE_BE_IA32(val) \ - (__extension__ \ + (G_GNUC_EXTENSION \ ({ union { guint64 __ll; \ guint32 __l[2]; } __w, __r; \ __w.__ll = ((guint64) (val)); \ @@ -200,12 +240,16 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, __r.__ll; })) /* Possibly just use the constant version and let gcc figure it out? */ # define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val)) -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val)) +# endif # elif defined (__ia64__) # define GUINT16_SWAP_LE_BE_IA64(val) \ - (__extension__ \ - ({ register guint16 __v, __x = ((guint16) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint16 __v, __x = ((guint16) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -215,8 +259,8 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, : "r" (__x)); \ __v; })) # define GUINT32_SWAP_LE_BE_IA64(val) \ - (__extension__ \ - ({ register guint32 __v, __x = ((guint32) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -226,8 +270,8 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, : "r" (__x)); \ __v; })) # define GUINT64_SWAP_LE_BE_IA64(val) \ - (__extension__ \ - ({ register guint64 __v, __x = ((guint64) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint64 __v, __x = ((guint64) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -236,12 +280,16 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, : "r" (__x)); \ __v; })) # define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA64 (val)) -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val)) -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val)) +# endif # elif defined (__x86_64__) # define GUINT32_SWAP_LE_BE_X86_64(val) \ - (__extension__ \ - ({ register guint32 __v, __x = ((guint32) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -250,8 +298,8 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, : "0" (__x)); \ __v; })) # define GUINT64_SWAP_LE_BE_X86_64(val) \ - (__extension__ \ - ({ register guint64 __v, __x = ((guint64) (val)); \ + (G_GNUC_EXTENSION \ + ({ guint64 __v, __x = ((guint64) (val)); \ if (__builtin_constant_p (__x)) \ __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ else \ @@ -261,12 +309,20 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, __v; })) /* gcc seems to figure out optimal code for this on its own */ # define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val)) -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val)) +# endif # else /* generic gcc */ # define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) +# endif # endif #else /* generic */ # define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) @@ -310,6 +366,11 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, #define GINT_FROM_BE(val) (GINT_TO_BE (val)) #define GUINT_FROM_BE(val) (GUINT_TO_BE (val)) +#define GSIZE_FROM_LE(val) (GSIZE_TO_LE (val)) +#define GSSIZE_FROM_LE(val) (GSSIZE_TO_LE (val)) +#define GSIZE_FROM_BE(val) (GSIZE_TO_BE (val)) +#define GSSIZE_FROM_BE(val) (GSSIZE_TO_BE (val)) + /* Portable versions of host-network order stuff */ @@ -396,7 +457,7 @@ struct _GTimeVal G_END_DECLS /* We prefix variable declarations so they can - * properly get exported in windows dlls. + * properly get exported in Windows DLLs. */ #ifndef GLIB_VAR # ifdef G_PLATFORM_WIN32 @@ -414,9 +475,8 @@ G_END_DECLS # endif /* !GLIB_COMPILATION */ # endif /* !GLIB_STATIC_COMPILATION */ # else /* !G_PLATFORM_WIN32 */ -# define GLIB_VAR extern +# define GLIB_VAR _GLIB_EXTERN # endif /* !G_PLATFORM_WIN32 */ #endif /* GLIB_VAR */ #endif /* __G_TYPES_H__ */ -