Get rid of #ifdef SERENITY. We're past that phase of bootstrapping.

This commit is contained in:
Andreas Kling 2019-01-17 01:41:36 +01:00
parent 5605295d00
commit b5c76d7559
14 changed files with 1 additions and 95 deletions

View file

@ -1,16 +1,10 @@
#pragma once
#ifdef SERENITY
#ifdef KERNEL
#include <Kernel/kassert.h>
#else
#include <LibC/assert.h>
#endif
#else
#include <assert.h>
#define ASSERT(x) assert(x)
#define ASSERT_NOT_REACHED() assert(false)
#endif
namespace AK {

View file

@ -1,48 +1,32 @@
#pragma once
#ifdef SERENITY
#ifdef KERNEL
#include <Kernel/StdLib.h>
#else
#include <LibC/stdlib.h>
#include <LibC/string.h>
#endif
#else
#include <cstring>
#include <cstdlib>
#include <utility>
#endif
#include <AK/Types.h>
ALWAYS_INLINE void fast_dword_copy(dword* dest, const dword* src, size_t count)
{
#ifdef SERENITY
asm volatile(
"rep movsl\n"
: "=S"(src), "=D"(dest), "=c"(count)
: "S"(src), "D"(dest), "c"(count)
: "memory"
);
#else
memcpy(dest, src, count * sizeof(dword));
#endif
}
ALWAYS_INLINE void fast_dword_fill(dword* dest, dword value, size_t count)
{
#ifdef SERENITY
asm volatile(
"rep stosl\n"
: "=D"(dest), "=c"(count)
: "D"(dest), "c"(count), "a"(value)
: "memory"
);
#else
for (size_t i = 0; x <= count; ++x) {
dest[i] = value;
}
#endif
}
namespace AK {

View file

@ -26,11 +26,7 @@ template<typename T>
struct Traits<T*> {
static unsigned hash(const T* p)
{
#ifdef SERENITY
return intHash((dword)p);
#else
return intHash((unsigned long long)p & 0xffffffff);
#endif
}
static void dump(const T* p) { kprintf("%p", p); }
};

View file

@ -11,7 +11,6 @@ private:
#define AK_MAKE_ETERNAL
#endif
#ifdef SERENITY
#ifdef KERNEL
#include <Kernel/kmalloc.h>
#else
@ -30,20 +29,3 @@ void* kmalloc_eternal(size_t) MALLOC_ATTR;
inline void* operator new(size_t, void* p) { return p; }
inline void* operator new[](size_t, void* p) { return p; }
#endif
#else
#include <new>
#include "Types.h"
extern "C" {
void* kcalloc(size_t nmemb, size_t size);
void* kmalloc(size_t size) MALLOC_ATTR;
void kfree(void* ptr);
void* krealloc(void* ptr, size_t size);
void* kmalloc_eternal(size_t) MALLOC_ATTR;
}
#endif

View file

@ -1,9 +1,3 @@
#pragma once
#ifdef SERENITY
#include <Kernel/kstdio.h>
#else
#include <cstdio>
#define kprintf printf
#define ksprintf sprintf
#endif

View file

@ -1,10 +1,3 @@
#pragma once
#ifdef SERENITY
#include <Kernel/ktime.h>
#else
#include <time.h>
#define ktime time
#define klocaltime localtime
#endif

View file

@ -8,6 +8,7 @@ AK_OBJS = \
WIDGETS_OBJS = \
../Widgets/Painter.o \
../Widgets/Font.o \
../Widgets/Rect.o \
../Widgets/GraphicsBitmap.o \
../Widgets/CharacterBitmap.o \
../Widgets/Color.o

View file

@ -1,10 +1,5 @@
#include "DiskBackedFileSystem.h"
#ifdef SERENITY
#include "i386.h"
#else
typedef int InterruptDisabler;
#endif
//#define DBFS_DEBUG

View file

@ -3,12 +3,8 @@
#include <AK/Retainable.h>
#include <AK/Types.h>
#ifdef SERENITY
// FIXME: Support 64-bit DiskOffset
typedef dword DiskOffset;
#else
typedef qword DiskOffset;
#endif
class DiskDevice : public Retainable<DiskDevice> {
public:

View file

@ -5,11 +5,8 @@
#include "UnixTypes.h"
#include <AK/BufferStream.h>
#include "FIFO.h"
#ifdef SERENITY
#include "TTY.h"
#include "MasterPTY.h"
#endif
RetainPtr<FileDescriptor> FileDescriptor::create(RetainPtr<Inode>&& inode)
{
@ -64,21 +61,17 @@ RetainPtr<FileDescriptor> FileDescriptor::clone()
if (!descriptor)
return nullptr;
descriptor->m_current_offset = m_current_offset;
#ifdef SERENITY
descriptor->m_is_blocking = m_is_blocking;
descriptor->m_file_flags = m_file_flags;
#endif
return descriptor;
}
#ifndef SERENITY
bool additionWouldOverflow(Unix::off_t a, Unix::off_t b)
{
ASSERT(a > 0);
uint64_t ua = a;
return (ua + b) > maxFileOffset;
}
#endif
int FileDescriptor::stat(Unix::stat* buffer)
{

View file

@ -7,11 +7,9 @@
#include <AK/CircularQueue.h>
#include <AK/Retainable.h>
#ifdef SERENITY
class TTY;
class MasterPTY;
class Process;
#endif
class FileDescriptor : public Retainable<FileDescriptor> {
public:
@ -45,7 +43,6 @@ public:
CharacterDevice* character_device() { return m_device.ptr(); }
const CharacterDevice* character_device() const { return m_device.ptr(); }
#ifdef SERENITY
bool is_tty() const;
const TTY* tty() const;
TTY* tty();
@ -53,7 +50,6 @@ public:
bool is_master_pty() const;
const MasterPTY* master_pty() const;
MasterPTY* master_pty();
#endif
InodeMetadata metadata() const;
Inode* inode() { return m_inode.ptr(); }
@ -61,7 +57,6 @@ public:
bool supports_mmap() const { return m_inode && !m_device; }
#ifdef SERENITY
bool is_blocking() const { return m_is_blocking; }
void set_blocking(bool b) { m_is_blocking = b; }
@ -70,7 +65,6 @@ public:
bool is_fifo() const { return m_fifo; }
FIFO::Direction fifo_direction() { return m_fifo_direction; }
#endif
ByteBuffer& generator_cache() { return m_generator_cache; }
@ -87,12 +81,10 @@ private:
ByteBuffer m_generator_cache;
#ifdef SERENITY
bool m_is_blocking { true };
dword m_file_flags { 0 };
RetainPtr<FIFO> m_fifo;
FIFO::Direction m_fifo_direction { FIFO::Neither };
#endif
};

View file

@ -2,12 +2,7 @@
#include "UnixTypes.h"
#ifdef SERENITY
inline static const Unix::off_t maxFileOffset = 2147483647;
#else
#include <limits>
inline static const Unix::off_t maxFileOffset = std::numeric_limits<Unix::off_t>::max();
#endif
static const size_t GoodBufferSize = 4096;

View file

@ -231,7 +231,6 @@ struct tms {
clock_t tms_cstime;
};
#ifdef SERENITY
typedef void (*__sighandler_t)(int);
typedef __sighandler_t sighandler_t;
@ -256,16 +255,9 @@ struct sigaction {
#define SIG_UNBLOCK 1
#define SIG_SETMASK 2
#endif
#ifdef SERENITY
// FIXME: Support 64-bit offsets!
typedef signed_dword off_t;
typedef unsigned int time_t;
#else
typedef signed_qword off_t;
typedef ::time_t time_t;
#endif
struct utimbuf {
time_t actime;

View file

@ -1,6 +1,5 @@
#include "Rect.h"
#include <AK/StdLibExtras.h>
#include "kstdio.h"
void Rect::intersect(const Rect& other)
{