Port: Use glib g_mkdir
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/3 Port: Use glib g_mkdir
Signed-off-by Michael Jeanson <[email protected]>
--- converter/babeltrace-log.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
converter/babeltrace-log.c +4 -2
@@ -38,6 +38,8 @@#include <errno.h> #include <string.h> #include <inttypes.h> +#include <glib.h> +#include <glib/gstdio.h> #include <babeltrace/babeltrace-internal.h> #include <babeltrace/ctf/types.h>
@@ -401,9 +403,9 @@ int main(int argc, char **argv)exit (EXIT_SUCCESS ); } - ret =mkdir (s_outputname,S_IRWXU |S_IRWXG ); + ret =g_mkdir (s_outputname,S_IRWXU |S_IRWXG );if (ret) { -perror ("mkdir" ); +perror ("g_mkdir" ); goto error; }
Signature · 6 lines
2.7.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
PATCH 3/3 Port: Add glib g_mkdtemp to mkdtemp wrapper
In reply to a message not in the archiveSigned-off-by Michael Jeanson <[email protected]>
--- include/babeltrace/compat/stdlib.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
include/babeltrace/compat/stdlib.h +19 -1
@@ -25,16 +25,34 @@* SOFTWARE. */ +/* +* This compat wrapper can be removed and replaced by g_mkdtemp() when we bump +* the requirement on glib to version 2.30. +*/ +#include <stdlib.h> #include <sys/stat.h> +#include <glib.h> #ifdef HAVE_MKDTEMP +static inline char *bt_mkdtemp (char *template) {return mkdtemp (template); } + +#elif GLIB_CHECK_VERSION (2 ,30 ,0 ) + +#include <glib/gstdio.h> +static inline +char *bt_mkdtemp (char *template) +{ +return g_mkdtemp (template); +} +#else +static inline char *bt_mkdtemp (char *template) {
@@ -54,7 +72,7 @@ char *bt_mkdtemp(char *template) end:return ret; } -#endif +#endif #endif /* _BABELTRACE_COMPAT_STDLIB_H */
Signature · 6 lines
2.7.4 _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Re: [PATCH babeltrace 1/3] Port: Use glib portable macros to convert gpointer to int
In reply to a message not in the archiveAll three patches were merged in master. Thanks!
Jérémie
Quoted 530 lines · Michael Jeanson
Signed-off-by Michael Jeanson <[email protected]>--- formats/ctf-text/ctf-text.c | 2 +- formats/ctf/callbacks.c | 4 ++-- formats/ctf/events.c | 2 +- formats/ctf/ir/field-types.c | 4 ++-- formats/ctf/metadata/ctf-parser.y | 2 +- .../ctf/metadata/ctf-visitor-generate-io-struct.c | 12 ++++++------ lib/context.c | 4 ++-- lib/registry.c | 8 ++++---- lib/trace-collection.c | 8 ++++---- lib/trace-handle.c | 6 +++--- lib/values.c | 6 +++--- types/enum.c | 10 +++++----- types/struct.c | 8 ++++---- types/types.c | 20 ++++++++++---------- types/variant.c | 12 ++++++------ 15 files changed, 54 insertions(+), 54 deletions(-)formats/ctf-text/ctf-text.c +1
-1@@ -136,7 +136,7 @@ struct ctf_callsite_dups *ctf_trace_callsite_lookup(struct ctf_trace *trace, GQuark callsite_name) {return g_hash_table_lookup (trace->callsites, - (gpointer ) (unsigned long ) callsite_name); +GUINT_TO_POINTER (callsite_name)); }void bt_ctf_text_hook (void )formats/ctf/callbacks.c +2
-2@@ -115,13 +115,13 @@ int bt_ctf_iter_add_callback(struct bt_ctf_iter *iter,if (event) {/* find the event id */ event_id_ptr =g_hash_table_lookup (stream->event_quark_to_id, - (gconstpointer ) (unsigned long ) event); + (gconstpointer )GUINT_TO_POINTER (event));/* event not found in this stream class */ if (!event_id_ptr) {fprintf (stderr,"[error] Event ID not found in stream class\n" );continue ; } - event_id = (uint64_t )(unsigned long ) *event_id_ptr; + event_id =GPOINTER_TO_UINT (*event_id_ptr);/* find or create the bt_callback_chain for this event */ if (event_id >= bt_stream_cb->per_id_callbacks->len) {formats/ctf/events.c +1
-1@@ -690,7 +690,7 @@ int bt_ctf_get_event_decl_list(int handle_id, struct bt_context *ctx, goto error; handle =g_hash_table_lookup (ctx->trace_handles, - (gpointer ) (unsigned long ) handle_id); +GUINT_TO_POINTER (handle_id));if (!handle) goto error;formats/ctf/ir/field-types.c +2
-2@@ -404,8 +404,8 @@ int add_structure_field(GPtrArray *fields, field->name = name_quark; field->type = field_type;g_hash_table_insert (field_name_to_index, - (gpointer ) (unsigned long ) name_quark, - (gpointer ) (unsigned long ) fields->len); +GUINT_TO_POINTER (name_quark), +GUINT_TO_POINTER (fields->len));g_ptr_array_add (fields, field); end:return ret;formats/ctf/metadata/ctf-parser.y +1
-1@@ -330,7 +330,7 @@ static int lookup_type(struct ctf_scanner_scope *s, const char *id) { int ret; - ret = (int) (long) g_hash_table_lookup(s->types, id); + ret = GPOINTER_TO_INT(g_hash_table_lookup(s->types, id)); printf_debug("lookup %p %s %d\n", s, id, ret); return ret; }formats/ctf/metadata/ctf-visitor-generate-io-struct.c +6
-6@@ -278,7 +278,7 @@ struct ctf_event_declaration *stream_event_lookup(struct ctf_stream_declarationstatic struct ctf_clock *trace_clock_lookup (struct ctf_trace *trace,GQuark clock_name) { -return g_hash_table_lookup (trace->parent.clocks, (gpointer ) (unsigned long ) clock_name); +return g_hash_table_lookup (trace->parent.clocks,GUINT_TO_POINTER (clock_name)); } static@@ -1907,7 +1907,7 @@ int ctf_event_visit(FILE *fd, int depth, struct ctf_node *node,g_ptr_array_set_size (event->stream->events_by_id, event->id +1 );g_ptr_array_index (event->stream->events_by_id, event->id) = event;g_hash_table_insert (event->stream->event_quark_to_id, - (gpointer ) (unsigned long ) event->name, +GUINT_TO_POINTER (event->name), &event->id);g_ptr_array_add (trace->event_declarations, event_decl);return 0 ;@@ -2491,7 +2491,7 @@ int ctf_clock_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace goto error; } trace->parent.single_clock = clock; -g_hash_table_insert (trace->parent.clocks, (gpointer ) (unsigned long ) clock->name, clock); +g_hash_table_insert (trace->parent.clocks,GUINT_TO_POINTER (clock->name), clock);return 0 ; error:@@ -2526,7 +2526,7 @@ void ctf_clock_default(FILE *fd, int depth, struct ctf_trace *trace) } trace->parent.single_clock = clock; -g_hash_table_insert (trace->parent.clocks, (gpointer ) (unsigned long ) clock->name, clock); +g_hash_table_insert (trace->parent.clocks,GUINT_TO_POINTER (clock->name), clock); } static@@ -2683,12 +2683,12 @@ int ctf_callsite_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_tr } cs_dups =g_hash_table_lookup (trace->callsites, - (gpointer ) (unsigned long ) callsite->name); +GUINT_TO_POINTER (callsite->name));if (!cs_dups) { cs_dups = g_new0(struct ctf_callsite_dups, 1);BT_INIT_LIST_HEAD (&cs_dups->head);g_hash_table_insert (trace->callsites, - (gpointer ) (unsigned long ) callsite->name, cs_dups); +GUINT_TO_POINTER (callsite->name), cs_dups); }bt_list_add_tail (&callsite->node, &cs_dups->head);return 0 ;lib/context.c +2
-2@@ -174,7 +174,7 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path,/* Add new handle to container */ g_hash_table_insert (ctx->trace_handles, - (gpointer ) (unsigned long ) handle->id, +GUINT_TO_POINTER (handle->id), handle);return handle->id;@@ -207,7 +207,7 @@ int bt_context_remove_trace(struct bt_context *ctx, int handle_id)* automatically. */ if (!g_hash_table_remove (ctx->trace_handles, - (gpointer ) (unsigned long ) handle_id)) { +GUINT_TO_POINTER (handle_id))) { ret = -ENOENT ; goto end; }lib/registry.c +4
-4@@ -73,7 +73,7 @@ struct bt_format *bt_lookup_format(bt_intern_str name)return NULL ;return g_hash_table_lookup (format_registry, - (gconstpointer ) (unsigned long ) name); + (gconstpointer )GUINT_TO_POINTER (name)); }static void show_format (gpointer key,gpointer value,gpointer user_data)@@ -81,7 +81,7 @@ static void show_format(gpointer key, gpointer value, gpointer user_data)struct walk_data *data = user_data;fprintf (data->fp,"%s%s" , data->iter ?", " :"" , -g_quark_to_string ((GQuark ) (unsigned long ) key)); +g_quark_to_string ((GQuark )GPOINTER_TO_UINT (key))); data->iter++; }@@ -116,7 +116,7 @@ int bt_register_format(struct bt_format *format)format_refcount_inc ();g_hash_table_insert (format_registry, - (gpointer ) (unsigned long ) format->name, +GUINT_TO_POINTER (format->name), format);return 0 ; }@@ -125,7 +125,7 @@ void bt_unregister_format(struct bt_format *format) {assert (bt_lookup_format (format->name));g_hash_table_remove (format_registry, - (gpointer ) (unsigned long ) format->name); +GUINT_TO_POINTER (format->name));format_refcount_dec (); }lib/trace-collection.c +4
-4@@ -53,7 +53,7 @@ static void check_clock_match(gpointer key, gpointer value, gpointer user_data)* by clock name. */ clock_b =g_hash_table_lookup (match->clocks, - (gpointer ) (unsigned long ) clock_a->name); +GUINT_TO_POINTER (clock_a->name));if (clock_b) { match->clock_match = clock_b;return ;@@ -64,7 +64,7 @@ static void check_clock_match(gpointer key, gpointer value, gpointer user_data)* clocks. */ clock_b =g_hash_table_lookup (match->clocks, - (gpointer ) (unsigned long ) clock_a->uuid); +GUINT_TO_POINTER (clock_a->uuid));if (clock_b) { match->clock_match = clock_b;return ;@@ -87,7 +87,7 @@ static void clock_add(gpointer key, gpointer value, gpointer user_data)struct ctf_clock *tc_clock; tc_clock =g_hash_table_lookup (tc_clocks, - (gpointer ) (unsigned long ) v); +GUINT_TO_POINTER (v));if (!tc_clock) {/* * For now we only support CTF that has one @@ -105,7 +105,7 @@ static void clock_add(gpointer key, gpointer value, gpointer user_data) clock_match->tc->offset_first; }g_hash_table_insert (tc_clocks, - (gpointer ) (unsigned long ) v, +GUINT_TO_POINTER (v), value); }else if (!t_clock->absolute) {int64_t diff_ns;lib/trace-handle.c +3
-3@@ -60,7 +60,7 @@ const char *bt_trace_handle_get_path(struct bt_context *ctx, int handle_id)return NULL ; handle =g_hash_table_lookup (ctx->trace_handles, - (gpointer ) (unsigned long ) handle_id); +GUINT_TO_POINTER (handle_id));if (!handle)return NULL ;return handle->path;@@ -77,7 +77,7 @@ int bt_trace_handle_get_timestamp_begin(struct bt_context *ctx,return -1 ; handle =g_hash_table_lookup (ctx->trace_handles, - (gpointer ) (unsigned long ) handle_id); +GUINT_TO_POINTER (handle_id));if (!handle) { ret =-1 ; goto end;@@ -105,7 +105,7 @@ int bt_trace_handle_get_timestamp_end(struct bt_context *ctx,return -1 ; handle =g_hash_table_lookup (ctx->trace_handles, - (gpointer ) (unsigned long ) handle_id); +GUINT_TO_POINTER (handle_id));if (!handle) { ret =-1 ; goto end;lib/values.c +3
-3@@ -226,7 +226,7 @@ struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)g_hash_table_iter_init (&iter, typed_map_obj->ght);while (g_hash_table_iter_next (&iter, &key, &element_obj)) { -const char *key_str =g_quark_to_string ((unsigned long ) key); +const char *key_str =g_quark_to_string (GPOINTER_TO_UINT (key)); element_obj_copy =bt_value_copy (element_obj);@@ -357,7 +357,7 @@ bool bt_value_map_compare(const struct bt_value *object_a,while (g_hash_table_iter_next (&iter, &key, &element_obj_a)) {struct bt_value *element_obj_b; -const char *key_str =g_quark_to_string ((unsigned long ) key); +const char *key_str =g_quark_to_string (GPOINTER_TO_UINT (key)); element_obj_b =bt_value_map_get (object_b, key_str);@@ -1156,7 +1156,7 @@ enum bt_value_status bt_value_map_foreach(const struct bt_value *map_obj,g_hash_table_iter_init (&iter, typed_map_obj->ght);while (g_hash_table_iter_next (&iter, &key, &element_obj)) { -const char *key_str =g_quark_to_string ((unsigned long ) key); +const char *key_str =g_quark_to_string (GPOINTER_TO_UINT (key));if (!cb (key_str, element_obj, data)) { ret =BT_VALUE_STATUS_CANCELLED ;types/enum.c +5
-5@@ -270,7 +270,7 @@ GArray *bt_enum_quark_to_range_set(const struct declaration_enum *enum_declarati GQuark q) {return g_hash_table_lookup (enum_declaration->table.quark_to_range_set, - (gconstpointer ) (unsigned long ) q); + (gconstpointer )GUINT_TO_POINTER (q)); } static@@ -319,12 +319,12 @@ void bt_enum_signed_insert(struct declaration_enum *enum_declaration, } array =g_hash_table_lookup (enum_declaration->table.quark_to_range_set, - (gconstpointer ) (unsigned long ) q); + (gconstpointer )GUINT_TO_POINTER (q));if (!array) { array =g_array_sized_new (FALSE, TRUE,sizeof (struct enum_range ),1 );g_hash_table_insert (enum_declaration->table.quark_to_range_set, - (gpointer ) (unsigned long ) q, +GUINT_TO_POINTER (q), array); }g_array_set_size (array, array->len +1 );@@ -354,12 +354,12 @@ void bt_enum_unsigned_insert(struct declaration_enum *enum_declaration, } array =g_hash_table_lookup (enum_declaration->table.quark_to_range_set, - (gconstpointer ) (unsigned long ) q); + (gconstpointer )GUINT_TO_POINTER (q));if (!array) { array =g_array_sized_new (FALSE, TRUE,sizeof (struct enum_range ),1 );g_hash_table_insert (enum_declaration->table.quark_to_range_set, - (gpointer ) (unsigned long ) q, +GUINT_TO_POINTER (q), array); }g_array_set_size (array, array->len +1 );types/struct.c +4
-4@@ -196,8 +196,8 @@ void bt_struct_declaration_add_field(struct declaration_struct *struct_declarati field->declaration = field_declaration;/* Keep index in hash rather than pointer, because array can relocate */ g_hash_table_insert (struct_declaration->fields_by_name, - (gpointer ) (unsigned long ) field->name, - (gpointer ) index); +GUINT_TO_POINTER (field->name), +GUINT_TO_POINTER (index));/* * Alignment of structure is the max alignment of declarations contained * therein. @@ -219,11 +219,11 @@ int bt_struct_declaration_lookup_field_index(struct declaration_struct *struct_dgboolean found; found =g_hash_table_lookup_extended (struct_declaration->fields_by_name, - (gconstpointer ) (unsigned long ) field_name, + (gconstpointer )GUINT_TO_POINTER (field_name),NULL , &index);if (!found)return -1 ; -return (int ) (unsigned long ) index; +return GPOINTER_TO_INT (index); }/* types/types.c +10
-10@@ -56,7 +56,7 @@ struct bt_declaration * struct declaration_scope *scope) {return g_hash_table_lookup (scope->typedef_declarations, - (gconstpointer ) (unsigned long ) declaration_name); + (gconstpointer )GUINT_TO_POINTER (declaration_name)); } struct bt_declaration *bt_lookup_declaration(GQuark declaration_name,@@ -85,7 +85,7 @@ int bt_register_declaration(GQuark name, struct bt_declaration *declaration,return -EEXIST ;g_hash_table_insert (scope->typedef_declarations, - (gpointer ) (unsigned long ) name, +GUINT_TO_POINTER (name), declaration);bt_declaration_ref (declaration);return 0 ;@@ -97,7 +97,7 @@ struct bt_definition * struct definition_scope *scope) {return g_hash_table_lookup (scope->definitions, - (gconstpointer ) (unsigned long ) field_name); + (gconstpointer )GUINT_TO_POINTER (field_name)); }/* @@ -273,7 +273,7 @@ int bt_register_field_definition(GQuark field_name, struct bt_definition *definireturn -EEXIST ;g_hash_table_insert (scope->definitions, - (gpointer ) (unsigned long ) field_name, +GUINT_TO_POINTER (field_name), definition);/* Don't keep reference on definition */ return 0 ;@@ -340,7 +340,7 @@ struct declaration_struct *bt_lookup_struct_declaration_scope(GQuark struct_name struct declaration_scope *scope) {return g_hash_table_lookup (scope->struct_declarations, - (gconstpointer ) (unsigned long ) struct_name); + (gconstpointer )GUINT_TO_POINTER (struct_name)); } struct declaration_struct *bt_lookup_struct_declaration(GQuark struct_name,@@ -372,7 +372,7 @@ int bt_register_struct_declaration(GQuark struct_name,return -EEXIST ;g_hash_table_insert (scope->struct_declarations, - (gpointer ) (unsigned long ) struct_name, +GUINT_TO_POINTER (struct_name), struct_declaration);bt_declaration_ref (&struct_declaration->p);@@ -389,7 +389,7 @@ struct declaration_untagged_variant * struct declaration_scope *scope) {return g_hash_table_lookup (scope->variant_declarations, - (gconstpointer ) (unsigned long ) variant_name); + (gconstpointer )GUINT_TO_POINTER (variant_name)); } struct declaration_untagged_variant *@@ -422,7 +422,7 @@ int bt_register_variant_declaration(GQuark variant_name,return -EEXIST ;g_hash_table_insert (scope->variant_declarations, - (gpointer ) (unsigned long ) variant_name, +GUINT_TO_POINTER (variant_name), untagged_variant_declaration);bt_declaration_ref (&untagged_variant_declaration->p);@@ -440,7 +440,7 @@ struct declaration_enum * struct declaration_scope *scope) {return g_hash_table_lookup (scope->enum_declarations, - (gconstpointer ) (unsigned long ) enum_name); + (gconstpointer )GUINT_TO_POINTER (enum_name)); } struct declaration_enum *@@ -473,7 +473,7 @@ int bt_register_enum_declaration(GQuark enum_name,return -EEXIST ;g_hash_table_insert (scope->enum_declarations, - (gpointer ) (unsigned long ) enum_name, +GUINT_TO_POINTER (enum_name), enum_declaration);bt_declaration_ref (&enum_declaration->p);types/variant.c +6
-7@@ -227,8 +227,8 @@ void bt_untagged_variant_declaration_add_field(struct declaration_untagged_varia field->declaration = field_declaration;/* Keep index in hash rather than pointer, because array can relocate */ g_hash_table_insert (untagged_variant_declaration->fields_by_tag, - (gpointer ) (unsigned long ) field->name, - (gpointer ) index); +GUINT_TO_POINTER (field->name), +GUINT_TO_POINTER (index));/* * Alignment of variant is based on the alignment of its currently * selected choice, so we leave variant alignment as-is (statically @@ -244,13 +244,13 @@ bt_untagged_variant_declaration_get_field_from_tag(struct declaration_untagged_v found =g_hash_table_lookup_extended ( untagged_variant_declaration->fields_by_tag, - (gconstpointer ) (unsigned long ) tag,NULL , &index); + (gconstpointer )GUINT_TO_POINTER (tag),NULL , &index);if (!found) {return NULL ; } - return &g_array_index(untagged_variant_declaration->fields, struct declaration_field, (unsigned long)index); + return &g_array_index(untagged_variant_declaration->fields, struct declaration_field, GPOINTER_TO_UINT(index)); }/* @@ -279,7 +279,7 @@ struct bt_definition *bt_variant_get_current_field(struct definition_variant *vaassert (tag_array->len ==1 ); tag =g_array_index (tag_array, GQuark,0 );if (!g_hash_table_lookup_extended (variant_declaration->untagged_variant->fields_by_tag, - (gconstpointer ) (unsigned long ) tag, + (gconstpointer )GUINT_TO_POINTER (tag), &orig_key, &value)) {/* Cannot find matching field. */ @@ -287,7 +287,7 @@ struct bt_definition *bt_variant_get_current_field(struct definition_variant *va g_quark_to_string(tag));return NULL ; } - index = (unsigned long ) value; + index =GPOINTER_TO_UINT (value); variant->current_field =g_ptr_array_index (variant->fields, index);return variant->current_field; } --2.7.4
Signature · 7 lines
Jérémie Galarneau EfficiOS Inc. http://www.efficios.com _______________________________________________ lttng-dev mailing list [email protected] https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev