aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-03-11 18:11:12 -0500
committerRob Landley <rob@landley.net>2014-03-11 18:11:12 -0500
commita8b88fe47237028fb5314c4c572a738b967b10b7 (patch)
tree761f2a7de480cdab9a9fdc09c4a47d22fea77063 /lib/lib.c
parentfad38c7d1675a34a350fb1d99fb6b66728cad8a7 (diff)
downloadtoybox-a8b88fe47237028fb5314c4c572a738b967b10b7.tar.gz
Add "volatile" annotation to peek/poke to stop potential optimizer overreach.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/lib.c b/lib/lib.c
index a8195dd4..7a3ada4a 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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;
}
}