diff --git a/meson.build b/meson.build
index 92c4049db..72e1783da 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 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);
 
