1b3e94a20d
From release 0.1.0 pre-patched archive. This includes all Red Bear modifications previously maintained as patches in local/patches/relibc/.
25 lines
506 B
C
25 lines
506 B
C
#ifndef _COMMON_H
|
|
#define _COMMON_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int fail(int status, const char *reason) {
|
|
fprintf(stderr, "%s failed: %s\n", reason, strerror(status));
|
|
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
uintptr_t black_box_uintptr_t(uintptr_t arg) {
|
|
// Rust implements this by putting the value behind a volatile pointer and then simply loading it.
|
|
|
|
uintptr_t arg_slot = arg;
|
|
volatile uintptr_t *ptr = &arg_slot;
|
|
|
|
return *ptr;
|
|
}
|
|
|
|
#endif // _COMMON_H
|