Skip to content

Commit

Permalink
Get rid of #ifdef SERENITY. We're past that phase of bootstrapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jan 17, 2019
1 parent 5605295 commit b5c76d7
Show file tree
Hide file tree
Showing 14 changed files with 1 addition and 95 deletions.
6 changes: 0 additions & 6 deletions AK/Assertions.h
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down
16 changes: 0 additions & 16 deletions AK/StdLibExtras.h
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions AK/Traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
};
Expand Down
18 changes: 0 additions & 18 deletions AK/kmalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public: \
#define AK_MAKE_ETERNAL
#endif

#ifdef SERENITY
#ifdef KERNEL
#include <Kernel/kmalloc.h>
#else
Expand All @@ -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

6 changes: 0 additions & 6 deletions AK/kstdio.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#pragma once

#ifdef SERENITY
#include <Kernel/kstdio.h>
#else
#include <cstdio>
#define kprintf printf
#define ksprintf sprintf
#endif
7 changes: 0 additions & 7 deletions AK/ktime.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#pragma once

#ifdef SERENITY
#include <Kernel/ktime.h>
#else
#include <time.h>
#define ktime time
#define klocaltime localtime
#endif

1 change: 1 addition & 0 deletions LibC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions VirtualFileSystem/DiskBackedFileSystem.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include "DiskBackedFileSystem.h"

#ifdef SERENITY
#include "i386.h"
#else
typedef int InterruptDisabler;
#endif

//#define DBFS_DEBUG

Expand Down
4 changes: 0 additions & 4 deletions VirtualFileSystem/DiskDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 0 additions & 7 deletions VirtualFileSystem/FileDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 0 additions & 8 deletions VirtualFileSystem/FileDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -45,23 +43,20 @@ class FileDescriptor : public Retainable<FileDescriptor> {
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();

bool is_master_pty() const;
const MasterPTY* master_pty() const;
MasterPTY* master_pty();
#endif

InodeMetadata metadata() const;
Inode* inode() { return m_inode.ptr(); }
const Inode* inode() const { return m_inode.ptr(); }

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; }

Expand All @@ -70,7 +65,6 @@ class FileDescriptor : public Retainable<FileDescriptor> {

bool is_fifo() const { return m_fifo; }
FIFO::Direction fifo_direction() { return m_fifo_direction; }
#endif

ByteBuffer& generator_cache() { return m_generator_cache; }

Expand All @@ -87,12 +81,10 @@ class FileDescriptor : public Retainable<FileDescriptor> {

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
};

5 changes: 0 additions & 5 deletions VirtualFileSystem/Limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 0 additions & 8 deletions VirtualFileSystem/UnixTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ struct tms {
clock_t tms_cstime;
};

#ifdef SERENITY
typedef void (*__sighandler_t)(int);
typedef __sighandler_t sighandler_t;

Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion Widgets/Rect.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "Rect.h"
#include <AK/StdLibExtras.h>
#include "kstdio.h"

void Rect::intersect(const Rect& other)
{
Expand Down

0 comments on commit b5c76d7

Please sign in to comment.