online
  +   ˆl–Ðz¾”ªe¶…8 ^¸ÜdJbÑ¿Á„iÇÚ{_†I|¥�+ÁÀ ?÷     /*
 * Copyright 2019-2025 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 OPENSSL_CORE_NUMBERS_H
#define OPENSSL_CORE_NUMBERS_H
#pragma once

#include <stdarg.h>
#include <openssl/core.h>
#include <openssl/indicator.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 * Generic function pointer for provider method arrays, or other contexts where
 * functions of various signatures must occupy a common slot in an array of
 * structures.
 */
typedef void (*OSSL_FUNC)(void);

/*-
 * Identities
 * ----------
 *
 * All series start with 1, to allow 0 to be an array terminator.
 * For any FUNC identity, we also provide a function signature typedef
 * and a static inline function to extract a function pointer from a
 * OSSL_DISPATCH element in a type safe manner.
 *
 * Names:
 * for any function base name 'foo' (uppercase form 'FOO'), we will have
 * the following:
 * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivatives
 *   thereof (to be specified further down)
 * - a function signature typedef with the name OSSL_FUNC_'foo'_fn
 * - a function pointer extractor function with the name OSSL_FUNC_'foo'
 */

/*
 * Helper macro to create the function signature typedef and the extractor
 * |type| is the return-type of the function, |name| is the name of the
 * function to fetch, and |args| is a parenthesized list of parameters
 * for the function (that is, it is |name|'s function signature).
 * Note: This is considered a "reserved" internal macro. Applications should
 * not use this or assume its existence.
 */
#define OSSL_CORE_MAKE_FUNC(type, name, args)          \
    typedef type(OSSL_FUNC_##name##_fn) args;          \
    static ossl_unused ossl_inline                     \
        OSSL_FUNC_##name##_fn *                        \
        OSSL_FUNC_##name(const OSSL_DISPATCH *opf)     \
    {                                                  \
        return (OSSL_FUNC_##name##_fn *)opf->function; \
    }

/*
 * Core function identities, for the two OSSL_DISPATCH tables being passed
 * in the OSSL_provider_init call.
 *
 * 0 serves as a marker for the end of the OSSL_DISPATCH array, and must
 * therefore NEVER be used as a function identity.
 */
/* Functions provided by the Core to the provider, reserved numbers 1-1023 */
#define OSSL_FUNC_CORE_GETTABLE_PARAMS 1
OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
    core_gettable_params, (const OSSL_CORE_HANDLE *prov))
#define OSSL_FUNC_CORE_GET_PARAMS 2
OSSL_CORE_MAKE_FUNC(int, core_get_params, (const OSSL_CORE_HANDLE *prov, OSSL_PARAM params[]))
#define OSSL_FUNC_CORE_THREAD_START 3
OSSL_CORE_MAKE_FUNC(int, core_thread_start, (const OSSL_CORE_HANDLE *prov, OSSL_thread_stop_handler_fn handfn, void *arg))
#define OSSL_FUNC_CORE_GET_LIBCTX 4
OSSL_CORE_MAKE_FUNC(OPENSSL_CORE_CTX *, core_get_libctx,
    (const OSSL_CORE_HANDLE *prov))
#define OSSL_FUNC_CORE_NEW_ERROR 5
OSSL_CORE_MAKE_FUNC(void, core_new_error, (const OSSL_CORE_HANDLE *prov))
#define OSSL_FUNC_CORE_SET_ERROR_DEBUG 6
OSSL_CORE_MAKE_FUNC(void, core_set_error_debug,
    (const OSSL_CORE_HANDLE *prov,
        const char *file, int line, const char *func))
#define OSSL_FUNC_CORE_VSET_ERROR 7
OSSL_CORE_MAKE_FUNC(void, core_vset_error,
    (const OSSL_CORE_HANDLE *prov,
        uint32_t reason, const char *fmt, va_list args))
#define OSSL_FUNC_CORE_SET_ERROR_MARK 8
OSSL_CORE_MAKE_FUNC(int, core_set_error_mark, (const OSSL_CORE_HANDLE *prov))
#define OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK 9
OSSL_CORE_MAKE_FUNC(int, core_clear_last_error_mark,
    (const OSSL_CORE_HANDLE *prov))
#define OSSL_FUNC_CORE_POP_ERROR_TO_MARK 10
OSSL_CORE_MAKE_FUNC(int, core_pop_error_to_mark, (const OSSL_CORE_HANDLE *prov))

/* Functions to access the OBJ database */

#define OSSL_FUNC_CORE_OBJ_ADD_SIGID 11
#define 