diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-04-20 15:34:56 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-04-20 15:43:06 -0600 |
commit | 8c0c96c5ced30d03454e3a1af20223585b3cf8db (patch) | |
tree | 31bc67639f755f18377e62b1a856d70fa82c54d8 /src/support.h | |
parent | global: move siphash helper out of support (diff) | |
download | wireguard-freebsd-8c0c96c5ced30d03454e3a1af20223585b3cf8db.tar.xz wireguard-freebsd-8c0c96c5ced30d03454e3a1af20223585b3cf8db.zip |
global: use ck for loads/stores, rather than macro maze
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/support.h')
-rw-r--r-- | src/support.h | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/support.h b/src/support.h index 041ffc3..5eff4fb 100644 --- a/src/support.h +++ b/src/support.h @@ -57,6 +57,15 @@ MALLOC_DECLARE(M_WG); #define IFT_WIREGUARD IFT_PPP #endif +#ifndef ck_pr_store_bool +#define ck_pr_store_bool(dst, val) ck_pr_store_8((uint8_t *)(dst), (uint8_t)(val)) +#endif + +#ifndef ck_pr_load_bool +#define ck_pr_load_bool(src) ((bool)ck_pr_load_8((uint8_t *)(src))) +#endif + + static inline int sogetsockaddr(struct socket *so, struct sockaddr **nam) { @@ -68,25 +77,4 @@ sogetsockaddr(struct socket *so, struct sockaddr **nam) return (error); } -/* These are defined in sys/compat/linuxkpi/common/include/linux/compiler.h, - * however I don't really want to include all that. */ -#define barrier() __asm__ __volatile__("": : :"memory") - -#define ACCESS_ONCE(x) (*(volatile __typeof(x) *)&(x)) - -#define WRITE_ONCE(x,v) do { \ - barrier(); \ - ACCESS_ONCE(x) = (v); \ - barrier(); \ -} while (0) - -#define READ_ONCE(x) ({ \ - __typeof(x) __var = ({ \ - barrier(); \ - ACCESS_ONCE(x); \ - }); \ - barrier(); \ - __var; \ -}) - #endif |