Commit 209b342e authored by Christian Hergert's avatar Christian Hergert

capture: switch to portability helpers

This switches over to using the portability helpers that may
be needed on some platforms other than Linux. On Linux, however,
they are just macros to the standard implementation provided
by (g)libc.
parent ac1767ef
......@@ -55,7 +55,7 @@ sp_capture_reader_read_file_header (SpCaptureReader *self,
g_assert (self != NULL);
g_assert (header != NULL);
if (sizeof *header != pread (self->fd, header, sizeof *header, 0L))
if (sizeof *header != _sp_pread (self->fd, header, sizeof *header, 0L))
{
g_set_error (error,
G_FILE_ERROR,
......@@ -254,10 +254,10 @@ sp_capture_reader_ensure_space_for (SpCaptureReader *self,
g_assert (self->len < self->bufsz);
/* Read into our buffer after our current read position */
r = pread (self->fd,
&self->buf[self->len],
self->bufsz - self->len,
self->fd_off);
r = _sp_pread (self->fd,
&self->buf[self->len],
self->bufsz - self->len,
self->fd_off);
if (r <= 0)
break;
......
......@@ -32,7 +32,7 @@
#include "capture/sp-capture-util-private.h"
#include "capture/sp-capture-writer.h"
#define DEFAULT_BUFFER_SIZE (getpagesize() * 64L)
#define DEFAULT_BUFFER_SIZE (_sp_getpagesize() * 64L)
#define INVALID_ADDRESS (G_GUINT64_CONSTANT(0))
#define MAX_COUNTERS ((1 << 24) - 1)
......@@ -170,7 +170,7 @@ sp_capture_writer_flush_data (SpCaptureWriter *self)
while (to_write > 0)
{
written = write (self->fd, buf, to_write);
written = _sp_write (self->fd, buf, to_write);
if (written < 0)
return FALSE;
......@@ -261,10 +261,10 @@ sp_capture_writer_flush_jitmap (SpCaptureWriter *self)
SP_CAPTURE_FRAME_JITMAP);
jitmap.n_jitmaps = self->addr_hash_size;
if (sizeof jitmap != write (self->fd, &jitmap, sizeof jitmap))
if (sizeof jitmap != _sp_write (self->fd, &jitmap, sizeof jitmap))
return FALSE;
r = write (self->fd, self->addr_buf, len - sizeof jitmap);
r = _sp_write (self->fd, self->addr_buf, len - sizeof jitmap);
if (r < 0 || (gsize)r != (len - sizeof jitmap))
return FALSE;
......@@ -419,7 +419,7 @@ sp_capture_writer_new_from_fd (int fd,
buffer_size = DEFAULT_BUFFER_SIZE;
g_assert (fd != -1);
g_assert (buffer_size % getpagesize() == 0);
g_assert (buffer_size % _sp_getpagesize() == 0);
if (ftruncate (fd, 0) != 0)
return NULL;
......@@ -463,7 +463,7 @@ sp_capture_writer_new_from_fd (int fd,
g_assert (self->pos == 0);
g_assert (self->len > 0);
g_assert (self->len % getpagesize() == 0);
g_assert (self->len % _sp_getpagesize() == 0);
g_assert (self->buf != NULL);
g_assert (self->addr_hash_size == 0);
g_assert (self->fd != -1);
......@@ -479,7 +479,7 @@ sp_capture_writer_new (const gchar *filename,
int fd;
g_assert (filename != NULL);
g_assert (buffer_size % getpagesize() == 0);
g_assert (buffer_size % _sp_getpagesize() == 0);
if ((-1 == (fd = open (filename, O_CREAT | O_RDWR, 0640))) ||
(-1 == ftruncate (fd, 0L)))
......@@ -765,10 +765,10 @@ sp_capture_writer_flush_end_time (SpCaptureWriter *self)
/* This field is opportunistic, so a failure is okay. */
again:
ret = pwrite (self->fd,
&end_time,
sizeof (end_time),
G_STRUCT_OFFSET (SpCaptureFileHeader, end_time));
ret = _sp_pwrite (self->fd,
&end_time,
sizeof (end_time),
G_STRUCT_OFFSET (SpCaptureFileHeader, end_time));
if (ret < 0 && errno == EAGAIN)
goto again;
......@@ -1202,19 +1202,19 @@ _sp_capture_writer_set_time_range (SpCaptureWriter *self,
g_assert (self != NULL);
do_start:
ret = pwrite (self->fd,
&start_time,
sizeof (start_time),
G_STRUCT_OFFSET (SpCaptureFileHeader, time));
ret = _sp_pwrite (self->fd,
&start_time,
sizeof (start_time),
G_STRUCT_OFFSET (SpCaptureFileHeader, time));
if (ret < 0 && errno == EAGAIN)
goto do_start;
do_end:
ret = pwrite (self->fd,
&end_time,
sizeof (end_time),
G_STRUCT_OFFSET (SpCaptureFileHeader, end_time));
ret = _sp_pwrite (self->fd,
&end_time,
sizeof (end_time),
G_STRUCT_OFFSET (SpCaptureFileHeader, end_time));
if (ret < 0 && errno == EAGAIN)
goto do_end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment