Fix incorrect usage of __is_sortix_foo macros in preprocessor conditionals.

These macros might not be defined, in which case this usage would have
generated warnings had they not been in system headers.
This commit is contained in:
Jonas 'Sortie' Termansen 2014-01-18 16:21:46 +01:00
parent c57b5fe176
commit a4220d5b5f
14 changed files with 37 additions and 29 deletions

View File

@ -10,7 +10,7 @@ endif
CPUDIR:=$(CPU)
CPPINCLUDES=-I preproc
CPPFLAGS=-D__is_sortix_libc=1 $(CPPINCLUDES)
CPPFLAGS=-D__is_sortix_libc $(CPPINCLUDES)
FLAGS=-Wall -Wextra $(OPTLEVEL)
CFLAGS=-std=gnu99
CXXFLAGS=-std=gnu++11 -fno-exceptions -fno-rtti
@ -517,7 +517,7 @@ INSTALLHEADERDIRS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(H
INSTALLHEADERS:=$(addprefix $(DESTDIR)$(INCLUDEDIR),$(patsubst preproc%,%,$(HEADERS)))
SORTIXOBJS:=$(addprefix sortix/,$(FREEOBJS))
SORTIXCPPFLAGS:=$(CPPFLAGS) -D__is_sortix_kernel=1
SORTIXCPPFLAGS:=$(CPPFLAGS) -D__is_sortix_kernel
SORTIXFLAGS:=$(FLAGS) -ffreestanding
SORTIXCFLAGS:=$(CFLAGS)
SORTIXCXXFLAGS:=$(CXXFLAGS)

View File

@ -38,7 +38,7 @@ void __assert(const char* filename,
const char* function_name,
const char* expression)
{
#if __is_sortix_kernel
#if defined(__is_sortix_kernel)
Sortix::PanicF("Assertion failure: %s:%lu: %s: %s\n", filename, line,
function_name, expression);
#else

View File

@ -25,14 +25,14 @@
#define __SORTIX_STDLIB_REDIRECTS 0
#include <errno.h>
#include <stddef.h>
#ifndef __is_sortix_kernel
#if !defined(__is_sortix_kernel)
#include <stdio.h>
#endif
extern "C" { int global_errno = 0; }
extern "C" { errno_location_func_t errno_location_func = NULL; }
#ifndef __is_sortix_kernel
#if !defined(__is_sortix_kernel)
extern "C" void init_error_functions()
{
global_errno = 0;

View File

@ -28,16 +28,16 @@
#define __sortix_libc__ 1
/* Detect whether we are a core system library. */
#if __is_sortix_libc || __is_sortix_libm
#if defined(__is_sortix_libc) || defined(__is_sortix_libm)
#if !defined(__is_sortix_system_library)
#define __is_sortix_system_library 1
#define __is_sortix_system_library
#endif
#endif
/* Detect whether we are a core system component. */
#if __is_sortix_kernel || __is_sortix_system_library
#if defined(__is_sortix_kernel) || defined(__is_sortix_system_library)
#if !defined(__is_sortix_system_component)
#define __is_sortix_system_component 1
#define __is_sortix_system_component
#endif
#endif
@ -47,7 +47,7 @@
((gcc_major) < __GNUC__))
/* Sortix system components implicitly use the native API. */
#if __is_sortix_system_component
#if defined(__is_sortix_system_component)
#define _SORTIX_SOURCE 1
#endif
@ -72,7 +72,7 @@
#endif
/* Provide the restrict keyword when building system components. */
#if __is_sortix_system_component && !defined(__want_restrict)
#if defined(__is_sortix_system_component) && !defined(__want_restrict)
#define __want_restrict 1
#endif
@ -82,7 +82,7 @@
#endif
/* Provide the full <stdint.h> in all system components. */
#if __is_sortix_system_component
#if defined(__is_sortix_system_component)
#undef __STDC_CONSTANT_MACROS
#undef __STDC_LIMIT_MACROS
#define __STDC_CONSTANT_MACROS

View File

@ -43,7 +43,7 @@ struct group
char* gr_passwd;
};
#if __is_sortix_libc
#if defined(__is_sortix_libc)
extern FILE* __grp_file;
#endif

View File

@ -47,7 +47,7 @@ struct passwd
char* pw_shell;
};
#if __is_sortix_libc
#if defined(__is_sortix_libc)
extern FILE* __pwd_file;
#endif

View File

@ -35,7 +35,7 @@
#endif
#include <stdarg.h>
#if __is_sortix_libc
#if defined(__is_sortix_libc)
#include <FILE.h>
#endif

View File

