|
17 | 17 | * DECLARE_STATIC_CALL(name, func);
|
18 | 18 | * DEFINE_STATIC_CALL(name, func);
|
19 | 19 | * DEFINE_STATIC_CALL_NULL(name, typename);
|
| 20 | + * DEFINE_STATIC_CALL_RET0(name, typename); |
| 21 | + * |
| 22 | + * __static_call_return0; |
| 23 | + * |
20 | 24 | * static_call(name)(args...);
|
21 | 25 | * static_call_cond(name)(args...);
|
22 | 26 | * static_call_update(name, func);
|
23 | 27 | * static_call_query(name);
|
24 | 28 | *
|
| 29 | + * EXPORT_STATIC_CALL{,_TRAMP}{,_GPL}() |
| 30 | + * |
25 | 31 | * Usage example:
|
26 | 32 | *
|
27 | 33 | * # Start with the following functions (with identical prototypes):
|
|
96 | 102 | * To query which function is currently set to be called, use:
|
97 | 103 | *
|
98 | 104 | * func = static_call_query(name);
|
| 105 | + * |
| 106 | + * |
| 107 | + * DEFINE_STATIC_CALL_RET0 / __static_call_return0: |
| 108 | + * |
| 109 | + * Just like how DEFINE_STATIC_CALL_NULL() / static_call_cond() optimize the |
| 110 | + * conditional void function call, DEFINE_STATIC_CALL_RET0 / |
| 111 | + * __static_call_return0 optimize the do nothing return 0 function. |
| 112 | + * |
| 113 | + * This feature is strictly UB per the C standard (since it casts a function |
| 114 | + * pointer to a different signature) and relies on the architecture ABI to |
| 115 | + * make things work. In particular it relies on Caller Stack-cleanup and the |
| 116 | + * whole return register being clobbered for short return values. All normal |
| 117 | + * CDECL style ABIs conform. |
| 118 | + * |
| 119 | + * In particular the x86_64 implementation replaces the 5 byte CALL |
| 120 | + * instruction at the callsite with a 5 byte clear of the RAX register, |
| 121 | + * completely eliding any function call overhead. |
| 122 | + * |
| 123 | + * Notably argument setup is unconditional. |
| 124 | + * |
| 125 | + * |
| 126 | + * EXPORT_STATIC_CALL() vs EXPORT_STATIC_CALL_TRAMP(): |
| 127 | + * |
| 128 | + * The difference is that the _TRAMP variant tries to only export the |
| 129 | + * trampoline with the result that a module can use static_call{,_cond}() but |
| 130 | + * not static_call_update(). |
| 131 | + * |
99 | 132 | */
|
100 | 133 |
|
101 | 134 | #include <linux/types.h>
|
|
0 commit comments