Hannes Frederic Sowa | 4623425 | 2015-10-08 01:20:35 +0200 | [diff] [blame^] | 1 | #ifndef _LINUX_ONCE_H |
| 2 | #define _LINUX_ONCE_H |
| 3 | |
| 4 | #include <linux/types.h> |
| 5 | #include <linux/jump_label.h> |
| 6 | |
| 7 | bool __get_random_once(void *buf, int nbytes, bool *done, |
| 8 | struct static_key *once_key); |
| 9 | |
| 10 | #define get_random_once(buf, nbytes) \ |
| 11 | ({ \ |
| 12 | bool ___ret = false; \ |
| 13 | static bool ___done = false; \ |
| 14 | static struct static_key ___once_key = \ |
| 15 | STATIC_KEY_INIT_TRUE; \ |
| 16 | if (static_key_true(&___once_key)) \ |
| 17 | ___ret = __get_random_once((buf), \ |
| 18 | (nbytes), \ |
| 19 | &___done, \ |
| 20 | &___once_key); \ |
| 21 | ___ret; \ |
| 22 | }) |
| 23 | |
| 24 | #endif /* _LINUX_ONCE_H */ |