summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoƮt Dejean <bdejean@gmail.com>2017-09-20 17:36:00 +0000
committerBastien Nocera <hadess@hadess.net>2017-10-05 17:40:41 +0200
commitf133b06fb34d90c4e9d047ee8a6ef468063afe11 (patch)
treea43727ece00398ef5d03d189c9f53f6994eedf3c /tests
parent13d75f2fc45b1595eb29db644d4157160fecbabd (diff)
downloadgdk-pixbuf-f133b06fb34d90c4e9d047ee8a6ef468063afe11.tar.gz
tests: Fix read-only to mutable on FreeBSD
https://bugzilla.gnome.org/show_bug.cgi?id=786306
Diffstat (limited to 'tests')
-rw-r--r--tests/pixbuf-readonly-to-mutable.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/pixbuf-readonly-to-mutable.c b/tests/pixbuf-readonly-to-mutable.c
index c47de7a3a..7b88458cd 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);