Skip to content

Commit

Permalink
Fix test code for some compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
GJDuck committed Oct 26, 2022
1 parent d2324cc commit 46768c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fi

set -x

LD_PRELOAD=$PWD/../libredfat.so gcc -O2 -o test test.c
LD_PRELOAD=$PWD/../libredfat.so gcc -fno-builtin -O2 -o test test.c
LD_PRELOAD=$PWD/../libredfat.so ../redfat.bin -Xreads ./test
LD_PRELOAD=$PWD/../libredfat.so ./test.redfat

8 changes: 6 additions & 2 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ static __attribute__((__noinline__)) void use(size_t x)
{
asm ("": : "r"(x): "memory");
}
static __attribute__((__noinline__)) void use2(void *x)
{
asm ("": : "r"(x): "memory");
}
static __attribute__((__noinline__)) size_t unknown(size_t size)
{
return size;
Expand Down Expand Up @@ -398,12 +402,12 @@ static void memset8x8(intptr_t ptr, ssize_t offset)
static void memcpy8x8(intptr_t ptr, ssize_t offset)
{
const char mem[8] = "ABCDEFG";
memcpy((void *)(ptr + offset), mem, unknown(sizeof(mem)));
use2(memcpy((void *)(ptr + offset), mem, unknown(sizeof(mem))));
}
static void memcpy8x8f(intptr_t ptr, ssize_t offset)
{
char mem[8];
memcpy(mem, (void *)(ptr + offset), unknown(sizeof(mem)));
use2(memcpy(mem, (void *)(ptr + offset), unknown(sizeof(mem))));
}
static void memcmp8x8(intptr_t ptr, ssize_t offset)
{
Expand Down

0 comments on commit 46768c1

Please sign in to comment.