<commit_before>diff --git a/Xext/shm.c b/Xext/shm.c
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -33,8 +33,10 @@ in this Software without prior written authorization from The Open Group.
 #endif
 
 #include <sys/types.h>
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#endif
 #include <unistd.h>
 #include <sys/stat.h>
 #include <X11/X.h>
@@ -317,6 +319,7 @@ ProcShmQueryVersion(ClientPtr client)
 static int
 shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     int uid, gid;
     mode_t mask;
     int uidset = 0, gidset = 0;
@@ -374,11 +377,15 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
         mask |= S_IWOTH;
     }
     return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1;
+#else
+    return -1;
+#endif
 }
 
 static int
 ProcShmAttach(ClientPtr client)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     SHMSTAT_TYPE buf;
     ShmDescPtr shmdesc;
 
@@ -428,12 +435,16 @@ ProcShmAttach(ClientPtr client)
     if (!AddResource(stuff->shmseg, ShmSegType, (pointer) shmdesc))
         return BadAlloc;
     return Success;
+#else
+    return BadAlloc;
+#endif
 }
 
  /*ARGSUSED*/ static int
 ShmDetachSegment(pointer value, /* must conform to DeleteType */
                  XID shmseg)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     ShmDescPtr shmdesc = (ShmDescPtr) value;
     ShmDescPtr *prev;
 
@@ -443,6 +454,7 @@ ShmDetachSegment(pointer value, /* must conform to DeleteType */
     for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next);
     *prev = shmdesc->next;
     free(shmdesc);
+#endif
     return Success;
 }
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -2228,6 +2228,7 @@ hw/kdrive/fake/Makefile
 hw/kdrive/fbdev/Makefile
 hw/kdrive/linux/Makefile
 hw/kdrive/src/Makefile
+hw/kdrive/sdl/Makefile
 test/Makefile
 test/xi2/Makefile
 xserver.ent
diff --git a/dix/main.c b/dix/main.c
--- a/dix/main.c
+++ b/dix/main.c
@@ -117,6 +117,10 @@ Equipment Corporation.
 
 extern void Dispatch(void);
 
+#if defined(__native_client__)
+# include "nacl_main.h"
+#endif
+
 #ifdef XQUARTZ
 #include <pthread.h>
 
@@ -130,11 +134,22 @@ int
 dix_main(int argc, char *argv[], char *envp[])
 #else
 int
+# if defined(__native_client__)
+__attribute__ (( visibility("default") ))
+main(int argc, char *argv[])
+# else
 main(int argc, char *argv[], char *envp[])
