| 1 | /* |
| 2 | * Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
| 5 | * this file except in compliance with the License. You can obtain a copy |
| 6 | * in the file LICENSE in the source distribution or at |
| 7 | * https://www.openssl.org/source/license.html |
| 8 | */ |
| 9 | |
| 10 | #ifndef OPENSSL_CORE_NUMBERS_H |
| 11 | # define OPENSSL_CORE_NUMBERS_H |
| 12 | # pragma once |
| 13 | |
| 14 | # include <stdarg.h> |
| 15 | # include <openssl/core.h> |
| 16 | # include <openssl/indicator.h> |
| 17 | |
| 18 | # ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | # endif |
| 21 | |
| 22 | /* |
| 23 | * Generic function pointer for provider method arrays, or other contexts where |
| 24 | * functions of various signatures must occupy a common slot in an array of |
| 25 | * structures. |
| 26 | */ |
| 27 | typedef void (*OSSL_FUNC)(void); |
| 28 | |
| 29 | /*- |
| 30 | * Identities |
| 31 | * ---------- |
| 32 | * |
| 33 | * All series start with 1, to allow 0 to be an array terminator. |
| 34 | * For any FUNC identity, we also provide a function signature typedef |
| 35 | * and a static inline function to extract a function pointer from a |
| 36 | * OSSL_DISPATCH element in a type safe manner. |
| 37 | * |
| 38 | * Names: |
| 39 | * for any function base name 'foo' (uppercase form 'FOO'), we will have |
| 40 | * the following: |
| 41 | * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivatives |
| 42 | * thereof (to be specified further down) |
| 43 | * - a function signature typedef with the name OSSL_FUNC_'foo'_fn |
| 44 | * - a function pointer extractor function with the name OSSL_FUNC_'foo' |
| 45 | */ |
| 46 | |
| 47 | /* |
| 48 | * Helper macro to create the function signature typedef and the extractor |
| 49 | * |type| is the return-type of the function, |name| is the name of the |
| 50 | * function to fetch, and |args| is a parenthesized list of parameters |
| 51 | * for the function (that is, it is |name|'s function signature). |
| 52 | * Note: This is considered a "reserved" internal macro. Applications should |
| 53 | * not use this or assume its existence. |
| 54 | */ |
| 55 | #define OSSL_CORE_MAKE_FUNC(type,name,args) \ |
| 56 | typedef type (OSSL_FUNC_##name##_fn)args; \ |
| 57 | static ossl_unused ossl_inline \ |
| 58 | OSSL_FUNC_##name##_fn *OSSL_FUNC_##name(const OSSL_DISPATCH * |
|---|