1e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley/* Copyright (c) 2015, Google Inc.
2e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley *
3e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * Permission to use, copy, modify, and/or distribute this software for any
4e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * purpose with or without fee is hereby granted, provided that the above
5e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * copyright notice and this permission notice appear in all copies.
6e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley *
7e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
15e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley#include "internal.h"
16e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
17e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley#if defined(OPENSSL_NO_THREADS)
18e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
19e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_MUTEX_init(CRYPTO_MUTEX *lock) {}
20e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
21e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_MUTEX_lock_read(CRYPTO_MUTEX *lock) {}
22e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
23e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_MUTEX_lock_write(CRYPTO_MUTEX *lock) {}
24e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
25e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_MUTEX_unlock(CRYPTO_MUTEX *lock) {}
26e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
27e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_MUTEX_cleanup(CRYPTO_MUTEX *lock) {}
28e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
29e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_STATIC_MUTEX_lock_read(struct CRYPTO_STATIC_MUTEX *lock) {}
30e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
31e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_STATIC_MUTEX_lock_write(struct CRYPTO_STATIC_MUTEX *lock) {}
32e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
33e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_STATIC_MUTEX_unlock(struct CRYPTO_STATIC_MUTEX *lock) {}
34e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
35e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid CRYPTO_once(CRYPTO_once_t *once, void (*init)(void)) {
36e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley  if (*once) {
37e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley    return;
38e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley  }
39e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley  *once = 1;
40e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley  init();
41e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley}
42e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
43e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleystatic void *g_thread_locals[NUM_OPENSSL_THREAD_LOCALS];
44e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
45e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyvoid *CRYPTO_get_thread_local(thread_local_data_t index) {
46e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley  return g_thread_locals[index];
47e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley}
48e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
49e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langleyint CRYPTO_set_thread_local(thread_local_data_t index, void *value,
50e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley                            thread_local_destructor_t destructor) {
51e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley  g_thread_locals[index] = value;
52e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley  return 1;
53e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley}
54e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley
55e9ada863a7b3e81f5d2b1e3bdd2305da902a87f5Adam Langley#endif  /* OPENSSL_NO_THREADS */
56