linux/include/linux/once_lite.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2#ifndef _LINUX_ONCE_LITE_H
   3#define _LINUX_ONCE_LITE_H
   4
   5#include <linux/types.h>
   6
   7/* Call a function once. Similar to DO_ONCE(), but does not use jump label
   8 * patching via static keys.
   9 */
  10#define DO_ONCE_LITE(func, ...)                                         \
  11        DO_ONCE_LITE_IF(true, func, ##__VA_ARGS__)
  12#define DO_ONCE_LITE_IF(condition, func, ...)                           \
  13        ({                                                              \
  14                static bool __section(".data.once") __already_done;     \
  15                bool __ret_do_once = !!(condition);                     \
  16                                                                        \
  17                if (unlikely(__ret_do_once && !__already_done)) {       \
  18                        __already_done = true;                          \
  19                        func(__VA_ARGS__);                              \
  20                }                                                       \
  21                unlikely(__ret_do_once);                                \
  22        })
  23
  24#endif /* _LINUX_ONCE_LITE_H */
  25