nullplan wrote:Well, what does happen? Have you asked a debugger? Is it possible the memset just takes a while?
Yeah that would be nice to know.
The code looks reasonable enough, except of course for the fact that you don't have the four mem* functions GCC requires even in freestanding mode. You must have an implementation of memset(), memcpy(), memcmp(), and memmove(). You only have memory_set(), which isn't the same.
That's not entirely true. First without a memset() implementation the code wouldn't compile and link in the first place. Second, gcc has a
dirty, totally libgcc independent hack for the mem functions (which works in freestanding mode too), it includes the __builtin_memset() in the final executable if memset() implementation otherwise not found. This is highly non-standard, and for example Clang doesn't do it.
The ISO C90 functions abort, abs, acos, asin, atan2, atan, calloc, ceil, cosh, cos, exit, exp, fabs, floor, fmod, fprintf, fputs, frexp, fscanf, isalnum, isalpha, iscntrl, isdigit, isgraph, islower, isprint, ispunct, isspace, isupper, isxdigit, tolower, toupper, labs, ldexp, log10, log, malloc, memchr, memcmp, memcpy, memset, modf, pow, printf, putchar, puts, scanf, sinh, sin, snprintf, sprintf, sqrt, sscanf, strcat, strchr, strcmp, strcpy, strcspn, strlen, strncat, strncmp, strncpy, strpbrk, strrchr, strspn, strstr, tanh, tan, vfprintf, vprintf and vsprintf are all recognized as built-in functions unless -fno-builtin is specified (or -fno-builtin-function is specified for an individual function). All of these functions have corresponding versions prefixed with __builtin_.
Cheers,
bzt