projects
/
platform
/
upstream
/
glib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GMutex (linux): detect and report some errors
[platform/upstream/glib.git]
/
glib
/
gvarianttypeinfo.c
diff --git
a/glib/gvarianttypeinfo.c
b/glib/gvarianttypeinfo.c
index
c5998d3
..
b398d65
100644
(file)
--- a/
glib/gvarianttypeinfo.c
+++ b/
glib/gvarianttypeinfo.c
@@
-13,9
+13,7
@@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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 <http://www.gnu.org/licenses/>.
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
*
* Author: Ryan Lortie <desrt@desrt.ca>
*/
@@
-26,9
+24,9
@@
#include <glib/gtestutils.h>
#include <glib/gthread.h>
#include <glib/gtestutils.h>
#include <glib/gthread.h>
+#include <glib/gslice.h>
#include <glib/ghash.h>
#include <glib/ghash.h>
-
/* < private >
* GVariantTypeInfo:
*
/* < private >
* GVariantTypeInfo:
*
@@
-50,7
+48,7
@@
* for "as" (note that "s" and "v" always exist in the static array).
*
* The trickiest part of GVariantTypeInfo (and in fact, the major reason
* for "as" (note that "s" and "v" always exist in the static array).
*
* The trickiest part of GVariantTypeInfo (and in fact, the major reason
- * for its exist
a
nce) is the storage of somewhat magical constants that
+ * for its exist
e
nce) is the storage of somewhat magical constants that
* allow for O(1) lookups of items in tuples. This is described below.
*
* 'container_class' is set to 'a' or 'r' if the GVariantTypeInfo is
* allow for O(1) lookups of items in tuples. This is described below.
*
* 'container_class' is set to 'a' or 'r' if the GVariantTypeInfo is
@@
-222,8
+220,8
@@
g_variant_type_info_get_type_string (GVariantTypeInfo *info)
/* < private >
* g_variant_type_info_query:
* @info: a #GVariantTypeInfo
/* < private >
* g_variant_type_info_query:
* @info: a #GVariantTypeInfo
- * @alignment: the location to store the alignment, or %NULL
- * @fixed_size: the location to store the fixed size, or %NULL
+ * @alignment:
(allow-none):
the location to store the alignment, or %NULL
+ * @fixed_size:
(allow-none):
the location to store the fixed size, or %NULL
*
* Queries @info to determine the alignment requirements and fixed size
* (if any) of the type.
*
* Queries @info to determine the alignment requirements and fixed size
* (if any) of the type.
@@
-254,11
+252,11
@@
g_variant_type_info_query (GVariantTypeInfo *info,
}
/* == array == */
}
/* == array == */
-#define ARRAY_INFO_CLASS 'a'
+#define
GV_
ARRAY_INFO_CLASS 'a'
static ArrayInfo *
static ArrayInfo *
-ARRAY_INFO (GVariantTypeInfo *info)
+
GV_
ARRAY_INFO (GVariantTypeInfo *info)
{
{
- g_variant_type_info_check (info, ARRAY_INFO_CLASS);
+ g_variant_type_info_check (info,
GV_
ARRAY_INFO_CLASS);
return (ArrayInfo *) info;
}
return (ArrayInfo *) info;
}
@@
-268,7
+266,7
@@
array_info_free (GVariantTypeInfo *info)
{
ArrayInfo *array_info;
{
ArrayInfo *array_info;
- g_assert (info->container_class == ARRAY_INFO_CLASS);
+ g_assert (info->container_class ==
GV_
ARRAY_INFO_CLASS);
array_info = (ArrayInfo *) info;
g_variant_type_info_unref (array_info->element);
array_info = (ArrayInfo *) info;
g_variant_type_info_unref (array_info->element);
@@
-281,7
+279,7
@@
array_info_new (const GVariantType *type)
ArrayInfo *info;
info = g_slice_new (ArrayInfo);
ArrayInfo *info;
info = g_slice_new (ArrayInfo);
- info->container.info.container_class = ARRAY_INFO_CLASS;
+ info->container.info.container_class =
GV_
ARRAY_INFO_CLASS;
info->element = g_variant_type_info_get (g_variant_type_element (type));
info->container.info.alignment = info->element->alignment;
info->element = g_variant_type_info_get (g_variant_type_element (type));
info->container.info.alignment = info->element->alignment;
@@
-300,14
+298,14
@@
array_info_new (const GVariantType *type)
GVariantTypeInfo *
g_variant_type_info_element (GVariantTypeInfo *info)
{
GVariantTypeInfo *
g_variant_type_info_element (GVariantTypeInfo *info)
{
- return ARRAY_INFO (info)->element;
+ return
GV_
ARRAY_INFO (info)->element;
}
/* < private >
* g_variant_type_query_element:
* @info: a #GVariantTypeInfo for an array or maybe type
}
/* < private >
* g_variant_type_query_element:
* @info: a #GVariantTypeInfo for an array or maybe type
- * @alignment: the location to store the alignment, or %NULL
- * @fixed_size: the location to store the fixed size, or %NULL
+ * @alignment:
(allow-none):
the location to store the alignment, or %NULL
+ * @fixed_size:
(allow-none):
the location to store the fixed size, or %NULL
*
* Returns the alignment requires and fixed size (if any) for the
* element type of the array. This call is a convenience wrapper around
*
* Returns the alignment requires and fixed size (if any) for the
* element type of the array. This call is a convenience wrapper around
@@
-318,16
+316,16
@@
g_variant_type_info_query_element (GVariantTypeInfo *info,
guint *alignment,
gsize *fixed_size)
{
guint *alignment,
gsize *fixed_size)
{
- g_variant_type_info_query (ARRAY_INFO (info)->element,
+ g_variant_type_info_query (
GV_
ARRAY_INFO (info)->element,
alignment, fixed_size);
}
/* == tuple == */
alignment, fixed_size);
}
/* == tuple == */
-#define TUPLE_INFO_CLASS 'r'
+#define
GV_
TUPLE_INFO_CLASS 'r'
static TupleInfo *
static TupleInfo *
-TUPLE_INFO (GVariantTypeInfo *info)
+
GV_
TUPLE_INFO (GVariantTypeInfo *info)
{
{
- g_variant_type_info_check (info, TUPLE_INFO_CLASS);
+ g_variant_type_info_check (info,
GV_
TUPLE_INFO_CLASS);
return (TupleInfo *) info;
}
return (TupleInfo *) info;
}
@@
-338,7
+336,7
@@
tuple_info_free (GVariantTypeInfo *info)
TupleInfo *tuple_info;
gint i;
TupleInfo *tuple_info;
gint i;
- g_assert (info->container_class == TUPLE_INFO_CLASS);
+ g_assert (info->container_class ==
GV_
TUPLE_INFO_CLASS);
tuple_info = (TupleInfo *) info;
for (i = 0; i < tuple_info->n_members; i++)
tuple_info = (TupleInfo *) info;
for (i = 0; i < tuple_info->n_members; i++)
@@
-662,7
+660,7
@@
tuple_info_new (const GVariantType *type)
TupleInfo *info;
info = g_slice_new (TupleInfo);
TupleInfo *info;
info = g_slice_new (TupleInfo);
- info->container.info.container_class = TUPLE_INFO_CLASS;
+ info->container.info.container_class =
GV_
TUPLE_INFO_CLASS;
tuple_allocate_members (type, &info->members, &info->n_members);
tuple_generate_table (info);
tuple_allocate_members (type, &info->members, &info->n_members);
tuple_generate_table (info);
@@
-681,7
+679,7
@@
tuple_info_new (const GVariantType *type)
gsize
g_variant_type_info_n_members (GVariantTypeInfo *info)
{
gsize
g_variant_type_info_n_members (GVariantTypeInfo *info)
{
- return TUPLE_INFO (info)->n_members;
+ return
GV_
TUPLE_INFO (info)->n_members;
}
/* < private >
}
/* < private >
@@
-700,7
+698,7
@@
const GVariantMemberInfo *
g_variant_type_info_member_info (GVariantTypeInfo *info,
gsize index)
{
g_variant_type_info_member_info (GVariantTypeInfo *info,
gsize index)
{
- TupleInfo *tuple_info = TUPLE_INFO (info);
+ TupleInfo *tuple_info =
GV_
TUPLE_INFO (info);
if (index < tuple_info->n_members)
return &tuple_info->members[index];
if (index < tuple_info->n_members)
return &tuple_info->members[index];
@@
-709,7
+707,7
@@
g_variant_type_info_member_info (GVariantTypeInfo *info,
}
/* == new/ref/unref == */
}
/* == new/ref/unref == */
-static G
StaticRecMutex g_variant_type_info_lock = G_STATIC_REC_MUTEX_INIT
;
+static G
RecMutex g_variant_type_info_lock
;
static GHashTable *g_variant_type_info_table;
/* < private >
static GHashTable *g_variant_type_info_table;
/* < private >
@@
-742,7
+740,7
@@
g_variant_type_info_get (const GVariantType *type)
type_string = g_variant_type_dup_string (type);
type_string = g_variant_type_dup_string (type);
- g_
static_
rec_mutex_lock (&g_variant_type_info_lock);
+ g_rec_mutex_lock (&g_variant_type_info_lock);
if (g_variant_type_info_table == NULL)
g_variant_type_info_table = g_hash_table_new (g_str_hash,
if (g_variant_type_info_table == NULL)
g_variant_type_info_table = g_hash_table_new (g_str_hash,
@@
-773,7
+771,7
@@
g_variant_type_info_get (const GVariantType *type)
else
g_variant_type_info_ref (info);
else
g_variant_type_info_ref (info);
- g_
static_
rec_mutex_unlock (&g_variant_type_info_lock);
+ g_rec_mutex_unlock (&g_variant_type_info_lock);
g_variant_type_info_check (info, 0);
g_free (type_string);
g_variant_type_info_check (info, 0);
g_free (type_string);
@@
-834,7
+832,7
@@
g_variant_type_info_unref (GVariantTypeInfo *info)
{
ContainerInfo *container = (ContainerInfo *) info;
{
ContainerInfo *container = (ContainerInfo *) info;
- g_
static_
rec_mutex_lock (&g_variant_type_info_lock);
+ g_rec_mutex_lock (&g_variant_type_info_lock);
if (g_atomic_int_dec_and_test (&container->ref_count))
{
g_hash_table_remove (g_variant_type_info_table,
if (g_atomic_int_dec_and_test (&container->ref_count))
{
g_hash_table_remove (g_variant_type_info_table,
@@
-844,21
+842,21
@@
g_variant_type_info_unref (GVariantTypeInfo *info)
g_hash_table_unref (g_variant_type_info_table);
g_variant_type_info_table = NULL;
}
g_hash_table_unref (g_variant_type_info_table);
g_variant_type_info_table = NULL;
}
- g_
static_
rec_mutex_unlock (&g_variant_type_info_lock);
+ g_rec_mutex_unlock (&g_variant_type_info_lock);
g_free (container->type_string);
g_free (container->type_string);
- if (info->container_class == ARRAY_INFO_CLASS)
+ if (info->container_class ==
GV_
ARRAY_INFO_CLASS)
array_info_free (info);
array_info_free (info);
- else if (info->container_class == TUPLE_INFO_CLASS)
+ else if (info->container_class ==
GV_
TUPLE_INFO_CLASS)
tuple_info_free (info);
else
g_assert_not_reached ();
}
else
tuple_info_free (info);
else
g_assert_not_reached ();
}
else
- g_
static_
rec_mutex_unlock (&g_variant_type_info_lock);
+ g_rec_mutex_unlock (&g_variant_type_info_lock);
}
}
}
}