diff --git a/libwrap/sys/_exit.c b/libwrap/sys/_exit.c index 5511705..7bcaf82 100644 --- a/libwrap/sys/_exit.c +++ b/libwrap/sys/_exit.c @@ -20,14 +20,14 @@ extern void __libc_fini_array(void); void __wrap_exit(int code) { #ifndef HAVE_NO_INIT_FINI - __libc_fini_array(); + __libc_fini_array(); #endif - const char message[] = "\nProgam has exited with code:"; - write(STDERR_FILENO, message, sizeof(message) - 1); - write_hex(STDERR_FILENO, code); - write(STDERR_FILENO, "\n", 1); - tohost = (code << 1) + 1; - for (;;) - ; + const char message[] = "\nProgram has exited with code:"; + write(STDERR_FILENO, message, sizeof(message) - 1); + write_hex(STDERR_FILENO, code); + write(STDERR_FILENO, "\n", 1); + tohost = (code << 1) + 1; + for(;;) + ; } weak_under_alias(exit); diff --git a/newlib-nano/syscalls.c b/newlib-nano/syscalls.c index e43328c..828a51f 100644 --- a/newlib-nano/syscalls.c +++ b/newlib-nano/syscalls.c @@ -1,10 +1,10 @@ -#include #include +#include extern int _end; void* _sbrk(int incr); int _close(int file); -int _fstat(int file, struct stat *st); +int _fstat(int file, struct stat* st); int _isatty(int fd); int _lseek(int file, int ptr, int dir); @@ -12,68 +12,67 @@ void _kill(int pid, int sig); int _getpid(void); void write_hex(int fd, unsigned long int hex); -void *_sbrk(int incr) { - static unsigned char *heap = NULL; - unsigned char *prev_heap; - if (heap == NULL) { - heap = (unsigned char *)&_end; - } - prev_heap = heap; - heap += incr; - return prev_heap; +void* _sbrk(int incr) { + static unsigned char* heap = NULL; + unsigned char* prev_heap; + if(heap == NULL) { + heap = (unsigned char*)&_end; + } + prev_heap = heap; + heap += incr; + return prev_heap; } int _close(int file) { - (void)file; - return -1; + (void)file; + return -1; } -int _fstat(int file, struct stat *st) { - (void)file; - st->st_mode = S_IFCHR; - return 0; +int _fstat(int file, struct stat* st) { + (void)file; + st->st_mode = S_IFCHR; + return 0; } int _isatty(int fd) { - if (fd == STDOUT_FILENO || fd == STDERR_FILENO) - return 1; - return 0; + if(fd == STDOUT_FILENO || fd == STDERR_FILENO) + return 1; + return 0; } int _lseek(int file, int ptr, int dir) { - (void)file; - (void)ptr; - (void)dir; - return 0; + (void)file; + (void)ptr; + (void)dir; + return 0; } void _exit(int status) { - const char message[] = "\nProgam has exited with code:"; - write(STDERR_FILENO, message, sizeof(message) - 1); - write_hex(STDERR_FILENO, status); - write(STDERR_FILENO, "\n", 1); - for (;;); + const char message[] = "\nProgram has exited with code:"; + write(STDERR_FILENO, message, sizeof(message) - 1); + write_hex(STDERR_FILENO, status); + write(STDERR_FILENO, "\n", 1); + for(;;) + ; } void _kill(int pid, int sig) { - (void)pid; - (void)sig; - return; + (void)pid; + (void)sig; + return; } -int _getpid(void) { - return -1; -} +int _getpid(void) { return -1; } -void write_hex(int fd, unsigned long int hex){ - uint8_t ii; - uint8_t jj; - char towrite; - write(fd , "0x", 2); - for (ii = sizeof(unsigned long int) * 2 ; ii > 0; ii--) { - jj = ii - 1; - uint8_t digit = ((hex & (0xF << (jj*4))) >> (jj*4)); - towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA)); - write(fd, &towrite, 1); - } +void write_hex(int fd, unsigned long int hex) { + uint8_t ii; + uint8_t jj; + char towrite; + write(fd, "0x", 2); + for(ii = sizeof(unsigned long int) * 2; ii > 0; ii--) { + jj = ii - 1; + uint8_t digit = ((hex & (0xF << (jj * 4))) >> (jj * 4)); + towrite = digit < 0xA ? ('0' + digit) : ('A' + (digit - 0xA)); + write(fd, &towrite, 1); + } }