mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-analyze: rename some private API
prefix with _, use frame type directly, use needs_swap rather than is_native so it's more clear to readers.
This commit is contained in:
@ -31,8 +31,8 @@ struct _SysprofDocumentFrameClass
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
SysprofDocumentFrame *sysprof_document_frame_new (GMappedFile *mapped,
|
||||
gconstpointer data,
|
||||
gboolean is_native);
|
||||
SysprofDocumentFrame *_sysprof_document_frame_new (GMappedFile *mapped,
|
||||
const SysprofCaptureFrame *frame,
|
||||
gboolean needs_swap);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@ -26,7 +26,7 @@ typedef struct _SysprofDocumentFramePrivate
|
||||
{
|
||||
GMappedFile *mapped_file;
|
||||
const SysprofCaptureFrame *frame;
|
||||
guint is_native : 1;
|
||||
guint needs_swap : 1;
|
||||
} SysprofDocumentFramePrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (SysprofDocumentFrame, sysprof_document_frame, G_TYPE_OBJECT)
|
||||
@ -50,7 +50,7 @@ sysprof_document_frame_finalize (GObject *object)
|
||||
g_clear_pointer (&priv->mapped_file, g_mapped_file_unref);
|
||||
|
||||
priv->frame = NULL;
|
||||
priv->is_native = 0;
|
||||
priv->needs_swap = 0;
|
||||
|
||||
G_OBJECT_CLASS (sysprof_document_frame_parent_class)->finalize (object);
|
||||
}
|
||||
@ -120,9 +120,9 @@ sysprof_document_frame_init (SysprofDocumentFrame *self)
|
||||
}
|
||||
|
||||
SysprofDocumentFrame *
|
||||
sysprof_document_frame_new (GMappedFile *mapped_file,
|
||||
gconstpointer data,
|
||||
gboolean is_native)
|
||||
_sysprof_document_frame_new (GMappedFile *mapped_file,
|
||||
const SysprofCaptureFrame *frame,
|
||||
gboolean needs_swap)
|
||||
{
|
||||
SysprofDocumentFrame *self;
|
||||
SysprofDocumentFramePrivate *priv;
|
||||
@ -131,8 +131,8 @@ sysprof_document_frame_new (GMappedFile *mapped_file,
|
||||
|
||||
priv = sysprof_document_frame_get_instance_private (self);
|
||||
priv->mapped_file = g_mapped_file_ref (mapped_file);
|
||||
priv->frame = data;
|
||||
priv->is_native = !!is_native;
|
||||
priv->frame = frame;
|
||||
priv->needs_swap = !!needs_swap;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -145,7 +145,7 @@ sysprof_document_frame_get_cpu (SysprofDocumentFrame *self)
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FRAME (self), 0);
|
||||
|
||||
if G_LIKELY (priv->is_native)
|
||||
if G_LIKELY (priv->needs_swap)
|
||||
ret = priv->frame->cpu;
|
||||
else
|
||||
ret = GUINT32_SWAP_LE_BE (priv->frame->cpu);
|
||||
@ -161,7 +161,7 @@ sysprof_document_frame_get_pid (SysprofDocumentFrame *self)
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FRAME (self), 0);
|
||||
|
||||
if G_LIKELY (priv->is_native)
|
||||
if G_LIKELY (priv->needs_swap)
|
||||
ret = priv->frame->pid;
|
||||
else
|
||||
ret = GUINT32_SWAP_LE_BE (priv->frame->pid);
|
||||
@ -177,7 +177,7 @@ sysprof_document_frame_get_time (SysprofDocumentFrame *self)
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_DOCUMENT_FRAME (self), 0);
|
||||
|
||||
if G_LIKELY (priv->is_native)
|
||||
if G_LIKELY (priv->needs_swap)
|
||||
ret = priv->frame->time;
|
||||
else
|
||||
ret = GUINT32_SWAP_LE_BE (priv->frame->time);
|
||||
|
||||
@ -33,7 +33,7 @@ struct _SysprofDocument
|
||||
GPtrArray *frames;
|
||||
GMappedFile *mapped_file;
|
||||
SysprofCaptureFileHeader header;
|
||||
guint is_native : 1;
|
||||
guint needs_swap : 1;
|
||||
};
|
||||
|
||||
static GType
|
||||
@ -57,9 +57,9 @@ sysprof_document_get_item (GListModel *model,
|
||||
if (position >= self->frames->len)
|
||||
return NULL;
|
||||
|
||||
return sysprof_document_frame_new (self->mapped_file,
|
||||
g_ptr_array_index (self->frames, position),
|
||||
self->is_native);
|
||||
return _sysprof_document_frame_new (self->mapped_file,
|
||||
g_ptr_array_index (self->frames, position),
|
||||
self->needs_swap);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -121,12 +121,12 @@ sysprof_document_load (SysprofDocument *self,
|
||||
/* Keep a copy of our header */
|
||||
memcpy (&self->header, data, sizeof self->header);
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
self->is_native = !!self->header.little_endian;
|
||||
self->needs_swap = !self->header.little_endian;
|
||||
#else
|
||||
self->is_native = !self->header.little_endian;
|
||||
self->needs_swap = !!self->header.little_endian;
|
||||
#endif
|
||||
|
||||
if (!self->is_native)
|
||||
if (self->needs_swap)
|
||||
{
|
||||
self->header.time = GUINT64_SWAP_LE_BE (self->header.time);
|
||||
self->header.end_time = GUINT64_SWAP_LE_BE (self->header.end_time);
|
||||
@ -138,8 +138,8 @@ sysprof_document_load (SysprofDocument *self,
|
||||
guint16 frame_len;
|
||||
|
||||
memcpy (&frame_len, &data[pos], sizeof frame_len);
|
||||
if (!self->is_native)
|
||||
frame_len = GUINT16_SWAP_LE_BE (self->is_native);
|
||||
if (self->needs_swap)
|
||||
frame_len = GUINT16_SWAP_LE_BE (frame_len);
|
||||
|
||||
if (frame_len < sizeof (SysprofCaptureFrame))
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user