From 301a269ca0361ba5fa94ad143d9f35049076f618 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 20 Apr 2019 12:58:02 +0200 Subject: [PATCH] Get rid of SERENITY macro since the compiler already defines __serenity__ This makes it a bit easier to use AK templates out-of-tree. --- AK/Assertions.h | 6 +++++- AK/StdLibExtras.h | 4 ++-- AK/Types.h | 2 +- AK/kmalloc.cpp | 25 +------------------------ AK/kmalloc.h | 18 ++++++++---------- Applications/About/Makefile | 2 +- Applications/Downloader/Makefile | 2 +- Applications/FileManager/Makefile | 2 +- Applications/FontEditor/Makefile | 2 +- Applications/IRCClient/Makefile | 2 +- Applications/Launcher/Makefile | 2 +- Applications/ProcessManager/Makefile | 2 +- Applications/Taskbar/Makefile | 2 +- Applications/Terminal/Makefile | 2 +- Applications/TextEditor/Makefile | 2 +- Applications/VisualBuilder/Makefile | 2 +- Games/Minesweeper/Makefile | 2 +- Games/Snake/Makefile | 2 +- Kernel/Makefile | 2 +- Kernel/Syscall.h | 2 +- LibC/Makefile | 2 +- LibCore/Makefile | 2 +- LibGUI/Makefile | 2 +- LibM/Makefile | 2 +- Servers/LookupServer/Makefile | 2 +- Servers/WindowServer/Makefile | 2 +- Userland/Makefile | 2 +- 27 files changed, 39 insertions(+), 60 deletions(-) diff --git a/AK/Assertions.h b/AK/Assertions.h index 0898b79a17d..bd2404cd684 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -3,7 +3,11 @@ #ifdef KERNEL #include #else -#include +#include +#ifndef __serenity__ +#define ASSERT assert +#define ASSERT_NOT_REACHED assert(false) +#endif #endif namespace AK { diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index e953d16d6eb..04c9ce72d0d 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -3,8 +3,8 @@ #ifdef KERNEL #include #else -#include -#include +#include +#include #endif #define UNUSED_PARAM(x) (void)x diff --git a/AK/Types.h b/AK/Types.h index 050d4930cc8..fb8501d21dd 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -1,6 +1,6 @@ #pragma once -#if defined(SERENITY) +#ifdef __serenity__ typedef unsigned char byte; typedef unsigned short word; typedef unsigned int dword; diff --git a/AK/kmalloc.cpp b/AK/kmalloc.cpp index f51bfd29102..13ad812270f 100644 --- a/AK/kmalloc.cpp +++ b/AK/kmalloc.cpp @@ -1,34 +1,11 @@ #include "kmalloc.h" -#ifndef SERENITY +#ifndef __serenity__ #include #endif extern "C" { -void* kcalloc(size_t nmemb, size_t size) -{ - return calloc(nmemb, size); -} -void* kmalloc(size_t size) -{ - return malloc(size); -} - -void kfree(void* ptr) -{ - free(ptr); -} - -void* krealloc(void* ptr, size_t size) -{ - return realloc(ptr, size); -} - -void* kmalloc_eternal(size_t size) -{ - return kmalloc(size); -} } diff --git a/AK/kmalloc.h b/AK/kmalloc.h index 99a3cd67bd7..c31352ec010 100644 --- a/AK/kmalloc.h +++ b/AK/kmalloc.h @@ -1,6 +1,6 @@ #pragma once -#if defined(SERENITY) && defined(KERNEL) +#ifdef KERNEL #define AK_MAKE_ETERNAL \ public: \ void* operator new(size_t size) { return kmalloc_eternal(size); } \ @@ -12,17 +12,14 @@ private: #ifdef KERNEL #include #else -#include +#include -extern "C" { - -[[gnu::malloc, gnu::returns_nonnull]] void* kmalloc(size_t size); -[[gnu::malloc, gnu::returns_nonnull]] void* kmalloc_eternal(size_t); -[[gnu::returns_nonnull]] void* krealloc(void* ptr, size_t size); -void kfree(void* ptr); - -} +#define kcalloc calloc +#define kmalloc malloc +#define kfree free +#define krealloc realloc +#ifdef __serenity__ inline void* operator new(size_t size) { return kmalloc(size); @@ -47,5 +44,6 @@ inline void* operator new(size_t, void* ptr) { return ptr; } +#endif #endif diff --git a/Applications/About/Makefile b/Applications/About/Makefile index 19612e3f209..a3170934def 100644 --- a/Applications/About/Makefile +++ b/Applications/About/Makefile @@ -9,7 +9,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/Downloader/Makefile b/Applications/Downloader/Makefile index 9d417a883ab..0a16ef94190 100644 --- a/Applications/Downloader/Makefile +++ b/Applications/Downloader/Makefile @@ -9,7 +9,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../../Servers -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/FileManager/Makefile b/Applications/FileManager/Makefile index 5b94becf18d..51209560e4b 100644 --- a/Applications/FileManager/Makefile +++ b/Applications/FileManager/Makefile @@ -11,7 +11,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I../../Servers -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/FontEditor/Makefile b/Applications/FontEditor/Makefile index b8d335bc1e9..c4190895eed 100644 --- a/Applications/FontEditor/Makefile +++ b/Applications/FontEditor/Makefile @@ -12,7 +12,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/IRCClient/Makefile b/Applications/IRCClient/Makefile index bb2ebaf1b09..c61164768cf 100644 --- a/Applications/IRCClient/Makefile +++ b/Applications/IRCClient/Makefile @@ -18,7 +18,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../../Servers -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/Launcher/Makefile b/Applications/Launcher/Makefile index 30651fe518f..7062a8f2662 100644 --- a/Applications/Launcher/Makefile +++ b/Applications/Launcher/Makefile @@ -9,7 +9,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/ProcessManager/Makefile b/Applications/ProcessManager/Makefile index 489897e5599..6b6f007f5f1 100644 --- a/Applications/ProcessManager/Makefile +++ b/Applications/ProcessManager/Makefile @@ -12,7 +12,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/Taskbar/Makefile b/Applications/Taskbar/Makefile index 50277448bf7..0c412c30397 100644 --- a/Applications/Taskbar/Makefile +++ b/Applications/Taskbar/Makefile @@ -11,7 +11,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I../../Servers -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/Terminal/Makefile b/Applications/Terminal/Makefile index f5d0a2ee479..fddf7f11bbb 100644 --- a/Applications/Terminal/Makefile +++ b/Applications/Terminal/Makefile @@ -10,7 +10,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/TextEditor/Makefile b/Applications/TextEditor/Makefile index 2e9f5fa92bb..9d608c49baf 100644 --- a/Applications/TextEditor/Makefile +++ b/Applications/TextEditor/Makefile @@ -9,7 +9,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Applications/VisualBuilder/Makefile b/Applications/VisualBuilder/Makefile index c2bb96cce15..5188ef20838 100644 --- a/Applications/VisualBuilder/Makefile +++ b/Applications/VisualBuilder/Makefile @@ -15,7 +15,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Games/Minesweeper/Makefile b/Games/Minesweeper/Makefile index c074a823acf..a289634ddd8 100644 --- a/Games/Minesweeper/Makefile +++ b/Games/Minesweeper/Makefile @@ -10,7 +10,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Games/Snake/Makefile b/Games/Snake/Makefile index a68bd0fa5bc..43a4217a7e4 100644 --- a/Games/Snake/Makefile +++ b/Games/Snake/Makefile @@ -10,7 +10,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../.. -I. -I../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Kernel/Makefile b/Kernel/Makefile index ebd182da68a..dd753ff3a01 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -87,7 +87,7 @@ INCLUDE_FLAGS = -I.. -I. CLANG_FLAGS = -Wconsumed -m32 -ffreestanding -march=i686 #SUGGEST_FLAGS = -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override #-Wsuggest-attribute=noreturn -DEFINES = -DSERENITY -DKERNEL -DSANITIZE_PTRS +DEFINES = -DKERNEL -DSANITIZE_PTRS CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(KERNEL_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(SUGGEST_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) #CXX = clang $(CLANG_FLAGS) diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index dfaddc070d3..14dc789558d 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -121,7 +121,7 @@ inline constexpr const char* to_string(Function function) return "Unknown"; } -#ifdef SERENITY +#ifdef __serenity__ struct SC_mmap_params { uint32_t addr; uint32_t size; diff --git a/LibC/Makefile b/LibC/Makefile index f6c209cfee2..6986aa6a4ae 100644 --- a/LibC/Makefile +++ b/LibC/Makefile @@ -55,7 +55,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti -fno-sized-deallocation OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. -DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS +DEFINES = -DUSERLAND -DSANITIZE_PTRS CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/LibCore/Makefile b/LibCore/Makefile index 8331bb64bdf..1d73ded45bb 100644 --- a/LibCore/Makefile +++ b/LibCore/Makefile @@ -23,7 +23,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../LibC -I../Servers -I.. -I. -DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS -DLIBGUI +DEFINES = -DUSERLAND -DSANITIZE_PTRS -DLIBGUI CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/LibGUI/Makefile b/LibGUI/Makefile index fac3de3998d..dea0f3751b1 100644 --- a/LibGUI/Makefile +++ b/LibGUI/Makefile @@ -61,7 +61,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I../LibC -I../Servers -I.. -I. -DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS -DLIBGUI +DEFINES = -DUSERLAND -DSANITIZE_PTRS -DLIBGUI CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/LibM/Makefile b/LibM/Makefile index ebc7927e3e2..4257c41cbfd 100644 --- a/LibM/Makefile +++ b/LibM/Makefile @@ -7,7 +7,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. -DEFINES = -DSERENITY -DUSERLAND -DSANITIZE_PTRS +DEFINES = -DUSERLAND -DSANITIZE_PTRS CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Servers/LookupServer/Makefile b/Servers/LookupServer/Makefile index e415e01a476..2986a501cde 100644 --- a/Servers/LookupServer/Makefile +++ b/Servers/LookupServer/Makefile @@ -11,7 +11,7 @@ OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I../.. -I. -I../../LibC LDFLAGS = -L../../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Servers/WindowServer/Makefile b/Servers/WindowServer/Makefile index 8c0434bf7b7..6d08d3546af 100644 --- a/Servers/WindowServer/Makefile +++ b/Servers/WindowServer/Makefile @@ -36,7 +36,7 @@ OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I../.. -I. -I../../LibC LDFLAGS = -L../../LibC -L../../LibCore -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++ diff --git a/Userland/Makefile b/Userland/Makefile index bae2fce7106..22c57efa088 100644 --- a/Userland/Makefile +++ b/Userland/Makefile @@ -9,7 +9,7 @@ FLAVOR_FLAGS = -fno-exceptions -fno-rtti -fno-sized-deallocation OPTIMIZATION_FLAGS = -Os INCLUDE_FLAGS = -I.. -I. -I../LibC -DEFINES = -DSERENITY -DSANITIZE_PTRS -DUSERLAND +DEFINES = -DSANITIZE_PTRS -DUSERLAND CXXFLAGS = -MMD -MP $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(FLAVOR_FLAGS) $(ARCH_FLAGS) $(STANDARD_FLAGS) $(INCLUDE_FLAGS) $(DEFINES) CXX = i686-pc-serenity-g++