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