static void ossl_lock_unlock(int mode, struct CRYPTO_dynlock_value *l) { if (mode & CRYPTO_LOCK) { /* TODO: rb_nativethread_id_t is not necessarily compared with ==. */ rb_nativethread_id_t tid = rb_nativethread_self(); if (l->count && l->owner == tid) { l->count++; return; } rb_nativethread_lock_lock(&l->lock); l->owner = tid; l->count = 1; } else { if (!--l->count) rb_nativethread_lock_unlock(&l->lock); } }
static unsigned long ossl_thread_id(void) { /* before OpenSSL 1.0, this is 'unsigned long' */ return (unsigned long)rb_nativethread_self(); }
static void ossl_threadid_func(CRYPTO_THREADID *id) { /* register native thread id */ CRYPTO_THREADID_set_pointer(id, (void *)rb_nativethread_self()); }