Compare commits

..

No commits in common. "d1dea3f1d60ee85c4d0919c880a7a0a76247969a" and "033c41cbd79e4f7474f099d0543ee73ce5a772bf" have entirely different histories.

19 changed files with 28 additions and 212 deletions

View File

@ -1,32 +1,24 @@
C_APPS := init sh uname uptime hello ps ls args cat stat su session date mkdir screen APPS := init sh uname uptime hello ps ls args cat stat su session date mkdir screen
CXX_APPS := hello-cpp
APPS_DIR := $(LUNA_ROOT)/apps APPS_DIR := $(LUNA_ROOT)/apps
APPS_SRC := $(APPS_DIR)/src APPS_SRC := $(APPS_DIR)/src
APPS_BIN := $(APPS_DIR)/bin APPS_BIN := $(APPS_DIR)/bin
C_APPS_PATH := $(patsubst %, $(APPS_BIN)/%, $(C_APPS)) REAL_APPS := $(patsubst %, $(APPS_BIN)/%, $(APPS))
CXX_APPS_PATH := $(patsubst %, $(APPS_BIN)/%, $(CXX_APPS))
CFLAGS := -Wall -Wextra -Werror -Os -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -Wl,--gc-sections CFLAGS := -Wall -Wextra -Werror -Os -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -Wl,--gc-sections
CXXFLAGS := -fno-exceptions
$(APPS_BIN)/%: $(APPS_SRC)/%.c $(APPS_BIN)/%: $(APPS_SRC)/%.c
@mkdir -p $(@D) @mkdir -p $(@D)
@$(CC) $(CFLAGS) -o $@ $^ @$(CC) $(CFLAGS) -o $@ $^
@echo " CC $^" @echo " CC $^"
$(APPS_BIN)/%: $(APPS_SRC)/%.cpp build: $(REAL_APPS)
@mkdir -p $(@D)
@$(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ $^
@echo " CXX $^"
build: $(C_APPS_PATH) $(CXX_APPS_PATH) install: $(REAL_APPS)
install: $(C_APPS_PATH) $(CXX_APPS_PATH)
@mkdir -p $(LUNA_ROOT)/initrd/bin @mkdir -p $(LUNA_ROOT)/initrd/bin
@cp $(C_APPS_PATH) $(CXX_APPS_PATH) $(LUNA_ROOT)/initrd/bin @cp $(REAL_APPS) $(LUNA_ROOT)/initrd/bin
@echo " INSTALL $(C_APPS_PATH) $(CXX_APPS_PATH)" @echo " INSTALL $(REAL_APPS)"
@chmod a+s $(LUNA_ROOT)/initrd/bin/su @chmod a+s $(LUNA_ROOT)/initrd/bin/su
clean: clean:

View File

@ -1,6 +0,0 @@
#include <cstdio>
int main()
{
printf("Well hello world!\n");
}

View File

@ -13,8 +13,7 @@ struct stat // FIXME: This struct is quite stubbed out.
ino_t st_ino; ino_t st_ino;
mode_t st_mode; mode_t st_mode;
off_t st_size; off_t st_size;
int st_dev; // FIXME: Implement this. int st_dev; // FIXME: Implement this.
int st_nlink; // FIXME: Implement this.
uid_t st_uid; uid_t st_uid;
gid_t st_gid; gid_t st_gid;
time_t st_atime; time_t st_atime;
@ -38,8 +37,6 @@ void do_stat(Context* context, VFS::Node* node, struct stat* buf)
kstat->st_atime = node->atime; kstat->st_atime = node->atime;
kstat->st_ctime = node->ctime; kstat->st_ctime = node->ctime;
kstat->st_mtime = node->mtime; kstat->st_mtime = node->mtime;
kstat->st_dev = 0;
kstat->st_nlink = 0;
release_user_ref(kstat); release_user_ref(kstat);
context->rax = 0; context->rax = 0;
} }

View File

