From 2c2cbf6343f0cc88bfdb8c7a4023efc8808ff419 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Wed, 1 Jul 2020 15:04:51 +0100 Subject: [PATCH] libsysprof-capture: Use C11 types instead of GLib types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an almost entirely mechanical* conversion from (for example) `gint` → `int`, `guint8` → `uint8_t`, etc. It is not entirely complete, as many GLib functions are still used in libsysprof-capture, which necessitate some use of GLib types. It also avoids renaming `gboolean` → `bool` as that’s a slightly more controversial change which will happen in the following commit. *Code was manually realigned afterwards. Signed-off-by: Philip Withnall Helps: #40 --- src/libsysprof-capture/mapped-ring-buffer.c | 73 ++-- src/libsysprof-capture/mapped-ring-buffer.h | 23 +- src/libsysprof-capture/sysprof-address.c | 2 +- src/libsysprof-capture/sysprof-address.h | 10 +- .../sysprof-capture-condition.c | 60 ++-- .../sysprof-capture-condition.h | 16 +- .../sysprof-capture-cursor.c | 8 +- .../sysprof-capture-cursor.h | 4 +- .../sysprof-capture-reader.c | 151 ++++---- .../sysprof-capture-reader.h | 22 +- .../sysprof-capture-types.h | 135 +++---- .../sysprof-capture-util-private.h | 2 +- src/libsysprof-capture/sysprof-capture-util.c | 2 +- .../sysprof-capture-writer-cat.c | 63 ++-- .../sysprof-capture-writer.c | 333 +++++++++--------- .../sysprof-capture-writer.h | 191 +++++----- src/libsysprof-capture/sysprof-clock.c | 6 +- src/libsysprof-capture/sysprof-clock.h | 7 +- src/libsysprof-capture/sysprof-collector.c | 68 ++-- src/libsysprof-capture/sysprof-collector.h | 28 +- src/libsysprof-capture/sysprof-platform.c | 4 +- src/libsysprof-capture/sysprof-platform.h | 7 +- 22 files changed, 616 insertions(+), 599 deletions(-) diff --git a/src/libsysprof-capture/mapped-ring-buffer.c b/src/libsysprof-capture/mapped-ring-buffer.c index ebc3ee93..a364ba8d 100644 --- a/src/libsysprof-capture/mapped-ring-buffer.c +++ b/src/libsysprof-capture/mapped-ring-buffer.c @@ -22,6 +22,7 @@ #include "config.h" +#include #include #include #include @@ -32,7 +33,7 @@ #include "mapped-ring-buffer.h" #define DEFAULT_N_PAGES 32 -#define BUFFER_MAX_SIZE ((G_MAXUINT32/2)-_sysprof_getpagesize()) +#define BUFFER_MAX_SIZE ((UINT32_MAX/2)-_sysprof_getpagesize()) enum { MODE_READER = 1, @@ -47,10 +48,10 @@ enum { */ typedef struct _MappedRingHeader { - guint32 head; - guint32 tail; - guint32 offset; - guint32 size; + uint32_t head; + uint32_t tail; + uint32_t offset; + uint32_t size; } MappedRingHeader; G_STATIC_ASSERT (sizeof (MappedRingHeader) == 16); @@ -61,12 +62,12 @@ G_STATIC_ASSERT (sizeof (MappedRingHeader) == 16); */ struct _MappedRingBuffer { - volatile gint ref_count; + volatile int ref_count; int mode; int fd; void *map; - gsize body_size; - gsize page_size; + size_t body_size; + size_t page_size; }; static inline MappedRingHeader * @@ -75,19 +76,19 @@ get_header (MappedRingBuffer *self) return (MappedRingHeader *)self->map; } -static inline gpointer +static inline void * get_body_at_pos (MappedRingBuffer *self, - gsize pos) + size_t pos) { g_assert (pos < (self->body_size + self->body_size)); - return (guint8 *)self->map + self->page_size + pos; + return (uint8_t *)self->map + self->page_size + pos; } -static gpointer -map_head_and_body_twice (int fd, - gsize head_size, - gsize body_size) +static void * +map_head_and_body_twice (int fd, + size_t head_size, + size_t body_size) { void *map; void *second; @@ -118,7 +119,7 @@ map_head_and_body_twice (int fd, * By mmap()'ing over the old region, the previous region is automatically * munmap()'d for us. */ - second = mmap ((guint8 *)map + head_size + body_size, + second = mmap ((uint8_t *)map + head_size + body_size, body_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, @@ -131,7 +132,7 @@ map_head_and_body_twice (int fd, return NULL; } - g_assert (second == (gpointer)((guint8 *)map + head_size + body_size)); + g_assert (second == (void *)((uint8_t *)map + head_size + body_size)); return map; } @@ -157,11 +158,11 @@ map_head_and_body_twice (int fd, * Returns: (transfer full): a #MappedRingBuffer */ MappedRingBuffer * -mapped_ring_buffer_new_reader (gsize buffer_size) +mapped_ring_buffer_new_reader (size_t buffer_size) { MappedRingBuffer *self; MappedRingHeader *header; - gsize page_size; + size_t page_size; void *map; int fd; @@ -212,7 +213,7 @@ mapped_ring_buffer_new_reader (gsize buffer_size) } MappedRingBuffer * -mapped_ring_buffer_new_readwrite (gsize buffer_size) +mapped_ring_buffer_new_readwrite (size_t buffer_size) { MappedRingBuffer *self; @@ -234,12 +235,12 @@ mapped_ring_buffer_new_readwrite (gsize buffer_size) * Returns: (transfer full) (nullable): a new #MappedRingBuffer */ MappedRingBuffer * -mapped_ring_buffer_new_writer (gint fd) +mapped_ring_buffer_new_writer (int fd) { MappedRingBuffer *self; MappedRingHeader *header; - gssize buffer_size; - gsize page_size; + ssize_t buffer_size; + size_t page_size; void *map; g_return_val_if_fail (fd > -1, NULL); @@ -346,7 +347,7 @@ mapped_ring_buffer_ref (MappedRingBuffer *self) return self; } -gint +int mapped_ring_buffer_get_fd (MappedRingBuffer *self) { g_return_val_if_fail (self != NULL, -1); @@ -377,13 +378,13 @@ mapped_ring_buffer_get_fd (MappedRingBuffer *self) * Returns: (nullable): a pointer to data of at least @length bytes * or %NULL if there is not enough space. */ -gpointer +void * mapped_ring_buffer_allocate (MappedRingBuffer *self, - gsize length) + size_t length) { MappedRingHeader *header; - gsize headpos; - gsize tailpos; + uint32_t headpos; + uint32_t tailpos; g_return_val_if_fail (self != NULL, NULL); g_return_val_if_fail (self->mode & MODE_WRITER, NULL); @@ -436,10 +437,10 @@ mapped_ring_buffer_allocate (MappedRingBuffer *self, */ void mapped_ring_buffer_advance (MappedRingBuffer *self, - gsize length) + size_t length) { MappedRingHeader *header; - guint32 tail; + uint32_t tail; g_return_if_fail (self != NULL); g_return_if_fail (self->mode & MODE_WRITER); @@ -480,11 +481,11 @@ mapped_ring_buffer_advance (MappedRingBuffer *self, gboolean mapped_ring_buffer_drain (MappedRingBuffer *self, MappedRingBufferCallback callback, - gpointer user_data) + void *user_data) { MappedRingHeader *header; - gsize headpos; - gsize tailpos; + uint32_t headpos; + uint32_t tailpos; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (self->mode & MODE_READER, FALSE); @@ -510,8 +511,8 @@ mapped_ring_buffer_drain (MappedRingBuffer *self, while (headpos < tailpos) { - gconstpointer data = get_body_at_pos (self, headpos); - gsize len = tailpos - headpos; + const void *data = get_body_at_pos (self, headpos); + size_t len = tailpos - headpos; if (!callback (data, &len, user_data)) return FALSE; @@ -545,7 +546,7 @@ gboolean mapped_ring_buffer_is_empty (MappedRingBuffer *self) { MappedRingHeader *header; - guint32 headpos, tailpos; + uint32_t headpos, tailpos; header = get_header (self); diff --git a/src/libsysprof-capture/mapped-ring-buffer.h b/src/libsysprof-capture/mapped-ring-buffer.h index 19740e17..15d9a00e 100644 --- a/src/libsysprof-capture/mapped-ring-buffer.h +++ b/src/libsysprof-capture/mapped-ring-buffer.h @@ -21,6 +21,7 @@ #pragma once #include +#include G_BEGIN_DECLS @@ -49,18 +50,18 @@ typedef struct _MappedRingBuffer MappedRingBuffer; * * Returns: %TRUE to coninue draining, otherwise %FALSE and draining stops */ -typedef gboolean (*MappedRingBufferCallback) (gconstpointer data, - gsize *length, - gpointer user_data); +typedef gboolean (*MappedRingBufferCallback) (const void *data, + size_t *length, + void *user_data); G_GNUC_INTERNAL -MappedRingBuffer *mapped_ring_buffer_new_reader (gsize buffer_size); +MappedRingBuffer *mapped_ring_buffer_new_reader (size_t buffer_size); G_GNUC_INTERNAL -MappedRingBuffer *mapped_ring_buffer_new_readwrite (gsize buffer_size); +MappedRingBuffer *mapped_ring_buffer_new_readwrite (size_t buffer_size); G_GNUC_INTERNAL -MappedRingBuffer *mapped_ring_buffer_new_writer (gint fd); +MappedRingBuffer *mapped_ring_buffer_new_writer (int fd); G_GNUC_INTERNAL -gint mapped_ring_buffer_get_fd (MappedRingBuffer *self); +int mapped_ring_buffer_get_fd (MappedRingBuffer *self); G_GNUC_INTERNAL MappedRingBuffer *mapped_ring_buffer_ref (MappedRingBuffer *self); G_GNUC_INTERNAL @@ -68,15 +69,15 @@ void mapped_ring_buffer_unref (MappedRingBuffer G_GNUC_INTERNAL void mapped_ring_buffer_clear (MappedRingBuffer *self); G_GNUC_INTERNAL -gpointer mapped_ring_buffer_allocate (MappedRingBuffer *self, - gsize length); +void *mapped_ring_buffer_allocate (MappedRingBuffer *self, + size_t length); G_GNUC_INTERNAL void mapped_ring_buffer_advance (MappedRingBuffer *self, - gsize length); + size_t length); G_GNUC_INTERNAL gboolean mapped_ring_buffer_drain (MappedRingBuffer *self, MappedRingBufferCallback callback, - gpointer user_data); + void *user_data); G_GNUC_INTERNAL gboolean mapped_ring_buffer_is_empty (MappedRingBuffer *self); diff --git a/src/libsysprof-capture/sysprof-address.c b/src/libsysprof-capture/sysprof-address.c index e6009627..8d2fc06f 100644 --- a/src/libsysprof-capture/sysprof-address.c +++ b/src/libsysprof-capture/sysprof-address.c @@ -105,7 +105,7 @@ sysprof_address_is_context_switch (SysprofAddress address, } } -const gchar * +const char * sysprof_address_context_to_string (SysprofAddressContext context) { switch (context) diff --git a/src/libsysprof-capture/sysprof-address.h b/src/libsysprof-capture/sysprof-address.h index 88cb5b72..ece0a99e 100644 --- a/src/libsysprof-capture/sysprof-address.h +++ b/src/libsysprof-capture/sysprof-address.h @@ -56,13 +56,15 @@ #pragma once +#include + #include "sysprof-version-macros.h" G_BEGIN_DECLS -typedef guint64 SysprofAddress; +typedef uint64_t SysprofAddress; -G_STATIC_ASSERT (sizeof (SysprofAddress) >= sizeof (gpointer)); +G_STATIC_ASSERT (sizeof (SysprofAddress) >= sizeof (void *)); typedef enum { @@ -79,9 +81,9 @@ SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_address_is_context_switch (SysprofAddress address, SysprofAddressContext *context); SYSPROF_AVAILABLE_IN_ALL -const gchar *sysprof_address_context_to_string (SysprofAddressContext context); +const char *sysprof_address_context_to_string (SysprofAddressContext context); -static inline gint +static inline int sysprof_address_compare (SysprofAddress a, SysprofAddress b) { diff --git a/src/libsysprof-capture/sysprof-capture-condition.c b/src/libsysprof-capture/sysprof-capture-condition.c index 78fb0362..aaa81262 100644 --- a/src/libsysprof-capture/sysprof-capture-condition.c +++ b/src/libsysprof-capture/sysprof-capture-condition.c @@ -86,13 +86,13 @@ typedef enum struct _SysprofCaptureCondition { - volatile gint ref_count; + volatile int ref_count; SysprofCaptureConditionType type; union { GArray *where_type_in; struct { - gint64 begin; - gint64 end; + int64_t begin; + int64_t end; } where_time_between; GArray *where_pid_in; GArray *where_counter_in; @@ -100,7 +100,7 @@ struct _SysprofCaptureCondition SysprofCaptureCondition *left; SysprofCaptureCondition *right; } and, or; - gchar *where_file; + char *where_file; } u; }; @@ -122,7 +122,7 @@ sysprof_capture_condition_match (const SysprofCaptureCondition *self, sysprof_capture_condition_match (self->u.or.right, frame); case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN: - for (guint i = 0; i < self->u.where_type_in->len; i++) + for (size_t i = 0; i < self->u.where_type_in->len; i++) { if (frame->type == g_array_index (self->u.where_type_in, SysprofCaptureFrameType, i)) return TRUE; @@ -133,9 +133,9 @@ sysprof_capture_condition_match (const SysprofCaptureCondition *self, return (frame->time >= self->u.where_time_between.begin && frame->time <= self->u.where_time_between.end); case SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN: - for (guint i = 0; i < self->u.where_pid_in->len; i++) + for (size_t i = 0; i < self->u.where_pid_in->len; i++) { - if (frame->pid == g_array_index (self->u.where_pid_in, gint32, i)) + if (frame->pid == g_array_index (self->u.where_pid_in, int32_t, i)) return TRUE; } return FALSE; @@ -145,11 +145,11 @@ sysprof_capture_condition_match (const SysprofCaptureCondition *self, { const SysprofCaptureCounterSet *set = (SysprofCaptureCounterSet *)frame; - for (guint i = 0; i < self->u.where_counter_in->len; i++) + for (size_t i = 0; i < self->u.where_counter_in->len; i++) { - guint counter = g_array_index (self->u.where_counter_in, guint, i); + unsigned int counter = g_array_index (self->u.where_counter_in, unsigned int, i); - for (guint j = 0; j < set->n_values; j++) + for (unsigned int j = 0; j < set->n_values; j++) { if (counter == set->values[j].ids[0] || counter == set->values[j].ids[1] || @@ -167,11 +167,11 @@ sysprof_capture_condition_match (const SysprofCaptureCondition *self, { const SysprofCaptureCounterDefine *def = (SysprofCaptureCounterDefine *)frame; - for (guint i = 0; i < self->u.where_counter_in->len; i++) + for (size_t i = 0; i < self->u.where_counter_in->len; i++) { - guint counter = g_array_index (self->u.where_counter_in, guint, i); + unsigned int counter = g_array_index (self->u.where_counter_in, unsigned int, i); - for (guint j = 0; j < def->n_counters; j++) + for (unsigned int j = 0; j < def->n_counters; j++) { if (def->counters[j].id == counter) return TRUE; @@ -225,7 +225,7 @@ sysprof_capture_condition_copy (const SysprofCaptureCondition *self) case SYSPROF_CAPTURE_CONDITION_WHERE_TYPE_IN: return sysprof_capture_condition_new_where_type_in ( self->u.where_type_in->len, - (const SysprofCaptureFrameType *)(gpointer)self->u.where_type_in->data); + (const SysprofCaptureFrameType *)(void *)self->u.where_type_in->data); case SYSPROF_CAPTURE_CONDITION_WHERE_TIME_BETWEEN: return sysprof_capture_condition_new_where_time_between ( @@ -235,12 +235,12 @@ sysprof_capture_condition_copy (const SysprofCaptureCondition *self) case SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN: return sysprof_capture_condition_new_where_pid_in ( self->u.where_pid_in->len, - (const gint32 *)(gpointer)self->u.where_pid_in->data); + (const int32_t *)(void *)self->u.where_pid_in->data); case SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN: return sysprof_capture_condition_new_where_counter_in ( self->u.where_counter_in->len, - (const guint *)(gpointer)self->u.where_counter_in->data); + (const unsigned int *)(void *)self->u.where_counter_in->data); case SYSPROF_CAPTURE_CONDITION_WHERE_FILE: return sysprof_capture_condition_new_where_file (self->u.where_file); @@ -315,8 +315,8 @@ sysprof_capture_condition_unref (SysprofCaptureCondition *self) } SysprofCaptureCondition * -sysprof_capture_condition_new_where_type_in (guint n_types, - const SysprofCaptureFrameType *types) +sysprof_capture_condition_new_where_type_in (unsigned int n_types, + const SysprofCaptureFrameType *types) { SysprofCaptureCondition *self; @@ -332,14 +332,14 @@ sysprof_capture_condition_new_where_type_in (guint n_types, } SysprofCaptureCondition * -sysprof_capture_condition_new_where_time_between (gint64 begin_time, - gint64 end_time) +sysprof_capture_condition_new_where_time_between (int64_t begin_time, + int64_t end_time) { SysprofCaptureCondition *self; if G_UNLIKELY (begin_time > end_time) { - gint64 tmp = begin_time; + int64_t tmp = begin_time; begin_time = end_time; end_time = tmp; } @@ -353,8 +353,8 @@ sysprof_capture_condition_new_where_time_between (gint64 begin_time, } SysprofCaptureCondition * -sysprof_capture_condition_new_where_pid_in (guint n_pids, - const gint32 *pids) +sysprof_capture_condition_new_where_pid_in (unsigned int n_pids, + const int32_t *pids) { SysprofCaptureCondition *self; @@ -362,16 +362,16 @@ sysprof_capture_condition_new_where_pid_in (guint n_pids, self = sysprof_capture_condition_init (); self->type = SYSPROF_CAPTURE_CONDITION_WHERE_PID_IN; - self->u.where_pid_in = g_array_sized_new (FALSE, FALSE, sizeof (gint32), n_pids); + self->u.where_pid_in = g_array_sized_new (FALSE, FALSE, sizeof (int32_t), n_pids); g_array_set_size (self->u.where_pid_in, n_pids); - memcpy (self->u.where_pid_in->data, pids, sizeof (gint32) * n_pids); + memcpy (self->u.where_pid_in->data, pids, sizeof (int32_t) * n_pids); return self; } SysprofCaptureCondition * -sysprof_capture_condition_new_where_counter_in (guint n_counters, - const guint *counters) +sysprof_capture_condition_new_where_counter_in (unsigned int n_counters, + const unsigned int *counters) { SysprofCaptureCondition *self; @@ -379,12 +379,12 @@ sysprof_capture_condition_new_where_counter_in (guint n_counters, self = sysprof_capture_condition_init (); self->type = SYSPROF_CAPTURE_CONDITION_WHERE_COUNTER_IN; - self->u.where_counter_in = g_array_sized_new (FALSE, FALSE, sizeof (guint), n_counters); + self->u.where_counter_in = g_array_sized_new (FALSE, FALSE, sizeof (unsigned int), n_counters); if (n_counters > 0) { g_array_set_size (self->u.where_counter_in, n_counters); - memcpy (self->u.where_counter_in->data, counters, sizeof (guint) * n_counters); + memcpy (self->u.where_counter_in->data, counters, sizeof (unsigned int) * n_counters); } return self; @@ -454,7 +454,7 @@ sysprof_capture_condition_new_or (SysprofCaptureCondition *left, * Returns: (transfer full): a new #SysprofCaptureCondition */ SysprofCaptureCondition * -sysprof_capture_condition_new_where_file (const gchar *path) +sysprof_capture_condition_new_where_file (const char *path) { SysprofCaptureCondition *self; diff --git a/src/libsysprof-capture/sysprof-capture-condition.h b/src/libsysprof-capture/sysprof-capture-condition.h index 33c356c7..8792449e 100644 --- a/src/libsysprof-capture/sysprof-capture-condition.h +++ b/src/libsysprof-capture/sysprof-capture-condition.h @@ -74,19 +74,19 @@ SYSPROF_AVAILABLE_IN_ALL SysprofCaptureCondition *sysprof_capture_condition_new_or (SysprofCaptureCondition *left, SysprofCaptureCondition *right); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureCondition *sysprof_capture_condition_new_where_type_in (guint n_types, +SysprofCaptureCondition *sysprof_capture_condition_new_where_type_in (unsigned int n_types, const SysprofCaptureFrameType *types); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureCondition *sysprof_capture_condition_new_where_time_between (gint64 begin_time, - gint64 end_time); +SysprofCaptureCondition *sysprof_capture_condition_new_where_time_between (int64_t begin_time, + int64_t end_time); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureCondition *sysprof_capture_condition_new_where_pid_in (guint n_pids, - const gint32 *pids); +SysprofCaptureCondition *sysprof_capture_condition_new_where_pid_in (unsigned int n_pids, + const int32_t *pids); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureCondition *sysprof_capture_condition_new_where_counter_in (guint n_counters, - const guint *counters); +SysprofCaptureCondition *sysprof_capture_condition_new_where_counter_in (unsigned int n_counters, + const unsigned int *counters); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureCondition *sysprof_capture_condition_new_where_file (const gchar *path); +SysprofCaptureCondition *sysprof_capture_condition_new_where_file (const char *path); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_condition_match (const SysprofCaptureCondition *self, const SysprofCaptureFrame *frame); diff --git a/src/libsysprof-capture/sysprof-capture-cursor.c b/src/libsysprof-capture/sysprof-capture-cursor.c index d2d014fb..b854a6c3 100644 --- a/src/libsysprof-capture/sysprof-capture-cursor.c +++ b/src/libsysprof-capture/sysprof-capture-cursor.c @@ -68,10 +68,10 @@ typedef const SysprofCaptureFrame *(*ReadDelegate) (SysprofCaptureReader *); struct _SysprofCaptureCursor { - volatile gint ref_count; + volatile int ref_count; GPtrArray *conditions; SysprofCaptureReader *reader; - guint reversed : 1; + unsigned int reversed : 1; }; static void @@ -138,7 +138,7 @@ sysprof_capture_cursor_unref (SysprofCaptureCursor *self) void sysprof_capture_cursor_foreach (SysprofCaptureCursor *self, SysprofCaptureCursorCallback callback, - gpointer user_data) + void *user_data) { g_return_if_fail (self != NULL); g_return_if_fail (self->reader != NULL); @@ -231,7 +231,7 @@ sysprof_capture_cursor_foreach (SysprofCaptureCursor *self, } else { - for (guint i = 0; i < self->conditions->len; i++) + for (size_t i = 0; i < self->conditions->len; i++) { const SysprofCaptureCondition *condition = g_ptr_array_index (self->conditions, i); diff --git a/src/libsysprof-capture/sysprof-capture-cursor.h b/src/libsysprof-capture/sysprof-capture-cursor.h index 13ef791a..8b2c0598 100644 --- a/src/libsysprof-capture/sysprof-capture-cursor.h +++ b/src/libsysprof-capture/sysprof-capture-cursor.h @@ -75,7 +75,7 @@ typedef struct _SysprofCaptureCursor SysprofCaptureCursor; * Returns: %TRUE if iteration should continue, otherwise %FALSE. */ typedef gboolean (*SysprofCaptureCursorCallback) (const SysprofCaptureFrame *frame, - gpointer user_data); + void *user_data); SYSPROF_AVAILABLE_IN_ALL SysprofCaptureCursor *sysprof_capture_cursor_new (SysprofCaptureReader *reader); @@ -88,7 +88,7 @@ SysprofCaptureReader *sysprof_capture_cursor_get_reader (SysprofCaptureCursor SYSPROF_AVAILABLE_IN_ALL void sysprof_capture_cursor_foreach (SysprofCaptureCursor *self, SysprofCaptureCursorCallback callback, - gpointer user_data); + void *user_data); SYSPROF_AVAILABLE_IN_ALL void sysprof_capture_cursor_reset (SysprofCaptureCursor *self); SYSPROF_AVAILABLE_IN_ALL diff --git a/src/libsysprof-capture/sysprof-capture-reader.c b/src/libsysprof-capture/sysprof-capture-reader.c index ed157621..4cf634bf 100644 --- a/src/libsysprof-capture/sysprof-capture-reader.c +++ b/src/libsysprof-capture/sysprof-capture-reader.c @@ -60,6 +60,7 @@ #include #include +#include #include #include #include @@ -71,19 +72,19 @@ struct _SysprofCaptureReader { - volatile gint ref_count; - gchar *filename; - guint8 *buf; - gsize bufsz; - gsize len; - gsize pos; - gsize fd_off; + volatile int ref_count; + char *filename; + uint8_t *buf; + size_t bufsz; + size_t len; + size_t pos; + size_t fd_off; int fd; - gint endian; + int endian; SysprofCaptureFileHeader header; - gint64 end_time; + int64_t end_time; SysprofCaptureStat st_buf; - guint st_buf_set : 1; + unsigned int st_buf_set : 1; }; static gboolean @@ -129,7 +130,7 @@ sysprof_capture_reader_finalize (SysprofCaptureReader *self) } } -const gchar * +const char * sysprof_capture_reader_get_time (SysprofCaptureReader *self) { g_return_val_if_fail (self != NULL, NULL); @@ -137,7 +138,7 @@ sysprof_capture_reader_get_time (SysprofCaptureReader *self) return self->header.capture_time; } -const gchar * +const char * sysprof_capture_reader_get_filename (SysprofCaptureReader *self) { g_return_val_if_fail (self != NULL, NULL); @@ -154,7 +155,7 @@ sysprof_capture_reader_discover_end_time (SysprofCaptureReader *self) while (sysprof_capture_reader_peek_frame (self, &frame)) { - gint64 end_time = frame.time; + int64_t end_time = frame.time; switch (frame.type) { @@ -215,7 +216,7 @@ sysprof_capture_reader_new_from_fd (int fd, self = g_new0 (SysprofCaptureReader, 1); self->ref_count = 1; - self->bufsz = G_MAXUSHORT * 2; + self->bufsz = USHRT_MAX * 2; self->buf = g_malloc (self->bufsz); self->len = 0; self->pos = 0; @@ -244,7 +245,7 @@ sysprof_capture_reader_new_from_fd (int fd, } SysprofCaptureReader * -sysprof_capture_reader_new (const gchar *filename, +sysprof_capture_reader_new (const char *filename, GError **error) { SysprofCaptureReader *self; @@ -350,7 +351,7 @@ sysprof_capture_reader_bswap_jitmap (SysprofCaptureReader *self, static gboolean sysprof_capture_reader_ensure_space_for (SysprofCaptureReader *self, - gsize len) + size_t len) { g_assert (self != NULL); g_assert (self->pos <= self->len); @@ -361,7 +362,7 @@ sysprof_capture_reader_ensure_space_for (SysprofCaptureReader *self, if ((self->len - self->pos) < len) { - gssize r; + ssize_t r; if (self->len > self->pos) memmove (self->buf, &self->buf[self->pos], self->len - self->pos); @@ -401,7 +402,7 @@ sysprof_capture_reader_skip (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof (SysprofCaptureFrame))) return FALSE; - frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos]; + frame = (SysprofCaptureFrame *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, frame); if (frame->len < sizeof (SysprofCaptureFrame)) @@ -410,7 +411,7 @@ sysprof_capture_reader_skip (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, frame->len)) return FALSE; - frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos]; + frame = (SysprofCaptureFrame *)(void *)&self->buf[self->pos]; self->pos += frame->len; @@ -436,7 +437,7 @@ sysprof_capture_reader_peek_frame (SysprofCaptureReader *self, g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0); - real_frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos]; + real_frame = (SysprofCaptureFrame *)(void *)&self->buf[self->pos]; *frame = *real_frame; @@ -472,10 +473,10 @@ sysprof_capture_reader_peek_type (SysprofCaptureReader *self, static const SysprofCaptureFrame * sysprof_capture_reader_read_basic (SysprofCaptureReader *self, SysprofCaptureFrameType type, - gsize extra) + size_t extra) { SysprofCaptureFrame *frame; - gsize len = sizeof *frame + extra; + size_t len = sizeof *frame + extra; g_assert (self != NULL); g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0); @@ -484,7 +485,7 @@ sysprof_capture_reader_read_basic (SysprofCaptureReader *self, if (!sysprof_capture_reader_ensure_space_for (self, len)) return NULL; - frame = (SysprofCaptureFrame *)(gpointer)&self->buf[self->pos]; + frame = (SysprofCaptureFrame *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, frame); @@ -524,7 +525,7 @@ sysprof_capture_reader_read_fork (SysprofCaptureReader *self) g_assert (self != NULL); fk = (SysprofCaptureFork *) - sysprof_capture_reader_read_basic (self, SYSPROF_CAPTURE_FRAME_FORK, sizeof(guint32)); + sysprof_capture_reader_read_basic (self, SYSPROF_CAPTURE_FRAME_FORK, sizeof (uint32_t)); if (fk != NULL) { @@ -547,7 +548,7 @@ sysprof_capture_reader_read_map (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *map)) return NULL; - map = (SysprofCaptureMap *)(gpointer)&self->buf[self->pos]; + map = (SysprofCaptureMap *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &map->frame); @@ -560,7 +561,7 @@ sysprof_capture_reader_read_map (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, map->frame.len)) return NULL; - map = (SysprofCaptureMap *)(gpointer)&self->buf[self->pos]; + map = (SysprofCaptureMap *)(void *)&self->buf[self->pos]; if (self->buf[self->pos + map->frame.len - 1] != '\0') return NULL; @@ -587,7 +588,7 @@ sysprof_capture_reader_read_log (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *log)) return NULL; - log = (SysprofCaptureLog *)(gpointer)&self->buf[self->pos]; + log = (SysprofCaptureLog *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &log->frame); @@ -600,7 +601,7 @@ sysprof_capture_reader_read_log (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, log->frame.len)) return NULL; - log = (SysprofCaptureLog *)(gpointer)&self->buf[self->pos]; + log = (SysprofCaptureLog *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_log (self, log); @@ -612,7 +613,7 @@ sysprof_capture_reader_read_log (SysprofCaptureReader *self) /* Ensure trailing \0 in domain and message */ log->domain[sizeof log->domain - 1] = 0; if (log->frame.len > sizeof *log) - ((gchar *)log)[log->frame.len - 1] = 0; + ((char *)log)[log->frame.len - 1] = 0; return log; } @@ -629,7 +630,7 @@ sysprof_capture_reader_read_mark (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *mark)) return NULL; - mark = (SysprofCaptureMark *)(gpointer)&self->buf[self->pos]; + mark = (SysprofCaptureMark *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &mark->frame); @@ -642,7 +643,7 @@ sysprof_capture_reader_read_mark (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, mark->frame.len)) return NULL; - mark = (SysprofCaptureMark *)(gpointer)&self->buf[self->pos]; + mark = (SysprofCaptureMark *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_mark (self, mark); @@ -654,7 +655,7 @@ sysprof_capture_reader_read_mark (SysprofCaptureReader *self) /* Ensure trailing \0 in name and message */ mark->name[sizeof mark->name - 1] = 0; if (mark->frame.len > sizeof *mark) - ((gchar *)mark)[mark->frame.len - 1] = 0; + ((char *)mark)[mark->frame.len - 1] = 0; /* Maybe update end-time */ if G_UNLIKELY ((mark->frame.time + mark->duration) > self->end_time) @@ -675,7 +676,7 @@ sysprof_capture_reader_read_metadata (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *metadata)) return NULL; - metadata = (SysprofCaptureMetadata *)(gpointer)&self->buf[self->pos]; + metadata = (SysprofCaptureMetadata *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &metadata->frame); @@ -688,7 +689,7 @@ sysprof_capture_reader_read_metadata (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, metadata->frame.len)) return NULL; - metadata = (SysprofCaptureMetadata *)(gpointer)&self->buf[self->pos]; + metadata = (SysprofCaptureMetadata *)(void *)&self->buf[self->pos]; self->pos += metadata->frame.len; @@ -698,7 +699,7 @@ sysprof_capture_reader_read_metadata (SysprofCaptureReader *self) /* Ensure trailing \0 in .id and .metadata */ metadata->id[sizeof metadata->id - 1] = 0; if (metadata->frame.len > sizeof *metadata) - ((gchar *)metadata)[metadata->frame.len - 1] = 0; + ((char *)metadata)[metadata->frame.len - 1] = 0; return metadata; } @@ -715,7 +716,7 @@ sysprof_capture_reader_read_process (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *process)) return NULL; - process = (SysprofCaptureProcess *)(gpointer)&self->buf[self->pos]; + process = (SysprofCaptureProcess *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &process->frame); @@ -728,7 +729,7 @@ sysprof_capture_reader_read_process (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, process->frame.len)) return NULL; - process = (SysprofCaptureProcess *)(gpointer)&self->buf[self->pos]; + process = (SysprofCaptureProcess *)(void *)&self->buf[self->pos]; if (self->buf[self->pos + process->frame.len - 1] != '\0') return NULL; @@ -746,9 +747,9 @@ sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self) { g_autoptr(GHashTable) ret = NULL; SysprofCaptureJitmap *jitmap; - guint8 *buf; - guint8 *endptr; - guint i; + uint8_t *buf; + uint8_t *endptr; + unsigned int i; g_assert (self != NULL); g_assert ((self->pos % SYSPROF_CAPTURE_ALIGN) == 0); @@ -757,7 +758,7 @@ sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *jitmap)) return NULL; - jitmap = (SysprofCaptureJitmap *)(gpointer)&self->buf[self->pos]; + jitmap = (SysprofCaptureJitmap *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &jitmap->frame); @@ -780,7 +781,7 @@ sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self) for (i = 0; i < jitmap->n_jitmaps; i++) { SysprofCaptureAddress addr; - const gchar *str; + const char *str; if (buf + sizeof addr >= endptr) return NULL; @@ -788,7 +789,7 @@ sysprof_capture_reader_read_jitmap (SysprofCaptureReader *self) memcpy (&addr, buf, sizeof addr); buf += sizeof addr; - str = (gchar *)buf; + str = (char *)buf; buf = memchr (buf, '\0', (endptr - buf)); @@ -819,7 +820,7 @@ sysprof_capture_reader_read_sample (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *sample)) return NULL; - sample = (SysprofCaptureSample *)(gpointer)&self->buf[self->pos]; + sample = (SysprofCaptureSample *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &sample->frame); @@ -838,11 +839,11 @@ sysprof_capture_reader_read_sample (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sample->frame.len)) return NULL; - sample = (SysprofCaptureSample *)(gpointer)&self->buf[self->pos]; + sample = (SysprofCaptureSample *)(void *)&self->buf[self->pos]; if (G_UNLIKELY (self->endian != G_BYTE_ORDER)) { - guint i; + unsigned int i; for (i = 0; i < sample->n_addrs; i++) sample->addrs[i] = GUINT64_SWAP_LE_BE (sample->addrs[i]); @@ -865,7 +866,7 @@ sysprof_capture_reader_read_counter_define (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *def)) return NULL; - def = (SysprofCaptureCounterDefine *)(gpointer)&self->buf[self->pos]; + def = (SysprofCaptureCounterDefine *)(void *)&self->buf[self->pos]; if (def->frame.type != SYSPROF_CAPTURE_FRAME_CTRDEF) return NULL; @@ -882,11 +883,11 @@ sysprof_capture_reader_read_counter_define (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, def->frame.len)) return NULL; - def = (SysprofCaptureCounterDefine *)(gpointer)&self->buf[self->pos]; + def = (SysprofCaptureCounterDefine *)(void *)&self->buf[self->pos]; if (G_UNLIKELY (self->endian != G_BYTE_ORDER)) { - guint i; + unsigned int i; for (i = 0; i < def->n_counters; i++) { @@ -912,7 +913,7 @@ sysprof_capture_reader_read_counter_set (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *set)) return NULL; - set = (SysprofCaptureCounterSet *)(gpointer)&self->buf[self->pos]; + set = (SysprofCaptureCounterSet *)(void *)&self->buf[self->pos]; if (set->frame.type != SYSPROF_CAPTURE_FRAME_CTRSET) return NULL; @@ -929,15 +930,15 @@ sysprof_capture_reader_read_counter_set (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, set->frame.len)) return NULL; - set = (SysprofCaptureCounterSet *)(gpointer)&self->buf[self->pos]; + set = (SysprofCaptureCounterSet *)(void *)&self->buf[self->pos]; if (G_UNLIKELY (self->endian != G_BYTE_ORDER)) { - guint i; + unsigned int i; for (i = 0; i < set->n_values; i++) { - guint j; + unsigned int j; for (j = 0; j < G_N_ELEMENTS (set->values[0].values); j++) { @@ -1026,12 +1027,12 @@ sysprof_capture_reader_splice (SysprofCaptureReader *self, */ gboolean sysprof_capture_reader_save_as (SysprofCaptureReader *self, - const gchar *filename, + const char *filename, GError **error) { struct stat stbuf; off_t in_off; - gsize to_write; + size_t to_write; int fd = -1; g_assert (self != NULL); @@ -1054,7 +1055,7 @@ sysprof_capture_reader_save_as (SysprofCaptureReader *self, while (to_write > 0) { - gssize written; + ssize_t written; written = _sysprof_sendfile (fd, self->fd, &in_off, to_write); @@ -1064,7 +1065,7 @@ sysprof_capture_reader_save_as (SysprofCaptureReader *self, if (written == 0 && errno != EAGAIN) goto handle_errno; - g_assert (written <= (gssize)to_write); + g_assert (written <= (ssize_t)to_write); to_write -= written; } @@ -1088,7 +1089,7 @@ handle_errno: return FALSE; } -gint64 +int64_t sysprof_capture_reader_get_start_time (SysprofCaptureReader *self) { g_return_val_if_fail (self != NULL, 0); @@ -1114,10 +1115,10 @@ sysprof_capture_reader_get_start_time (SysprofCaptureReader *self) * * Since: 3.22.1 */ -gint64 +int64_t sysprof_capture_reader_get_end_time (SysprofCaptureReader *self) { - gint64 end_time = 0; + int64_t end_time = 0; g_return_val_if_fail (self != NULL, 0); @@ -1212,7 +1213,7 @@ sysprof_capture_reader_read_file (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *file_chunk)) return NULL; - file_chunk = (SysprofCaptureFileChunk *)(gpointer)&self->buf[self->pos]; + file_chunk = (SysprofCaptureFileChunk *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &file_chunk->frame); @@ -1225,7 +1226,7 @@ sysprof_capture_reader_read_file (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, file_chunk->frame.len)) return NULL; - file_chunk = (SysprofCaptureFileChunk *)(gpointer)&self->buf[self->pos]; + file_chunk = (SysprofCaptureFileChunk *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_file_chunk (self, file_chunk); @@ -1244,7 +1245,7 @@ sysprof_capture_reader_read_file (SysprofCaptureReader *self) return file_chunk; } -gchar ** +char ** sysprof_capture_reader_list_files (SysprofCaptureReader *self) { g_autoptr(GHashTable) files = NULL; @@ -1280,13 +1281,13 @@ sysprof_capture_reader_list_files (SysprofCaptureReader *self) g_ptr_array_add (ar, g_strdup (key)); g_ptr_array_add (ar, NULL); - return (gchar **)g_ptr_array_free (g_steal_pointer (&ar), FALSE); + return (char **)g_ptr_array_free (g_steal_pointer (&ar), FALSE); } gboolean sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self, - const gchar *path, - gint fd) + const char *path, + int fd) { g_assert (self != NULL); g_assert (path != NULL); @@ -1296,8 +1297,8 @@ sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self, { SysprofCaptureFrameType type; const SysprofCaptureFileChunk *file; - const guint8 *buf; - gsize to_write; + const uint8_t *buf; + size_t to_write; if (!sysprof_capture_reader_peek_type (self, &type)) return FALSE; @@ -1316,7 +1317,7 @@ sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self, while (to_write > 0) { - gssize written; + ssize_t written; written = _sysprof_write (fd, buf, to_write); if (written < 0) @@ -1325,7 +1326,7 @@ sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self, if (written == 0 && errno != EAGAIN) return FALSE; - g_assert (written <= (gssize)to_write); + g_assert (written <= (ssize_t)to_write); buf += written; to_write -= written; @@ -1344,7 +1345,7 @@ sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self, g_return_val_if_reached (FALSE); } -gint +int sysprof_capture_reader_get_byte_order (SysprofCaptureReader *self) { g_return_val_if_fail (self != NULL, 0); @@ -1354,7 +1355,7 @@ sysprof_capture_reader_get_byte_order (SysprofCaptureReader *self) const SysprofCaptureFileChunk * sysprof_capture_reader_find_file (SysprofCaptureReader *self, - const gchar *path) + const char *path) { SysprofCaptureFrameType type; @@ -1395,7 +1396,7 @@ sysprof_capture_reader_read_allocation (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, sizeof *ma)) return NULL; - ma = (SysprofCaptureAllocation *)(gpointer)&self->buf[self->pos]; + ma = (SysprofCaptureAllocation *)(void *)&self->buf[self->pos]; sysprof_capture_reader_bswap_frame (self, &ma->frame); @@ -1419,11 +1420,11 @@ sysprof_capture_reader_read_allocation (SysprofCaptureReader *self) if (!sysprof_capture_reader_ensure_space_for (self, ma->frame.len)) return NULL; - ma = (SysprofCaptureAllocation *)(gpointer)&self->buf[self->pos]; + ma = (SysprofCaptureAllocation *)(void *)&self->buf[self->pos]; if (G_UNLIKELY (self->endian != G_BYTE_ORDER)) { - for (guint i = 0; i < ma->n_addrs; i++) + for (unsigned int i = 0; i < ma->n_addrs; i++) ma->addrs[i] = GUINT64_SWAP_LE_BE (ma->addrs[i]); } diff --git a/src/libsysprof-capture/sysprof-capture-reader.h b/src/libsysprof-capture/sysprof-capture-reader.h index 9c732b0a..09348584 100644 --- a/src/libsysprof-capture/sysprof-capture-reader.h +++ b/src/libsysprof-capture/sysprof-capture-reader.h @@ -64,7 +64,7 @@ G_BEGIN_DECLS typedef struct _SysprofCaptureReader SysprofCaptureReader; SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureReader *sysprof_capture_reader_new (const gchar *filename, +SysprofCaptureReader *sysprof_capture_reader_new (const char *filename, GError **error); SYSPROF_AVAILABLE_IN_ALL SysprofCaptureReader *sysprof_capture_reader_new_from_fd (int fd, @@ -76,15 +76,15 @@ SysprofCaptureReader *sysprof_capture_reader_ref ( SYSPROF_AVAILABLE_IN_ALL void sysprof_capture_reader_unref (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL -gint sysprof_capture_reader_get_byte_order (SysprofCaptureReader *self); +int sysprof_capture_reader_get_byte_order (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL -const gchar *sysprof_capture_reader_get_filename (SysprofCaptureReader *self); +const char *sysprof_capture_reader_get_filename (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL -const gchar *sysprof_capture_reader_get_time (SysprofCaptureReader *self); +const char *sysprof_capture_reader_get_time (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_capture_reader_get_start_time (SysprofCaptureReader *self); +int64_t sysprof_capture_reader_get_start_time (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL -gint64 sysprof_capture_reader_get_end_time (SysprofCaptureReader *self); +int64_t sysprof_capture_reader_get_end_time (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_reader_skip (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL @@ -129,7 +129,7 @@ gboolean sysprof_capture_reader_splice ( GError **error); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_reader_save_as (SysprofCaptureReader *self, - const gchar *filename, + const char *filename, GError **error); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_reader_get_stat (SysprofCaptureReader *self, @@ -139,13 +139,13 @@ void sysprof_capture_reader_set_stat ( const SysprofCaptureStat *st_buf); SYSPROF_AVAILABLE_IN_ALL const SysprofCaptureFileChunk *sysprof_capture_reader_find_file (SysprofCaptureReader *self, - const gchar *path); + const char *path); SYSPROF_AVAILABLE_IN_ALL -gchar **sysprof_capture_reader_list_files (SysprofCaptureReader *self); +char **sysprof_capture_reader_list_files (SysprofCaptureReader *self); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_reader_read_file_fd (SysprofCaptureReader *self, - const gchar *path, - gint fd); + const char *path, + int fd); G_END_DECLS diff --git a/src/libsysprof-capture/sysprof-capture-types.h b/src/libsysprof-capture/sysprof-capture-types.h index fab5ba13..05f36c44 100644 --- a/src/libsysprof-capture/sysprof-capture-types.h +++ b/src/libsysprof-capture/sysprof-capture-types.h @@ -57,6 +57,9 @@ #pragma once #include +#include +#include +#include #include "sysprof-clock.h" @@ -92,25 +95,25 @@ typedef struct _SysprofCaptureWriter SysprofCaptureWriter; typedef struct _SysprofCaptureCursor SysprofCaptureCursor; typedef struct _SysprofCaptureCondition SysprofCaptureCondition; -typedef guint64 SysprofCaptureAddress; +typedef uint64_t SysprofCaptureAddress; typedef struct { /* * The number of frames indexed by SysprofCaptureFrameType */ - gsize frame_count[16]; + size_t frame_count[16]; /* * Padding for future expansion. */ - gsize padding[48]; + size_t padding[48]; } SysprofCaptureStat; typedef union { - gint64 v64; - gdouble vdbl; + int64_t v64; + double vdbl; } SysprofCaptureCounterValue; typedef enum @@ -137,28 +140,28 @@ typedef enum SYSPROF_ALIGNED_BEGIN(1) typedef struct { - guint32 magic; - guint32 version : 8; - guint32 little_endian : 1; - guint32 padding : 23; - gchar capture_time[64]; - gint64 time; - gint64 end_time; - gchar suffix[168]; + uint32_t magic; + uint32_t version : 8; + uint32_t little_endian : 1; + uint32_t padding : 23; + char capture_time[64]; + int64_t time; + int64_t end_time; + char suffix[168]; } SysprofCaptureFileHeader SYSPROF_ALIGNED_END(1); SYSPROF_ALIGNED_BEGIN(1) typedef struct { - guint16 len; - gint16 cpu; - gint32 pid; - gint64 time; - guint32 type : 8; - guint32 padding1 : 24; - guint32 padding2; - guint8 data[0]; + uint16_t len; + int16_t cpu; + int32_t pid; + int64_t time; + uint32_t type : 8; + uint32_t padding1 : 24; + uint32_t padding2; + uint8_t data[0]; } SysprofCaptureFrame SYSPROF_ALIGNED_END(1); @@ -166,11 +169,11 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - guint64 start; - guint64 end; - guint64 offset; - guint64 inode; - gchar filename[0]; + uint64_t start; + uint64_t end; + uint64_t offset; + uint64_t inode; + char filename[0]; } SysprofCaptureMap SYSPROF_ALIGNED_END(1); @@ -178,8 +181,8 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - guint32 n_jitmaps; - guint8 data[0]; + uint32_t n_jitmaps; + uint8_t data[0]; } SysprofCaptureJitmap SYSPROF_ALIGNED_END(1); @@ -187,7 +190,7 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - gchar cmdline[0]; + char cmdline[0]; } SysprofCaptureProcess SYSPROF_ALIGNED_END(1); @@ -195,9 +198,9 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - guint32 n_addrs : 16; - guint32 padding1 : 16; - gint32 tid; + uint32_t n_addrs : 16; + uint32_t padding1 : 16; + int32_t tid; SysprofCaptureAddress addrs[0]; } SysprofCaptureSample SYSPROF_ALIGNED_END(1); @@ -206,7 +209,7 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - gint32 child_pid; + int32_t child_pid; } SysprofCaptureFork SYSPROF_ALIGNED_END(1); @@ -227,11 +230,11 @@ SYSPROF_ALIGNED_END(1); SYSPROF_ALIGNED_BEGIN(1) typedef struct { - gchar category[32]; - gchar name[32]; - gchar description[52]; - guint32 id : 24; - guint32 type : 8; + char category[32]; + char name[32]; + char description[52]; + uint32_t id : 24; + uint32_t type : 8; SysprofCaptureCounterValue value; } SysprofCaptureCounter SYSPROF_ALIGNED_END(1); @@ -240,9 +243,9 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - guint32 n_counters : 16; - guint32 padding1 : 16; - guint32 padding2; + uint32_t n_counters : 16; + uint32_t padding1 : 16; + uint32_t padding2; SysprofCaptureCounter counters[0]; } SysprofCaptureCounterDefine SYSPROF_ALIGNED_END(1); @@ -255,7 +258,7 @@ typedef struct * bytes. So this makes a nice 2-cacheline aligned size which is * useful when the number of counters is rather small. */ - guint32 ids[8]; + uint32_t ids[8]; SysprofCaptureCounterValue values[8]; } SysprofCaptureCounterValues SYSPROF_ALIGNED_END(1); @@ -264,9 +267,9 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - guint32 n_values : 16; - guint32 padding1 : 16; - guint32 padding2; + uint32_t n_values : 16; + uint32_t padding1 : 16; + uint32_t padding2; SysprofCaptureCounterValues values[0]; } SysprofCaptureCounterSet SYSPROF_ALIGNED_END(1); @@ -275,10 +278,10 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - gint64 duration; - gchar group[24]; - gchar name[40]; - gchar message[0]; + int64_t duration; + char group[24]; + char name[40]; + char message[0]; } SysprofCaptureMark SYSPROF_ALIGNED_END(1); @@ -286,8 +289,8 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - gchar id[40]; - gchar metadata[0]; + char id[40]; + char metadata[0]; } SysprofCaptureMetadata SYSPROF_ALIGNED_END(1); @@ -295,11 +298,11 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - guint32 severity : 16; - guint32 padding1 : 16; - guint32 padding2 : 32; - gchar domain[32]; - gchar message[0]; + uint32_t severity : 16; + uint32_t padding1 : 16; + uint32_t padding2 : 32; + char domain[32]; + char message[0]; } SysprofCaptureLog SYSPROF_ALIGNED_END(1); @@ -307,11 +310,11 @@ SYSPROF_ALIGNED_BEGIN(1) typedef struct { SysprofCaptureFrame frame; - guint32 is_last : 1; - guint32 padding1 : 15; - guint32 len : 16; - gchar path[256]; - guint8 data[0]; + uint32_t is_last : 1; + uint32_t padding1 : 15; + uint32_t len : 16; + char path[256]; + uint8_t data[0]; } SysprofCaptureFileChunk SYSPROF_ALIGNED_END(1); @@ -320,10 +323,10 @@ typedef struct { SysprofCaptureFrame frame; SysprofCaptureAddress alloc_addr; - gint64 alloc_size; - gint32 tid; - guint32 n_addrs : 16; - guint32 padding1 : 16; + int64_t alloc_size; + int32_t tid; + uint32_t n_addrs : 16; + uint32_t padding1 : 16; SysprofCaptureAddress addrs[0]; } SysprofCaptureAllocation SYSPROF_ALIGNED_END(1); @@ -350,7 +353,7 @@ G_STATIC_ASSERT (sizeof (SysprofCaptureAllocation) == 48); G_STATIC_ASSERT ((G_STRUCT_OFFSET (SysprofCaptureAllocation, addrs) % SYSPROF_CAPTURE_ALIGN) == 0); G_STATIC_ASSERT ((G_STRUCT_OFFSET (SysprofCaptureSample, addrs) % SYSPROF_CAPTURE_ALIGN) == 0); -static inline gint +static inline int sysprof_capture_address_compare (SysprofCaptureAddress a, SysprofCaptureAddress b) { diff --git a/src/libsysprof-capture/sysprof-capture-util-private.h b/src/libsysprof-capture/sysprof-capture-util-private.h index 5350a178..26ba79e1 100644 --- a/src/libsysprof-capture/sysprof-capture-util-private.h +++ b/src/libsysprof-capture/sysprof-capture-util-private.h @@ -84,7 +84,7 @@ ssize_t _sysprof_pwrite (int fd, ssize_t _sysprof_write (int fd, const void *buf, size_t count); -gint32 _sysprof_getpid (void); +int32_t _sysprof_getpid (void); ssize_t _sysprof_sendfile (int out_fd, int in_fd, off_t *offset, diff --git a/src/libsysprof-capture/sysprof-capture-util.c b/src/libsysprof-capture/sysprof-capture-util.c index 58336e7f..4571b4dd 100644 --- a/src/libsysprof-capture/sysprof-capture-util.c +++ b/src/libsysprof-capture/sysprof-capture-util.c @@ -157,7 +157,7 @@ ssize_t #endif } -gint32 +int32_t (_sysprof_getpid) (void) { #ifdef G_OS_WIN32 diff --git a/src/libsysprof-capture/sysprof-capture-writer-cat.c b/src/libsysprof-capture/sysprof-capture-writer-cat.c index 0e473f40..504835a6 100644 --- a/src/libsysprof-capture/sysprof-capture-writer-cat.c +++ b/src/libsysprof-capture/sysprof-capture-writer-cat.c @@ -59,14 +59,15 @@ #include "config.h" #include +#include #include #include #include typedef struct { - guint64 src; - guint64 dst; + uint64_t src; + uint64_t dst; } TranslateItem; enum { @@ -76,15 +77,15 @@ enum { }; static void -translate_table_clear (GArray **tables, - guint table) +translate_table_clear (GArray **tables, + unsigned int table) { g_clear_pointer (&tables[table], g_array_unref); } -static gint -compare_by_src (gconstpointer a, - gconstpointer b) +static int +compare_by_src (const void *a, + const void *b) { const TranslateItem *itema = a; const TranslateItem *itemb = b; @@ -98,18 +99,18 @@ compare_by_src (gconstpointer a, } static void -translate_table_sort (GArray **tables, - guint table) +translate_table_sort (GArray **tables, + unsigned int table) { if (tables[table]) g_array_sort (tables[table], compare_by_src); } static void -translate_table_add (GArray **tables, - guint table, - guint64 src, - guint64 dst) +translate_table_add (GArray **tables, + unsigned int table, + uint64_t src, + uint64_t dst) { const TranslateItem item = { src, dst }; @@ -119,10 +120,10 @@ translate_table_add (GArray **tables, g_array_append_val (tables[table], item); } -static guint64 -translate_table_translate (GArray **tables, - guint table, - guint64 src) +static uint64_t +translate_table_translate (GArray **tables, + unsigned int table, + uint64_t src) { const TranslateItem *item; TranslateItem key = { src, 0 }; @@ -152,9 +153,9 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self, { GArray *tables[N_TRANSLATE] = { NULL }; SysprofCaptureFrameType type; - gint64 start_time; - gint64 first_start_time = G_MAXINT64; - gint64 end_time = -1; + int64_t start_time; + int64_t first_start_time = INT64_MAX; + int64_t end_time = -1; g_return_val_if_fail (self != NULL, FALSE); g_return_val_if_fail (reader != NULL, FALSE); @@ -176,8 +177,8 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self, { g_autoptr(GHashTable) jitmap = NULL; GHashTableIter iter; - const gchar *name; - guint64 addr; + const char *name; + uint64_t addr; if (type != SYSPROF_CAPTURE_FRAME_JITMAP) { @@ -192,7 +193,7 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self, g_hash_table_iter_init (&iter, jitmap); while (g_hash_table_iter_next (&iter, (gpointer *)&addr, (gpointer *)&name)) { - guint64 replace = sysprof_capture_writer_add_jitmap (self, name); + uint64_t replace = sysprof_capture_writer_add_jitmap (self, name); /* We need to keep a table of replacement addresses so that * we can translate the samples into the destination address * space that we synthesized for the address identifier. @@ -378,7 +379,7 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self, { SysprofCaptureAddress addrs[frame->n_addrs]; - for (guint z = 0; z < frame->n_addrs; z++) + for (unsigned int z = 0; z < frame->n_addrs; z++) addrs[z] = translate_table_translate (tables, TRANSLATE_ADDR, frame->addrs[z]); sysprof_capture_writer_add_sample (self, @@ -403,10 +404,10 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self, { g_autoptr(GArray) counter = g_array_new (FALSE, FALSE, sizeof (SysprofCaptureCounter)); - for (guint z = 0; z < frame->n_counters; z++) + for (unsigned int z = 0; z < frame->n_counters; z++) { SysprofCaptureCounter c = frame->counters[z]; - guint src = c.id; + unsigned int src = c.id; c.id = sysprof_capture_writer_request_counter (self, 1); @@ -440,15 +441,15 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self, g_autoptr(GArray) ids = g_array_new (FALSE, FALSE, sizeof (guint)); g_autoptr(GArray) values = g_array_new (FALSE, FALSE, sizeof (SysprofCaptureCounterValue)); - for (guint z = 0; z < frame->n_values; z++) + for (unsigned int z = 0; z < frame->n_values; z++) { const SysprofCaptureCounterValues *v = &frame->values[z]; - for (guint y = 0; y < G_N_ELEMENTS (v->ids); y++) + for (unsigned int y = 0; y < G_N_ELEMENTS (v->ids); y++) { if (v->ids[y]) { - guint dst = translate_table_translate (tables, TRANSLATE_CTR, v->ids[y]); + unsigned int dst = translate_table_translate (tables, TRANSLATE_CTR, v->ids[y]); SysprofCaptureCounterValue value = v->values[y]; g_array_append_val (ids, dst); @@ -463,8 +464,8 @@ sysprof_capture_writer_cat (SysprofCaptureWriter *self, frame->frame.time, frame->frame.cpu, frame->frame.pid, - (const guint *)(gpointer)ids->data, - (const SysprofCaptureCounterValue *)(gpointer)values->data, + (const unsigned int *)(void *)ids->data, + (const SysprofCaptureCounterValue *)(void *)values->data, ids->len); } diff --git a/src/libsysprof-capture/sysprof-capture-writer.c b/src/libsysprof-capture/sysprof-capture-writer.c index 8e4c5a61..57c176c2 100644 --- a/src/libsysprof-capture/sysprof-capture-writer.c +++ b/src/libsysprof-capture/sysprof-capture-writer.c @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include @@ -83,10 +84,10 @@ typedef struct { /* A pinter into the string buffer */ - const gchar *str; + const char *str; /* The unique address for the string */ - guint64 addr; + uint64_t addr; } SysprofCaptureJitmapBucket; struct _SysprofCaptureWriter @@ -98,7 +99,7 @@ struct _SysprofCaptureWriter * * This is paired with a closed hash table for deduplication. */ - gchar addr_buf[4096*4]; + char addr_buf[4096*4]; /* Our hashtable for deduplication. */ SysprofCaptureJitmapBucket addr_hash[512]; @@ -107,38 +108,38 @@ struct _SysprofCaptureWriter * alinged for the write buffer. This improves the performance of large * writes to the target file-descriptor. */ - volatile gint ref_count; + volatile int ref_count; /* * Our address sequence counter. The value that comes from * monotonically increasing this is OR'd with JITMAP_MARK to denote * the address name should come from the JIT map. */ - gsize addr_seq; + size_t addr_seq; /* Our position in addr_buf. */ - gsize addr_buf_pos; + size_t addr_buf_pos; /* * The number of hash table items in @addr_hash. This is an * optimization so that we can avoid calculating the number of strings * when flushing out the jitmap. */ - guint addr_hash_size; + unsigned int addr_hash_size; /* Capture file handle */ int fd; /* Our write buffer for fd */ - guint8 *buf; - gsize pos; - gsize len; + uint8_t *buf; + size_t pos; + size_t len; /* GSource for periodic flush */ GSource *periodic_flush; /* counter id sequence */ - gint next_counter_id; + int next_counter_id; /* Statistics while recording */ SysprofCaptureStat stat; @@ -146,10 +147,10 @@ struct _SysprofCaptureWriter static inline void sysprof_capture_writer_frame_init (SysprofCaptureFrame *frame_, - gint len, - gint cpu, - gint32 pid, - gint64 time_, + int len, + int cpu, + int32_t pid, + int64_t time_, SysprofCaptureFrameType type) { g_assert (frame_ != NULL); @@ -207,9 +208,9 @@ sysprof_capture_writer_unref (SysprofCaptureWriter *self) static gboolean sysprof_capture_writer_flush_data (SysprofCaptureWriter *self) { - const guint8 *buf; - gssize written; - gsize to_write; + const uint8_t *buf; + ssize_t written; + size_t to_write; g_assert (self != NULL); g_assert (self->pos <= self->len); @@ -230,7 +231,7 @@ sysprof_capture_writer_flush_data (SysprofCaptureWriter *self) if (written == 0 && errno != EAGAIN) return FALSE; - g_assert (written <= (gssize)to_write); + g_assert (written <= (ssize_t)to_write); buf += written; to_write -= written; @@ -242,17 +243,17 @@ sysprof_capture_writer_flush_data (SysprofCaptureWriter *self) } static inline void -sysprof_capture_writer_realign (gsize *pos) +sysprof_capture_writer_realign (size_t *pos) { *pos = (*pos + SYSPROF_CAPTURE_ALIGN - 1) & ~(SYSPROF_CAPTURE_ALIGN - 1); } static inline gboolean sysprof_capture_writer_ensure_space_for (SysprofCaptureWriter *self, - gsize len) + size_t len) { /* Check for max frame size */ - if (len > G_MAXUSHORT) + if (len > USHRT_MAX) return FALSE; if ((self->len - self->pos) < len) @@ -264,11 +265,11 @@ sysprof_capture_writer_ensure_space_for (SysprofCaptureWriter *self, return TRUE; } -static inline gpointer +static inline void * sysprof_capture_writer_allocate (SysprofCaptureWriter *self, - gsize *len) + size_t *len) { - gpointer p; + void *p; g_assert (self != NULL); g_assert (len != NULL); @@ -279,7 +280,7 @@ sysprof_capture_writer_allocate (SysprofCaptureWriter *self, if (!sysprof_capture_writer_ensure_space_for (self, *len)) return NULL; - p = (gpointer)&self->buf[self->pos]; + p = (void *)&self->buf[self->pos]; self->pos += *len; @@ -292,8 +293,8 @@ static gboolean sysprof_capture_writer_flush_jitmap (SysprofCaptureWriter *self) { SysprofCaptureJitmap jitmap; - gssize r; - gsize len; + ssize_t r; + size_t len; g_assert (self != NULL); @@ -318,7 +319,7 @@ sysprof_capture_writer_flush_jitmap (SysprofCaptureWriter *self) return FALSE; r = _sysprof_write (self->fd, self->addr_buf, len - sizeof jitmap); - if (r < 0 || (gsize)r != (len - sizeof jitmap)) + if (r < 0 || (size_t)r != (len - sizeof jitmap)) return FALSE; self->addr_buf_pos = 0; @@ -332,11 +333,11 @@ sysprof_capture_writer_flush_jitmap (SysprofCaptureWriter *self) static gboolean sysprof_capture_writer_lookup_jitmap (SysprofCaptureWriter *self, - const gchar *name, + const char *name, SysprofCaptureAddress *addr) { - guint hash; - guint i; + unsigned int hash; + unsigned int i; g_assert (self != NULL); g_assert (name != NULL); @@ -377,13 +378,13 @@ sysprof_capture_writer_lookup_jitmap (SysprofCaptureWriter *self, static SysprofCaptureAddress sysprof_capture_writer_insert_jitmap (SysprofCaptureWriter *self, - const gchar *str) + const char *str) { SysprofCaptureAddress addr; - gchar *dst; - gsize len; - guint hash; - guint i; + char *dst; + size_t len; + unsigned int hash; + unsigned int i; g_assert (self != NULL); g_assert (str != NULL); @@ -408,7 +409,7 @@ sysprof_capture_writer_insert_jitmap (SysprofCaptureWriter *self, addr = SYSPROF_CAPTURE_JITMAP_MARK | ++self->addr_seq; /* Copy the address into the buffer */ - dst = (gchar *)&self->addr_buf[self->addr_buf_pos]; + dst = (char *)&self->addr_buf[self->addr_buf_pos]; memcpy (dst, &addr, sizeof addr); /* @@ -459,14 +460,14 @@ sysprof_capture_writer_insert_jitmap (SysprofCaptureWriter *self, } SysprofCaptureWriter * -sysprof_capture_writer_new_from_fd (int fd, - gsize buffer_size) +sysprof_capture_writer_new_from_fd (int fd, + size_t buffer_size) { g_autofree gchar *nowstr = NULL; g_autoptr(GDateTime) now = NULL; SysprofCaptureWriter *self; SysprofCaptureFileHeader *header; - gsize header_len = sizeof(*header); + size_t header_len = sizeof(*header); if (fd < 0) return NULL; @@ -538,8 +539,8 @@ sysprof_capture_writer_new_from_fd (int fd, } SysprofCaptureWriter * -sysprof_capture_writer_new (const gchar *filename, - gsize buffer_size) +sysprof_capture_writer_new (const char *filename, + size_t buffer_size) { SysprofCaptureWriter *self; int fd; @@ -561,17 +562,17 @@ sysprof_capture_writer_new (const gchar *filename, gboolean sysprof_capture_writer_add_map (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - guint64 start, - guint64 end, - guint64 offset, - guint64 inode, - const gchar *filename) + int64_t time, + int cpu, + int32_t pid, + uint64_t start, + uint64_t end, + uint64_t offset, + uint64_t inode, + const char *filename) { SysprofCaptureMap *ev; - gsize len; + size_t len; if (filename == NULL) filename = ""; @@ -606,17 +607,17 @@ sysprof_capture_writer_add_map (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_mark (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - guint64 duration, - const gchar *group, - const gchar *name, - const gchar *message) + int64_t time, + int cpu, + int32_t pid, + uint64_t duration, + const char *group, + const char *name, + const char *message) { SysprofCaptureMark *ev; - gsize message_len; - gsize len; + size_t message_len; + size_t len; g_assert (self != NULL); g_assert (name != NULL); @@ -650,15 +651,15 @@ sysprof_capture_writer_add_mark (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_metadata (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *id, - const gchar *metadata, - gssize metadata_len) + int64_t time, + int cpu, + int32_t pid, + const char *id, + const char *metadata, + ssize_t metadata_len) { SysprofCaptureMetadata *ev; - gsize len; + size_t len; g_assert (self != NULL); g_assert (id != NULL); @@ -695,7 +696,7 @@ sysprof_capture_writer_add_metadata (SysprofCaptureWriter *self, SysprofCaptureAddress sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self, - const gchar *name) + const char *name) { SysprofCaptureAddress addr = INVALID_ADDRESS; @@ -713,13 +714,13 @@ sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_process (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *cmdline) + int64_t time, + int cpu, + int32_t pid, + const char *cmdline) { SysprofCaptureProcess *ev; - gsize len; + size_t len; if (cmdline == NULL) cmdline = ""; @@ -750,15 +751,15 @@ sysprof_capture_writer_add_process (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_sample (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 tid, + int64_t time, + int cpu, + int32_t pid, + int32_t tid, const SysprofCaptureAddress *addrs, - guint n_addrs) + unsigned int n_addrs) { SysprofCaptureSample *ev; - gsize len; + size_t len; g_assert (self != NULL); @@ -786,13 +787,13 @@ sysprof_capture_writer_add_sample (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_fork (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 child_pid) + int64_t time, + int cpu, + int32_t pid, + int32_t child_pid) { SysprofCaptureFork *ev; - gsize len = sizeof *ev; + size_t len = sizeof *ev; g_assert (self != NULL); @@ -815,12 +816,12 @@ sysprof_capture_writer_add_fork (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_exit (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid) + int64_t time, + int cpu, + int32_t pid) { SysprofCaptureExit *ev; - gsize len = sizeof *ev; + size_t len = sizeof *ev; g_assert (self != NULL); @@ -842,12 +843,12 @@ sysprof_capture_writer_add_exit (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_timestamp (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid) + int64_t time, + int cpu, + int32_t pid) { SysprofCaptureTimestamp *ev; - gsize len = sizeof *ev; + size_t len = sizeof *ev; g_assert (self != NULL); @@ -870,7 +871,7 @@ sysprof_capture_writer_add_timestamp (SysprofCaptureWriter *self, static gboolean sysprof_capture_writer_flush_end_time (SysprofCaptureWriter *self) { - gint64 end_time = SYSPROF_CAPTURE_CURRENT_TIME; + int64_t end_time = SYSPROF_CAPTURE_CURRENT_TIME; ssize_t ret; g_assert (self != NULL); @@ -914,10 +915,10 @@ sysprof_capture_writer_flush (SysprofCaptureWriter *self) */ gboolean sysprof_capture_writer_save_as (SysprofCaptureWriter *self, - const gchar *filename, + const char *filename, GError **error) { - gsize to_write; + size_t to_write; off_t in_off; off_t pos; int fd = -1; @@ -940,7 +941,7 @@ sysprof_capture_writer_save_as (SysprofCaptureWriter *self, while (to_write > 0) { - gssize written; + ssize_t written; written = _sysprof_sendfile (fd, self->fd, &in_off, pos); @@ -950,7 +951,7 @@ sysprof_capture_writer_save_as (SysprofCaptureWriter *self, if (written == 0 && errno != EAGAIN) goto handle_errno; - g_assert (written <= (gssize)to_write); + g_assert (written <= (ssize_t)to_write); to_write -= written; } @@ -997,7 +998,7 @@ _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self, { struct stat stbuf; off_t in_off; - gsize to_write; + size_t to_write; g_assert (self != NULL); g_assert (self->fd != -1); @@ -1019,7 +1020,7 @@ _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self, while (to_write > 0) { - gssize written; + ssize_t written; written = _sysprof_sendfile (self->fd, fd, &in_off, to_write); @@ -1029,7 +1030,7 @@ _sysprof_capture_writer_splice_from_fd (SysprofCaptureWriter *self, if (written == 0 && errno != EAGAIN) goto handle_errno; - g_assert (written <= (gssize)to_write); + g_assert (written <= (ssize_t)to_write); to_write -= written; } @@ -1166,15 +1167,15 @@ sysprof_capture_writer_stat (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_define_counters (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, + int64_t time, + int cpu, + int32_t pid, const SysprofCaptureCounter *counters, - guint n_counters) + unsigned int n_counters) { SysprofCaptureCounterDefine *def; - gsize len; - guint i; + size_t len; + unsigned int i; g_assert (self != NULL); g_assert (counters != NULL); @@ -1216,19 +1217,19 @@ sysprof_capture_writer_define_counters (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_set_counters (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const guint *counters_ids, + int64_t time, + int cpu, + int32_t pid, + const unsigned int *counters_ids, const SysprofCaptureCounterValue *values, - guint n_counters) + unsigned int n_counters) { SysprofCaptureCounterSet *set; - gsize len; - guint n_groups; - guint group; - guint field; - guint i; + size_t len; + unsigned int n_groups; + unsigned int group; + unsigned int field; + unsigned int i; g_assert (self != NULL); g_assert (counters_ids != NULL || n_counters == 0); @@ -1292,11 +1293,11 @@ sysprof_capture_writer_set_counters (SysprofCaptureWriter *self, * * Returns: The next series of counter values or zero on failure. */ -guint +unsigned int sysprof_capture_writer_request_counter (SysprofCaptureWriter *self, - guint n_counters) + unsigned int n_counters) { - gint ret; + int ret; g_assert (self != NULL); @@ -1311,8 +1312,8 @@ sysprof_capture_writer_request_counter (SysprofCaptureWriter *self, gboolean _sysprof_capture_writer_set_time_range (SysprofCaptureWriter *self, - gint64 start_time, - gint64 end_time) + int64_t start_time, + int64_t end_time) { ssize_t ret; @@ -1340,9 +1341,9 @@ do_end: } SysprofCaptureWriter * -sysprof_capture_writer_new_from_env (gsize buffer_size) +sysprof_capture_writer_new_from_env (size_t buffer_size) { - const gchar *fdstr; + const char *fdstr; int fd; if (!(fdstr = g_getenv ("SYSPROF_TRACE_FD"))) @@ -1361,7 +1362,7 @@ sysprof_capture_writer_new_from_env (gsize buffer_size) return sysprof_capture_writer_new_from_fd (dup (fd), buffer_size); } -gsize +size_t sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self) { g_return_val_if_fail (self != NULL, 0); @@ -1371,16 +1372,16 @@ sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self) gboolean sysprof_capture_writer_add_log (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - GLogLevelFlags severity, - const gchar *domain, - const gchar *message) + int64_t time, + int cpu, + int32_t pid, + int severity, + const char *domain, + const char *message) { SysprofCaptureLog *ev; - gsize message_len; - gsize len; + size_t message_len; + size_t len; g_assert (self != NULL); @@ -1416,16 +1417,16 @@ sysprof_capture_writer_add_log (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_file (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *path, - gboolean is_last, - const guint8 *data, - gsize data_len) + int64_t time, + int cpu, + int32_t pid, + const char *path, + bool is_last, + const uint8_t *data, + size_t data_len) { SysprofCaptureFileChunk *ev; - gsize len; + size_t len; g_assert (self != NULL); @@ -1454,20 +1455,20 @@ sysprof_capture_writer_add_file (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_file_fd (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *path, - gint fd) + int64_t time, + int cpu, + int32_t pid, + const char *path, + int fd) { - guint8 data[(4096*4L) - sizeof(SysprofCaptureFileChunk)]; + uint8_t data[(4096*4L) - sizeof(SysprofCaptureFileChunk)]; g_assert (self != NULL); for (;;) { gboolean is_last; - gssize n_read; + ssize_t n_read; again: n_read = read (fd, data, sizeof data); @@ -1524,18 +1525,18 @@ sysprof_capture_writer_set_flush_delay (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_allocation (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 tid, + int64_t time, + int cpu, + int32_t pid, + int32_t tid, SysprofCaptureAddress alloc_addr, - gint64 alloc_size, + int64_t alloc_size, SysprofBacktraceFunc backtrace_func, - gpointer backtrace_data) + void *backtrace_data) { SysprofCaptureAllocation *ev; - gsize len; - guint n_addrs; + size_t len; + unsigned int n_addrs; g_assert (self != NULL); g_assert (backtrace_func != NULL); @@ -1565,7 +1566,7 @@ sysprof_capture_writer_add_allocation (SysprofCaptureWriter *self, if (ev->n_addrs < MAX_UNWIND_DEPTH) { - gsize diff = (sizeof (SysprofCaptureAddress) * (MAX_UNWIND_DEPTH - ev->n_addrs)); + size_t diff = (sizeof (SysprofCaptureAddress) * (MAX_UNWIND_DEPTH - ev->n_addrs)); ev->frame.len -= diff; self->pos -= diff; @@ -1578,17 +1579,17 @@ sysprof_capture_writer_add_allocation (SysprofCaptureWriter *self, gboolean sysprof_capture_writer_add_allocation_copy (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 tid, + int64_t time, + int cpu, + int32_t pid, + int32_t tid, SysprofCaptureAddress alloc_addr, - gint64 alloc_size, + int64_t alloc_size, const SysprofCaptureAddress *addrs, - guint n_addrs) + unsigned int n_addrs) { SysprofCaptureAllocation *ev; - gsize len; + size_t len; g_assert (self != NULL); @@ -1624,8 +1625,8 @@ gboolean _sysprof_capture_writer_add_raw (SysprofCaptureWriter *self, const SysprofCaptureFrame *fr) { - gpointer begin; - gsize len; + void *begin; + size_t len; g_assert (self != NULL); g_assert ((fr->len & 0x7) == 0); diff --git a/src/libsysprof-capture/sysprof-capture-writer.h b/src/libsysprof-capture/sysprof-capture-writer.h index 409e88b4..a20bb822 100644 --- a/src/libsysprof-capture/sysprof-capture-writer.h +++ b/src/libsysprof-capture/sysprof-capture-writer.h @@ -56,6 +56,9 @@ #pragma once +#include +#include + #include "sysprof-capture-types.h" #include "sysprof-version-macros.h" @@ -72,20 +75,20 @@ typedef struct _SysprofCaptureWriter SysprofCaptureWriter; * * Returns: the number of addresses filled in @addrs */ -typedef gint (*SysprofBacktraceFunc) (SysprofCaptureAddress *addrs, - guint n_addrs, - gpointer user_data); +typedef int (*SysprofBacktraceFunc) (SysprofCaptureAddress *addrs, + unsigned int n_addrs, + void *user_data); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureWriter *sysprof_capture_writer_new_from_env (gsize buffer_size); +SysprofCaptureWriter *sysprof_capture_writer_new_from_env (size_t buffer_size); SYSPROF_AVAILABLE_IN_ALL -SysprofCaptureWriter *sysprof_capture_writer_new (const gchar *filename, - gsize buffer_size); +SysprofCaptureWriter *sysprof_capture_writer_new (const char *filename, + size_t buffer_size); SYSPROF_AVAILABLE_IN_ALL SysprofCaptureWriter *sysprof_capture_writer_new_from_fd (int fd, - gsize buffer_size); + size_t buffer_size); SYSPROF_AVAILABLE_IN_ALL -gsize sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self); +size_t sysprof_capture_writer_get_buffer_size (SysprofCaptureWriter *self); SYSPROF_AVAILABLE_IN_ALL SysprofCaptureWriter *sysprof_capture_writer_ref (SysprofCaptureWriter *self); SYSPROF_AVAILABLE_IN_ALL @@ -96,135 +99,135 @@ void sysprof_capture_writer_stat (Sy SYSPROF_AVAILABLE_IN_ALL void sysprof_capture_writer_set_flush_delay (SysprofCaptureWriter *self, GMainContext *main_context, - guint timeout_seconds); + unsigned int timeout_seconds); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_file (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *path, + int64_t time, + int cpu, + int32_t pid, + const char *path, gboolean is_last, - const guint8 *data, - gsize data_len); + const uint8_t *data, + size_t data_len); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_file_fd (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *path, - gint fd); + int64_t time, + int cpu, + int32_t pid, + const char *path, + int fd); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_map (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - guint64 start, - guint64 end, - guint64 offset, - guint64 inode, - const gchar *filename); + int64_t time, + int cpu, + int32_t pid, + uint64_t start, + uint64_t end, + uint64_t offset, + uint64_t inode, + const char *filename); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_mark (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - guint64 duration, - const gchar *group, - const gchar *name, - const gchar *message); + int64_t time, + int cpu, + int32_t pid, + uint64_t duration, + const char *group, + const char *name, + const char *message); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_metadata (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *id, - const gchar *metadata, - gssize metadata_len); + int64_t time, + int cpu, + int32_t pid, + const char *id, + const char *metadata, + ssize_t metadata_len); SYSPROF_AVAILABLE_IN_ALL -guint64 sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self, - const gchar *name); +uint64_t sysprof_capture_writer_add_jitmap (SysprofCaptureWriter *self, + const char *name); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_process (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const gchar *cmdline); + int64_t time, + int cpu, + int32_t pid, + const char *cmdline); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_sample (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 tid, + int64_t time, + int cpu, + int32_t pid, + int32_t tid, const SysprofCaptureAddress *addrs, - guint n_addrs); + unsigned int n_addrs); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_fork (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 child_pid); + int64_t time, + int cpu, + int32_t pid, + int32_t child_pid); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_exit (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid); + int64_t time, + int cpu, + int32_t pid); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_timestamp (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid); + int64_t time, + int cpu, + int32_t pid); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_define_counters (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, + int64_t time, + int cpu, + int32_t pid, const SysprofCaptureCounter *counters, - guint n_counters); + unsigned int n_counters); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_set_counters (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - const guint *counters_ids, + int64_t time, + int cpu, + int32_t pid, + const unsigned int *counters_ids, const SysprofCaptureCounterValue *values, - guint n_counters); + unsigned int n_counters); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_add_log (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - GLogLevelFlags severity, - const gchar *domain, - const gchar *message); + int64_t time, + int cpu, + int32_t pid, + int severity, + const char *domain, + const char *message); SYSPROF_AVAILABLE_IN_3_36 gboolean sysprof_capture_writer_add_allocation (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 tid, + int64_t time, + int cpu, + int32_t pid, + int32_t tid, SysprofCaptureAddress alloc_addr, - gint64 alloc_size, + int64_t alloc_size, SysprofBacktraceFunc backtrace_func, - gpointer backtrace_data); + void *backtrace_data); SYSPROF_AVAILABLE_IN_3_36 gboolean sysprof_capture_writer_add_allocation_copy (SysprofCaptureWriter *self, - gint64 time, - gint cpu, - gint32 pid, - gint32 tid, + int64_t time, + int cpu, + int32_t pid, + int32_t tid, SysprofCaptureAddress alloc_addr, - gint64 alloc_size, + int64_t alloc_size, const SysprofCaptureAddress *addrs, - guint n_addrs); + unsigned int n_addrs); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_flush (SysprofCaptureWriter *self); SYSPROF_AVAILABLE_IN_ALL gboolean sysprof_capture_writer_save_as (SysprofCaptureWriter *self, - const gchar *filename, + const char *filename, GError **error); SYSPROF_AVAILABLE_IN_ALL -guint sysprof_capture_writer_request_counter (SysprofCaptureWriter *self, - guint n_counters); +unsigned int sysprof_capture_writer_request_counter (SysprofCaptureWriter *self, + unsigned int n_counters); SYSPROF_AVAILABLE_IN_ALL SysprofCaptureReader *sysprof_capture_writer_create_reader (SysprofCaptureWriter *self, GError **error); @@ -245,8 +248,8 @@ gboolean _sysprof_capture_writer_splice_from_fd (Sy GError **error) G_GNUC_INTERNAL; G_GNUC_INTERNAL gboolean _sysprof_capture_writer_set_time_range (SysprofCaptureWriter *self, - gint64 start_time, - gint64 end_time) G_GNUC_INTERNAL; + int64_t start_time, + int64_t end_time) G_GNUC_INTERNAL; G_END_DECLS diff --git a/src/libsysprof-capture/sysprof-clock.c b/src/libsysprof-capture/sysprof-clock.c index 066605c3..f517deea 100644 --- a/src/libsysprof-capture/sysprof-clock.c +++ b/src/libsysprof-capture/sysprof-clock.c @@ -60,12 +60,12 @@ #include "sysprof-clock.h" -gint sysprof_clock = -1; +int sysprof_clock = -1; void sysprof_clock_init (void) { - static const gint clock_ids[] = { + static const int clock_ids[] = { CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW, #ifdef __linux__ @@ -78,7 +78,7 @@ sysprof_clock_init (void) if (sysprof_clock != -1) return; - for (guint i = 0; i < G_N_ELEMENTS (clock_ids); i++) + for (unsigned int i = 0; i < G_N_ELEMENTS (clock_ids); i++) { struct timespec ts; int clock_id = clock_ids [i]; diff --git a/src/libsysprof-capture/sysprof-clock.h b/src/libsysprof-capture/sysprof-clock.h index ac101a33..fba81a4f 100644 --- a/src/libsysprof-capture/sysprof-clock.h +++ b/src/libsysprof-capture/sysprof-clock.h @@ -57,15 +57,16 @@ #pragma once #include +#include #include #include "sysprof-version-macros.h" G_BEGIN_DECLS -typedef gint SysprofClock; -typedef gint64 SysprofTimeStamp; -typedef gint32 SysprofTimeSysprofan; +typedef int SysprofClock; +typedef int64_t SysprofTimeStamp; +typedef int32_t SysprofTimeSysprofan; #define SYSPROF_NSEC_PER_SEC G_GINT64_CONSTANT(1000000000) diff --git a/src/libsysprof-capture/sysprof-collector.c b/src/libsysprof-capture/sysprof-collector.c index 064586de..29e74318 100644 --- a/src/libsysprof-capture/sysprof-collector.c +++ b/src/libsysprof-capture/sysprof-collector.c @@ -87,10 +87,10 @@ typedef struct int pid; } SysprofCollector; -#define COLLECTOR_INVALID ((gpointer)&invalid) +#define COLLECTOR_INVALID ((void *)&invalid) static MappedRingBuffer *request_writer (void); -static void sysprof_collector_free (gpointer data); +static void sysprof_collector_free (void *data); static const SysprofCollector *sysprof_collector_get (void); static G_LOCK_DEFINE (control_fd); @@ -115,8 +115,8 @@ _do_getcpu (void) #endif } -static inline gsize -realign (gsize size) +static inline size_t +realign (size_t size) { return (size + SYSPROF_CAPTURE_ALIGN - 1) & ~(SYSPROF_CAPTURE_ALIGN - 1); } @@ -129,7 +129,7 @@ request_writer (void) if (conn == NULL) { - const gchar *fdstr = g_getenv ("SYSPROF_CONTROL_FD"); + const char *fdstr = g_getenv ("SYSPROF_CONTROL_FD"); int peer_fd = -1; if (fdstr != NULL) @@ -166,7 +166,7 @@ request_writer (void) if (g_output_stream_write_all (G_OUTPUT_STREAM (out_stream), CREATRING, CREATRING_LEN, &len, NULL, NULL) && len == CREATRING_LEN) { - gint ring_fd = g_unix_connection_receive_fd (conn, NULL, NULL); + int ring_fd = g_unix_connection_receive_fd (conn, NULL, NULL); if (ring_fd > -1) { @@ -198,7 +198,7 @@ write_final_frame (MappedRingBuffer *ring) } static void -sysprof_collector_free (gpointer data) +sysprof_collector_free (void *data) { SysprofCollector *collector = data; @@ -263,7 +263,7 @@ sysprof_collector_get (void) void sysprof_collector_init (void) { - static gsize once_init; + static size_t once_init; if (g_once_init_enter (&once_init)) { @@ -293,19 +293,19 @@ sysprof_collector_init (void) void sysprof_collector_allocate (SysprofCaptureAddress alloc_addr, - gint64 alloc_size, + int64_t alloc_size, SysprofBacktraceFunc backtrace_func, - gpointer backtrace_data) + void *backtrace_data) { COLLECTOR_BEGIN { SysprofCaptureAllocation *ev; - gsize len; + size_t len; len = sizeof *ev + (sizeof (SysprofCaptureAllocation) * MAX_UNWIND_DEPTH); if ((ev = mapped_ring_buffer_allocate (collector->buffer, len))) { - gint n_addrs; + int n_addrs; /* First take a backtrace, so that backtrace_func() can overwrite * a little bit of data *BEFORE* ev->addrs as stratch space. This @@ -338,18 +338,18 @@ sysprof_collector_allocate (SysprofCaptureAddress alloc_addr, } void -sysprof_collector_sample (SysprofBacktraceFunc backtrace_func, - gpointer backtrace_data) +sysprof_collector_sample (SysprofBacktraceFunc backtrace_func, + void *backtrace_data) { COLLECTOR_BEGIN { SysprofCaptureSample *ev; - gsize len; + size_t len; len = sizeof *ev + (sizeof (SysprofCaptureSample) * MAX_UNWIND_DEPTH); if ((ev = mapped_ring_buffer_allocate (collector->buffer, len))) { - gint n_addrs; + int n_addrs; /* See comment from sysprof_collector_allocate(). */ if (backtrace_func) @@ -373,16 +373,16 @@ sysprof_collector_sample (SysprofBacktraceFunc backtrace_func, } void -sysprof_collector_mark (gint64 time, - gint64 duration, - const gchar *group, - const gchar *mark, - const gchar *message) +sysprof_collector_mark (int64_t time, + int64_t duration, + const char *group, + const char *mark, + const char *message) { COLLECTOR_BEGIN { SysprofCaptureMark *ev; - gsize len; - gsize sl; + size_t len; + size_t sl; if (group == NULL) group = ""; @@ -416,14 +416,14 @@ sysprof_collector_mark (gint64 time, } void -sysprof_collector_log (GLogLevelFlags severity, - const gchar *domain, - const gchar *message) +sysprof_collector_log (int severity, + const char *domain, + const char *message) { COLLECTOR_BEGIN { SysprofCaptureLog *ev; - gsize len; - gsize sl; + size_t len; + size_t sl; if (domain == NULL) domain = ""; @@ -455,17 +455,17 @@ sysprof_collector_log (GLogLevelFlags severity, } void -sysprof_collector_log_printf (GLogLevelFlags severity, - const gchar *domain, - const gchar *format, +sysprof_collector_log_printf (int severity, + const char *domain, + const char *format, ...) { COLLECTOR_BEGIN { - g_autofree gchar *formatted = NULL; + g_autofree char *formatted = NULL; SysprofCaptureLog *ev; va_list args; - gsize len; - gsize sl; + size_t len; + size_t sl; va_start (args, format); formatted = g_strdup_vprintf (format, args); diff --git a/src/libsysprof-capture/sysprof-collector.h b/src/libsysprof-capture/sysprof-collector.h index f234bc2f..c7ff9a63 100644 --- a/src/libsysprof-capture/sysprof-collector.h +++ b/src/libsysprof-capture/sysprof-collector.h @@ -64,26 +64,26 @@ SYSPROF_AVAILABLE_IN_3_36 void sysprof_collector_init (void); SYSPROF_AVAILABLE_IN_3_36 void sysprof_collector_allocate (SysprofCaptureAddress alloc_addr, - gint64 alloc_size, + int64_t alloc_size, SysprofBacktraceFunc backtrace_func, - gpointer backtrace_data); + void *backtrace_data); SYSPROF_AVAILABLE_IN_3_36 void sysprof_collector_sample (SysprofBacktraceFunc backtrace_func, - gpointer backtrace_data); + void *backtrace_data); SYSPROF_AVAILABLE_IN_3_36 -void sysprof_collector_mark (gint64 time, - gint64 duration, - const gchar *group, - const gchar *mark, - const gchar *message); +void sysprof_collector_mark (int64_t time, + int64_t duration, + const char *group, + const char *mark, + const char *message); SYSPROF_AVAILABLE_IN_3_36 -void sysprof_collector_log (GLogLevelFlags severity, - const gchar *domain, - const gchar *message); +void sysprof_collector_log (int severity, + const char *domain, + const char *message); SYSPROF_AVAILABLE_IN_3_38 -void sysprof_collector_log_printf (GLogLevelFlags severity, - const gchar *domain, - const gchar *format, +void sysprof_collector_log_printf (int severity, + const char *domain, + const char *format, ...) G_GNUC_PRINTF (3, 4); G_END_DECLS diff --git a/src/libsysprof-capture/sysprof-platform.c b/src/libsysprof-capture/sysprof-platform.c index 99c9a55c..51464d19 100644 --- a/src/libsysprof-capture/sysprof-platform.c +++ b/src/libsysprof-capture/sysprof-platform.c @@ -77,7 +77,7 @@ * Returns: An fd if successful; otherwise -1 and errno is set. */ int -sysprof_memfd_create (const gchar *name) +sysprof_memfd_create (const char *name) { #ifdef __NR_memfd_create if (name == NULL) @@ -116,7 +116,7 @@ sysprof_memfd_create (const gchar *name) * * Since: 3.36 */ -gsize +size_t sysprof_getpagesize (void) { return _sysprof_getpagesize (); diff --git a/src/libsysprof-capture/sysprof-platform.h b/src/libsysprof-capture/sysprof-platform.h index 6dbe4ff2..3f0b3768 100644 --- a/src/libsysprof-capture/sysprof-platform.h +++ b/src/libsysprof-capture/sysprof-platform.h @@ -56,13 +56,16 @@ #pragma once +#include +#include + #include "sysprof-version-macros.h" G_BEGIN_DECLS SYSPROF_AVAILABLE_IN_ALL -int sysprof_memfd_create (const gchar *desc); +int sysprof_memfd_create (const char *desc); SYSPROF_AVAILABLE_IN_3_36 -gsize sysprof_getpagesize (void); +size_t sysprof_getpagesize (void); G_END_DECLS