+# endif
 #endif
 {
     int i;
     HWEventQueueType alwaysCheckForInput[2];
+#if defined(__native_client__)
+    char **envp = environ;
+    unsetenv("NACL_SPAWN_MODE");
+    if (nacl_startup_untar(argv[0], "xorg-xkb.tar", "/"))
+      return 1;
+#endif
 
     display = "0";
 
diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -15,6 +15,7 @@ LINUX_SUBDIRS = linux
 endif
 
 SERVER_SUBDIRS = 		\
+        sdl                     \
 	$(FBDEV_SUBDIRS)	\
 	$(XEPHYR_SUBDIRS)       \
 	$(XFAKE_SUBDIRS)
@@ -24,7 +25,7 @@ SUBDIRS =			\
 	$(LINUX_SUBDIRS)	\
 	$(SERVER_SUBDIRS)
 
-DIST_SUBDIRS = fbdev ephyr src linux fake
+DIST_SUBDIRS = fbdev ephyr src linux fake sdl
 
 relink:
 	$(AM_V_at)for i in $(SERVER_SUBDIRS) ; do $(MAKE) -C $$i relink || exit 1 ; done
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -27,6 +27,8 @@
 #include <xorg-config.h>
 #endif
 
+#include <errno.h>
+
 #include "xf86.h"
 #include "xf86Config.h"
 #include "xf86_OSlib.h"
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -53,6 +53,7 @@
 #include <xorg-config.h>
 #endif
 
+#include <errno.h>
 #include <X11/X.h>
 #include <X11/Xpoll.h>
 #include <X11/Xproto.h>
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -135,7 +135,7 @@
 #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
 #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
 
-#if defined(linux)
+#if defined(linux) || defined(__native_client__)
 #define osPciInit(x) do {} while (0)
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
 	defined(__OpenBSD__) || defined(__NetBSD__) || \
diff --git a/include/do-not-use-config.h.in b/include/do-not-use-config.h.in
--- a/include/do-not-use-config.h.in
+++ b/include/do-not-use-config.h.in
@@ -705,6 +705,9 @@
 /* Define for large files, on AIX-style hosts. */
 #undef _LARGE_FILES
 
+/* Defined if needed to expose struct msghdr.msg_control */
+#undef _XOPEN_SOURCE
+
 /* Define to 1 if unsigned long is 64 bits. */
 #undef _XSERVER64
 
diff --git a/include/servermd.h b/include/servermd.h
--- a/include/servermd.h
+++ b/include/servermd.h
@@ -279,6 +279,13 @@ SOFTWARE.
 #define GLYPHPADBYTES		4
 #endif
 
+/* nacl on ARM */
+#if defined(__native_client__) && defined(__arm__)
+#define IMAGE_BYTE_ORDER	LSBFirst
+#define BITMAP_BIT_ORDER	LSBFirst
+#define GLYPHPADBYTES		4
+#endif
+
 /* linux on IBM S/390 */
 #if defined (linux) && defined (__s390__)
 #define IMAGE_BYTE_ORDER	MSBFirst
diff --git a/os/access.c b/os/access.c
--- a/os/access.c
+++ b/os/access.c
@@ -322,7 +322,7 @@ DefineSelf(int fd)
     int family;
     register HOST *host;
 
-#ifndef WIN32
+#if !defined(WIN32) && !(defined(__native_client__) && defined(_NEWLIB_VERSION))
     struct utsname name;
 #else
     struct {
@@ -353,7 +353,7 @@ DefineSelf(int fd)
      * uname() lets me access to the whole string (it smashes release, you
      * see), whereas gethostname() kindly truncates it for me.
      */
-#ifndef WIN32
+#if !defined(WIN32) && !(defined(__native_client__) && defined(_NEWLIB_VERSION))
     uname(&name);
 #else
     gethostname(name.nodename, sizeof(name.nodename));
diff --git a/os/utils.c b/os/utils.c
--- a/os/utils.c
+++ b/os/utils.c
@@ -247,6 +247,7 @@ static Bool nolock = FALSE;
 void
 LockServer(void)
 {
+#if !defined(__native_client__)
     char tmp[PATH_MAX], pid_str[12];
     int lfd, i, haslock, l_pid, t;
     const char *tmppath = LOCK_DIR;
@@ -364,6 +365,7 @@ LockServer(void)
     if (!haslock)
         FatalError("Could not create server lock file: %s\n", LockFile);
     StillLocking = FALSE;
+#endif
 }
 
 /*
@@ -1093,6 +1095,7 @@ XNFstrdup(const char *s)
 void
 SmartScheduleStopTimer(void)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     struct itimerval timer;
 
     if (SmartScheduleDisable)
@@ -1102,11 +1105,13 @@ SmartScheduleStopTimer(void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = 0;
     (void) setitimer(ITIMER_REAL, &timer, 0);
+#endif
 }
 
 void
 SmartScheduleStartTimer(void)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     struct itimerval timer;
 
     if (SmartScheduleDisable)
@@ -1116,6 +1121,7 @@ SmartScheduleStartTimer(void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = SmartScheduleInterval * 1000;
     setitimer(ITIMER_REAL, &timer, 0);
+#endif
 }
 
 static void
@@ -1209,9 +1215,25 @@ OsAbort(void)
  * as well.  As it is now, xkbcomp messages don't end up in the log file.
  */
 
+#if defined(__native_client__)
+#include <spawn.h>
+#endif
+
 int
 System(const char *command)
 {
+#if defined(__native_client__)
+  int pid, p;
+  int status;
+
+  const char *args[] = {
+    "bash", "-c", command, NULL,
+  };
+
+  pid = spawnve(P_NOWAIT, "bash", args, NULL);
+  p = waitpid(pid, &status, 0);
+  return p == -1 ? -1 : status;
+#else
     int pid, p;
     void (*csig) (int);
     int status;
@@ -1249,6 +1271,7 @@ System(const char *command)
     }
 
     return p == -1 ? -1 : status;
+#endif
 }
 
 static struct pid {
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -179,7 +179,7 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
     const char *xkbbindir = emptystring;
     const char *xkbbindirsep = emptystring;
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__native_client__)
     /* WIN32 has no popen. The input must be stored in a file which is
        used as input for xkbcomp. xkbcomp does not read from stdin. */
     char tmpname[PATH_MAX];
@@ -192,6 +192,10 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
 
     OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
 
+#if defined(__native_client__)
+    strcpy(tmpname, "/tmp");
+    strcat(tmpname, "/xkb_XXXXXX");
+#endif
 #ifdef WIN32
     strcpy(tmpname, Win32TempDir());
     strcat(tmpname, "\\xkb_XXXXXX");
@@ -233,7 +237,7 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
         return FALSE;
     }
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__native_client__)
     out = Popen(buf, "w");
 #else
     out = fopen(tmpname, "w");
