File: threads_common.h

package info (click to toggle)
openssl 4.0.0~alpha1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 147,524 kB
  • sloc: ansic: 679,298; perl: 250,893; asm: 6,332; sh: 2,550; python: 648; makefile: 552; pascal: 311; lisp: 35; ruby: 17; cpp: 10; sed: 6
file content (51 lines) | stat: -rw-r--r-- 1,576 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright 2025-2026 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#ifndef _CRYPTO_THREADS_COMMON_H_
#define _CRYPTO_THREADS_COMMON_H_

#if defined(__clang__) && defined(__has_feature)
#if __has_feature(thread_sanitizer)
#define __SANITIZE_THREAD__
#endif
#endif

#if defined(__SANITIZE_THREAD__)
#include <sanitizer/tsan_interface.h>
extern void AnnotateBenignRaceSized(const char *f, int l,
    const volatile void *mem, unsigned int size, const char *desc);
#define TSAN_BENIGN(x, desc) \
    AnnotateBenignRaceSized(__FILE__, __LINE__, &(x), sizeof(x), desc);
#else
#define TSAN_BENIGN(x, desc)
#endif

typedef enum {
    CRYPTO_THREAD_LOCAL_RCU_KEY = 0,
    CRYPTO_THREAD_LOCAL_DRBG_PRIV_KEY,
    CRYPTO_THREAD_LOCAL_DRBG_PUB_KEY,
    CRYPTO_THREAD_LOCAL_ERR_KEY,
    CRYPTO_THREAD_LOCAL_ASYNC_CTX_KEY,
    CRYPTO_THREAD_LOCAL_ASYNC_POOL_KEY,
    CRYPTO_THREAD_LOCAL_TEVENT_KEY,
    CRYPTO_THREAD_LOCAL_TANDEM_ID_KEY,
    CRYPTO_THREAD_LOCAL_FIPS_DEFERRED_KEY,
    CRYPTO_THREAD_LOCAL_KEY_MAX
} CRYPTO_THREAD_LOCAL_KEY_ID;

#define CRYPTO_THREAD_NO_CONTEXT (void *)1

void *CRYPTO_THREAD_get_local_ex(CRYPTO_THREAD_LOCAL_KEY_ID id,
    OSSL_LIB_CTX *ctx);
int CRYPTO_THREAD_set_local_ex(CRYPTO_THREAD_LOCAL_KEY_ID id,
    OSSL_LIB_CTX *ctx, void *data);

void CRYPTO_THREAD_clean_local(void);

#endif