@ -59,8 +59,6 @@ build: $(LIBC_BIN)/crt0.o $(LIBC_BIN)/crti.o $(LIBC_BIN)/crtn.o $(LIBC_BIN)/libc
$(DESTDIR)/libc.a: $(LIBC_BIN)/libc.a $(DESTDIR)/libc.a: $(LIBC_BIN)/libc.a
@mkdir -p $(@D) @mkdir -p $(@D)
@cp $^ $@ @cp $^ $@
@rm -f $(DESTDIR)/libm.a
@ln -s $@ $(DESTDIR)/libm.a
@echo " INSTALL $^" @echo " INSTALL $^"
$(DESTDIR)/crt0.o: $(LIBC_BIN)/crt0.o $(DESTDIR)/crt0.o: $(LIBC_BIN)/crt0.o

View File

@ -14,15 +14,6 @@ struct dirent
char d_name[NAME_MAX]; char d_name[NAME_MAX];
}; };
#define DT_BLK 1 // This is a block device.
#define DT_CHR 2 // This is a character device.
#define DT_DIR 3 // This is a directory.
#define DT_FIFO 4 // This is a named pipe (FIFO).
#define DT_LNK 5 // This is a symbolic link.
#define DT_REG 6 // This is a regular file.
#define DT_SOCK 7 // This is a UNIX domain socket.
#define DT_UNKNOWN 0 // The file type could not be determined.
/* A stream representing a directory. */ /* A stream representing a directory. */
typedef struct typedef struct
{ {

View File

@ -44,7 +44,6 @@ extern int errno;
#define ENOTEMPTY 39 // Directory not empty. Not implemented. #define ENOTEMPTY 39 // Directory not empty. Not implemented.
#define ELOOP 40 // Too many levels of symbolic links. Not implemented. #define ELOOP 40 // Too many levels of symbolic links. Not implemented.
#define ENOMSG 42 // No message of desired type. Not implemented. #define ENOMSG 42 // No message of desired type. Not implemented.
#define EOVERFLOW 75 // Value too large for defined data type. Not implemented.
#define EILSEQ 84 // Invalid or incomplete multibyte or wide character. Not implemented. #define EILSEQ 84 // Invalid or incomplete multibyte or wide character. Not implemented.
#define ENOTSOCK 88 // Socket operation on non-socket. Not implemented. #define ENOTSOCK 88 // Socket operation on non-socket. Not implemented.
#define ENOTSUP 95 // Operation not supported #define ENOTSUP 95 // Operation not supported
@ -58,23 +57,23 @@ extern int errno;
// FIXME: Right now I don't want to have to order and label these, since we have no net support anyways. // FIXME: Right now I don't want to have to order and label these, since we have no net support anyways.
#define EADDRNOTAVAIL -1 #define EADDRNOTAVAIL -1
#define EAFNOSUPPORT -2 #define EAFNOSUPPORT -1
#define ECONNABORTED -3 #define ECONNABORTED -1
#define ECONNREFUSED -4 #define ECONNREFUSED -1
#define EDESTADDRREQ -5 #define EDESTADDRREQ -1
#define EHOSTUNREACH -6 #define EHOSTUNREACH -1
#define EINPROGRESS -7 #define EINPROGRESS -1
#define EMSGSIZE -8 #define EMSGSIZE -1
#define ENETDOWN -9 #define ENETDOWN -1
#define ENETRESET -10 #define ENETRESET -1
#define ENETUNREACH -11 #define ENETUNREACH -1
#define ENOBUFS -12 #define ENOBUFS -1
#define ENOMSG -13 #define ENOMSG -1
#define ENOPROTOOPT -14 #define ENOPROTOOPT -1
#define ENOTCONN -15 #define ENOTCONN -1
#define ENOTSOCK -16 #define ENOTSOCK -1
#define EPROTONOSUPPORT -17 #define EPROTONOSUPPORT -1
#define EPROTOTYPE -18 #define EPROTOTYPE -1
#ifdef _GNU_SOURCE // Give it only to programs that ask for it. #ifdef _GNU_SOURCE // Give it only to programs that ask for it.
/* Name used to invoke calling program. Same value as argv[0] in main(), but can be used globally. */ /* Name used to invoke calling program. Same value as argv[0] in main(), but can be used globally. */

View File

@ -5,42 +5,13 @@
#define LC_CTYPE 1 #define LC_CTYPE 1
#define LC_COLLATE 2 #define LC_COLLATE 2
#define LC_NUMERIC 3 #define LC_NUMERIC 3
#define LC_MONETARY 4
#define LC_TIME 5
/* Structure representing numeric formatting information for the current locale. */
struct lconv
{
char* decimal_point;
char* thousands_sep;
char* grouping;
char* int_curr_symbol;
char* currency_symbol;
char* mon_decimal_point;
char* mon_thousands_sep;
char* mon_grouping;
char* positive_sign;
char* negative_sign;
char int_frac_digits;
char frac_digits;
char p_cs_precedes;
char p_sep_by_space;
char n_cs_precedes;
char n_sep_by_space;
char p_sign_posn;
char n_sign_posn;
};
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
/* Set or query the current locale. */ char* setlocale(int category, const char* locale); // Not implemented.
char* setlocale(int category, const char* locale);
/* Retrieve numeric formatting information for the current locale. */
struct lconv* localeconv(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -4,13 +4,6 @@
typedef float float_t; typedef float float_t;
typedef double double_t; typedef double double_t;
#define FP_NAN 0
#define FP_INFINITE 1
#define FP_ZERO 2
#define FP_SUBNORMAL 3
#define FP_NORMAL 4
#define fpclassify(x) __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_ZERO, x)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {

View File

@ -6,16 +6,4 @@ typedef int sig_atomic_t; // On the x86, writes to aligned 32-bit and 64-bit int
#define SIGINT 1 // Not implemented. #define SIGINT 1 // Not implemented.
#ifdef __cplusplus
extern "C"
{
#endif
void (*signal(int sig, void (*func)(int)))(int); // Not implemented.
int raise(int sig); // Not implemented.
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@ -63,8 +63,6 @@ extern "C"
/* Returns an integer (of type unsigned long) parsed from the string str. */ /* Returns an integer (of type unsigned long) parsed from the string str. */
unsigned long strtoul(const char* str, char** endptr, int base); unsigned long strtoul(const char* str, char** endptr, int base);
double strtod(const char* str, char** endptr); // Not implemented.
/* Returns an integer (of type long) parsed from the string str. */ /* Returns an integer (of type long) parsed from the string str. */
long strtol(const char* str, char** endptr, int base); long strtol(const char* str, char** endptr, int base);

View File

@ -91,8 +91,6 @@ extern "C"
__lc_deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char* dest, __lc_deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char* dest,
const char* src); const char* src);
char* strtok(char* str, const char* delim); // Not implemented.
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -9,8 +9,7 @@ struct stat // FIXME: This struct is quite stubbed out.
ino_t st_ino; ino_t st_ino;
mode_t st_mode; mode_t st_mode;
off_t st_size; off_t st_size;
int st_dev; // Not implemented. int st_dev; // Not implemented.
int st_nlink; // Not implemented.
uid_t st_uid; uid_t st_uid;
gid_t st_gid; gid_t st_gid;
time_t st_atime; time_t st_atime;
@ -36,10 +35,6 @@ struct stat // FIXME: This struct is quite stubbed out.
/* Is it a character device? */ /* Is it a character device? */
#define S_ISCHR(mode) (__S_IFCMP((mode), S_IFCHR)) #define S_ISCHR(mode) (__S_IFCMP((mode), S_IFCHR))
// Not implemented.
#define S_ISBLK(mode) ((mode)&0)
#define S_ISFIFO(mode) ((mode)&0)
#define S_IRWXU 0700 #define S_IRWXU 0700
#define S_IRUSR 0400 #define S_IRUSR 0400
#define S_IWUSR 0200 #define S_IWUSR 0200

View File

@ -1,50 +0,0 @@
typedef void* (*cxa_atexit_func_t)(void*);
struct cxa_atexit_entry
{
cxa_atexit_func_t function;
void* argument;
void* dso_handle;
};
#define CXA_ATEXIT_MAX 64
int cxa_atexit_entry_count = 0;
cxa_atexit_entry cxa_atexit_entries[CXA_ATEXIT_MAX];
extern "C"
{
int __cxa_atexit(cxa_atexit_func_t func, void* arg, void* dso)
{
if (cxa_atexit_entry_count >= CXA_ATEXIT_MAX) return -1;
cxa_atexit_entries[cxa_atexit_entry_count].function = func;
cxa_atexit_entries[cxa_atexit_entry_count].argument = arg;
cxa_atexit_entries[cxa_atexit_entry_count].dso_handle = dso;
cxa_atexit_entry_count++;
return 0;
}
void __cxa_finalize(void* f)
{
int i = cxa_atexit_entry_count;
if (!f)
{
while (i--)
{
if (cxa_atexit_entries[i].function) { cxa_atexit_entries[i].function(cxa_atexit_entries[i].argument); }
}
}
else
{
while (i--)
{
if (cxa_atexit_entries[i].function == (cxa_atexit_func_t)f)
{
cxa_atexit_entries[i].function(cxa_atexit_entries[i].argument);
cxa_atexit_entries[i].function = 0;
}
}
}
}
}

View File

@ -46,7 +46,7 @@ extern "C"
result.d_ino = ent.inode; result.d_ino = ent.inode;
result.d_reclen = sizeof(result); result.d_reclen = sizeof(result);
result.d_off = ent.offset; result.d_off = ent.offset;
result.d_type = DT_UNKNOWN; result.d_type = 0;
strlcpy(result.d_name, ent.name, NAME_MAX); strlcpy(result.d_name, ent.name, NAME_MAX);
return &result; return &result;
} }

