linux/include/linux/static_call_types.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _STATIC_CALL_TYPES_H
#define _STATIC_CALL_TYPES_H

#include <linux/types.h>
#include <linux/stringify.h>
#include <linux/compiler.h>

#define STATIC_CALL_KEY_PREFIX
#define STATIC_CALL_KEY_PREFIX_STR
#define STATIC_CALL_KEY_PREFIX_LEN
#define STATIC_CALL_KEY(name)
#define STATIC_CALL_KEY_STR(name)

#define STATIC_CALL_TRAMP_PREFIX
#define STATIC_CALL_TRAMP_PREFIX_STR
#define STATIC_CALL_TRAMP_PREFIX_LEN
#define STATIC_CALL_TRAMP(name)
#define STATIC_CALL_TRAMP_STR(name)

/*
 * Flags in the low bits of static_call_site::key.
 */
#define STATIC_CALL_SITE_TAIL
#define STATIC_CALL_SITE_INIT
#define STATIC_CALL_SITE_FLAGS

/*
 * The static call site table needs to be created by external tooling (objtool
 * or a compiler plugin).
 */
struct static_call_site {};

#define DECLARE_STATIC_CALL(name, func)

#ifdef CONFIG_HAVE_STATIC_CALL

#define __raw_static_call(name)

#ifdef CONFIG_HAVE_STATIC_CALL_INLINE

/*
 * __ADDRESSABLE() is used to ensure the key symbol doesn't get stripped from
 * the symbol table so that objtool can reference it when it generates the
 * .static_call_sites section.
 */
#define __STATIC_CALL_ADDRESSABLE(name)

#define __static_call(name)

struct static_call_key {};

#else /* !CONFIG_HAVE_STATIC_CALL_INLINE */

#define __STATIC_CALL_ADDRESSABLE
#define __static_call

struct static_call_key {
	void *func;
};

#endif /* CONFIG_HAVE_STATIC_CALL_INLINE */

#ifdef MODULE
#define __STATIC_CALL_MOD_ADDRESSABLE
#define static_call_mod
#else
#define __STATIC_CALL_MOD_ADDRESSABLE(name)
#define static_call_mod(name)
#endif

#define static_call(name)

#else

struct static_call_key {
	void *func;
};

#define static_call

#endif /* CONFIG_HAVE_STATIC_CALL */

#endif /* _STATIC_CALL_TYPES_H */