/*
 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <errno.h>
#include <pthread.h>
#include <unistd.h>

#include "native_client/src/untrusted/nacl/tls.h"

/*
 * libstdc++ makes minimal use of pthread_key_t stuff.
 */

#undef  PTHREAD_KEYS_MAX
#define PTHREAD_KEYS_MAX        32

#define NC_TSD_NO_MORE_KEYS     irt_tsd_no_more_keys()
static void irt_tsd_no_more_keys(void) {
  static const char msg[] = "IRT: too many pthread keys\n";
  write(2, msg, sizeof msg - 1);
}

#define NACL_IN_IRT

/* @IGNORE_LINES_FOR_CODE_HYGIENE[2] */
#include "native_client/src/untrusted/pthread/nc_init_private.c"
#include "native_client/src/untrusted/pthread/nc_thread.c"

/*
 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include <errno.h>
#include <pthread.h>
#include <unistd.h>

#include "native_client/src/untrusted/nacl/tls.h"

/*
 * libstdc++ makes minimal use of pthread_key_t stuff.
 */

#undef  PTHREAD_KEYS_MAX
#define PTHREAD_KEYS_MAX        16

#define NC_TSD_NO_MORE_KEYS     irt_tsd_no_more_keys()
static void irt_tsd_no_more_keys(void) {
  static const char msg[] = "IRT: too many pthread keys\n";
  write(2, msg, sizeof msg - 1);
}

#define NACL_IN_IRT

/* @IGNORE_LINES_FOR_CODE_HYGIENE[2] */
#include "native_client/src/untrusted/pthread/nc_init_private.c"
#include "native_client/src/untrusted/pthread/nc_thread.c"

--- 
+++ 
@@ -15,7 +15,7 @@
  */
 
 #undef  PTHREAD_KEYS_MAX
-#define PTHREAD_KEYS_MAX        16
+#define PTHREAD_KEYS_MAX        32
 
 #define NC_TSD_NO_MORE_KEYS     irt_tsd_no_more_keys()
 static void irt_tsd_no_more_keys(void) {
Increase the number of pthread keys available to the IRT

The Mojo EDK uses an additional key for thread-local storage
and is now necessary to bring up IPC in Chrome. This is apparently
enough to push us over the 16 key limit in some cases.

Doubling to 32 to leave some room for further expansion.

BUG=https://code.google.com/p/chromium/issues/detail?id=612500

Review-Url: https://codereview.chromium.org/2050043004
