mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
remove the libstdc++ dependency once and for all
The trick is to make all destructors non-virtual. This is safe because we never use the delete operator, which is the only case where virtual destructors are relevant. This is a better solution than implementing our own delete operator, because we want libraries loaded at runtime to use the libstdc++ version, not ours.
This commit is contained in:
parent
88a1faa2a2
commit
6f1d02dae7
13
makefile
13
makefile
@ -50,7 +50,11 @@ strip-all = --strip-all
|
|||||||
|
|
||||||
rdynamic = -rdynamic
|
rdynamic = -rdynamic
|
||||||
|
|
||||||
warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self
|
# note that we supress the non-virtual-dtor warning because we never
|
||||||
|
# use the delete operator, which means we don't need virtual
|
||||||
|
# destructors:
|
||||||
|
warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \
|
||||||
|
-Wno-non-virtual-dtor
|
||||||
|
|
||||||
common-cflags = $(warnings) -fno-rtti -fno-exceptions \
|
common-cflags = $(warnings) -fno-rtti -fno-exceptions \
|
||||||
"-I$(JAVA_HOME)/include" -idirafter $(src) -I$(native-build) \
|
"-I$(JAVA_HOME)/include" -idirafter $(src) -I$(native-build) \
|
||||||
@ -62,15 +66,8 @@ build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
|||||||
|
|
||||||
cflags = $(build-cflags)
|
cflags = $(build-cflags)
|
||||||
|
|
||||||
use-libstdcpp = true
|
|
||||||
|
|
||||||
common-lflags = -lm -lz
|
common-lflags = -lm -lz
|
||||||
|
|
||||||
ifeq ($(use-libstdcpp),true)
|
|
||||||
common-lflags += -lstdc++
|
|
||||||
common-cflags += -DUSE_LIBSTDCPP
|
|
||||||
endif
|
|
||||||
|
|
||||||
build-lflags =
|
build-lflags =
|
||||||
|
|
||||||
lflags = $(common-lflags) -lpthread -ldl
|
lflags = $(common-lflags) -lpthread -ldl
|
||||||
|
@ -17,7 +17,6 @@ namespace vm {
|
|||||||
|
|
||||||
class Allocator {
|
class Allocator {
|
||||||
public:
|
public:
|
||||||
virtual ~Allocator() { }
|
|
||||||
virtual void* tryAllocate(unsigned size) = 0;
|
virtual void* tryAllocate(unsigned size) = 0;
|
||||||
virtual void* allocate(unsigned size) = 0;
|
virtual void* allocate(unsigned size) = 0;
|
||||||
virtual void free(const void* p, unsigned size) = 0;
|
virtual void free(const void* p, unsigned size) = 0;
|
||||||
|
@ -78,8 +78,6 @@ const int AnyRegister = -2;
|
|||||||
|
|
||||||
class Promise {
|
class Promise {
|
||||||
public:
|
public:
|
||||||
virtual ~Promise() { }
|
|
||||||
|
|
||||||
virtual int64_t value() = 0;
|
virtual int64_t value() = 0;
|
||||||
virtual bool resolved() = 0;
|
virtual bool resolved() = 0;
|
||||||
};
|
};
|
||||||
@ -101,8 +99,6 @@ class ResolvedPromise: public Promise {
|
|||||||
|
|
||||||
class TraceHandler {
|
class TraceHandler {
|
||||||
public:
|
public:
|
||||||
virtual ~TraceHandler() { }
|
|
||||||
|
|
||||||
virtual void handleTrace(Promise* address) = 0;
|
virtual void handleTrace(Promise* address) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -146,8 +142,6 @@ class Assembler {
|
|||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
public:
|
public:
|
||||||
virtual ~Client() { }
|
|
||||||
|
|
||||||
virtual int acquireTemporary
|
virtual int acquireTemporary
|
||||||
(uint32_t mask = ~static_cast<uint32_t>(0)) = 0;
|
(uint32_t mask = ~static_cast<uint32_t>(0)) = 0;
|
||||||
virtual void releaseTemporary(int r) = 0;
|
virtual void releaseTemporary(int r) = 0;
|
||||||
@ -156,8 +150,6 @@ class Assembler {
|
|||||||
virtual void restore(int r) = 0;
|
virtual void restore(int r) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Assembler() { }
|
|
||||||
|
|
||||||
virtual void setClient(Client* client) = 0;
|
virtual void setClient(Client* client) = 0;
|
||||||
|
|
||||||
virtual unsigned registerCount() = 0;
|
virtual unsigned registerCount() = 0;
|
||||||
|
@ -11,12 +11,9 @@
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
#ifndef USE_LIBSTDCPP
|
// since we aren't linking against libstdc++, we must implement this
|
||||||
// since we aren't linking against libstdc++, we must implement some
|
// ourselves:
|
||||||
// dummy functions:
|
|
||||||
extern "C" void __cxa_pure_virtual(void) { abort(); }
|
extern "C" void __cxa_pure_virtual(void) { abort(); }
|
||||||
void operator delete(void*) { abort(); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
# define EXPORT __declspec(dllexport)
|
# define EXPORT __declspec(dllexport)
|
||||||
|
@ -48,8 +48,6 @@ class Site {
|
|||||||
public:
|
public:
|
||||||
Site(): next(0) { }
|
Site(): next(0) { }
|
||||||
|
|
||||||
virtual ~Site() { }
|
|
||||||
|
|
||||||
virtual Site* readTarget(Context*, Read*) { return this; }
|
virtual Site* readTarget(Context*, Read*) { return this; }
|
||||||
|
|
||||||
virtual unsigned copyCost(Context*, Site*) = 0;
|
virtual unsigned copyCost(Context*, Site*) = 0;
|
||||||
@ -364,8 +362,6 @@ class Event {
|
|||||||
sequence(sequence), stackReset(false)
|
sequence(sequence), stackReset(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual ~Event() { }
|
|
||||||
|
|
||||||
virtual void compile(Context* c) = 0;
|
virtual void compile(Context* c) = 0;
|
||||||
|
|
||||||
virtual bool skipMove(unsigned) { return false; }
|
virtual bool skipMove(unsigned) { return false; }
|
||||||
|
@ -21,8 +21,6 @@ class Compiler {
|
|||||||
public:
|
public:
|
||||||
class Client {
|
class Client {
|
||||||
public:
|
public:
|
||||||
virtual ~Client() { }
|
|
||||||
|
|
||||||
virtual intptr_t getThunk(UnaryOperation op, unsigned size) = 0;
|
virtual intptr_t getThunk(UnaryOperation op, unsigned size) = 0;
|
||||||
virtual intptr_t getThunk(BinaryOperation op, unsigned size) = 0;
|
virtual intptr_t getThunk(BinaryOperation op, unsigned size) = 0;
|
||||||
};
|
};
|
||||||
@ -32,8 +30,6 @@ class Compiler {
|
|||||||
|
|
||||||
class Operand { };
|
class Operand { };
|
||||||
|
|
||||||
virtual ~Compiler() { }
|
|
||||||
|
|
||||||
virtual void pushState() = 0;
|
virtual void pushState() = 0;
|
||||||
virtual void popState() = 0;
|
virtual void popState() = 0;
|
||||||
virtual void saveStack() = 0;
|
virtual void saveStack() = 0;
|
||||||
|
@ -60,7 +60,7 @@ equal(const void* a, unsigned al, const void* b, unsigned bl)
|
|||||||
class Element {
|
class Element {
|
||||||
public:
|
public:
|
||||||
Element(): next(0) { }
|
Element(): next(0) { }
|
||||||
virtual ~Element() { }
|
|
||||||
virtual System::Region* find(const char* name) = 0;
|
virtual System::Region* find(const char* name) = 0;
|
||||||
virtual bool exists(const char* name) = 0;
|
virtual bool exists(const char* name) = 0;
|
||||||
virtual void dispose() = 0;
|
virtual void dispose() = 0;
|
||||||
|
@ -19,7 +19,6 @@ namespace vm {
|
|||||||
|
|
||||||
class Finder {
|
class Finder {
|
||||||
public:
|
public:
|
||||||
virtual ~Finder() { }
|
|
||||||
virtual System::Region* find(const char* name) = 0;
|
virtual System::Region* find(const char* name) = 0;
|
||||||
virtual bool exists(const char* name) = 0;
|
virtual bool exists(const char* name) = 0;
|
||||||
virtual const char* path() = 0;
|
virtual const char* path() = 0;
|
||||||
|
@ -32,19 +32,16 @@ class Heap: public Allocator {
|
|||||||
|
|
||||||
class Visitor {
|
class Visitor {
|
||||||
public:
|
public:
|
||||||
virtual ~Visitor() { }
|
|
||||||
virtual void visit(void*) = 0;
|
virtual void visit(void*) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Walker {
|
class Walker {
|
||||||
public:
|
public:
|
||||||
virtual ~Walker() { }
|
|
||||||
virtual bool visit(unsigned) = 0;
|
virtual bool visit(unsigned) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
public:
|
public:
|
||||||
virtual ~Client() { }
|
|
||||||
virtual void collect(void* context, CollectionType type) = 0;
|
virtual void collect(void* context, CollectionType type) = 0;
|
||||||
virtual void visitRoots(Visitor*) = 0;
|
virtual void visitRoots(Visitor*) = 0;
|
||||||
virtual bool isFixed(void*) = 0;
|
virtual bool isFixed(void*) = 0;
|
||||||
@ -54,7 +51,6 @@ class Heap: public Allocator {
|
|||||||
virtual void walk(void*, Walker*) = 0;
|
virtual void walk(void*, Walker*) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Heap() { }
|
|
||||||
virtual void setClient(Client* client) = 0;
|
virtual void setClient(Client* client) = 0;
|
||||||
virtual void collect(CollectionType type, unsigned footprint) = 0;
|
virtual void collect(CollectionType type, unsigned footprint) = 0;
|
||||||
virtual void* allocateFixed(Allocator* allocator, unsigned sizeInWords,
|
virtual void* allocateFixed(Allocator* allocator, unsigned sizeInWords,
|
||||||
|
@ -1212,7 +1212,7 @@ class Thread {
|
|||||||
t->protector = this;
|
t->protector = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Protector() {
|
~Protector() {
|
||||||
t->protector = next;
|
t->protector = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,15 +23,11 @@ class Processor {
|
|||||||
|
|
||||||
class StackVisitor {
|
class StackVisitor {
|
||||||
public:
|
public:
|
||||||
virtual ~StackVisitor() { }
|
|
||||||
|
|
||||||
virtual bool visit(StackWalker* walker) = 0;
|
virtual bool visit(StackWalker* walker) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class StackWalker {
|
class StackWalker {
|
||||||
public:
|
public:
|
||||||
virtual ~StackWalker() { }
|
|
||||||
|
|
||||||
virtual void walk(StackVisitor* v) = 0;
|
virtual void walk(StackVisitor* v) = 0;
|
||||||
|
|
||||||
virtual object method() = 0;
|
virtual object method() = 0;
|
||||||
@ -41,8 +37,6 @@ class Processor {
|
|||||||
virtual unsigned count() = 0;
|
virtual unsigned count() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Processor() { }
|
|
||||||
|
|
||||||
virtual Thread*
|
virtual Thread*
|
||||||
makeThread(Machine* m, object javaThread, Thread* parent) = 0;
|
makeThread(Machine* m, object javaThread, Thread* parent) = 0;
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ class Stream {
|
|||||||
public:
|
public:
|
||||||
class Client {
|
class Client {
|
||||||
public:
|
public:
|
||||||
virtual ~Client() { }
|
|
||||||
virtual void NO_RETURN handleError() = 0;
|
virtual void NO_RETURN handleError() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
12
src/system.h
12
src/system.h
@ -28,7 +28,6 @@ class System {
|
|||||||
|
|
||||||
class Thread {
|
class Thread {
|
||||||
public:
|
public:
|
||||||
virtual ~Thread() { }
|
|
||||||
virtual void interrupt() = 0;
|
virtual void interrupt() = 0;
|
||||||
virtual void join() = 0;
|
virtual void join() = 0;
|
||||||
virtual void dispose() = 0;
|
virtual void dispose() = 0;
|
||||||
@ -36,13 +35,11 @@ class System {
|
|||||||
|
|
||||||
class ThreadVisitor {
|
class ThreadVisitor {
|
||||||
public:
|
public:
|
||||||
virtual ~ThreadVisitor() { }
|
|
||||||
virtual void visit(void* ip, void* base, void* stack) = 0;
|
virtual void visit(void* ip, void* base, void* stack) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Runnable {
|
class Runnable {
|
||||||
public:
|
public:
|
||||||
virtual ~Runnable() { }
|
|
||||||
virtual void attach(Thread*) = 0;
|
virtual void attach(Thread*) = 0;
|
||||||
virtual void run() = 0;
|
virtual void run() = 0;
|
||||||
virtual bool interrupted() = 0;
|
virtual bool interrupted() = 0;
|
||||||
@ -51,7 +48,6 @@ class System {
|
|||||||
|
|
||||||
class Mutex {
|
class Mutex {
|
||||||
public:
|
public:
|
||||||
virtual ~Mutex() { }
|
|
||||||
virtual void acquire() = 0;
|
virtual void acquire() = 0;
|
||||||
virtual void release() = 0;
|
virtual void release() = 0;
|
||||||
virtual void dispose() = 0;
|
virtual void dispose() = 0;
|
||||||
@ -59,7 +55,6 @@ class System {
|
|||||||
|
|
||||||
class Monitor {
|
class Monitor {
|
||||||
public:
|
public:
|
||||||
virtual ~Monitor() { }
|
|
||||||
virtual bool tryAcquire(Thread* context) = 0;
|
virtual bool tryAcquire(Thread* context) = 0;
|
||||||
virtual void acquire(Thread* context) = 0;
|
virtual void acquire(Thread* context) = 0;
|
||||||
virtual void release(Thread* context) = 0;
|
virtual void release(Thread* context) = 0;
|
||||||
@ -72,7 +67,6 @@ class System {
|
|||||||
|
|
||||||
class Local {
|
class Local {
|
||||||
public:
|
public:
|
||||||
virtual ~Local() { }
|
|
||||||
virtual void* get() = 0;
|
virtual void* get() = 0;
|
||||||
virtual void set(void* p) = 0;
|
virtual void set(void* p) = 0;
|
||||||
virtual void dispose() = 0;
|
virtual void dispose() = 0;
|
||||||
@ -80,7 +74,6 @@ class System {
|
|||||||
|
|
||||||
class Region {
|
class Region {
|
||||||
public:
|
public:
|
||||||
virtual ~Region() { }
|
|
||||||
virtual const uint8_t* start() = 0;
|
virtual const uint8_t* start() = 0;
|
||||||
virtual size_t length() = 0;
|
virtual size_t length() = 0;
|
||||||
virtual void dispose() = 0;
|
virtual void dispose() = 0;
|
||||||
@ -88,7 +81,6 @@ class System {
|
|||||||
|
|
||||||
class Library {
|
class Library {
|
||||||
public:
|
public:
|
||||||
virtual ~Library() { }
|
|
||||||
virtual void* resolve(const char* function) = 0;
|
virtual void* resolve(const char* function) = 0;
|
||||||
virtual const char* name() = 0;
|
virtual const char* name() = 0;
|
||||||
virtual bool mapName() = 0;
|
virtual bool mapName() = 0;
|
||||||
@ -99,8 +91,6 @@ class System {
|
|||||||
|
|
||||||
class SignalHandler {
|
class SignalHandler {
|
||||||
public:
|
public:
|
||||||
virtual ~SignalHandler() { }
|
|
||||||
|
|
||||||
virtual bool handleSignal(void** ip, void** base, void** stack,
|
virtual bool handleSignal(void** ip, void** base, void** stack,
|
||||||
void** thread) = 0;
|
void** thread) = 0;
|
||||||
};
|
};
|
||||||
@ -120,8 +110,6 @@ class System {
|
|||||||
System::Monitor* m;
|
System::Monitor* m;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~System() { }
|
|
||||||
|
|
||||||
virtual bool success(Status) = 0;
|
virtual bool success(Status) = 0;
|
||||||
virtual void* tryAllocate(unsigned sizeInBytes) = 0;
|
virtual void* tryAllocate(unsigned sizeInBytes) = 0;
|
||||||
virtual void free(const void* p) = 0;
|
virtual void free(const void* p) = 0;
|
||||||
|
@ -130,8 +130,6 @@ class Task {
|
|||||||
public:
|
public:
|
||||||
Task(Task* next): next(next) { }
|
Task(Task* next): next(next) { }
|
||||||
|
|
||||||
virtual ~Task() { }
|
|
||||||
|
|
||||||
virtual void run(Context* c) = 0;
|
virtual void run(Context* c) = 0;
|
||||||
|
|
||||||
Task* next;
|
Task* next;
|
||||||
|
Loading…
Reference in New Issue
Block a user