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