mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
first pass at cmake + visual studio support
This commit is contained in:
parent
6c8426459a
commit
51b510cbea
@ -16,9 +16,10 @@ add_definitions (
|
||||
-D__STDC_CONSTANT_MACROS
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -fno-exceptions -std=c++0x")
|
||||
|
||||
include ("cmake/Platform.cmake")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CXX_FLAGS}")
|
||||
|
||||
include (CTest)
|
||||
|
||||
# Sadly, we can't use the 'test' target, as that's coopted by ctest
|
||||
|
@ -6,3 +6,10 @@ IF (APPLE)
|
||||
|
||||
SET(PLATFORM_LIBS ${CORE_FOUNDATION_LIBRARY})
|
||||
ENDIF()
|
||||
|
||||
IF (MSVC)
|
||||
SET(PLATFORM_CXX_FLAGS "/Wall")
|
||||
ELSE()
|
||||
SET(PLATFORM_CXX_FLAGS "-Wall -Werror -fno-exceptions -std=c++0x")
|
||||
SET(PLATFORM_LIBS ${PLATFORM_LIBS} pthread dl)
|
||||
ENDIF()
|
||||
|
@ -32,8 +32,13 @@ class Args {
|
||||
|
||||
template <class... Ts>
|
||||
Args(Ts... ts)
|
||||
#ifndef _MSC_VER
|
||||
: values{ts...}
|
||||
#endif
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
setArrayElements(values, ts...);
|
||||
#endif
|
||||
}
|
||||
|
||||
operator util::Slice<ir::Value*>()
|
||||
|
@ -44,6 +44,16 @@ struct ArgumentCount<> {
|
||||
enum { Result = 0 };
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void setArrayElements(T*) {
|
||||
}
|
||||
|
||||
template<class T, class... Ts>
|
||||
void setArrayElements(T* arr, T elem, Ts... ts) {
|
||||
*arr = elem;
|
||||
setArrayElements(arr, ts...);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace avian
|
||||
|
||||
|
@ -39,29 +39,9 @@
|
||||
|
||||
#define strncasecmp _strnicmp
|
||||
|
||||
#define FP_NAN 0
|
||||
#define FP_INFINITE 1
|
||||
#define FP_UNDEF 2
|
||||
|
||||
inline int fpclassify(double d)
|
||||
{
|
||||
switch (_fpclass(d)) {
|
||||
case _FPCLASS_SNAN:
|
||||
case _FPCLASS_QNAN:
|
||||
return FP_NAN;
|
||||
case _FPCLASS_PINF:
|
||||
case _FPCLASS_NINF:
|
||||
return FP_INFINITE;
|
||||
}
|
||||
return FP_UNDEF;
|
||||
}
|
||||
|
||||
inline int signbit(double d)
|
||||
{
|
||||
return _copysign(1.0, d) < 0;
|
||||
}
|
||||
|
||||
#define not!
|
||||
#define not !
|
||||
#define or ||
|
||||
#define and &&
|
||||
#define xor ^
|
||||
|
@ -1,3 +1,7 @@
|
||||
|
||||
# TODO: use posix.cpp or windows.cpp, depending on platform
|
||||
add_library(avian_system posix.cpp posix/crash.cpp)
|
||||
if (MSVC)
|
||||
#todo: support mingw compiler
|
||||
add_library(avian_system windows.cpp windows/crash.cpp)
|
||||
else()
|
||||
add_library(avian_system posix.cpp posix/crash.cpp)
|
||||
endif()
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <sys/stat.h>
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
@ -90,7 +91,7 @@ void usageAndExit(const char* name)
|
||||
|
||||
int main(int argc, const char** argv)
|
||||
{
|
||||
if (argc < 7 or argc > 10) {
|
||||
if (argc < 7 || argc > 10) {
|
||||
usageAndExit(argv[0]);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,12 @@ namespace {
|
||||
#define IMAGE_SCN_MEM_WRITE 0x80000000
|
||||
#define IMAGE_SCN_CNT_CODE 32
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define PACKED_STRUCT _declspec(align(1))
|
||||
#else
|
||||
#define PACKED_STRUCT __attribute__((packed))
|
||||
#endif
|
||||
|
||||
struct IMAGE_FILE_HEADER {
|
||||
uint16_t Machine;
|
||||
uint16_t NumberOfSections;
|
||||
@ -48,7 +54,7 @@ struct IMAGE_FILE_HEADER {
|
||||
uint32_t NumberOfSymbols;
|
||||
uint16_t SizeOfOptionalHeader;
|
||||
uint16_t Characteristics;
|
||||
} __attribute__((packed));
|
||||
} PACKED_STRUCT;
|
||||
|
||||
struct IMAGE_SECTION_HEADER {
|
||||
uint8_t Name[IMAGE_SIZEOF_SHORT_NAME];
|
||||
@ -64,7 +70,7 @@ struct IMAGE_SECTION_HEADER {
|
||||
uint16_t NumberOfRelocations;
|
||||
uint16_t NumberOfLinenumbers;
|
||||
uint32_t Characteristics;
|
||||
} __attribute__((packed));
|
||||
} PACKED_STRUCT;
|
||||
|
||||
struct IMAGE_SYMBOL {
|
||||
union {
|
||||
@ -78,7 +84,7 @@ struct IMAGE_SYMBOL {
|
||||
uint16_t Type;
|
||||
uint8_t StorageClass;
|
||||
uint8_t NumberOfAuxSymbols;
|
||||
} __attribute__((packed));
|
||||
} PACKED_STRUCT;
|
||||
// --- winnt.h ----
|
||||
|
||||
inline unsigned pad(unsigned n)
|
||||
|
@ -94,13 +94,13 @@ Platform* Platform::first = 0;
|
||||
|
||||
PlatformInfo::Format PlatformInfo::formatFromString(const char* format)
|
||||
{
|
||||
if (strcmp(format, "elf") == 0 or strcmp(format, "linux") == 0
|
||||
or strcmp(format, "freebsd") == 0 or strcmp(format, "qnx") == 0) {
|
||||
if (strcmp(format, "elf") == 0 || strcmp(format, "linux") == 0
|
||||
|| strcmp(format, "freebsd") == 0 || strcmp(format, "qnx") == 0) {
|
||||
return Elf;
|
||||
} else if (strcmp(format, "pe") == 0 or strcmp(format, "windows") == 0) {
|
||||
} else if (strcmp(format, "pe") == 0 || strcmp(format, "windows") == 0) {
|
||||
return Pe;
|
||||
} else if (strcmp(format, "macho") == 0 or strcmp(format, "darwin") == 0
|
||||
or strcmp(format, "ios") == 0 or strcmp(format, "macosx") == 0) {
|
||||
} else if (strcmp(format, "macho") == 0 || strcmp(format, "darwin") == 0
|
||||
|| strcmp(format, "ios") == 0 || strcmp(format, "macosx") == 0) {
|
||||
return MachO;
|
||||
} else {
|
||||
return UnknownFormat;
|
||||
@ -110,13 +110,13 @@ PlatformInfo::Format PlatformInfo::formatFromString(const char* format)
|
||||
PlatformInfo::Architecture PlatformInfo::archFromString(const char* arch)
|
||||
{
|
||||
if (strcmp(arch, "i386") == 0) {
|
||||
return x86;
|
||||
return Architecture::x86;
|
||||
} else if (strcmp(arch, "x86_64") == 0) {
|
||||
return x86_64;
|
||||
return Architecture::x86_64;
|
||||
} else if (strcmp(arch, "arm") == 0) {
|
||||
return Arm;
|
||||
return Architecture::Arm;
|
||||
} else {
|
||||
return UnknownArch;
|
||||
return Architecture::UnknownArch;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ class Output {
|
||||
{
|
||||
static const int Size = 32;
|
||||
char s[Size];
|
||||
int c UNUSED = ::snprintf(s, Size, "%d", i);
|
||||
int c UNUSED = vm::snprintf(s, Size, "%d", i);
|
||||
assert(c > 0 and c < Size);
|
||||
write(s);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class Class {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void dumpToStdout() const AVIAN_EXPORT
|
||||
void dumpToStdout() const
|
||||
{
|
||||
printf("%s\n", dump().c_str());
|
||||
}
|
||||
@ -615,13 +615,14 @@ const char* fieldType(const char* spec)
|
||||
|
||||
void parseJavaClass(Module& module, ClassParser& clparser, Stream* s)
|
||||
{
|
||||
uint32_t magic UNUSED = s->read4();
|
||||
uint32_t magic = s->read4();
|
||||
assert(magic == 0xCAFEBABE);
|
||||
(void)magic;
|
||||
s->read2(); // minor version
|
||||
s->read2(); // major version
|
||||
|
||||
unsigned poolCount = s->read2() - 1;
|
||||
uintptr_t pool[poolCount];
|
||||
std::vector<uintptr_t> pool(poolCount, -1);
|
||||
for (unsigned i = 0; i < poolCount; ++i) {
|
||||
unsigned c = s->read1();
|
||||
|
||||
|
@ -16,8 +16,6 @@ target_link_libraries (avian_unittest
|
||||
avian_system
|
||||
avian_heap
|
||||
avian_util
|
||||
pthread
|
||||
dl
|
||||
${PLATFORM_LIBS}
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user