Interface __barrier_ptr

Inline function

SpaceUser/kernel
ContextSync/async
May blockNo
SPLAny
Dynamic memoryNo

#include <SPAD/BARRIER_PTR.H>

static __finline__ void __barrier_ptr(void *p);

Description

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.

Arguments

Example

__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.

See also

__barrier