diff --git a/crosscompilemakefile.mak b/crosscompilemakefile.mak index 6ba47887..a1ce9423 100644 --- a/crosscompilemakefile.mak +++ b/crosscompilemakefile.mak @@ -21,7 +21,7 @@ LIBMAXSIROOT=$(OSROOT)/libmaxsi LIBC=$(LIBMAXSIROOT)/start.o $(LIBMAXSIROOT)/libc.a LIBS=$(LIBC) -CPPFLAGS=$(CPUDEFINES) +CPPFLAGS=$(CPUDEFINES) -U_GNU_SOURCE FLAGS=-nostdinc -nostdlib -fno-builtin -nostartfiles -nodefaultlibs INCLUDES=-I $(LIBMAXSIROOT)/c/h/ -I $(OSROOT)/ diff --git a/libmaxsi/Makefile b/libmaxsi/Makefile index 8f1ab344..7c1eabca 100644 --- a/libmaxsi/Makefile +++ b/libmaxsi/Makefile @@ -20,7 +20,7 @@ ifeq ($(CPU),x64) LIBMAXSI_NO_SHARED=1 # This doesn't work yet endif -DEFINES=-DLIBMAXSI_LIBRARY -DSORTIX $(CPUDEFINES) +DEFINES=-DLIBMAXSI_LIBRARY -DSORTIX -U_GNU_SOURCE $(CPUDEFINES) FLAGSRELEASE=-O2 FLAGSDEBUG=-O2 FLAGS=$(CPUFLAGS) -std=gnu++0x -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-stack-protector -nostdinc $(FLAGSRELEASE) $(DEFINES) diff --git a/libmaxsi/c/hsrc/dirent.h b/libmaxsi/c/hsrc/dirent.h index 12acf7f2..8945eff2 100644 --- a/libmaxsi/c/hsrc/dirent.h +++ b/libmaxsi/c/hsrc/dirent.h @@ -43,7 +43,7 @@ DIR* opendir(const char* path); struct dirent* readdir(DIR* dir); void rewinddir(DIR* dir); -#ifdef SORTIX_EXTENSIONS +#if defined(_SORTIX_SOURCE) void dregister(DIR* dir); void dunregister(DIR* dir); DIR* dnewdir(void); diff --git a/libmaxsi/c/hsrc/fcntl.h b/libmaxsi/c/hsrc/fcntl.h index d100fd28..418cd145 100644 --- a/libmaxsi/c/hsrc/fcntl.h +++ b/libmaxsi/c/hsrc/fcntl.h @@ -86,7 +86,7 @@ typedef struct _flock flock; /* TODO: These are not implemented in libmaxsi/sortix yet. */ int open(const char* path, int oflag, ...); -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) int creat(const char* path, mode_t mode); int fcntl(int fd, int cmd, ...); int openat(int fd, const char* path, int oflag, ...); diff --git a/libmaxsi/c/hsrc/features.h b/libmaxsi/c/hsrc/features.h index 21e2d441..a7e359fe 100644 --- a/libmaxsi/c/hsrc/features.h +++ b/libmaxsi/c/hsrc/features.h @@ -34,8 +34,52 @@ #define __END_DECLS #endif +/* By default, assume the source is compiled using the native API. */ +#if !defined(_SORTIX_SOURCE) && \ + !defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) && \ + !defined(_BSD_SOURCE) && \ + !defined(_SVID_SOURCE) && \ + !defined(_XOPEN_SOURCE) && !defined(_XOPEN_SOURCE_EXTENDED) && \ + !defined(_GNU_SOURCE) && \ + true + #define _SORTIX_SOURCE 1 +#endif + +#ifdef _SORTIX_SOURCE + #warning _SORTIX_SOURCE +#endif + +#ifdef _POSIX_SOURCE + #warning _POSIX_SOURCE +#endif + +#ifdef _POSIX_C_SOURCE + #warning _POSIX_C_SOURCE +#endif + +#ifdef _BSD_SOURCE + #warning _BSD_SOURCE +#endif + +#ifdef _SVID_SOURCE + #warning _SVID_SOURCE +#endif + +#ifdef _XOPEN_SOURCE + #warning _XOPEN_SOURCE +#endif + +#ifdef _XOPEN_SOURCE_EXTENDED + #warning XOPEN_SOURCE_EXTENDED +#endif + +#ifdef _GNU_SOURCE + #warning _GNU_SOURCE +#endif + #define restrict +/* TODO: Improve these declarations, perhaps like they are in glibc. */ #define __POSIX_NO_OBSOLETE #ifdef __POSIX_NO_OBSOLETE @@ -44,13 +88,8 @@ #define __POSIX_OBSOLETE 200112L #endif -/* Whether sortix-specific extensions to the C library are available. */ -#ifndef SORTIX_NO_EXTENSIONS -#define SORTIX_EXTENSIONS -#endif - /* Don't provide things from standard headers that is not implemented. */ -#define SORTIX_UNIMPLEMENTED +/*#define __SORTIX_SHOW_UNIMPLEMENTED*/ #include diff --git a/libmaxsi/c/hsrc/stdio.h b/libmaxsi/c/hsrc/stdio.h index e6179e60..cd783b89 100644 --- a/libmaxsi/c/hsrc/stdio.h +++ b/libmaxsi/c/hsrc/stdio.h @@ -108,7 +108,7 @@ extern int vsnprintf(char* restrict, size_t, const char* restrict, va_list); extern int vsprintf(char* restrict s, const char* restrict format, va_list ap); /* TODO: These are not implemented in libmaxsi/sortix yet. */ -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) extern char* ctermid(char* s); extern char* fgets(char* restrict s, int n, FILE* restrict stream); extern FILE *fmemopen(void* restrict buf, size_t size, const char* restrict mode); @@ -151,7 +151,7 @@ extern char* tempnam(const char* dir, const char* pfx); #endif #endif -#ifdef SORTIX_EXTENSIONS +#if defined(_SORTIX_SOURCE) void fregister(FILE* fp); void funregister(FILE* fp); FILE* fnewfile(void); diff --git a/libmaxsi/c/hsrc/stdlib.h b/libmaxsi/c/hsrc/stdlib.h index a65bcac9..0c972699 100644 --- a/libmaxsi/c/hsrc/stdlib.h +++ b/libmaxsi/c/hsrc/stdlib.h @@ -58,7 +58,7 @@ unsigned long long strtoull(const char* restrict, char** restrict, int); long long strtoll(const char* restrict, char** restrict, int); /* TODO: These are not implemented in libmaxsi/sortix yet. */ -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) long a64l(const char* s); void abort(void); int abs(int value); diff --git a/libmaxsi/c/hsrc/string.h b/libmaxsi/c/hsrc/string.h index a5121939..9fe71b94 100644 --- a/libmaxsi/c/hsrc/string.h +++ b/libmaxsi/c/hsrc/string.h @@ -53,7 +53,7 @@ char* strtok(char* restrict, const char* restrict); char* strtok_r(char* restrict, const char* restrict, char** restrict); /* TODO: These are not implemented in libmaxsi/sortix yet. */ -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) void* memccpy(void* restrict, const void* restrict, int, size_t); void* memmove(void*, const void*, size_t); char* stpncpy(char* restrict, const char* restrict, size_t); @@ -72,7 +72,7 @@ size_t strxfrm(char* restrict, const char* restrict, size_t); size_t strxfrm_l(char* restrict, const char* restrict, size_t, locale_t); #endif -#ifdef SORTIX_EXTENSIONS +#if defined(_SORTIX_SOURCE) || defined(_GNU_SOURCE) char* strchrnul(const char* str, int c); #endif diff --git a/libmaxsi/c/hsrc/sys/wait.h b/libmaxsi/c/hsrc/sys/wait.h index 232ccd10..6278f9ae 100644 --- a/libmaxsi/c/hsrc/sys/wait.h +++ b/libmaxsi/c/hsrc/sys/wait.h @@ -34,7 +34,7 @@ __BEGIN_DECLS @include(pid_t.h) /* TODO: These are not implemented in libmaxsi/sortix yet. */ -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) int waitid(idtype_t, id_t, siginfo_t*, int); #endif diff --git a/libmaxsi/c/hsrc/unistd.h b/libmaxsi/c/hsrc/unistd.h index 9cc326b3..a6302b73 100644 --- a/libmaxsi/c/hsrc/unistd.h +++ b/libmaxsi/c/hsrc/unistd.h @@ -74,12 +74,12 @@ __BEGIN_DECLS @include(off_t.h) @include(pid_t.h) @include(useconds_t.h) -#ifdef SORTIX_EXTENSIONS +#if defined(_SORTIX_SOURCE) @include(intn_t.h) #endif /* TODO: These are not implemented in libmaxsi/sortix yet. */ -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) int access(const char*, int); unsigned alarm(unsigned); int chown(const char*, uid_t, gid_t); @@ -169,13 +169,13 @@ ssize_t read(int, void*, size_t); int rmdir(const char*); unsigned sleep(unsigned); int truncate(const char*, off_t); -#if __POSIX_OBSOLETE <= 200112 || defined(SORTIX_EXTENSIONS) +#if __POSIX_OBSOLETE <= 200112 || defined(_SORTIX_SOURCE) int usleep(useconds_t useconds); #endif int unlink(const char*); ssize_t write(int, const void*, size_t); -#ifdef SORTIX_EXTENSIONS +#if defined(_SORTIX_SOURCE) size_t getpagesize(void); int memstat(size_t* memused, size_t* memtotal); int uptime(uintmax_t* usecssinceboot); diff --git a/libmaxsi/c/hsrc/wchar.h b/libmaxsi/c/hsrc/wchar.h index 3c44e7d2..476f76e5 100644 --- a/libmaxsi/c/hsrc/wchar.h +++ b/libmaxsi/c/hsrc/wchar.h @@ -61,7 +61,7 @@ __BEGIN_DECLS struct tm; /* TODO: These are not implemented in libmaxsi/sortix yet. */ -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) double wcstod(const wchar_t* restrict, wchar_t** restrict); FILE* open_wmemstream(wchar_t** bufp, size_t* sizep); float wcstof(const wchar_t* restrict, wchar_t** restrict); diff --git a/libmaxsi/c/hsrc/wctype.h b/libmaxsi/c/hsrc/wctype.h index 92cd44d6..83ce3319 100644 --- a/libmaxsi/c/hsrc/wctype.h +++ b/libmaxsi/c/hsrc/wctype.h @@ -35,7 +35,7 @@ __BEGIN_DECLS @include(WEOF.h) /* TODO: These are not implemented in libmaxsi/sortix yet. */ -#ifndef SORTIX_UNIMPLEMENTED +#if defined(__SORTIX_SHOW_UNIMPLEMENTED) int iswalnum(wint_t); int iswalnum_l(wint_t, locale_t); int iswalpha(wint_t); diff --git a/sortix/Makefile b/sortix/Makefile index f12b5fdc..2094864c 100644 --- a/sortix/Makefile +++ b/sortix/Makefile @@ -44,7 +44,7 @@ endif DIRS=. x64 x86 x86-family fs kb kb/layout -DEFINES:=-DSORTIX_KERNEL $(CPUDEFINES) +DEFINES:=-DSORTIX_KERNEL -U_GNU_SOURCE $(CPUDEFINES) ifeq ($(JSSORTIX),1) DEFINES:=$(DEFINES) -DPLATFORM_SERIAL -DJSSORTIX BUILDID:=$(BUILDID)-js