Add build test
This commit is contained in:
48
buildtest.c
Normal file
48
buildtest.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#include <stdint.h>
|
||||
#include "sys.h"
|
||||
|
||||
|
||||
int main() {
|
||||
#if defined(__x86_64__) || defined(__aarch64__) || defined(__mips__)
|
||||
uint64_t pid = fork();
|
||||
char msg[17] = {' '};
|
||||
msg[16] = '\n';
|
||||
for(int i = 0; i < 16; ++i) {
|
||||
char nibble = (pid >> ((15 - i) * 4)) & 0xf;
|
||||
char c;
|
||||
if (nibble > 9) {c = nibble + '7';}
|
||||
else {c = nibble + '0';}
|
||||
msg[i] = c;
|
||||
}
|
||||
write(STDIO, msg, 17);
|
||||
#else
|
||||
char *msg = "Hello World!\n";
|
||||
write(STDIO, msg, 13);
|
||||
#endif
|
||||
return 69;
|
||||
}
|
||||
void __libc_start_main() {exit(main());}
|
||||
|
||||
void _start() {
|
||||
__libc_start_main();
|
||||
}
|
||||
|
||||
void __start() {
|
||||
_start();
|
||||
}
|
||||
/*
|
||||
#if defined(__x86_64__)
|
||||
printf("Compiled for x86_64 architecture\n");
|
||||
#elif defined(__i386__)
|
||||
printf("Compiled for x86 architecture\n");
|
||||
#elif defined(__arm__)
|
||||
printf("Compiled for ARM architecture\n");
|
||||
#elif defined(__aarch64__)
|
||||
printf("Compiled for ARM64 architecture\n");
|
||||
#elif defined(__mips__)
|
||||
printf("Compiled for ARM architecture\n");
|
||||
#else
|
||||
printf("Unknown architecture\n");
|
||||
#endif
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user