X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcfg%2Fcompiler.h;h=c2e814e522e0be69086eb447ef7442d81ced9d51;hb=620a5af8d34e5e7e9fc902eb46537faa479411f4;hp=0121b96367fe067cc98ba9a92004356c05ef56a5;hpb=48586b4fc3e575029a88ab37930c8a0e723ca99d;p=bertos.git diff --git a/bertos/cfg/compiler.h b/bertos/cfg/compiler.h index 0121b963..c2e814e5 100644 --- a/bertos/cfg/compiler.h +++ b/bertos/cfg/compiler.h @@ -603,4 +603,11 @@ typedef unsigned char sigmask_t; /**< Type for signal masks. */ do { (void)(&(var) == (type *)0); } while(0) #endif +/** + * Prevent the compiler from optimizing access to the variable \a x, enforcing + * a refetch from memory. This also forbid from reordering successing instances + * of ACCESS_SAFE(). + */ +#define ACCESS_SAFE(x) (*(volatile typeof(x) *)&(x)) + #endif /* BERTOS_COMPILER_H */