From 2d68cbbb7d37d3f265bf1087e6ddedcc58bc62be Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Mon, 21 Sep 1998 02:32:30 +0000 Subject: [PATCH] NEWS file update for upcoming release of GLib + GModule version 1.1.3, Mon Sep 21 02:22:12 1998 Tim Janik * NEWS file update for upcoming release of GLib + GModule version 1.1.3, binary age 0, interface age 0. (GModule uses the same version numbers as GLib.) * glib.h: swap the inclusion of of float.h and limits.h to work around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by Per Abrahamsen ). * glib.h: * gscanner.c: renamed the GValue union to GTokenValue, this should not affect source compatibility in most cases. * ghash.c: added some g_return_if_fail() statements. make g_hash_table_lookup_node() an inline function so we save an extra function invokation on lookups. Mon Sep 21 01:54:48 1998 Tim Janik * gmodule.h: * gmodule.c: renamed old _de_init functionality to _unload. modules are now expected to export: G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module); and G_MODULE_EXPORT void g_module_unload (GModule *module); returning a string other than NULL from g_module_check_init() will prevent the module from being loaded. a call to g_module_make_resident() from g_module_unload() will prevent the module from being unloaded and still make it resident. --- ChangeLog | 18 ++++ ChangeLog.pre-2-0 | 18 ++++ ChangeLog.pre-2-10 | 18 ++++ ChangeLog.pre-2-12 | 18 ++++ ChangeLog.pre-2-2 | 18 ++++ ChangeLog.pre-2-4 | 18 ++++ ChangeLog.pre-2-6 | 18 ++++ ChangeLog.pre-2-8 | 18 ++++ NEWS | 27 +++++- configure.in | 4 + ghash.c | 228 ++++++++++++++++++++++++------------------------- glib.h | 82 ++++++++---------- glib/ghash.c | 228 ++++++++++++++++++++++++------------------------- glib/glib.h | 82 ++++++++---------- glib/gscanner.c | 18 ++-- gmodule/ChangeLog | 13 +++ gmodule/gmodule.c | 20 ++--- gmodule/gmodule.h | 2 +- gmodule/libgplugin_b.c | 4 +- gscanner.c | 18 ++-- 20 files changed, 515 insertions(+), 355 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6757c1a..054416d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 6757c1a..054416d 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 6757c1a..054416d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 6757c1a..054416d 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 6757c1a..054416d 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 6757c1a..054416d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 6757c1a..054416d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 6757c1a..054416d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,21 @@ +Mon Sep 21 02:22:12 1998 Tim Janik + + * NEWS file update for upcoming release of GLib + GModule + version 1.1.3, binary age 0, interface age 0. (GModule uses + the same version numbers as GLib.) + + * glib.h: swap the inclusion of of float.h and limits.h to work + around a egcs 1.1 oddity on Solaris 2.5.1 (fix provided by + Per Abrahamsen ). + + * glib.h: + * gscanner.c: renamed the GValue union to GTokenValue, this should + not affect source compatibility in most cases. + + * ghash.c: added some g_return_if_fail() statements. make + g_hash_table_lookup_node() an inline function so we save an extra + function invokation on lookups. + Sun Sep 20 18:21:46 1998 Owen Taylor * ltconfig.sh: Patch to libtool-1.2b to make --disable-static diff --git a/NEWS b/NEWS index 8068051..9449005 100644 --- a/NEWS +++ b/NEWS @@ -1,14 +1,33 @@ Overview of Changes in GLib 1.1.3: -* New library gmodule included which basically wraps dlopen() facilities. +* New GModule mechanism (implemented in an extra library) which wraps dynamic + object code loading facilities in a portable manner. +* glib-config features extra "glib" (old behaviour remains) and "gmodule" + (add libgmodule.so to the --libs output) arguments now. this can also + be specified as fourth argument to the AM_PATH_GLIB() macro. +* Overhaul of the `inline' autoconfiguration stuff, so inlining should be + sufficiently supported on all systems that allow inlining now. * New g_log() mechanism for logging of messages at different log levels, - associated with certain log domains (define -DG_LOG_DOMAIN for your module). + associated with certain log domains (define -DG_LOG_DOMAIN for your library). * New inline functions for bit masks tests. -* GNode functions now return the newly allocated node. +* GNode macros (and functions) now return the newly allocated node. * New macro G_VA_COPY() to work around va_list copying oddities on some platforms. the non-static g_vsprintf() function vanished in favour of a publically exported g_strdup_vprintf(). -* New utility functions for string and printf-like format handling . + People that used the former g_vsprintf() would definitely want to read the + associated ChangeLog entries (grep for printf). +* New utility functions: + g_strndup(), g_on_error_query(), g_on_error_stack_trace(), g_strdup_printf(), + g_strdup_vprintf(), g_printf_string_upper_bound(), g_spaced_primes_closest(), + g_strnfill(), g_memdup(). +* Overhaul of the array implementations, this contains some source incompatible + changes. Again, the ChangeLog is much more informative (grep for garray.c). +* The internals of the g_dataset mechanism are now exported through the + new g_datalist_* API (this is also the underlying implementation for the + keyed data of GtkObjects). +* New function g_atexit(), use of the ATEXIT() macro is discouraged. +* Better configure checks for ansi compliance. +* Libtool update to version 1.2b. * Lotsa bug fixes and cleanups as always ;) Overview of Changes in GLib 1.1.2: diff --git a/configure.in b/configure.in index 47461ce..3efe1ea 100644 --- a/configure.in +++ b/configure.in @@ -4,6 +4,10 @@ AC_INIT(glist.c) # Save this value here, since automake will set cflags later cflags_set=${CFLAGS+set} +# The following version number definitions apply to GLib and GModule +# as a whole, so if changes occoured in either of them, they are both +# treated with the same interface and binary age. +# # Making releases: # GLIB_MICRO_VERSION += 1; # GLIB_INTERFACE_AGE += 1; diff --git a/ghash.c b/ghash.c index 065f889..0ff5a24 100644 --- a/ghash.c +++ b/ghash.c @@ -8,7 +8,7 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public @@ -43,13 +43,13 @@ struct _GHashTable }; -static void g_hash_table_resize (GHashTable *hash_table); -static GHashNode** g_hash_table_lookup_node(GHashTable *hash_table, - gconstpointer key); -static GHashNode* g_hash_node_new (gpointer key, - gpointer value); -static void g_hash_node_destroy (GHashNode *hash_node); -static void g_hash_nodes_destroy (GHashNode *hash_node); +static void g_hash_table_resize (GHashTable *hash_table); +static GHashNode** g_hash_table_lookup_node (GHashTable *hash_table, + gconstpointer key); +static GHashNode* g_hash_node_new (gpointer key, + gpointer value); +static void g_hash_node_destroy (GHashNode *hash_node); +static void g_hash_nodes_destroy (GHashNode *hash_node); static GMemChunk *node_mem_chunk = NULL; @@ -61,8 +61,8 @@ g_hash_table_new (GHashFunc hash_func, GCompareFunc key_compare_func) { GHashTable *hash_table; - gint i; - + guint i; + hash_table = g_new (GHashTable, 1); hash_table->size = HASH_TABLE_MIN_SIZE; hash_table->nnodes = 0; @@ -70,38 +70,75 @@ g_hash_table_new (GHashFunc hash_func, hash_table->hash_func = hash_func ? hash_func : g_direct_hash; hash_table->key_compare_func = key_compare_func; hash_table->nodes = g_new (GHashNode*, hash_table->size); - + for (i = 0; i < hash_table->size; i++) hash_table->nodes[i] = NULL; - + return hash_table; } void g_hash_table_destroy (GHashTable *hash_table) { - gint i; - - g_return_if_fail (hash_table); - + guint i; + + g_return_if_fail (hash_table != NULL); + for (i = 0; i < hash_table->size; i++) g_hash_nodes_destroy (hash_table->nodes[i]); - + g_free (hash_table->nodes); g_free (hash_table); } -void -g_hash_table_insert (GHashTable *hash_table, - gpointer key, - gpointer value) +static inline GHashNode** +g_hash_table_lookup_node (GHashTable *hash_table, + gconstpointer key) { GHashNode **node; + + node = &hash_table->nodes + [(* hash_table->hash_func) (key) % hash_table->size]; + + /* Hash table lookup needs to be fast. + * We therefore remove the extra conditional of testing + * whether to call the key_compare_func or not from + * the inner loop. + */ + if (hash_table->key_compare_func) + while (*node && !(*hash_table->key_compare_func) ((*node)->key, key)) + node = &(*node)->next; + else + while (*node && (*node)->key != key) + node = &(*node)->next; + + return node; +} - g_return_if_fail (hash_table); +gpointer +g_hash_table_lookup (GHashTable *hash_table, + gconstpointer key) +{ + GHashNode *node; + + g_return_val_if_fail (hash_table != NULL, NULL); + + node = *g_hash_table_lookup_node (hash_table, key); + + return node ? node->value : NULL; +} +void +g_hash_table_insert (GHashTable *hash_table, + gpointer key, + gpointer value) +{ + GHashNode **node; + + g_return_if_fail (hash_table != NULL); + node = g_hash_table_lookup_node (hash_table, key); - + if (*node) { /* do not reset node->key in this place, keeping @@ -122,13 +159,13 @@ g_hash_table_insert (GHashTable *hash_table, } void -g_hash_table_remove (GHashTable *hash_table, +g_hash_table_remove (GHashTable *hash_table, gconstpointer key) { GHashNode **node, *dest; - - g_return_if_fail (hash_table); - + + g_return_if_fail (hash_table != NULL); + while (*(node = g_hash_table_lookup_node (hash_table, key))) { dest = *node; @@ -136,22 +173,11 @@ g_hash_table_remove (GHashTable *hash_table, g_hash_node_destroy (dest); hash_table->nnodes--; } + if (!hash_table->frozen) g_hash_table_resize (hash_table); } -gpointer -g_hash_table_lookup (GHashTable *hash_table, - gconstpointer key) -{ - GHashNode *node; - - g_return_val_if_fail (hash_table, NULL); - - node = *g_hash_table_lookup_node (hash_table, key); - return node ? node->value : NULL; -} - gboolean g_hash_table_lookup_extended (GHashTable *hash_table, gconstpointer lookup_key, @@ -159,11 +185,11 @@ g_hash_table_lookup_extended (GHashTable *hash_table, gpointer *value) { GHashNode *node; - - g_return_val_if_fail (hash_table, FALSE); - + + g_return_val_if_fail (hash_table != NULL, FALSE); + node = *g_hash_table_lookup_node (hash_table, lookup_key); - + if (node) { if (orig_key) @@ -179,45 +205,47 @@ g_hash_table_lookup_extended (GHashTable *hash_table, void g_hash_table_freeze (GHashTable *hash_table) { - g_return_if_fail (hash_table); - + g_return_if_fail (hash_table != NULL); + hash_table->frozen = TRUE; } void g_hash_table_thaw (GHashTable *hash_table) { - g_return_if_fail (hash_table); - + g_return_if_fail (hash_table != NULL); + hash_table->frozen = FALSE; - + g_hash_table_resize (hash_table); } gint -g_hash_table_foreach_remove (GHashTable *hash_table, - GHRFunc func, - gpointer user_data) +g_hash_table_foreach_remove (GHashTable *hash_table, + GHRFunc func, + gpointer user_data) { - gint deleted = 0, i; GHashNode *node, *prev; - - g_return_val_if_fail (hash_table && func, -1); - + guint i; + gint deleted = 0; + + g_return_val_if_fail (hash_table != NULL, 0); + g_return_val_if_fail (func != NULL, 0); + for (i = 0; i < hash_table->size; i++) { restart: - + prev = NULL; - + for (node = hash_table->nodes[i]; node; prev = node, node = node->next) { if ((* func) (node->key, node->value, user_data)) { deleted += 1; - + hash_table->nnodes -= 1; - + if (prev) { prev->next = node->next; @@ -233,33 +261,35 @@ g_hash_table_foreach_remove (GHashTable *hash_table, } } } - - if (! hash_table->frozen) + + if (!hash_table->frozen) g_hash_table_resize (hash_table); - + return deleted; } void g_hash_table_foreach (GHashTable *hash_table, - GHFunc func, - gpointer user_data) + GHFunc func, + gpointer user_data) { GHashNode *node; gint i; - - g_return_if_fail (hash_table); - + + g_return_if_fail (hash_table != NULL); + g_return_if_fail (func != NULL); + for (i = 0; i < hash_table->size; i++) for (node = hash_table->nodes[i]; node; node = node->next) (* func) (node->key, node->value, user_data); } /* Returns the number of elements contained in the hash table. */ -gint g_hash_table_size (GHashTable *hash_table) +gint +g_hash_table_size (GHashTable *hash_table) { - g_return_val_if_fail (hash_table, 0); - + g_return_val_if_fail (hash_table != NULL, 0); + return hash_table->nnodes; } @@ -273,23 +303,21 @@ g_hash_table_resize (GHashTable *hash_table) guint hash_val; gint new_size; gint i; - - g_return_if_fail (hash_table); - + nodes_per_list = (gfloat) hash_table->nnodes / (gfloat) hash_table->size; - + if ((nodes_per_list > 0.3 || hash_table->size <= HASH_TABLE_MIN_SIZE) && (nodes_per_list < 3.0 || hash_table->size >= HASH_TABLE_MAX_SIZE)) return; - + new_size = CLAMP(g_spaced_primes_closest (hash_table->nnodes), HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE); new_nodes = g_new (GHashNode*, new_size); - + for (i = 0; i < new_size; i++) new_nodes[i] = NULL; - + for (i = 0; i < hash_table->size; i++) for (node = hash_table->nodes[i]; node; node = next) { @@ -298,44 +326,18 @@ g_hash_table_resize (GHashTable *hash_table) node->next = new_nodes[hash_val]; new_nodes[hash_val] = node; } - + g_free (hash_table->nodes); hash_table->nodes = new_nodes; hash_table->size = new_size; } -static GHashNode ** -g_hash_table_lookup_node (GHashTable *hash_table, - gconstpointer key) -{ - GHashNode **node; - - g_return_val_if_fail (hash_table, NULL); - - node = &hash_table->nodes - [(* hash_table->hash_func) (key) % hash_table->size]; - - /* Hash table lookup needs to be fast. - * We therefore remove the extra conditional of testing - * whether to call the key_compare_func or not from - * the inner loop. - */ - if (hash_table->key_compare_func) - while (*node && !(*hash_table->key_compare_func) ((*node)->key, key)) - node = &(*node)->next; - else - while (*node && (*node)->key != key) - node = &(*node)->next; - - return node; -} - static GHashNode* g_hash_node_new (gpointer key, gpointer value) { GHashNode *hash_node; - + if (node_free_list) { hash_node = node_free_list; @@ -347,22 +349,20 @@ g_hash_node_new (gpointer key, node_mem_chunk = g_mem_chunk_new ("hash node mem chunk", sizeof (GHashNode), 1024, G_ALLOC_ONLY); - + hash_node = g_chunk_new (GHashNode, node_mem_chunk); } - + hash_node->key = key; hash_node->value = value; hash_node->next = NULL; - + return hash_node; } static void g_hash_node_destroy (GHashNode *hash_node) { - g_return_if_fail (hash_node); - hash_node->next = node_free_list; node_free_list = hash_node; } @@ -371,15 +371,15 @@ static void g_hash_nodes_destroy (GHashNode *hash_node) { GHashNode *node; - + if (!hash_node) return; - + node = hash_node; - + while (node->next) node = node->next; - + node->next = node_free_list; node_free_list = hash_node; } diff --git a/glib.h b/glib.h index 6b199cb..eea0bbb 100644 --- a/glib.h +++ b/glib.h @@ -46,52 +46,42 @@ * G_MAXINT * G_MINLONG * G_MAXLONG + * + * We include limits.h before float.h to work around a egcs 1.1 + * oddity on Solaris 2.5.1 */ - -#ifdef HAVE_FLOAT_H - -#include - -#define G_MINFLOAT FLT_MIN -#define G_MAXFLOAT FLT_MAX -#define G_MINDOUBLE DBL_MIN -#define G_MAXDOUBLE DBL_MAX - -#elif HAVE_VALUES_H - -#include - -#define G_MINFLOAT MINFLOAT -#define G_MAXFLOAT MAXFLOAT -#define G_MINDOUBLE MINDOUBLE -#define G_MAXDOUBLE MAXDOUBLE - -#endif /* HAVE_VALUES_H */ - #ifdef HAVE_LIMITS_H - -#include - -#define G_MINSHORT SHRT_MIN -#define G_MAXSHORT SHRT_MAX -#define G_MININT INT_MIN -#define G_MAXINT INT_MAX -#define G_MINLONG LONG_MIN -#define G_MAXLONG LONG_MAX - +# include +# define G_MINSHORT SHRT_MIN +# define G_MAXSHORT SHRT_MAX +# define G_MININT INT_MIN +# define G_MAXINT INT_MAX +# define G_MINLONG LONG_MIN +# define G_MAXLONG LONG_MAX #elif HAVE_VALUES_H +# ifdef HAVE_FLOAT_H +# include +# endif /* HAVE_FLOAT_H */ +# define G_MINSHORT MINSHORT +# define G_MAXSHORT MAXSHORT +# define G_MININT MININT +# define G_MAXINT MAXINT +# define G_MINLONG MINLONG +# define G_MAXLONG MAXLONG +#endif /* HAVE_VALUES_H */ #ifdef HAVE_FLOAT_H -#include -#endif /* HAVE_FLOAT_H */ - -#define G_MINSHORT MINSHORT -#define G_MAXSHORT MAXSHORT -#define G_MININT MININT -#define G_MAXINT MAXINT -#define G_MINLONG MINLONG -#define G_MAXLONG MAXLONG - +# include +# define G_MINFLOAT FLT_MIN +# define G_MAXFLOAT FLT_MAX +# define G_MINDOUBLE DBL_MIN +# define G_MAXDOUBLE DBL_MAX +#elif HAVE_VALUES_H +# include +# define G_MINFLOAT MINFLOAT +# define G_MAXFLOAT MAXFLOAT +# define G_MINDOUBLE MINDOUBLE +# define G_MAXDOUBLE MAXDOUBLE #endif /* HAVE_VALUES_H */ @@ -596,7 +586,7 @@ typedef struct _GStringChunk GStringChunk; typedef struct _GTimer GTimer; typedef struct _GTree GTree; typedef struct _GTuples GTuples; -typedef union _GValue GValue; +typedef union _GTokenValue GTokenValue; typedef enum @@ -1579,7 +1569,7 @@ typedef enum G_TOKEN_LAST } GTokenType; -union _GValue +union _GTokenValue { gpointer v_symbol; gchar *v_identifier; @@ -1652,13 +1642,13 @@ struct _GScanner /* fields filled in after g_scanner_get_next_token() */ GTokenType token; - GValue value; + GTokenValue value; guint line; guint position; /* fields filled in after g_scanner_peek_next_token() */ GTokenType next_token; - GValue next_value; + GTokenValue next_value; guint next_line; guint next_position; @@ -1684,7 +1674,7 @@ void g_scanner_input_text (GScanner *scanner, GTokenType g_scanner_get_next_token (GScanner *scanner); GTokenType g_scanner_peek_next_token (GScanner *scanner); GTokenType g_scanner_cur_token (GScanner *scanner); -GValue g_scanner_cur_value (GScanner *scanner); +GTokenValue g_scanner_cur_value (GScanner *scanner); guint g_scanner_cur_line (GScanner *scanner); guint g_scanner_cur_position (GScanner *scanner); gboolean g_scanner_eof (GScanner *scanner); diff --git a/glib/ghash.c b/glib/ghash.c index 065f889..0ff5a24 100644 --- a/glib/ghash.c +++ b/glib/ghash.c @@ -8,7 +8,7 @@ * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public @@ -43,13 +43,13 @@ struct _GHashTable }; -static void g_hash_table_resize (GHashTable *hash_table); -static GHashNode** g_hash_table_lookup_node(GHashTable *hash_table, - gconstpointer key); -static GHashNode* g_hash_node_new (gpointer key, - gpointer value); -static void g_hash_node_destroy (GHashNode *hash_node); -static void g_hash_nodes_destroy (GHashNode *hash_node); +static void g_hash_table_resize (GHashTable *hash_table); +static GHashNode** g_hash_table_lookup_node (GHashTable *hash_table, + gconstpointer key); +static GHashNode* g_hash_node_new (gpointer key, + gpointer value); +static void g_hash_node_destroy (GHashNode *hash_node); +static void g_hash_nodes_destroy (GHashNode *hash_node); static GMemChunk *node_mem_chunk = NULL; @@ -61,8 +61,8 @@ g_hash_table_new (GHashFunc hash_func, GCompareFunc key_compare_func) { GHashTable *hash_table; - gint i; - + guint i; + hash_table = g_new (GHashTable, 1); hash_table->size = HASH_TABLE_MIN_SIZE; hash_table->nnodes = 0; @@ -70,38 +70,75 @@ g_hash_table_new (GHashFunc hash_func, hash_table->hash_func = hash_func ? hash_func : g_direct_hash; hash_table->key_compare_func = key_compare_func; hash_table->nodes = g_new (GHashNode*, hash_table->size); - + for (i = 0; i < hash_table->size; i++) hash_table->nodes[i] = NULL; - + return hash_table; } void g_hash_table_destroy (GHashTable *hash_table) { - gint i; - - g_return_if_fail (hash_table); - + guint i; + + g_return_if_fail (hash_table != NULL); + for (i = 0; i < hash_table->size; i++) g_hash_nodes_destroy (hash_table->nodes[i]); - + g_free (hash_table->nodes); g_free (hash_table); } -void -g_hash_table_insert (GHashTable *hash_table, - gpointer key, - gpointer value) +static inline GHashNode** +g_hash_table_lookup_node (GHashTable *hash_table, + gconstpointer key) { GHashNode **node; + + node = &hash_table->nodes + [(* hash_table->hash_func) (key) % hash_table->size]; + + /* Hash table lookup needs to be fast. + * We therefore remove the extra conditional of testing + * whether to call the key_compare_func or not from + * the inner loop. + */ + if (hash_table->key_compare_func) + while (*node && !(*hash_table->key_compare_func) ((*node)->key, key)) + node = &(*node)->next; + else + while (*node && (*node)->key != key) + node = &(*node)->next; + + return node; +} - g_return_if_fail (hash_table); +gpointer +g_hash_table_lookup (GHashTable *hash_table, + gconstpointer key) +{ + GHashNode *node; + + g_return_val_if_fail (hash_table != NULL, NULL); + + node = *g_hash_table_lookup_node (hash_table, key); + + return node ? node->value : NULL; +} +void +g_hash_table_insert (GHashTable *hash_table, + gpointer key, + gpointer value) +{ + GHashNode **node; + + g_return_if_fail (hash_table != NULL); + node = g_hash_table_lookup_node (hash_table, key); - + if (*node) { /* do not reset node->key in this place, keeping @@ -122,13 +159,13 @@ g_hash_table_insert (GHashTable *hash_table, } void -g_hash_table_remove (GHashTable *hash_table, +g_hash_table_remove (GHashTable *hash_table, gconstpointer key) { GHashNode **node, *dest; - - g_return_if_fail (hash_table); - + + g_return_if_fail (hash_table != NULL); + while (*(node = g_hash_table_lookup_node (hash_table, key))) { dest = *node; @@ -136,22 +173,11 @@ g_hash_table_remove (GHashTable *hash_table, g_hash_node_destroy (dest); hash_table->nnodes--; } + if (!hash_table->frozen) g_hash_table_resize (hash_table); } -gpointer -g_hash_table_lookup (GHashTable *hash_table, - gconstpointer key) -{ - GHashNode *node; - - g_return_val_if_fail (hash_table, NULL); - - node = *g_hash_table_lookup_node (hash_table, key); - return node ? node->value : NULL; -} - gboolean g_hash_table_lookup_extended (GHashTable *hash_table, gconstpointer lookup_key, @@ -159,11 +185,11 @@ g_hash_table_lookup_extended (GHashTable *hash_table, gpointer *value) { GHashNode *node; - - g_return_val_if_fail (hash_table, FALSE); - + + g_return_val_if_fail (hash_table != NULL, FALSE); + node = *g_hash_table_lookup_node (hash_table, lookup_key); - + if (node) { if (orig_key) @@ -179,45 +205,47 @@ g_hash_table_lookup_extended (GHashTable *hash_table, void g_hash_table_freeze (GHashTable *hash_table) { - g_return_if_fail (hash_table); - + g_return_if_fail (hash_table != NULL); + hash_table->frozen = TRUE; } void g_hash_table_thaw (GHashTable *hash_table) { - g_return_if_fail (hash_table); - + g_return_if_fail (hash_table != NULL); + hash_table->frozen = FALSE; - + g_hash_table_resize (hash_table); } gint -g_hash_table_foreach_remove (GHashTable *hash_table, - GHRFunc func, - gpointer user_data) +g_hash_table_foreach_remove (GHashTable *hash_table, + GHRFunc func, + gpointer user_data) { - gint deleted = 0, i; GHashNode *node, *prev; - - g_return_val_if_fail (hash_table && func, -1); - + guint i; + gint deleted = 0; + + g_return_val_if_fail (hash_table != NULL, 0); + g_return_val_if_fail (func != NULL, 0); + for (i = 0; i < hash_table->size; i++) { restart: - + prev = NULL; - + for (node = hash_table->nodes[i]; node; prev = node, node = node->next) { if ((* func) (node->key, node->value, user_data)) { deleted += 1; - + hash_table->nnodes -= 1; - + if (prev) { prev->next = node->next; @@ -233,33 +261,35 @@ g_hash_table_foreach_remove (GHashTable *hash_table, } } } - - if (! hash_table->frozen) + + if (!hash_table->frozen) g_hash_table_resize (hash_table); - + return deleted; } void g_hash_table_foreach (GHashTable *hash_table, - GHFunc func, - gpointer user_data) + GHFunc func, + gpointer user_data) { GHashNode *node; gint i; - - g_return_if_fail (hash_table); - + + g_return_if_fail (hash_table != NULL); + g_return_if_fail (func != NULL); + for (i = 0; i < hash_table->size; i++) for (node = hash_table->nodes[i]; node; node = node->next) (* func) (node->key, node->value, user_data); } /* Returns the number of elements contained in the hash table. */ -gint g_hash_table_size (GHashTable *hash_table) +gint +g_hash_table_size (GHashTable *hash_table) { - g_return_val_if_fail (hash_table, 0); - + g_return_val_if_fail (hash_table != NULL, 0); + return hash_table->nnodes; } @@ -273,23 +303,21 @@ g_hash_table_resize (GHashTable *hash_table) guint hash_val; gint new_size; gint i; - - g_return_if_fail (hash_table); - + nodes_per_list = (gfloat) hash_table->nnodes / (gfloat) hash_table->size; - + if ((nodes_per_list > 0.3 || hash_table->size <= HASH_TABLE_MIN_SIZE) && (nodes_per_list < 3.0 || hash_table->size >= HASH_TABLE_MAX_SIZE)) return; - + new_size = CLAMP(g_spaced_primes_closest (hash_table->nnodes), HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE); new_nodes = g_new (GHashNode*, new_size); - + for (i = 0; i < new_size; i++) new_nodes[i] = NULL; - + for (i = 0; i < hash_table->size; i++) for (node = hash_table->nodes[i]; node; node = next) { @@ -298,44 +326,18 @@ g_hash_table_resize (GHashTable *hash_table) node->next = new_nodes[hash_val]; new_nodes[hash_val] = node; } - + g_free (hash_table->nodes); hash_table->nodes = new_nodes; hash_table->size = new_size; } -static GHashNode ** -g_hash_table_lookup_node (GHashTable *hash_table, - gconstpointer key) -{ - GHashNode **node; - - g_return_val_if_fail (hash_table, NULL); - - node = &hash_table->nodes - [(* hash_table->hash_func) (key) % hash_table->size]; - - /* Hash table lookup needs to be fast. - * We therefore remove the extra conditional of testing - * whether to call the key_compare_func or not from - * the inner loop. - */ - if (hash_table->key_compare_func) - while (*node && !(*hash_table->key_compare_func) ((*node)->key, key)) - node = &(*node)->next; - else - while (*node && (*node)->key != key) - node = &(*node)->next; - - return node; -} - static GHashNode* g_hash_node_new (gpointer key, gpointer value) { GHashNode *hash_node; - + if (node_free_list) { hash_node = node_free_list; @@ -347,22 +349,20 @@ g_hash_node_new (gpointer key, node_mem_chunk = g_mem_chunk_new ("hash node mem chunk", sizeof (GHashNode), 1024, G_ALLOC_ONLY); - + hash_node = g_chunk_new (GHashNode, node_mem_chunk); } - + hash_node->key = key; hash_node->value = value; hash_node->next = NULL; - + return hash_node; } static void g_hash_node_destroy (GHashNode *hash_node) { - g_return_if_fail (hash_node); - hash_node->next = node_free_list; node_free_list = hash_node; } @@ -371,15 +371,15 @@ static void g_hash_nodes_destroy (GHashNode *hash_node) { GHashNode *node; - + if (!hash_node) return; - + node = hash_node; - + while (node->next) node = node->next; - + node->next = node_free_list; node_free_list = hash_node; } diff --git a/glib/glib.h b/glib/glib.h index 6b199cb..eea0bbb 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -46,52 +46,42 @@ * G_MAXINT * G_MINLONG * G_MAXLONG + * + * We include limits.h before float.h to work around a egcs 1.1 + * oddity on Solaris 2.5.1 */ - -#ifdef HAVE_FLOAT_H - -#include - -#define G_MINFLOAT FLT_MIN -#define G_MAXFLOAT FLT_MAX -#define G_MINDOUBLE DBL_MIN -#define G_MAXDOUBLE DBL_MAX - -#elif HAVE_VALUES_H - -#include - -#define G_MINFLOAT MINFLOAT -#define G_MAXFLOAT MAXFLOAT -#define G_MINDOUBLE MINDOUBLE -#define G_MAXDOUBLE MAXDOUBLE - -#endif /* HAVE_VALUES_H */ - #ifdef HAVE_LIMITS_H - -#include - -#define G_MINSHORT SHRT_MIN -#define G_MAXSHORT SHRT_MAX -#define G_MININT INT_MIN -#define G_MAXINT INT_MAX -#define G_MINLONG LONG_MIN -#define G_MAXLONG LONG_MAX - +# include +# define G_MINSHORT SHRT_MIN +# define G_MAXSHORT SHRT_MAX +# define G_MININT INT_MIN +# define G_MAXINT INT_MAX +# define G_MINLONG LONG_MIN +# define G_MAXLONG LONG_MAX #elif HAVE_VALUES_H +# ifdef HAVE_FLOAT_H +# include +# endif /* HAVE_FLOAT_H */ +# define G_MINSHORT MINSHORT +# define G_MAXSHORT MAXSHORT +# define G_MININT MININT +# define G_MAXINT MAXINT +# define G_MINLONG MINLONG +# define G_MAXLONG MAXLONG +#endif /* HAVE_VALUES_H */ #ifdef HAVE_FLOAT_H -#include -#endif /* HAVE_FLOAT_H */ - -#define G_MINSHORT MINSHORT -#define G_MAXSHORT MAXSHORT -#define G_MININT MININT -#define G_MAXINT MAXINT -#define G_MINLONG MINLONG -#define G_MAXLONG MAXLONG - +# include +# define G_MINFLOAT FLT_MIN +# define G_MAXFLOAT FLT_MAX +# define G_MINDOUBLE DBL_MIN +# define G_MAXDOUBLE DBL_MAX +#elif HAVE_VALUES_H +# include +# define G_MINFLOAT MINFLOAT +# define G_MAXFLOAT MAXFLOAT +# define G_MINDOUBLE MINDOUBLE +# define G_MAXDOUBLE MAXDOUBLE #endif /* HAVE_VALUES_H */ @@ -596,7 +586,7 @@ typedef struct _GStringChunk GStringChunk; typedef struct _GTimer GTimer; typedef struct _GTree GTree; typedef struct _GTuples GTuples; -typedef union _GValue GValue; +typedef union _GTokenValue GTokenValue; typedef enum @@ -1579,7 +1569,7 @@ typedef enum G_TOKEN_LAST } GTokenType; -union _GValue +union _GTokenValue { gpointer v_symbol; gchar *v_identifier; @@ -1652,13 +1642,13 @@ struct _GScanner /* fields filled in after g_scanner_get_next_token() */ GTokenType token; - GValue value; + GTokenValue value; guint line; guint position; /* fields filled in after g_scanner_peek_next_token() */ GTokenType next_token; - GValue next_value; + GTokenValue next_value; guint next_line; guint next_position; @@ -1684,7 +1674,7 @@ void g_scanner_input_text (GScanner *scanner, GTokenType g_scanner_get_next_token (GScanner *scanner); GTokenType g_scanner_peek_next_token (GScanner *scanner); GTokenType g_scanner_cur_token (GScanner *scanner); -GValue g_scanner_cur_value (GScanner *scanner); +GTokenValue g_scanner_cur_value (GScanner *scanner); guint g_scanner_cur_line (GScanner *scanner); guint g_scanner_cur_position (GScanner *scanner); gboolean g_scanner_eof (GScanner *scanner); diff --git a/glib/gscanner.c b/glib/gscanner.c index 8577368..d11e8bd 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -114,16 +114,16 @@ static gint g_scanner_key_equal (gconstpointer v1, static guint g_scanner_key_hash (gconstpointer v); static void g_scanner_get_token_ll (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p); static void g_scanner_get_token_i (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p); static void g_scanner_free_value (GTokenType *token_p, - GValue *value_p); + GTokenValue *value_p); static guchar g_scanner_peek_next_char (GScanner *scanner); static guchar g_scanner_get_char (GScanner *scanner, @@ -627,10 +627,10 @@ g_scanner_cur_token (GScanner *scanner) return scanner->token; } -GValue +GTokenValue g_scanner_cur_value (GScanner *scanner) { - GValue v; + GTokenValue v; v.v_int = 0; g_return_val_if_fail (scanner != NULL, v); @@ -1051,7 +1051,7 @@ g_scanner_stat_mode (const gchar *filename) static void g_scanner_free_value (GTokenType *token_p, - GValue *value_p) + GTokenValue *value_p) { switch (*token_p) { @@ -1073,7 +1073,7 @@ g_scanner_free_value (GTokenType *token_p, static void g_scanner_get_token_i (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p) { @@ -1127,7 +1127,7 @@ g_scanner_get_token_i (GScanner *scanner, static void g_scanner_get_token_ll (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p) { @@ -1139,7 +1139,7 @@ g_scanner_get_token_ll (GScanner *scanner, static guchar ch; register GTokenType token; register GString *gstring; - GValue value; + GTokenValue value; config = scanner->config; (*value_p).v_int = 0; diff --git a/gmodule/ChangeLog b/gmodule/ChangeLog index 723d524..07493b4 100644 --- a/gmodule/ChangeLog +++ b/gmodule/ChangeLog @@ -1,3 +1,16 @@ +Mon Sep 21 01:54:48 1998 Tim Janik + + * gmodule.h: + * gmodule.c: renamed old _de_init functionality to _unload. + modules are now expected to export: + G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module); + and + G_MODULE_EXPORT void g_module_unload (GModule *module); + returning a string other than NULL from g_module_check_init() will + prevent the module from being loaded. a call to g_module_make_resident() + from g_module_unload() will prevent the module from being unloaded and + still make it resident. + Thu Sep 17 06:34:22 1998 Tim Janik * gmodule.h: diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index 04d435e..17133ff 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -38,7 +38,7 @@ struct _GModule gpointer handle; guint ref_count : 31; guint is_resident : 1; - GModuleDeInit de_init; + GModuleUnload unload; GModule *next; }; @@ -166,7 +166,7 @@ g_module_open (const gchar *file_name, main_module->handle = handle; main_module->ref_count = 1; main_module->is_resident = TRUE; - main_module->de_init = NULL; + main_module->unload = NULL; main_module->next = NULL; } } @@ -211,7 +211,7 @@ g_module_open (const gchar *file_name, module->handle = handle; module->ref_count = 1; module->is_resident = FALSE; - module->de_init = NULL; + module->unload = NULL; module->next = modules; modules = module; @@ -219,9 +219,9 @@ g_module_open (const gchar *file_name, if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init)) check_failed = check_init (module); - /* we don't call de_init() if the initialization check failed. */ + /* we don't call unload() if the initialization check failed. */ if (!check_failed) - g_module_symbol (module, "g_module_de_init", (gpointer) &module->de_init); + g_module_symbol (module, "g_module_unload", (gpointer) &module->unload); if (check_failed) { @@ -251,13 +251,13 @@ g_module_close (GModule *module) module->ref_count--; - if (!module->ref_count && !module->is_resident && module->de_init) + if (!module->ref_count && !module->is_resident && module->unload) { - GModuleDeInit de_init; + GModuleUnload unload; - de_init = module->de_init; - module->de_init = NULL; - de_init (module); + unload = module->unload; + module->unload = NULL; + unload (module); } if (!module->ref_count && !module->is_resident) diff --git a/gmodule/gmodule.h b/gmodule/gmodule.h index 966d5ef..dbc794a 100644 --- a/gmodule/gmodule.h +++ b/gmodule/gmodule.h @@ -44,7 +44,7 @@ typedef enum typedef struct _GModule GModule; typedef const gchar* (*GModuleCheckInit) (GModule *module); -typedef void (*GModuleDeInit) (GModule *module); +typedef void (*GModuleUnload) (GModule *module); /* return TRUE if dynamic module loading is supported */ gboolean g_module_supported (void); diff --git a/gmodule/libgplugin_b.c b/gmodule/libgplugin_b.c index 2d2de96..b6e7521 100644 --- a/gmodule/libgplugin_b.c +++ b/gmodule/libgplugin_b.c @@ -27,9 +27,9 @@ g_module_check_init (GModule *module) } G_MODULE_EXPORT void -g_module_de_init (GModule *module) +g_module_unload (GModule *module) { - g_print ("GPluginB: de-init\n"); + g_print ("GPluginB: unloaded\n"); } G_MODULE_EXPORT void diff --git a/gscanner.c b/gscanner.c index 8577368..d11e8bd 100644 --- a/gscanner.c +++ b/gscanner.c @@ -114,16 +114,16 @@ static gint g_scanner_key_equal (gconstpointer v1, static guint g_scanner_key_hash (gconstpointer v); static void g_scanner_get_token_ll (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p); static void g_scanner_get_token_i (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p); static void g_scanner_free_value (GTokenType *token_p, - GValue *value_p); + GTokenValue *value_p); static guchar g_scanner_peek_next_char (GScanner *scanner); static guchar g_scanner_get_char (GScanner *scanner, @@ -627,10 +627,10 @@ g_scanner_cur_token (GScanner *scanner) return scanner->token; } -GValue +GTokenValue g_scanner_cur_value (GScanner *scanner) { - GValue v; + GTokenValue v; v.v_int = 0; g_return_val_if_fail (scanner != NULL, v); @@ -1051,7 +1051,7 @@ g_scanner_stat_mode (const gchar *filename) static void g_scanner_free_value (GTokenType *token_p, - GValue *value_p) + GTokenValue *value_p) { switch (*token_p) { @@ -1073,7 +1073,7 @@ g_scanner_free_value (GTokenType *token_p, static void g_scanner_get_token_i (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p) { @@ -1127,7 +1127,7 @@ g_scanner_get_token_i (GScanner *scanner, static void g_scanner_get_token_ll (GScanner *scanner, GTokenType *token_p, - GValue *value_p, + GTokenValue *value_p, guint *line_p, guint *position_p) { @@ -1139,7 +1139,7 @@ g_scanner_get_token_ll (GScanner *scanner, static guchar ch; register GTokenType token; register GString *gstring; - GValue value; + GTokenValue value; config = scanner->config; (*value_p).v_int = 0; -- 2.7.4