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
Notes: sideshowbarker 2024-07-19 16:01:08 +09:00
14 changed files with 1 additions and 95 deletions

View file

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

View file

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

View file

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

View file

@ -11,7 +11,6 @@ private:
#define AK_MAKE_ETERNAL #define AK_MAKE_ETERNAL
#endif #endif
#ifdef SERENITY
#ifdef KERNEL #ifdef KERNEL
#include <Kernel/kmalloc.h> #include <Kernel/kmalloc.h>
#else #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; }
inline void* operator new[](size_t, void* p) { return p; } inline void* operator new[](size_t, void* p) { return p; }
#endif #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 #pragma once
#ifdef SERENITY
#include <Kernel/kstdio.h> #include <Kernel/kstdio.h>
#else
#include <cstdio>
#define kprintf printf
#define ksprintf sprintf
#endif

View file

@ -1,10 +1,3 @@
#pragma once #pragma once
#ifdef SERENITY
#include <Kernel/ktime.h> #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_OBJS = \
../Widgets/Painter.o \ ../Widgets/Painter.o \
../Widgets/Font.o \ ../Widgets/Font.o \
../Widgets/Rect.o \
../Widgets/GraphicsBitmap.o \ ../Widgets/GraphicsBitmap.o \
../Widgets/CharacterBitmap.o \ ../Widgets/CharacterBitmap.o \
../Widgets/Color.o ../Widgets/Color.o

View file

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

View file

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

View file

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

View file

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

View file

@ -2,12 +2,7 @@
#include "UnixTypes.h" #include "UnixTypes.h"
#ifdef SERENITY
inline static const Unix::off_t maxFileOffset = 2147483647; 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; static const size_t GoodBufferSize = 4096;

View file

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

View file

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