Mostly fixing up alloy clang build.

This commit is contained in:
Ben Vanik
2014-08-18 22:01:55 -07:00
parent 2356164525
commit d578f5d0f0
16 changed files with 64 additions and 56 deletions

View File

@@ -19,7 +19,7 @@ namespace poly {
#define static_assert_size(type, size) \
static_assert(sizeof(type) == size, \
"bad definition for "## #type##": must be "## #size##" bytes")
"bad definition for " #type ": must be " #size " bytes")
// We rely on assert being compiled out in NDEBUG.
#define poly_assert assert

View File

@@ -40,10 +40,12 @@ inline int64_t atomic_exchange(int64_t new_value, volatile int64_t* value) {
return OSAtomicCompareAndSwap64Barrier(*value, new_value, value);
}
//inline int32_t atomic_exchange_add(int32_t amount, volatile int32_t* value) {
//}
//inline int64_t atomic_exchange_add(int64_t amount, volatile int64_t* value) {
//}
inline int32_t atomic_exchange_add(int32_t amount, volatile int32_t* value) {
return OSAtomicAdd32Barrier(amount, value) - amount;
}
inline int64_t atomic_exchange_add(int64_t amount, volatile int64_t* value) {
return OSAtomicAdd64Barrier(amount, value) - amount;
}
inline bool atomic_cas(int32_t old_value, int32_t new_value,
volatile int32_t* value) {
@@ -51,7 +53,7 @@ inline bool atomic_cas(int32_t old_value, int32_t new_value,
old_value, new_value, reinterpret_cast<volatile int32_t*>(value));
}
inline bool atomic_cas(int64_t old_value, int64_t new_value,
volatile int32_t* value) {
volatile int64_t* value) {
return OSAtomicCompareAndSwap64Barrier(
old_value, new_value, reinterpret_cast<volatile int64_t*>(value));
}
@@ -110,10 +112,12 @@ inline int64_t atomic_exchange(int64_t new_value, volatile int64_t* value) {
return __sync_val_compare_and_swap(*value, value, new_value);
}
//inline int32_t atomic_exchange_add(int32_t amount, volatile int32_t* value) {
//}
//inline int64_t atomic_exchange_add(int64_t amount, volatile int64_t* value) {
//}
inline int32_t atomic_exchange_add(int32_t amount, volatile int32_t* value) {
return __sync_fetch_and_add(amount, value);
}
inline int64_t atomic_exchange_add(int64_t amount, volatile int64_t* value) {
return __sync_fetch_and_add(amount, value);
}
inline bool atomic_cas(int32_t old_value, int32_t new_value,
volatile int32_t* value) {

View File

@@ -36,12 +36,14 @@
// C++1y make_unique.
// http://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/
// This is present in clang with -std=c++1y, but not otherwise.
#if __clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 4)
namespace std {
template <typename T, typename... Args>
unique_ptr<T> make_unique(Args&&... args) {
return unique_ptr<T>(new T(forward<Args>(args)...));
}
} // namespace std
#endif // clang < 3.4
#endif // !XE_COMPILER_MSVC
namespace poly {} // namespace poly

View File

@@ -9,22 +9,20 @@
#include <poly/main.h>
#include <gflags/gflags.h>
#include <poly/string.h>
namespace poly {
bool has_console_attached() {
return true;
}
bool has_console_attached() { return true; }
} // namespace poly
extern "C" int main(int argc, char** argv) {
auto entry_info = poly::GetEntryInfo();
google::SetUsageMessage(std::string("usage: ") +
poly::to_string(entry_info.usage));
poly::to_string(entry_info.usage));
google::SetVersionString("1.0");
google::ParseCommandLineFlags(&argc, &argv, true);

View File

@@ -36,22 +36,22 @@ class PosixMappedMemory : public MappedMemory {
std::unique_ptr<MappedMemory> MappedMemory::Open(const std::wstring& path,
Mode mode, size_t offset,
size_t length) {
const char* mode;
const char* mode_str;
int prot;
switch (mode) {
case Mode::READ:
mode = "rb";
mode_str = "rb";
prot = PROT_READ;
break;
case Mode::READ_WRITE:
mode = "r+b";
mode_str = "r+b";
prot = PROT_READ | PROT_WRITE;
break;
}
auto mm = std::make_unique<PosixMappedMemory>(path, mode);
mm->file_handle = fopen(poly::to_string(path).c_str(), mode);
mm->file_handle = fopen(poly::to_string(path).c_str(), mode_str);
if (!mm->file_handle) {
return nullptr;
}

View File

@@ -14,6 +14,7 @@
#include <cstdint>
#include <cstring>
#include <type_traits>
#include <poly/config.h>
#include <poly/platform.h>

View File

@@ -10,6 +10,7 @@
#include <poly/string.h>
#include <codecvt>
#include <locale>
namespace poly {