| diff --git a/gio/glocalfile.c b/gio/glocalfile.c |
| --- a/gio/glocalfile.c |
| +++ b/gio/glocalfile.c |
| @@ -69,6 +69,16 @@ |
| |
| #include "glib-private.h" |
| |
| +/* |
| + * The headers for the NaCl newlib toolchain define AT_FDCWD |
| + * and this file interprets that to mean that openat, and fstatat |
| + * are useable, which they are not. |
| + * TODO(sbc): remove this once we fix this bug: http://crbug.com/436533 |
| + */ |
| +#if defined(__native_client__) && defined(_NEWLIB_VERSION) |
| +#undef AT_FDCWD |
| +#endif |
| + |
| #ifdef G_OS_WIN32 |
| #include <windows.h> |
| #include <io.h> |
| diff --git a/gio/gsocket.c b/gio/gsocket.c |
| --- a/gio/gsocket.c |
| +++ b/gio/gsocket.c |
| @@ -2501,7 +2501,9 @@ g_socket_get_available_bytes (GSocket *socket) |
| if (!g_socket_get_option (socket, SOL_SOCKET, SO_NREAD, &avail, NULL)) |
| return -1; |
| #elif !defined (G_OS_WIN32) |
| +#ifndef __native_client__ |
| if (ioctl (socket->priv->fd, FIONREAD, &avail) < 0) |
| +#endif |
| avail = -1; |
| #else |
| if (socket->priv->type == G_SOCKET_TYPE_DATAGRAM) |
| diff --git a/glib/gbacktrace.h b/glib/gbacktrace.h |
| --- a/glib/gbacktrace.h |
| +++ b/glib/gbacktrace.h |
| @@ -47,7 +47,9 @@ void g_on_error_stack_trace (const gchar *prg_name); |
| * On x86 and alpha systems this is implemented as a soft interrupt |
| * and on other architectures it raises a `SIGTRAP` signal. |
| */ |
| -#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2 |
| +#ifdef __native_client__ |
| +# define G_BREAKPOINT() __builtin_trap() |
| +#elif (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2 |
| # define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END |
| #elif (defined (_MSC_VER) || defined (__DMC__)) && defined (_M_IX86) |
| # define G_BREAKPOINT() G_STMT_START{ __asm int 3h }G_STMT_END |
| diff --git a/glib/gbitlock.c b/glib/gbitlock.c |
| --- a/glib/gbitlock.c |
| +++ b/glib/gbitlock.c |
| @@ -178,7 +178,7 @@ g_futex_wake (const volatile gint *address) |
| #define CONTENTION_CLASSES 11 |
| static volatile gint g_bit_lock_contended[CONTENTION_CLASSES]; |
| |
| -#if (defined (i386) || defined (__amd64__)) |
| +#if (defined (i386) || defined (__amd64__)) && !defined(__native_client__) |
| #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) |
| #define USE_ASM_GOTO 1 |
| #endif |
| diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c |
| --- a/glib/gthread-posix.c |
| +++ b/glib/gthread-posix.c |
| @@ -652,6 +652,9 @@ g_cond_impl_new (void) |
| pthread_condattr_init (&attr); |
| |
| #ifdef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP |
| +#elif defined(__native_client__) |
| + if G_UNLIKELY ((status = pthread_condattr_setclock (&attr, CLOCK_REALTIME)) != 0) |
| + g_thread_abort (status, "pthread_condattr_setclock - CLOCK_REALTIME"); |
| #elif defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC) |
| if G_UNLIKELY ((status = pthread_condattr_setclock (&attr, CLOCK_MONOTONIC)) != 0) |
| g_thread_abort (status, "pthread_condattr_setclock"); |
| diff --git a/glib/gtypes.h b/glib/gtypes.h |
| --- a/glib/gtypes.h |
| +++ b/glib/gtypes.h |
| @@ -178,7 +178,7 @@ typedef const gchar * (*GTranslateFunc) (const gchar *str, |
| |
| /* Arch specific stuff for speed |
| */ |
| -#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) |
| +#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) && !defined(__native_client__) |
| |
| # if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3 |
| # define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((gint32) (val))) |