1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-30 21:27:46 +00:00

Get rid of SERENITY macro since the compiler already defines __serenity__

This makes it a bit easier to use AK templates out-of-tree.
This commit is contained in:
Andreas Kling 2019-04-20 12:58:02 +02:00
parent 6aead8998a
commit 301a269ca0
27 changed files with 39 additions and 60 deletions

View file

@ -3,7 +3,11 @@
#ifdef KERNEL
#include <Kernel/Assertions.h>
#else
#include <LibC/assert.h>
#include <assert.h>
#ifndef __serenity__
#define ASSERT assert
#define ASSERT_NOT_REACHED assert(false)
#endif
#endif
namespace AK {

View file

@ -3,8 +3,8 @@
#ifdef KERNEL
#include <Kernel/StdLib.h>
#else
#include <LibC/stdlib.h>
#include <LibC/string.h>
#include <stdlib.h>
#include <string.h>
#endif
#define UNUSED_PARAM(x) (void)x

View file

@ -1,6 +1,6 @@
#pragma once
#if defined(SERENITY)
#ifdef __serenity__
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned int dword;

View file

@ -1,34 +1,11 @@
#include "kmalloc.h"
#ifndef SERENITY
#ifndef __serenity__
#include <cstdlib>
#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);
}
}

View file

@ -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 <Kernel/kmalloc.h>
#else
#include <LibC/stdlib.h>
#include <stdlib.h>
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