29 lines
1010 B
C
29 lines
1010 B
C
typedef unsigned long size_t;
|
|
void *memcpy(void *restrict d, const void *restrict s, size_t n);
|
|
void *memset(void *d, int c, size_t n);
|
|
int memcmp(const void *l, const void *r, size_t n);
|
|
size_t strlen(const char *s);
|
|
int strcmp(const char *l, const char *r);
|
|
|
|
void _start(void)
|
|
{
|
|
int code = 0;
|
|
char src[] = "hello world", dst[64];
|
|
memcpy(dst, src, 12); dst[12] = 0;
|
|
if (strcmp(dst, "hello world") != 0) code = 1;
|
|
else if (strlen("") != 0) code = 2;
|
|
else if (strlen("abc") != 3) code = 3;
|
|
else {
|
|
char buf[10];
|
|
memset(buf, 0xAB, 10);
|
|
for (int i = 0; i < 10; i++)
|
|
if ((unsigned char)buf[i] != 0xAB) { code = 4; break; }
|
|
}
|
|
if (code == 0 && memcmp("abc", "abc", 3) != 0) code = 5;
|
|
if (code == 0 && memcmp("abc", "abd", 3) >= 0) code = 6;
|
|
if (code == 0 && strcmp("hello", "hello") != 0) code = 7;
|
|
if (code == 0 && strcmp("abc", "def") >= 0) code = 8;
|
|
|
|
__asm__ volatile ("mov $60, %%eax\n syscall" : : "D"(code) : "rax");
|
|
}
|