Server IP : 15.235.198.142 / Your IP : 216.73.216.0 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/modules/6.8.0-60-generic/build/include/linux/ |
Upload File : |
#ifndef _LINUX_CALL_ONCE_H #define _LINUX_CALL_ONCE_H #include <linux/types.h> #include <linux/mutex.h> #define ONCE_NOT_STARTED 0 #define ONCE_RUNNING 1 #define ONCE_COMPLETED 2 struct once { atomic_t state; struct mutex lock; }; static inline void __once_init(struct once *once, const char *name, struct lock_class_key *key) { atomic_set(&once->state, ONCE_NOT_STARTED); __mutex_init(&once->lock, name, key); } #define once_init(once) \ do { \ static struct lock_class_key __key; \ __once_init((once), #once, &__key); \ } while (0) static inline void call_once(struct once *once, void (*cb)(struct once *)) { /* Pairs with atomic_set_release() below. */ if (atomic_read_acquire(&once->state) == ONCE_COMPLETED) return; guard(mutex)(&once->lock); WARN_ON(atomic_read(&once->state) == ONCE_RUNNING); if (atomic_read(&once->state) != ONCE_NOT_STARTED) return; atomic_set(&once->state, ONCE_RUNNING); cb(once); atomic_set_release(&once->state, ONCE_COMPLETED); } #endif /* _LINUX_CALL_ONCE_H */