You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.0 KiB

#ifndef _IT_IFUNC_H
#define _IT_IFUNC_H
//! ifunc helpers
#if !IFUNC_PREFIX
#define IFUNC_PREFIX _ifun__
#endif
#define _IFUNC_STR_(X) #X
#define _IFUNC_STR(X) _IFUNC_STR_(X)
#define _IFUNC_PREFIX_S _IFUNC_STR(IFUNC_PREFIX)
#define _IFUNC_PASTE_(X,Y) X##Y
#define _IFUNC_PASTE(X,Y) _IFUNC_PASTE_(X,Y)
#define _IFUNC_PREFIX(X) _IFUNC_PASTE(IFUNC_PREFIX, X)
#define IFUNC_NAME(name, ver) _impl__ ## name ## __ ## ver
#define IFUNC_IMPL(name, ver) __attribute__((copy(name))) IFUNC_NAME(name, ver)
#define IFUNC_RESOLVER_A(attr, name) __attribute__((returns_nonnull)) (* __attribute__(attr) _IFUNC_PREFIX(name) /*_ifun__ ## name*/ (void)) // When the ifunc resolver wants to return a function pointer that has attributes on it, the attribute inner list (e.g. `(returns_nonnull, const, nonnull)') can be provided as the first argument
#define IFUNC_RESOLVER(name) IFUNC_RESOLVER_A((copy(name)), name)
#define IFUNC_DEF(name, params) name params __attribute__((__ifunc__(_IFUNC_PREFIX_S #name)))
#endif /* _IT_IFUNC_H */