View File

@ -1,25 +1,12 @@
#include <limits.h>
#include <locale.h> #include <locale.h>
#include <luna.h> #include <luna.h>
static char default_locale[] = "C"; static char default_locale[] = "C";
static char dot[] = ".";
static char empty[] = "";
static struct lconv default_lconv = {dot, empty, empty, empty, empty, empty,
empty, empty, empty, empty, CHAR_MAX, CHAR_MAX,
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX};
extern "C" extern "C"
{ {
char* setlocale(int, const char*) char* setlocale(int, const char*)
{ {
return default_locale; return default_locale;
} }
struct lconv* localeconv(void)
{
return &default_lconv;
}
} }

View File

@ -1,15 +0,0 @@
#include <luna.h>
#include <signal.h>
extern "C"
{
void (*signal(int, void (*)(int)))(int)
{
NOT_IMPLEMENTED("signal");
}
int raise(int)
{
NOT_IMPLEMENTED("raise");
}
}

View File

@ -303,9 +303,4 @@ extern "C"
if (errno) return NULL; if (errno) return NULL;
return str; return str;
} }
double strtod(const char*, char**)
{
NOT_IMPLEMENTED("strtod");
}
} }

View File

@ -1,5 +1,4 @@
#include <errno.h> #include <errno.h>
#include <luna.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -296,9 +295,4 @@ extern "C"
} }
#pragma GCC pop_options #pragma GCC pop_options
char* strtok(char*, const char*)
{
NOT_IMPLEMENTED("strtok");
}
} }

View File

@ -57,13 +57,4 @@ make all-target-libgcc -j$(nproc) CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-
echo Installing GCC... echo Installing GCC...
make install-gcc | filter-lines "gcc" "install" make install-gcc | filter-lines "gcc" "install"
make install-target-libgcc | filter-lines "libgcc" "install" make install-target-libgcc | filter-lines "libgcc" "install"
echo Building libstdc++...
$LUNA_ROOT/tools/sync-libc.sh # libstdc++ needs libc to be built
make all-target-libstdc++v3 -j$(nproc) | filter-lines "libstdc++" "build"
echo Installing libstdc++...
make install-target-libstdc++v3 | filter-lines "libstdc++" "install"