diff options
author | Rob Landley <rob@landley.net> | 2014-03-11 18:11:12 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-03-11 18:11:12 -0500 |
commit | a8b88fe47237028fb5314c4c572a738b967b10b7 (patch) | |
tree | 761f2a7de480cdab9a9fdc09c4a47d22fea77063 /lib | |
parent | fad38c7d1675a34a350fb1d99fb6b66728cad8a7 (diff) | |
download | toybox-a8b88fe47237028fb5314c4c572a738b967b10b7.tar.gz |
Add "volatile" annotation to peek/poke to stop potential optimizer overreach.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lib.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -314,16 +314,16 @@ void msleep(long miliseconds) int64_t peek(void *ptr, int size) { if (size & 8) { - int64_t *p = (int64_t *)ptr; + volatile int64_t *p = (int64_t *)ptr; return *p; } else if (size & 4) { - int *p = (int *)ptr; + volatile int *p = (int *)ptr; return *p; } else if (size & 2) { - short *p = (short *)ptr; + volatile short *p = (short *)ptr; return *p; } else { - char *p = (char *)ptr; + volatile char *p = (char *)ptr; return *p; } } @@ -331,16 +331,16 @@ int64_t peek(void *ptr, int size) void poke(void *ptr, uint64_t val, int size) { if (size & 8) { - uint64_t *p = (uint64_t *)ptr; + volatile uint64_t *p = (uint64_t *)ptr; *p = val; } else if (size & 4) { - int *p = (int *)ptr; + volatile int *p = (int *)ptr; *p = val; } else if (size & 2) { - short *p = (short *)ptr; + volatile short *p = (short *)ptr; *p = val; } else { - char *p = (char *)ptr; + volatile char *p = (char *)ptr; *p = val; } } |