@@ -247,7 +251,7 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
         }
 #endif
         XkbWriteXKBKeymapForNames(out, names, xkb, want, need);
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__native_client__)
         if (Pclose(out) == 0)
 #else
         if (fclose(out) == 0 && System(buf) >= 0)
@@ -259,20 +263,20 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
                 strlcpy(nameRtrn, keymap, nameRtrnLen);
             }
             free(buf);
-#ifdef WIN32
+#if defined(WIN32) || defined(__native_client__)
             unlink(tmpname);
 #endif
             return TRUE;
         }
         else
             LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap);
-#ifdef WIN32
+#if defined(WIN32) || defined(__native_client__)
         /* remove the temporary file */
         unlink(tmpname);
 #endif
     }
     else {
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__native_client__)
         LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n");
 #else
         LogMessage(X_ERROR, "Could not open file %s\n", tmpname);
<commit_msg>Fix PNaCl build of xorg-server<commit_after>diff --git a/Xext/shm.c b/Xext/shm.c
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -33,8 +33,10 @@ in this Software without prior written authorization from The Open Group.
 #endif
 
 #include <sys/types.h>
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#endif
 #include <unistd.h>
 #include <sys/stat.h>
 #include <X11/X.h>
@@ -317,6 +319,7 @@ ProcShmQueryVersion(ClientPtr client)
 static int
 shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     int uid, gid;
     mode_t mask;
     int uidset = 0, gidset = 0;
@@ -374,11 +377,15 @@ shm_access(ClientPtr client, SHMPERM_TYPE * perm, int readonly)
         mask |= S_IWOTH;
     }
     return (SHMPERM_MODE(perm) & mask) == mask ? 0 : -1;
+#else
+    return -1;
+#endif
 }
 
 static int
 ProcShmAttach(ClientPtr client)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     SHMSTAT_TYPE buf;
     ShmDescPtr shmdesc;
 
@@ -428,12 +435,16 @@ ProcShmAttach(ClientPtr client)
     if (!AddResource(stuff->shmseg, ShmSegType, (pointer) shmdesc))
         return BadAlloc;
     return Success;
+#else
+    return BadAlloc;
+#endif
 }
 
  /*ARGSUSED*/ static int
 ShmDetachSegment(pointer value, /* must conform to DeleteType */
                  XID shmseg)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     ShmDescPtr shmdesc = (ShmDescPtr) value;
     ShmDescPtr *prev;
 
@@ -443,6 +454,7 @@ ShmDetachSegment(pointer value, /* must conform to DeleteType */
     for (prev = &Shmsegs; *prev != shmdesc; prev = &(*prev)->next);
     *prev = shmdesc->next;
     free(shmdesc);
+#endif
     return Success;
 }
 
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -2228,6 +2228,7 @@ hw/kdrive/fake/Makefile
 hw/kdrive/fbdev/Makefile
 hw/kdrive/linux/Makefile
 hw/kdrive/src/Makefile
+hw/kdrive/sdl/Makefile
 test/Makefile
 test/xi2/Makefile
 xserver.ent
diff --git a/dix/main.c b/dix/main.c
--- a/dix/main.c
+++ b/dix/main.c
@@ -117,6 +117,10 @@ Equipment Corporation.
 
 extern void Dispatch(void);
 
+#if defined(__native_client__)
+# include "nacl_main.h"
+#endif
+
 #ifdef XQUARTZ
 #include <pthread.h>
 
@@ -130,11 +134,22 @@ int
 dix_main(int argc, char *argv[], char *envp[])
 #else
 int
