[glib/wip/mutexes: 40/58] Merge branch 'master' into wip/mutexes
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/mutexes: 40/58] Merge branch 'master' into wip/mutexes
- Date: Mon, 19 Sep 2011 05:15:26 +0000 (UTC)
commit a0284d26e867a9240a8e0e9129915917da4a1ee6
Merge: b96f889 8080356
Author: Ryan Lortie <desrt desrt ca>
Date: Sun Sep 18 22:24:05 2011 -0400
Merge branch 'master' into wip/mutexes
Conflicts:
glib/gthread.c (needed to add #include "gslice.h")
glib/gmem.c
configure.ac | 2 +
docs/reference/glib/glib-docs.sgml | 2 -
docs/reference/glib/glib-sections.txt | 56 -
docs/reference/glib/tmpl/fileutils.sgml | 4 +-
gio/glib-compile-schemas.c | 2 -
gio/gsocks4aproxy.c | 9 +-
gio/gsocks5proxy.c | 12 +-
glib/Makefile.am | 16 +-
glib/deprecated/gallocator.c | 99 +
glib/deprecated/gallocator.h | 72 +
glib/{ => deprecated}/gcompletion.c | 12 +-
glib/{ => deprecated}/gcompletion.h | 4 -
glib/{ => deprecated}/grel.c | 17 +-
glib/{ => deprecated}/grel.h | 4 -
glib/garray.c | 1 +
glib/gbitlock.c | 1 +
glib/gbuffer.c | 2 +-
glib/gcache.c | 1 +
glib/gchecksum.c | 1 +
glib/gconvert.c | 25 +-
glib/gdataset.c | 1 +
glib/gdatetime.c | 1 +
glib/gdebug.h | 59 -
glib/gerror.c | 1 +
glib/ghash.c | 1 +
glib/ghmac.c | 1 +
glib/ghook.c | 1 +
glib/glib.h | 8 +-
glib/glist.c | 34 +-
glib/glist.h | 5 -
glib/gmappedfile.c | 13 +-
glib/gmarkup.c | 1 +
glib/gmem.c | 443 +--
glib/gmem.h | 45 -
glib/gmessages.c | 89 +-
glib/gnode.c | 33 +-
glib/gnode.h | 5 -
glib/gqueue.c | 1 +
glib/gsequence.c | 1 +
glib/gslist.c | 34 +-
glib/gslist.h | 5 -
glib/gstrfuncs.c | 61 +-
glib/gtestutils.c | 1 +
glib/gthread.c | 1 +
glib/gtimezone.c | 1 +
glib/gtree.c | 1 +
glib/gvariant-parser.c | 1 +
glib/gvariant.c | 1 +
glib/gvarianttypeinfo.c | 2 +-
glib/tests/mappedfile.c | 13 +
glib/tests/strfuncs.c | 1 +
po/bg.po | 339 +-
po/sr.po | 7956 ++++++++++++-------------------
po/sr latin po | 7956 ++++++++++++-------------------
54 files changed, 6832 insertions(+), 10626 deletions(-)
---
diff --cc glib/gmem.c
index b7b9b8d,1553ed7..0e1b5cf
--- a/glib/gmem.c
+++ b/glib/gmem.c
@@@ -930,445 -909,48 +931,3 @@@ static GMemVTable profiler_table =
GMemVTable *glib_mem_profiler_table = &profiler_table;
#endif /* !G_DISABLE_CHECKS */
--
- /* --- MemChunks --- */
- /**
- * SECTION:allocators
- * @title: Memory Allocators
- * @short_description: deprecated way to allocate chunks of memory for
- * GList, GSList and GNode
- *
- * Prior to 2.10, #GAllocator was used as an efficient way to allocate
- * small pieces of memory for use with the #GList, #GSList and #GNode
- * data structures. Since 2.10, it has been completely replaced by the
- * <link linkend="glib-Memory-Slices">slice allocator</link> and
- * deprecated.
- **/
-
- /**
- * SECTION:memory_chunks
- * @title: Memory Chunks
- * @short_description: deprecated way to allocate groups of equal-sized
- * chunks of memory
- *
- * Memory chunks provide an space-efficient way to allocate equal-sized
- * pieces of memory, called atoms. However, due to the administrative
- * overhead (in particular for #G_ALLOC_AND_FREE, and when used from
- * multiple threads), they are in practise often slower than direct use
- * of g_malloc(). Therefore, memory chunks have been deprecated in
- * favor of the <link linkend="glib-Memory-Slices">slice
- * allocator</link>, which has been added in 2.10. All internal uses of
- * memory chunks in GLib have been converted to the
- * <literal>g_slice</literal> API.
- *
- * There are two types of memory chunks, #G_ALLOC_ONLY, and
- * #G_ALLOC_AND_FREE. <itemizedlist> <listitem><para> #G_ALLOC_ONLY
- * chunks only allow allocation of atoms. The atoms can never be freed
- * individually. The memory chunk can only be free in its entirety.
- * </para></listitem> <listitem><para> #G_ALLOC_AND_FREE chunks do
- * allow atoms to be freed individually. The disadvantage of this is
- * that the memory chunk has to keep track of which atoms have been
- * freed. This results in more memory being used and a slight
- * degradation in performance. </para></listitem> </itemizedlist>
- *
- * To create a memory chunk use g_mem_chunk_new() or the convenience
- * macro g_mem_chunk_create().
- *
- * To allocate a new atom use g_mem_chunk_alloc(),
- * g_mem_chunk_alloc0(), or the convenience macros g_chunk_new() or
- * g_chunk_new0().
- *
- * To free an atom use g_mem_chunk_free(), or the convenience macro
- * g_chunk_free(). (Atoms can only be freed if the memory chunk is
- * created with the type set to #G_ALLOC_AND_FREE.)
- *
- * To free any blocks of memory which are no longer being used, use
- * g_mem_chunk_clean(). To clean all memory chunks, use g_blow_chunks().
- *
- * To reset the memory chunk, freeing all of the atoms, use
- * g_mem_chunk_reset().
- *
- * To destroy a memory chunk, use g_mem_chunk_destroy().
- *
- * To help debug memory chunks, use g_mem_chunk_info() and
- * g_mem_chunk_print().
- *
- * <example>
- * <title>Using a #GMemChunk</title>
- * <programlisting>
- * GMemChunk *mem_chunk;
- * gchar *mem[10000];
- * gint i;
- *
- * /<!-- -->* Create a GMemChunk with atoms 50 bytes long, and memory
- * blocks holding 100 bytes. Note that this means that only 2 atoms
- * fit into each memory block and so isn't very efficient. *<!-- -->/
- * mem_chunk = g_mem_chunk_new ("test mem chunk", 50, 100, G_ALLOC_AND_FREE);
- * /<!-- -->* Now allocate 10000 atoms. *<!-- -->/
- * for (i = 0; i < 10000; i++)
- * {
- * mem[i] = g_chunk_new (gchar, mem_chunk);
- * /<!-- -->* Fill in the atom memory with some junk. *<!-- -->/
- * for (j = 0; j < 50; j++)
- * mem[i][j] = i * j;
- * }
- * /<!-- -->* Now free all of the atoms. Note that since we are going to
- * destroy the GMemChunk, this wouldn't normally be used. *<!-- -->/
- * for (i = 0; i < 10000; i++)
- * {
- * g_mem_chunk_free (mem_chunk, mem[i]);
- * }
- * /<!-- -->* We are finished with the GMemChunk, so we destroy it. *<!-- -->/
- * g_mem_chunk_destroy (mem_chunk);
- * </programlisting>
- * </example>
- *
- * <example>
- * <title>Using a #GMemChunk with data structures</title>
- * <programlisting>
- * GMemChunk *array_mem_chunk;
- * GRealArray *array;
- * /<!-- -->* Create a GMemChunk to hold GRealArray structures, using
- * the g_mem_chunk_create(<!-- -->) convenience macro. We want 1024 atoms in each
- * memory block, and we want to be able to free individual atoms. *<!-- -->/
- * array_mem_chunk = g_mem_chunk_create (GRealArray, 1024, G_ALLOC_AND_FREE);
- * /<!-- -->* Allocate one atom, using the g_chunk_new(<!-- -->) convenience macro. *<!-- -->/
- * array = g_chunk_new (GRealArray, array_mem_chunk);
- * /<!-- -->* We can now use array just like a normal pointer to a structure. *<!-- -->/
- * array->data = NULL;
- * array->len = 0;
- * array->alloc = 0;
- * array->zero_terminated = (zero_terminated ? 1 : 0);
- * array->clear = (clear ? 1 : 0);
- * array->elt_size = elt_size;
- * /<!-- -->* We can free the element, so it can be reused. *<!-- -->/
- * g_chunk_free (array, array_mem_chunk);
- * /<!-- -->* We destroy the GMemChunk when we are finished with it. *<!-- -->/
- * g_mem_chunk_destroy (array_mem_chunk);
- * </programlisting>
- * </example>
- **/
-
- #ifndef G_ALLOC_AND_FREE
-
- /**
- * GAllocator:
- *
- * The #GAllocator struct contains private data. and should only be
- * accessed using the following functions.
- **/
- typedef struct _GAllocator GAllocator;
-
- /**
- * GMemChunk:
- *
- * The #GMemChunk struct is an opaque data structure representing a
- * memory chunk. It should be accessed only through the use of the
- * following functions.
- **/
- typedef struct _GMemChunk GMemChunk;
-
- /**
- * G_ALLOC_ONLY:
- *
- * Specifies the type of a #GMemChunk. Used in g_mem_chunk_new() and
- * g_mem_chunk_create() to specify that atoms will never be freed
- * individually.
- **/
- #define G_ALLOC_ONLY 1
-
- /**
- * G_ALLOC_AND_FREE:
- *
- * Specifies the type of a #GMemChunk. Used in g_mem_chunk_new() and
- * g_mem_chunk_create() to specify that atoms will be freed
- * individually.
- **/
- #define G_ALLOC_AND_FREE 2
- #endif
-
- struct _GMemChunk {
- guint alloc_size; /* the size of an atom */
- };
-
- /**
- * g_mem_chunk_new:
- * @name: a string to identify the #GMemChunk. It is not copied so it
- * should be valid for the lifetime of the #GMemChunk. It is
- * only used in g_mem_chunk_print(), which is used for debugging.
- * @atom_size: the size, in bytes, of each element in the #GMemChunk.
- * @area_size: the size, in bytes, of each block of memory allocated to
- * contain the atoms.
- * @type: the type of the #GMemChunk. #G_ALLOC_AND_FREE is used if the
- * atoms will be freed individually. #G_ALLOC_ONLY should be
- * used if atoms will never be freed individually.
- * #G_ALLOC_ONLY is quicker, since it does not need to track
- * free atoms, but it obviously wastes memory if you no longer
- * need many of the atoms.
- * @Returns: the new #GMemChunk.
- *
- * Creates a new #GMemChunk.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- GMemChunk*
- g_mem_chunk_new (const gchar *name,
- gint atom_size,
- gsize area_size,
- gint type)
- {
- GMemChunk *mem_chunk;
- g_return_val_if_fail (atom_size > 0, NULL);
-
- mem_chunk = g_slice_new (GMemChunk);
- mem_chunk->alloc_size = atom_size;
- return mem_chunk;
- }
-
- /**
- * g_mem_chunk_destroy:
- * @mem_chunk: a #GMemChunk.
- *
- * Frees all of the memory allocated for a #GMemChunk.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- void
- g_mem_chunk_destroy (GMemChunk *mem_chunk)
- {
- g_return_if_fail (mem_chunk != NULL);
-
- g_slice_free (GMemChunk, mem_chunk);
- }
-
- /**
- * g_mem_chunk_alloc:
- * @mem_chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom.
- *
- * Allocates an atom of memory from a #GMemChunk.
- *
- * Deprecated:2.10: Use g_slice_alloc() instead
- **/
- gpointer
- g_mem_chunk_alloc (GMemChunk *mem_chunk)
- {
- g_return_val_if_fail (mem_chunk != NULL, NULL);
-
- return g_slice_alloc (mem_chunk->alloc_size);
- }
-
- /**
- * g_mem_chunk_alloc0:
- * @mem_chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom.
- *
- * Allocates an atom of memory from a #GMemChunk, setting the memory to
- * 0.
- *
- * Deprecated:2.10: Use g_slice_alloc0() instead
- **/
- gpointer
- g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
- {
- g_return_val_if_fail (mem_chunk != NULL, NULL);
-
- return g_slice_alloc0 (mem_chunk->alloc_size);
- }
-
- /**
- * g_mem_chunk_free:
- * @mem_chunk: a #GMemChunk.
- * @mem: a pointer to the atom to free.
- *
- * Frees an atom in a #GMemChunk. This should only be called if the
- * #GMemChunk was created with #G_ALLOC_AND_FREE. Otherwise it will
- * simply return.
- *
- * Deprecated:2.10: Use g_slice_free1() instead
- **/
- void
- g_mem_chunk_free (GMemChunk *mem_chunk,
- gpointer mem)
- {
- g_return_if_fail (mem_chunk != NULL);
-
- g_slice_free1 (mem_chunk->alloc_size, mem);
- }
-
- /**
- * g_mem_chunk_clean:
- * @mem_chunk: a #GMemChunk.
- *
- * Frees any blocks in a #GMemChunk which are no longer being used.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- void g_mem_chunk_clean (GMemChunk *mem_chunk) {}
-
- /**
- * g_mem_chunk_reset:
- * @mem_chunk: a #GMemChunk.
- *
- * Resets a GMemChunk to its initial state. It frees all of the
- * currently allocated blocks of memory.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- void g_mem_chunk_reset (GMemChunk *mem_chunk) {}
-
-
- /**
- * g_mem_chunk_print:
- * @mem_chunk: a #GMemChunk.
- *
- * Outputs debugging information for a #GMemChunk. It outputs the name
- * of the #GMemChunk (set with g_mem_chunk_new()), the number of bytes
- * used, and the number of blocks of memory allocated.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- void g_mem_chunk_print (GMemChunk *mem_chunk) {}
-
-
- /**
- * g_mem_chunk_info:
- *
- * Outputs debugging information for all #GMemChunk objects currently
- * in use. It outputs the number of #GMemChunk objects currently
- * allocated, and calls g_mem_chunk_print() to output information on
- * each one.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- void g_mem_chunk_info (void) {}
-
- /**
- * g_blow_chunks:
- *
- * Calls g_mem_chunk_clean() on all #GMemChunk objects.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- void g_blow_chunks (void) {}
-
- /**
- * g_chunk_new0:
- * @type: the type of the #GMemChunk atoms, typically a structure name.
- * @chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom, cast to a pointer to
- * @type.
- *
- * A convenience macro to allocate an atom of memory from a #GMemChunk.
- * It calls g_mem_chunk_alloc0() and casts the returned atom to a
- * pointer to the given type, avoiding a type cast in the source code.
- *
- * Deprecated:2.10: Use g_slice_new0() instead
- **/
-
- /**
- * g_chunk_free:
- * @mem: a pointer to the atom to be freed.
- * @mem_chunk: a #GMemChunk.
- *
- * A convenience macro to free an atom of memory from a #GMemChunk. It
- * simply switches the arguments and calls g_mem_chunk_free() It is
- * included simply to complement the other convenience macros,
- * g_chunk_new() and g_chunk_new0().
- *
- * Deprecated:2.10: Use g_slice_free() instead
- **/
-
- /**
- * g_chunk_new:
- * @type: the type of the #GMemChunk atoms, typically a structure name.
- * @chunk: a #GMemChunk.
- * @Returns: a pointer to the allocated atom, cast to a pointer to
- * @type.
- *
- * A convenience macro to allocate an atom of memory from a #GMemChunk.
- * It calls g_mem_chunk_alloc() and casts the returned atom to a
- * pointer to the given type, avoiding a type cast in the source code.
- *
- * Deprecated:2.10: Use g_slice_new() instead
- **/
-
- /**
- * g_mem_chunk_create:
- * @type: the type of the atoms, typically a structure name.
- * @pre_alloc: the number of atoms to store in each block of memory.
- * @alloc_type: the type of the #GMemChunk. #G_ALLOC_AND_FREE is used
- * if the atoms will be freed individually. #G_ALLOC_ONLY
- * should be used if atoms will never be freed
- * individually. #G_ALLOC_ONLY is quicker, since it does
- * not need to track free atoms, but it obviously wastes
- * memory if you no longer need many of the atoms.
- * @Returns: the new #GMemChunk.
- *
- * A convenience macro for creating a new #GMemChunk. It calls
- * g_mem_chunk_new(), using the given type to create the #GMemChunk
- * name. The atom size is determined using
- * <function>sizeof()</function>, and the area size is calculated by
- * multiplying the @pre_alloc parameter with the atom size.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
-
-
- /**
- * g_allocator_new:
- * @name: the name of the #GAllocator. This name is used to set the
- * name of the #GMemChunk used by the #GAllocator, and is only
- * used for debugging.
- * @n_preallocs: the number of elements in each block of memory
- * allocated. Larger blocks mean less calls to
- * g_malloc(), but some memory may be wasted. (GLib uses
- * 128 elements per block by default.) The value must be
- * between 1 and 65535.
- * @Returns: a new #GAllocator.
- *
- * Creates a new #GAllocator.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- GAllocator*
- g_allocator_new (const gchar *name,
- guint n_preallocs)
- {
- static struct _GAllocator {
- gchar *name;
- guint16 n_preallocs;
- guint is_unused : 1;
- guint type : 4;
- GAllocator *last;
- GMemChunk *mem_chunk;
- gpointer free_list;
- } dummy = {
- "GAllocator is deprecated", 1, TRUE, 0, NULL, NULL, NULL,
- };
- /* some (broken) GAllocator uses depend on non-NULL allocators */
- return (void*) &dummy;
- }
-
- /**
- * g_allocator_free:
- * @allocator: a #GAllocator.
- *
- * Frees all of the memory allocated by the #GAllocator.
- *
- * Deprecated:2.10: Use the <link linkend="glib-Memory-Slices">slice
- * allocator</link> instead
- **/
- void
- g_allocator_free (GAllocator *allocator)
- {
- }
-#ifdef ENABLE_GC_FRIENDLY_DEFAULT
-gboolean g_mem_gc_friendly = TRUE;
-#else
-/**
- * g_mem_gc_friendly:
- *
- * This variable is %TRUE if the <envar>G_DEBUG</envar> environment variable
- * includes the key <link linkend="G_DEBUG">gc-friendly</link>.
- */
-gboolean g_mem_gc_friendly = FALSE;
-#endif
-
-static void
-g_mem_init_nomessage (void)
-{
- gchar buffer[1024];
- const gchar *val;
- const GDebugKey keys[] = {
- { "gc-friendly", 1 },
- };
- gint flags;
- if (g_mem_initialized)
- return;
- /* don't use g_malloc/g_message here */
- val = _g_getenv_nomalloc ("G_DEBUG", buffer);
- flags = !val ? 0 : g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
- if (flags & 1) /* gc-friendly */
- {
- g_mem_gc_friendly = TRUE;
- }
- g_mem_initialized = TRUE;
-}
-
-void
-_g_mem_thread_init_noprivate_nomessage (void)
-{
- /* we may only create mutexes here, locking/
- * unlocking a mutex does not yet work.
- */
- g_mem_init_nomessage();
-#ifndef G_DISABLE_CHECKS
- gmem_profile_mutex = g_mutex_new ();
-#endif
-}
diff --cc glib/gmessages.c
index d9eb7f1,9df841f..1295afc
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@@ -502,12 -538,12 +545,12 @@@ g_logv (const gchar *log_domain
else
log_func = g_log_domain_get_handler_L (domain, test_level, &data);
domain = NULL;
- g_mutex_unlock (g_messages_lock);
+ g_mutex_unlock (&g_messages_lock);
- g_private_set (g_log_depth, GUINT_TO_POINTER (depth));
+ g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
/* had to defer debug initialization until we can keep track of recursion */
- if (!(test_level & G_LOG_FLAG_RECURSION) && !_g_debug_initialized)
+ if (!(test_level & G_LOG_FLAG_RECURSION) && !g_debug_initialized)
{
GLogLevelFlags orig_test_level = test_level;
@@@ -1178,46 -1214,10 +1221,8 @@@ g_printf_string_upper_bound (const gcha
void
_g_messages_thread_init_nomessage (void)
{
- g_messages_lock = g_mutex_new ();
- g_log_depth = g_private_new (NULL);
g_messages_prefixed_init ();
- _g_debug_init ();
+ g_debug_init ();
}
- gboolean _g_debug_initialized = FALSE;
- guint _g_debug_flags = 0;
- void
- _g_debug_init (void)
- {
- const gchar *val;
-
- _g_debug_initialized = TRUE;
-
- val = g_getenv ("G_DEBUG");
- if (val != NULL)
- {
- const GDebugKey keys[] = {
- {"fatal_warnings", G_DEBUG_FATAL_WARNINGS},
- {"fatal_criticals", G_DEBUG_FATAL_CRITICALS}
- };
-
- _g_debug_flags = g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
- }
-
- if (_g_debug_flags & G_DEBUG_FATAL_WARNINGS)
- {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
-
- if (_g_debug_flags & G_DEBUG_FATAL_CRITICALS)
- {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
- }
diff --cc glib/gthread.c
index 4ed4d24,cc8e717..750a4ce
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@@ -61,6 -61,6 +61,7 @@@
#include "gbitlock.h"
#include "gslist.h"
#include "gtestutils.h"
++#include "gslice.h"
#include "gtimer.h"
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]