From d9d572b55716bcf721291e6a94a0209378e2280a Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 8 May 2019 10:12:36 -0700 Subject: [PATCH] libsysprof-capture: add availability macros --- src/libsysprof-capture/sp-capture-condition.h | 10 ++++++ src/libsysprof-capture/sp-capture-cursor.h | 9 +++++ src/libsysprof-capture/sp-capture-reader.h | 35 ++++++++++++++----- .../sp-capture-util-private.h | 1 + src/libsysprof-capture/sp-capture-writer.h | 33 ++++++++++++----- src/libsysprof-capture/sp-platform.h | 3 +- 6 files changed, 74 insertions(+), 17 deletions(-) diff --git a/src/libsysprof-capture/sp-capture-condition.h b/src/libsysprof-capture/sp-capture-condition.h index 0c29add1..2ac46ec3 100644 --- a/src/libsysprof-capture/sp-capture-condition.h +++ b/src/libsysprof-capture/sp-capture-condition.h @@ -21,22 +21,32 @@ #pragma once #include "sp-capture-types.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS +SYSPROF_AVAILABLE_IN_ALL SpCaptureCondition *sp_capture_condition_copy (const SpCaptureCondition *self); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_condition_unref (SpCaptureCondition *self); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCondition *sp_capture_condition_ref (SpCaptureCondition *self); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCondition *sp_capture_condition_new_and (SpCaptureCondition *left, SpCaptureCondition *right); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCondition *sp_capture_condition_new_where_type_in (guint n_types, const SpCaptureFrameType *types); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCondition *sp_capture_condition_new_where_time_between (gint64 begin_time, gint64 end_time); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCondition *sp_capture_condition_new_where_pid_in (guint n_pids, const gint32 *pids); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCondition *sp_capture_condition_new_where_counter_in (guint n_counters, const guint *counters); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_condition_match (const SpCaptureCondition *self, const SpCaptureFrame *frame); diff --git a/src/libsysprof-capture/sp-capture-cursor.h b/src/libsysprof-capture/sp-capture-cursor.h index 1a881825..51cc5323 100644 --- a/src/libsysprof-capture/sp-capture-cursor.h +++ b/src/libsysprof-capture/sp-capture-cursor.h @@ -21,6 +21,7 @@ #pragma once #include "sp-capture-types.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS @@ -40,15 +41,23 @@ typedef struct _SpCaptureCursor SpCaptureCursor; typedef gboolean (*SpCaptureCursorCallback) (const SpCaptureFrame *frame, gpointer user_data); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCursor *sp_capture_cursor_new (SpCaptureReader *reader); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_cursor_unref (SpCaptureCursor *self); +SYSPROF_AVAILABLE_IN_ALL SpCaptureCursor *sp_capture_cursor_ref (SpCaptureCursor *self); +SYSPROF_AVAILABLE_IN_ALL SpCaptureReader *sp_capture_cursor_get_reader (SpCaptureCursor *self); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_cursor_foreach (SpCaptureCursor *self, SpCaptureCursorCallback callback, gpointer user_data); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_cursor_reset (SpCaptureCursor *self); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_cursor_reverse (SpCaptureCursor *self); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_cursor_add_condition (SpCaptureCursor *self, SpCaptureCondition *condition); diff --git a/src/libsysprof-capture/sp-capture-reader.h b/src/libsysprof-capture/sp-capture-reader.h index 656fe644..04d95975 100644 --- a/src/libsysprof-capture/sp-capture-reader.h +++ b/src/libsysprof-capture/sp-capture-reader.h @@ -21,52 +21,71 @@ #pragma once #include "sp-capture-types.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS typedef struct _SpCaptureReader SpCaptureReader; +SYSPROF_AVAILABLE_IN_ALL SpCaptureReader *sp_capture_reader_new (const gchar *filename, GError **error); +SYSPROF_AVAILABLE_IN_ALL SpCaptureReader *sp_capture_reader_new_from_fd (int fd, GError **error); +SYSPROF_AVAILABLE_IN_ALL SpCaptureReader *sp_capture_reader_copy (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL SpCaptureReader *sp_capture_reader_ref (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_reader_unref (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const gchar *sp_capture_reader_get_filename (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const gchar *sp_capture_reader_get_time (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL gint64 sp_capture_reader_get_start_time (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL gint64 sp_capture_reader_get_end_time (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_reader_skip (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_reader_peek_type (SpCaptureReader *self, SpCaptureFrameType *type); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_reader_peek_frame (SpCaptureReader *self, SpCaptureFrame *frame); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureMap *sp_capture_reader_read_map (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureMark *sp_capture_reader_read_mark (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureExit *sp_capture_reader_read_exit (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureFork *sp_capture_reader_read_fork (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureTimestamp *sp_capture_reader_read_timestamp (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureProcess *sp_capture_reader_read_process (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureSample *sp_capture_reader_read_sample (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL GHashTable *sp_capture_reader_read_jitmap (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureFrameCounterDefine *sp_capture_reader_read_counter_define (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL const SpCaptureFrameCounterSet *sp_capture_reader_read_counter_set (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_reader_reset (SpCaptureReader *self); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_reader_splice (SpCaptureReader *self, SpCaptureWriter *dest, GError **error); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_reader_save_as (SpCaptureReader *self, const gchar *filename, GError **error); -#ifdef SP_ENABLE_GOBJECT -# define SP_TYPE_CAPTURE_READER (sp_capture_reader_get_type()) - GType sp_capture_reader_get_type (void); -#endif - -#if GLIB_CHECK_VERSION(2, 44, 0) - G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureReader, sp_capture_reader_unref) -#endif +G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureReader, sp_capture_reader_unref) G_END_DECLS diff --git a/src/libsysprof-capture/sp-capture-util-private.h b/src/libsysprof-capture/sp-capture-util-private.h index f686cc9c..ab486d10 100644 --- a/src/libsysprof-capture/sp-capture-util-private.h +++ b/src/libsysprof-capture/sp-capture-util-private.h @@ -53,4 +53,5 @@ ssize_t _sp_sendfile (int out_fd, int in_fd, off_t *offset, size_t count); + #endif diff --git a/src/libsysprof-capture/sp-capture-writer.h b/src/libsysprof-capture/sp-capture-writer.h index 0b9e796c..1e84c05f 100644 --- a/src/libsysprof-capture/sp-capture-writer.h +++ b/src/libsysprof-capture/sp-capture-writer.h @@ -21,6 +21,7 @@ #pragma once #include "sp-capture-types.h" +#include "sysprof-version-macros.h" G_BEGIN_DECLS @@ -39,15 +40,22 @@ typedef struct gsize padding[48]; } SpCaptureStat; +SYSPROF_AVAILABLE_IN_ALL SpCaptureWriter *sp_capture_writer_new_from_env (gsize buffer_size); +SYSPROF_AVAILABLE_IN_ALL SpCaptureWriter *sp_capture_writer_new (const gchar *filename, gsize buffer_size); +SYSPROF_AVAILABLE_IN_ALL SpCaptureWriter *sp_capture_writer_new_from_fd (int fd, gsize buffer_size); +SYSPROF_AVAILABLE_IN_ALL SpCaptureWriter *sp_capture_writer_ref (SpCaptureWriter *self); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_writer_unref (SpCaptureWriter *self); +SYSPROF_AVAILABLE_IN_ALL void sp_capture_writer_stat (SpCaptureWriter *self, SpCaptureStat *stat); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_add_map (SpCaptureWriter *self, gint64 time, gint cpu, @@ -57,6 +65,7 @@ gboolean sp_capture_writer_add_map (SpCaptureWriter * guint64 offset, guint64 inode, const gchar *filename); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_add_mark (SpCaptureWriter *self, gint64 time, gint cpu, @@ -65,13 +74,16 @@ gboolean sp_capture_writer_add_mark (SpCaptureWriter * const gchar *group, const gchar *name, const gchar *message); +SYSPROF_AVAILABLE_IN_ALL guint64 sp_capture_writer_add_jitmap (SpCaptureWriter *self, const gchar *name); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_add_process (SpCaptureWriter *self, gint64 time, gint cpu, gint32 pid, const gchar *cmdline); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_add_sample (SpCaptureWriter *self, gint64 time, gint cpu, @@ -79,25 +91,30 @@ gboolean sp_capture_writer_add_sample (SpCaptureWriter * gint32 tid, const SpCaptureAddress *addrs, guint n_addrs); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_add_fork (SpCaptureWriter *self, gint64 time, gint cpu, gint32 pid, gint32 child_pid); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_add_exit (SpCaptureWriter *self, gint64 time, gint cpu, gint32 pid); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_add_timestamp (SpCaptureWriter *self, gint64 time, gint cpu, gint32 pid); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_define_counters (SpCaptureWriter *self, gint64 time, gint cpu, gint32 pid, const SpCaptureCounter *counters, guint n_counters); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_set_counters (SpCaptureWriter *self, gint64 time, gint cpu, @@ -105,31 +122,31 @@ gboolean sp_capture_writer_set_counters (SpCaptureWriter * const guint *counters_ids, const SpCaptureCounterValue *values, guint n_counters); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_flush (SpCaptureWriter *self); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_save_as (SpCaptureWriter *self, const gchar *filename, GError **error); +SYSPROF_AVAILABLE_IN_ALL guint sp_capture_writer_request_counter (SpCaptureWriter *self, guint n_counters); +SYSPROF_AVAILABLE_IN_ALL SpCaptureReader *sp_capture_writer_create_reader (SpCaptureWriter *self, GError **error); +SYSPROF_AVAILABLE_IN_ALL gboolean sp_capture_writer_splice (SpCaptureWriter *self, SpCaptureWriter *dest, GError **error); +G_GNUC_INTERNAL gboolean _sp_capture_writer_splice_from_fd (SpCaptureWriter *self, int fd, GError **error) G_GNUC_INTERNAL; +G_GNUC_INTERNAL gboolean _sp_capture_writer_set_time_range (SpCaptureWriter *self, gint64 start_time, gint64 end_time) G_GNUC_INTERNAL; -#ifdef SP_ENABLE_GOBJECT -# define SP_TYPE_CAPTURE_WRITER (sp_capture_writer_get_type()) - GType sp_capture_writer_get_type (void); -#endif - -#if GLIB_CHECK_VERSION(2, 44, 0) - G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureWriter, sp_capture_writer_unref) -#endif +G_DEFINE_AUTOPTR_CLEANUP_FUNC (SpCaptureWriter, sp_capture_writer_unref) G_END_DECLS diff --git a/src/libsysprof-capture/sp-platform.h b/src/libsysprof-capture/sp-platform.h index c5646272..06d845b1 100644 --- a/src/libsysprof-capture/sp-platform.h +++ b/src/libsysprof-capture/sp-platform.h @@ -20,10 +20,11 @@ #pragma once -#include +#include "sysprof-version-macros.h" G_BEGIN_DECLS +SYSPROF_AVAILABLE_IN_ALL int sp_memfd_create (const gchar *desc); G_END_DECLS