+# if defined(__native_client__)
+__attribute__ (( visibility("default") ))
+main(int argc, char *argv[])
+# else
 main(int argc, char *argv[], char *envp[])
+# endif
 #endif
 {
     int i;
     HWEventQueueType alwaysCheckForInput[2];
+#if defined(__native_client__)
+    char **envp = environ;
+    unsetenv("NACL_SPAWN_MODE");
+    if (nacl_startup_untar(argv[0], "xorg-xkb.tar", "/"))
+      return 1;
+#endif
 
     display = "0";
 
diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -15,6 +15,7 @@ LINUX_SUBDIRS = linux
 endif
 
 SERVER_SUBDIRS = 		\
+        sdl                     \
 	$(FBDEV_SUBDIRS)	\
 	$(XEPHYR_SUBDIRS)       \
 	$(XFAKE_SUBDIRS)
@@ -24,7 +25,7 @@ SUBDIRS =			\
 	$(LINUX_SUBDIRS)	\
 	$(SERVER_SUBDIRS)
 
-DIST_SUBDIRS = fbdev ephyr src linux fake
+DIST_SUBDIRS = fbdev ephyr src linux fake sdl
 
 relink:
 	$(AM_V_at)for i in $(SERVER_SUBDIRS) ; do $(MAKE) -C $$i relink || exit 1 ; done
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -27,6 +27,8 @@
 #include <xorg-config.h>
 #endif
 
+#include <errno.h>
+
 #include "xf86.h"
 #include "xf86Config.h"
 #include "xf86_OSlib.h"
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -53,6 +53,7 @@
 #include <xorg-config.h>
 #endif
 
+#include <errno.h>
 #include <X11/X.h>
 #include <X11/Xpoll.h>
 #include <X11/Xproto.h>
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -135,7 +135,7 @@
 #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
 #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
 
-#if defined(linux)
+#if defined(linux) || defined(__native_client__)
 #define osPciInit(x) do {} while (0)
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
 	defined(__OpenBSD__) || defined(__NetBSD__) || \
diff --git a/include/do-not-use-config.h.in b/include/do-not-use-config.h.in
--- a/include/do-not-use-config.h.in
+++ b/include/do-not-use-config.h.in
@@ -705,6 +705,9 @@
 /* Define for large files, on AIX-style hosts. */
 #undef _LARGE_FILES
 
+/* Defined if needed to expose struct msghdr.msg_control */
+#undef _XOPEN_SOURCE
+
 /* Define to 1 if unsigned long is 64 bits. */
 #undef _XSERVER64
 
diff --git a/include/servermd.h b/include/servermd.h
--- a/include/servermd.h
+++ b/include/servermd.h
@@ -279,6 +279,13 @@ SOFTWARE.
 #define GLYPHPADBYTES		4
 #endif
 
+/* nacl on ARM/PNaCl */
+#if (defined(__native_client__) && defined(__arm__)) || defined(__pnacl__)
+#define IMAGE_BYTE_ORDER	LSBFirst
+#define BITMAP_BIT_ORDER	LSBFirst
+#define GLYPHPADBYTES		4
+#endif
+
 /* linux on IBM S/390 */
 #if defined (linux) && defined (__s390__)
 #define IMAGE_BYTE_ORDER	MSBFirst
diff --git a/os/access.c b/os/access.c
--- a/os/access.c
+++ b/os/access.c
@@ -322,7 +322,7 @@ DefineSelf(int fd)
     int family;
     register HOST *host;
 
-#ifndef WIN32
+#if !defined(WIN32) && !(defined(__native_client__) && defined(_NEWLIB_VERSION))
     struct utsname name;
 #else
     struct {
@@ -353,7 +353,7 @@ DefineSelf(int fd)
      * uname() lets me access to the whole string (it smashes release, you
      * see), whereas gethostname() kindly truncates it for me.
      */
-#ifndef WIN32
+#if !defined(WIN32) && !(defined(__native_client__) && defined(_NEWLIB_VERSION))
     uname(&name);
 #else
     gethostname(name.nodename, sizeof(name.nodename));
diff --git a/os/utils.c b/os/utils.c
--- a/os/utils.c
+++ b/os/utils.c
@@ -247,6 +247,7 @@ static Bool nolock = FALSE;
 void
 LockServer(void)
 {
+#if !defined(__native_client__)
     char tmp[PATH_MAX], pid_str[12];
     int lfd, i, haslock, l_pid, t;
     const char *tmppath = LOCK_DIR;
@@ -364,6 +365,7 @@ LockServer(void)
     if (!haslock)
         FatalError("Could not create server lock file: %s\n", LockFile);
     StillLocking = FALSE;
+#endif
 }
 
 /*
@@ -1093,6 +1095,7 @@ XNFstrdup(const char *s)
 void
 SmartScheduleStopTimer(void)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     struct itimerval timer;
 
     if (SmartScheduleDisable)
@@ -1102,11 +1105,13 @@ SmartScheduleStopTimer(void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = 0;
     (void) setitimer(ITIMER_REAL, &timer, 0);
+#endif
 }
 
 void
 SmartScheduleStartTimer(void)
 {
+#if !defined(__native_client__) || !defined(_NEWLIB_VERSION)
     struct itimerval timer;
 
     if (SmartScheduleDisable)
@@ -1116,6 +1121,7 @@ SmartScheduleStartTimer(void)
     timer.it_value.tv_sec = 0;
     timer.it_value.tv_usec = SmartScheduleInterval * 1000;
     setitimer(ITIMER_REAL, &timer, 0);
+#endif
 }
 
 static void
@@ -1209,9 +1215,25 @@ OsAbort(void)
  * as well.  As it is now, xkbcomp messages don't end up in the log file.
  */
 
+#if defined(__native_client__)
+#include <spawn.h>
+#endif
+
 int
 System(const char *command)
 {
+#if defined(__native_client__)
+  int pid, p;
+  int status;
+
+  const char *args[] = {
+    "bash", "-c", command, NULL,
+  };
+
+  pid = spawnve(P_NOWAIT, "bash", args, NULL);
+  p = waitpid(pid, &status, 0);
+  return p == -1 ? -1 : status;
+#else
     int pid, p;
     void (*csig) (int);
     int status;
@@ -1249,6 +1271,7 @@ System(const char *command)
     }
 
     return p == -1 ? -1 : status;
+#endif
 }
 
 static struct pid {
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -179,7 +179,7 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
     const char *xkbbindir = emptystring;
     const char *xkbbindirsep = emptystring;
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__native_client__)
     /* WIN32 has no popen. The input must be stored in a file which is
        used as input for xkbcomp. xkbcomp does not read from stdin. */
     char tmpname[PATH_MAX];
@@ -192,6 +192,10 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
 
     OutputDirectory(xkm_output_dir, sizeof(xkm_output_dir));
 
+#if defined(__native_client__)
+    strcpy(tmpname, "/tmp");
+    strcat(tmpname, "/xkb_XXXXXX");
+#endif
 #ifdef WIN32
     strcpy(tmpname, Win32TempDir());
     strcat(tmpname, "\\xkb_XXXXXX");
@@ -233,7 +237,7 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
         return FALSE;
     }
 
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__native_client__)
     out = Popen(buf, "w");
 #else
     out = fopen(tmpname, "w");