@ -128,7 +128,7 @@ char* getenv(const char*);
int clearenv(void);
#endif
#if __is_sortix_libc
#if defined(__is_sortix_libc)
struct exit_handler
{
void (*hook)(int, void*);

View File

@ -29,7 +29,7 @@
#include <sys/__/types.h>
#if __is_sortix_libc
#if defined(__is_sortix_libc)
#include <FILE.h>
#endif

View File

@ -47,7 +47,7 @@ extern "C" int fsetdefaultbuf(FILE* fp)
// Determine the buffering semantics depending on whether the destination is
// an interactive device or not.
#ifdef __is_sortix_kernel
#if defined(__is_sortix_kernel)
int mode = _IOLBF; // TODO: Detect this?
#else
int mode = fp->buffer_mode != -1 ? fp->buffer_mode

View File

@ -37,7 +37,7 @@ extern "C" void abort(void)
Sortix::PanicF("abort()");
}
#else
#elif __STDC_HOSTED__
extern "C" void abort(void)
{
@ -50,4 +50,12 @@ extern "C" void abort(void)
_Exit(128 + 6);
}
#else
extern "C" void abort(void)
{
while ( true ) { };
__builtin_unreachable();
}
#endif

View File

@ -24,7 +24,7 @@
#include <sys/mman.h>
#ifndef __is_sortix_kernel
#if __STDC_HOSTED__
#include <error.h>
#include <stdio.h>
#include <unistd.h>
@ -39,7 +39,7 @@
#define PARANOIA 1
#ifdef __is_sortix_kernel
#if defined(__is_sortix_kernel)
#include <sortix/kernel/decl.h>
#include <sortix/kernel/addralloc.h>
#include <sortix/kernel/kthread.h>
@ -66,7 +66,7 @@ const size_t NUMBINS = 8UL * sizeof(size_t);
static uintptr_t wilderness;
#ifdef __is_sortix_kernel
#if defined(__is_sortix_kernel)
static uintptr_t GetHeapStart()
{
return Sortix::GetHeapLower();
@ -195,7 +195,7 @@ inline size_t BSF(size_t Value)
struct Chunk;
struct Trailer;
#ifdef __is_sortix_kernel
#if defined(__is_sortix_kernel)
Sortix::kthread_mutex_t heaplock;
#endif
@ -407,7 +407,7 @@ extern "C" void _init_heap()
wildernesssize = 0;
for ( size_t i = 0; i < NUMBINS; i++ ) { bins[i] = NULL; }
bincontainschunks = 0;
#ifdef __is_sortix_kernel
#if defined(__is_sortix_kernel)
heaplock = Sortix::KTHREAD_MUTEX_INITIALIZER;
#endif
}
@ -445,7 +445,7 @@ static bool ExpandWilderness(size_t bytesneeded)
extern "C" void* malloc(size_t size)
{
#ifdef __is_sortix_kernel
#if defined(__is_sortix_kernel)
Sortix::ScopedLock scopedlock(&heaplock);
#endif
@ -619,7 +619,7 @@ static void UnifyNeighbors(Chunk** chunk)
extern "C" void free(void* addr)
{
#ifdef __is_sortix_kernel
#if defined(__is_sortix_kernel)
Sortix::ScopedLock scopedlock(&heaplock);
#endif
@ -629,7 +629,7 @@ extern "C" void free(void* addr)
if ( !addr) { return; }
Chunk* chunk = (Chunk*) ((uintptr_t) addr - sizeof(Chunk));
#ifndef __is_sortix_kernel
#if __STDC_HOSTED__
if ( !IsGoodHeapPointer(addr, 1) ||
!IsGoodHeapPointer(chunk, sizeof(*chunk)) )
{

View File

@ -352,7 +352,7 @@ CFLAGS:=$(CFLAGS) -std=gnu99 -Wall -Wextra
CPPFLAGS:=$(CPPFLAGS) -I include -I src -I $(ARCH_SUBDIR)
# TODO: Figure out whether these are the defines that we want to pass.
CPPFLAGS:=$(CPPFLAGS) -D__is_sortix_libm=1 -D_MULTI_LIBM -D_POSIX_MODE
CPPFLAGS:=$(CPPFLAGS) -D__is_sortix_libm -D_MULTI_LIBM -D_POSIX_MODE
ARCH_SRCS:=$(addprefix $(ARCH_SUBDIR)/,$(ARCH_SRCS))
COMMON_SRCS:=$(addprefix src/,$(COMMON_SRCS))

View File

@ -56,7 +56,7 @@ struct rlimit
#define RLIMIT_STACK 6
#define __RLIMIT_NUM_DECLARED 7 /* index of highest constant plus 1. */
#if !__STDC_HOSTED__ && defined(__is_sortix_kernel)
#if defined(__is_sortix_kernel)
#define RLIMIT_NUM_DECLARED __RLIMIT_NUM_DECLARED
#endif