[gdk-pixbuf] tests: Fix read-only to mutable on FreeBSD
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] tests: Fix read-only to mutable on FreeBSD
- Date: Thu, 5 Oct 2017 15:42:32 +0000 (UTC)
commit f133b06fb34d90c4e9d047ee8a6ef468063afe11
Author: BenoƮt Dejean <bdejean gmail com>
Date: Wed Sep 20 17:36:00 2017 +0000
tests: Fix read-only to mutable on FreeBSD
https://bugzilla.gnome.org/show_bug.cgi?id=786306
meson.build | 2 +-
tests/pixbuf-readonly-to-mutable.c | 14 +++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/meson.build b/meson.build
index 92c4049..72e1783 100644
--- a/meson.build
+++ b/meson.build
@@ -8,7 +8,7 @@ project('gdk-pixbuf', 'c',
],
meson_version: '>= 0.40.1')
-add_project_arguments([ '-D_POSIX_C_SOURCE', '-D_DEFAULT_SOURCE' ], language: 'c')
+add_project_arguments([ '-D_POSIX_C_SOURCE=200809L', '-D_DEFAULT_SOURCE', '-D_XOPEN_SOURCE' ], language: 'c')
cc = meson.get_compiler('c')
host_system = host_machine.system()
diff --git a/tests/pixbuf-readonly-to-mutable.c b/tests/pixbuf-readonly-to-mutable.c
index c47de7a..7b88458 100644
--- a/tests/pixbuf-readonly-to-mutable.c
+++ b/tests/pixbuf-readonly-to-mutable.c
@@ -22,17 +22,13 @@
#include <string.h>
#ifdef G_OS_UNIX
+#include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
#endif
#ifdef G_OS_UNIX
-/* see https://bugzilla.gnome.org/show_bug.cgi?id=741933 */
-#ifndef MAP_ANONYMOUS
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-
typedef struct {
void *buf;
gsize len;
@@ -67,9 +63,10 @@ get_readonly_pixbuf (void)
int pagesize;
int pages;
int r;
+ int zero_fd;
gsize pixlen;
- pagesize = sysconf (_SC_PAGE_SIZE);
+ pagesize = sysconf (_SC_PAGESIZE);
g_assert_cmpint (pagesize, >, 0);
pixlen = gdk_pixbuf_get_byte_length (reference);
@@ -77,8 +74,11 @@ get_readonly_pixbuf (void)
buf = g_new0 (MappedBuf, 1);
buf->len = pages * pagesize;
- buf->buf = mmap (NULL, buf->len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ zero_fd = open("/dev/zero", O_RDWR);
+ g_assert(zero_fd != -1);
+ buf->buf = mmap (NULL, buf->len, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0);
g_assert (buf->buf != NULL);
+ close(zero_fd);
memcpy (buf->buf, gdk_pixbuf_get_pixels (reference), pixlen);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]