@@ -247,7 +251,7 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
         }
 #endif
         XkbWriteXKBKeymapForNames(out, names, xkb, want, need);
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__native_client__)
         if (Pclose(out) == 0)
 #else
         if (fclose(out) == 0 && System(buf) >= 0)
@@ -259,20 +263,20 @@ XkbDDXCompileKeymapByNames(XkbDescPtr xkb,
                 strlcpy(nameRtrn, keymap, nameRtrnLen);
             }
             free(buf);
-#ifdef WIN32
+#if defined(WIN32) || defined(__native_client__)
             unlink(tmpname);
 #endif
             return TRUE;
         }
         else
             LogMessage(X_ERROR, "Error compiling keymap (%s)\n", keymap);
-#ifdef WIN32
+#if defined(WIN32) || defined(__native_client__)
         /* remove the temporary file */
         unlink(tmpname);
 #endif
     }
     else {
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__native_client__)
         LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp\n");
 #else
         LogMessage(X_ERROR, "Could not open file %s\n", tmpname);

{'fraction_non_alphanumeric': 0.16043746550945667, 'fraction_numerical': 0.03923142527467015, 'mean_word_length': 3.3782121678014496, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '898138', 'n_tokens_mistral': 8362, 'n_tokens_neox': 7715, 'n_words': 1661}