Inline function
| Space | User/kernel |
| Context | Sync/async |
| May block | No |
| SPL | Any |
| Dynamic memory | No |
#include <SPAD/BARRIER_PTR.H>
static __finline__ void __barrier_ptr(void *p); This function has the same effect as __barrier and additionally it invalidates optimizations pointer p. The purpose of this function is to defeat aliasing optimizations in C99.
__u32 p;
__u16 q;
p = 0x12345678;
__barrier_ptr(&p);
q = *(__u16 *)p;
Note that without __barrier_ptr the compiler can reorder these two assignments according to C99, because they touch memory with different types.
C99 has special exception for char types. If one of these types were char, __u8 or __s8, __barrier_ptr would be unnecessary.