Compare commits

..

No commits in common. "f50017912d6aea11802821f3171c2f987c288d2e" and "b1739f7f0db32ce2213f49b89514fcd1819d1595" have entirely different histories.

2 changed files with 5 additions and 51 deletions

View File

@ -15,20 +15,11 @@ extern "C"
/* Normally exits the program with the specified status code. */
__lc_noreturn void exit(int status);
/* Abnormally exits the program with the specified status code. */
__lc_noreturn void _Exit(int status);
/* Registers a handler function to be run at normal program termination. */
int atexit(void (*handler)(void));
/* Returns an integer (of type int) parsed from the string str. */
int atoi(const char* str);
/* Returns an integer (of type long) parsed from the string str. */
long atol(const char* str);
/* Returns an integer (of type long long) parsed from the string str. */
long long atoll(const char* str);
/* Not implemented.*/
int atoi(const char*);
/* Not implemented. */
char* getenv(const char*);

View File

@ -1,59 +1,22 @@
#include <ctype.h>
#include <luna.h>
#include <stdlib.h>
#include <sys/syscall.h>
#include <unistd.h>
template <typename T> T string_to_integer_type(const char* str)
{
bool neg = false;
T val = 0;
switch (*str)
{
case '-':
neg = true;
str++;
break;
case '+': str++; break;
default: break;
}
while (isdigit(*str)) { val = (10 * val) + (*str++ - '0'); }
return (neg ? -val : val);
}
extern "C"
{
__lc_noreturn void abort()
{
_Exit(-1);
_exit(-1);
}
int atoi(const char* str)
int atoi(const char*)
{
return string_to_integer_type<int>(str);
}
long atol(const char* str)
{
return string_to_integer_type<long>(str);
}
long long atoll(const char* str)
{
return string_to_integer_type<long long>(str);
NOT_IMPLEMENTED("atoi");
}
char* getenv(const char*)
{
NOT_IMPLEMENTED("getenv");
}
__lc_noreturn void _Exit(int status)
{
syscall(SYS_exit, status);
__lc_unreachable();
}
}