Compare commits
12 Commits
033c41cbd7
...
d1dea3f1d6
Author | SHA1 | Date | |
---|---|---|---|
d1dea3f1d6 | |||
b6f2b41f1f | |||
61753a6f51 | |||
57ef8feddb | |||
0bfe5e27ef | |||
d3030d2111 | |||
da4c0d5184 | |||
f8f5968753 | |||
1300b8f5ee | |||
bbc7a7338c | |||
59e03d0799 | |||
accf7ee417 |
@ -1,24 +1,32 @@
|
||||
APPS := init sh uname uptime hello ps ls args cat stat su session date mkdir screen
|
||||
C_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_SRC := $(APPS_DIR)/src
|
||||
APPS_BIN := $(APPS_DIR)/bin
|
||||
|
||||
REAL_APPS := $(patsubst %, $(APPS_BIN)/%, $(APPS))
|
||||
C_APPS_PATH := $(patsubst %, $(APPS_BIN)/%, $(C_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
|
||||
CXXFLAGS := -fno-exceptions
|
||||
|
||||
$(APPS_BIN)/%: $(APPS_SRC)/%.c
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) $(CFLAGS) -o $@ $^
|
||||
@echo " CC $^"
|
||||
|
||||
build: $(REAL_APPS)
|
||||
$(APPS_BIN)/%: $(APPS_SRC)/%.cpp
|
||||
@mkdir -p $(@D)
|
||||
@$(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ $^
|
||||
@echo " CXX $^"
|
||||
|
||||
install: $(REAL_APPS)
|
||||
build: $(C_APPS_PATH) $(CXX_APPS_PATH)
|
||||
|
||||
install: $(C_APPS_PATH) $(CXX_APPS_PATH)
|
||||
@mkdir -p $(LUNA_ROOT)/initrd/bin
|
||||
@cp $(REAL_APPS) $(LUNA_ROOT)/initrd/bin
|
||||
@echo " INSTALL $(REAL_APPS)"
|
||||
@cp $(C_APPS_PATH) $(CXX_APPS_PATH) $(LUNA_ROOT)/initrd/bin
|
||||
@echo " INSTALL $(C_APPS_PATH) $(CXX_APPS_PATH)"
|
||||
@chmod a+s $(LUNA_ROOT)/initrd/bin/su
|
||||
|
||||
clean:
|
||||
|
6
apps/src/hello-cpp.cpp
Normal file
6
apps/src/hello-cpp.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include <cstdio>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Well hello world!\n");
|
||||
}
|
@ -13,7 +13,8 @@ struct stat // FIXME: This struct is quite stubbed out.
|
||||
ino_t st_ino;
|
||||
mode_t st_mode;
|
||||
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;
|
||||
gid_t st_gid;
|
||||
time_t st_atime;
|
||||
@ -37,6 +38,8 @@ void do_stat(Context* context, VFS::Node* node, struct stat* buf)
|
||||
kstat->st_atime = node->atime;
|
||||
kstat->st_ctime = node->ctime;
|
||||
kstat->st_mtime = node->mtime;
|
||||
kstat->st_dev = 0;
|
||||
kstat->st_nlink = 0;
|
||||
release_user_ref(kstat);
|
||||
context->rax = 0;
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ build: $(LIBC_BIN)/crt0.o $(LIBC_BIN)/crti.o $(LIBC_BIN)/crtn.o $(LIBC_BIN)/libc
|
||||
$(DESTDIR)/libc.a: $(LIBC_BIN)/libc.a
|
||||
@mkdir -p $(@D)
|
||||
@cp $^ $@
|
||||
@rm -f $(DESTDIR)/libm.a
|
||||
@ln -s $@ $(DESTDIR)/libm.a
|
||||
@echo " INSTALL $^"
|
||||
|
||||
$(DESTDIR)/crt0.o: $(LIBC_BIN)/crt0.o
|
||||
|
@ -14,6 +14,15 @@ struct dirent
|
||||
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. */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ extern int errno;
|
||||
#define ENOTEMPTY 39 // Directory not empty. Not implemented.
|
||||
#define ELOOP 40 // Too many levels of symbolic links. 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 ENOTSOCK 88 // Socket operation on non-socket. Not implemented.
|
||||
#define ENOTSUP 95 // Operation not supported
|
||||
@ -57,23 +58,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.
|
||||
#define EADDRNOTAVAIL -1
|
||||
#define EAFNOSUPPORT -1
|
||||
#define ECONNABORTED -1
|
||||
#define ECONNREFUSED -1
|
||||
#define EDESTADDRREQ -1
|
||||
#define EHOSTUNREACH -1
|
||||
#define EINPROGRESS -1
|
||||
#define EMSGSIZE -1
|
||||
#define ENETDOWN -1
|
||||
#define ENETRESET -1
|
||||
#define ENETUNREACH -1
|
||||
#define ENOBUFS -1
|
||||
#define ENOMSG -1
|
||||
#define ENOPROTOOPT -1
|
||||
#define ENOTCONN -1
|
||||
#define ENOTSOCK -1
|
||||
#define EPROTONOSUPPORT -1
|
||||
#define EPROTOTYPE -1
|
||||
#define EAFNOSUPPORT -2
|
||||
#define ECONNABORTED -3
|
||||
#define ECONNREFUSED -4
|
||||
#define EDESTADDRREQ -5
|
||||
#define EHOSTUNREACH -6
|
||||
#define EINPROGRESS -7
|
||||
#define EMSGSIZE -8
|
||||
#define ENETDOWN -9
|
||||
#define ENETRESET -10
|
||||
#define ENETUNREACH -11
|
||||
#define ENOBUFS -12
|
||||
#define ENOMSG -13
|
||||
#define ENOPROTOOPT -14
|
||||
#define ENOTCONN -15
|
||||
#define ENOTSOCK -16
|
||||
#define EPROTONOSUPPORT -17
|
||||
#define EPROTOTYPE -18
|
||||
|
||||
#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. */
|
||||
|
@ -5,13 +5,42 @@
|
||||
#define LC_CTYPE 1
|
||||
#define LC_COLLATE 2
|
||||
#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
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
char* setlocale(int category, const char* locale); // Not implemented.
|
||||
/* Set or query the current locale. */
|
||||
char* setlocale(int category, const char* locale);
|
||||
|
||||
/* Retrieve numeric formatting information for the current locale. */
|
||||
struct lconv* localeconv(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -4,6 +4,13 @@
|
||||
typedef float float_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
|
||||
extern "C"
|
||||
{
|
||||
|
@ -6,4 +6,16 @@ typedef int sig_atomic_t; // On the x86, writes to aligned 32-bit and 64-bit int
|
||||
|
||||
#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
|
@ -63,6 +63,8 @@ extern "C"
|
||||
/* Returns an integer (of type unsigned long) parsed from the string str. */
|
||||
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. */
|
||||
long strtol(const char* str, char** endptr, int base);
|
||||
|
||||
|
@ -91,6 +91,8 @@ extern "C"
|
||||
__lc_deprecated("strcat is unsafe and should not be used; use strncat instead") char* strcat(char* dest,
|
||||
const char* src);
|
||||
|
||||
char* strtok(char* str, const char* delim); // Not implemented.
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -9,7 +9,8 @@ struct stat // FIXME: This struct is quite stubbed out.
|
||||
ino_t st_ino;
|
||||
mode_t st_mode;
|
||||
off_t st_size;
|
||||
int st_dev; // Not implemented.
|
||||
int st_dev; // Not implemented.
|
||||
int st_nlink; // Not implemented.
|
||||
uid_t st_uid;
|
||||
gid_t st_gid;
|
||||
time_t st_atime;
|
||||
@ -35,6 +36,10 @@ struct stat // FIXME: This struct is quite stubbed out.
|
||||
/* Is it a character device? */
|
||||
#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_IRUSR 0400
|
||||
#define S_IWUSR 0200
|
||||
|
50
libs/libc/src/cxxabi.cpp
Normal file
50
libs/libc/src/cxxabi.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ extern "C"
|
||||
result.d_ino = ent.inode;
|
||||
result.d_reclen = sizeof(result);
|
||||
result.d_off = ent.offset;
|
||||
result.d_type = 0;
|
||||
result.d_type = DT_UNKNOWN;
|
||||
strlcpy(result.d_name, ent.name, NAME_MAX);
|
||||
return &result;
|
||||
}
|
||||
|
@ -1,12 +1,25 @@
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <luna.h>
|
||||
|
||||
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"
|
||||
{
|
||||
char* setlocale(int, const char*)
|
||||
{
|
||||
return default_locale;
|
||||
}
|
||||
|
||||
struct lconv* localeconv(void)
|
||||
{
|
||||
return &default_lconv;
|
||||
}
|
||||
}
|
15
libs/libc/src/signal.cpp
Normal file
15
libs/libc/src/signal.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include <luna.h>
|
||||
#include <signal.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void (*signal(int, void (*)(int)))(int)
|
||||
{
|
||||
NOT_IMPLEMENTED("signal");
|
||||
}
|
||||
|
||||
int raise(int)
|
||||
{
|
||||
NOT_IMPLEMENTED("raise");
|
||||
}
|
||||
}
|
@ -303,4 +303,9 @@ extern "C"
|
||||
if (errno) return NULL;
|
||||
return str;
|
||||
}
|
||||
|
||||
double strtod(const char*, char**)
|
||||
{
|
||||
NOT_IMPLEMENTED("strtod");
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include <errno.h>
|
||||
#include <luna.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -295,4 +296,9 @@ extern "C"
|
||||
}
|
||||
|
||||
#pragma GCC pop_options
|
||||
|
||||
char* strtok(char*, const char*)
|
||||
{
|
||||
NOT_IMPLEMENTED("strtok");
|
||||
}
|
||||
}
|
@ -57,4 +57,13 @@ make all-target-libgcc -j$(nproc) CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-
|
||||
echo Installing GCC...
|
||||
|
||||
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"
|
Loading…
Reference in New Issue
Block a user