Replaced SORTIX_EXTENSIONS macro with _SORTIX_SOURCE macro.

<features.h> declares _SORTIX_SOURCE if no conflicting macros are
declared, such as _GNU_SOURCE.

Fixed g++ automatically declaring _GNU_SOURCE, but Sortix isn't GNU.

Replaced SORTIX_UNIMPLEMENTED macro with __SORTIX_SHOW_UNIMPLEMENTED.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-02-11 18:50:12 +01:00
parent 88c7788b4e
commit ed68db03fb
13 changed files with 62 additions and 23 deletions

View File

@ -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)/

View File

@ -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)

View File

@ -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);

View File

@ -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, ...);

View File

@ -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 <sortix/bits.h>

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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