aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-07-03 08:52:19 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-07-03 08:53:44 +0200
commit1cf82930191d6498fc14e1854472f0d955a4c4ea (patch)
tree58edfdc7fc506ab46591beac8e74ba9dd8c5b08f
parentfe1ad5b086c46b82aa72cb0f9625ebdf941e50f9 (diff)
downloadnextpnr-1cf82930191d6498fc14e1854472f0d955a4c4ea.tar.gz
nextpnr-1cf82930191d6498fc14e1854472f0d955a4c4ea.tar.bz2
nextpnr-1cf82930191d6498fc14e1854472f0d955a4c4ea.zip
Fixed macros and includes for MSVC
-rw-r--r--CMakeLists.txt18
-rw-r--r--common/log.h21
-rw-r--r--common/nextpnr.h19
-rw-r--r--ice40/arch.h42
-rw-r--r--ice40/bitstream.cc1
-rw-r--r--ice40/pack.cc1
-rw-r--r--json/jsonparse.cc1
7 files changed, 66 insertions, 37 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c81692d..1e265154 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,8 +9,13 @@ option(BUILD_TESTS "Build GUI" OFF)
# List of families to build
set(FAMILIES generic ice40)
set(CMAKE_CXX_STANDARD 11)
+if (MSVC)
+set(CMAKE_CXX_FLAGS_DEBUG "/W4 /wd4100 /wd4244 /wd4125 /wd4800 /wd4456 /wd4458 /wd4305")
+set(CMAKE_CXX_FLAGS_RELEASE "/W4 /wd4100 /wd4244 /wd4125 /wd4800 /wd4456 /wd4458 /wd4305")
+else()
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -fPIC -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "-Wall -fPIC -O3 -g")
+endif()
set(CMAKE_DEFIN)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/3rdparty/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
@@ -114,6 +119,10 @@ set(CMAKE_BUILD_TYPE Release)
if(MINGW)
add_definitions("-Wa,-mbig-obj")
endif(MINGW)
+if (MSVC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+endif()
foreach (family ${FAMILIES})
string(TOUPPER ${family} ufamily)
@@ -186,12 +195,3 @@ add_custom_target(
-i
${CLANGFORMAT_FILES}
)
-
-unset(BUILD_GUI CACHE)
-unset(BUILD_PYTHON CACHE)
-unset(BUILD_TESTS CACHE)
-unset(SANITIZE_ADDRESS CACHE)
-unset(SANITIZE_MEMORY CACHE)
-unset(SANITIZE_THREAD CACHE)
-unset(SANITIZE_UNDEFINED CACHE)
-unset(SANITIZE_LINK_STATIC CACHE)
diff --git a/common/log.h b/common/log.h
index 01d0bf41..c3607e39 100644
--- a/common/log.h
+++ b/common/log.h
@@ -30,11 +30,6 @@
#include "nextpnr.h"
-// from libs/sha1/sha1.h
-
-#define NXP_NORETURN
-#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
-
NEXTPNR_NAMESPACE_BEGIN
typedef std::function<void(std::string)> log_write_type;
@@ -60,16 +55,16 @@ extern void (*log_error_atexit)();
void logv(const char *format, va_list ap);
void logv_warning(const char *format, va_list ap);
void logv_warning_noprefix(const char *format, va_list ap);
-NXP_NORETURN void logv_error(const char *format, va_list ap) NXP_ATTRIBUTE(noreturn);
+NPNR_NORETURN void logv_error(const char *format, va_list ap) NPNR_ATTRIBUTE(noreturn);
extern std::ostream clog;
-void log(const char *format, ...) NXP_ATTRIBUTE(format(printf, 1, 2));
-void log_header(const char *format, ...) NXP_ATTRIBUTE(format(printf, 1, 2));
-void log_info(const char *format, ...) NXP_ATTRIBUTE(format(printf, 1, 2));
-void log_warning(const char *format, ...) NXP_ATTRIBUTE(format(printf, 1, 2));
-void log_warning_noprefix(const char *format, ...) NXP_ATTRIBUTE(format(printf, 1, 2));
-NXP_NORETURN void log_error(const char *format, ...) NXP_ATTRIBUTE(format(printf, 1, 2), noreturn);
-NXP_NORETURN void log_cmd_error(const char *format, ...) NXP_ATTRIBUTE(format(printf, 1, 2), noreturn);
+void log(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2));
+void log_header(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2));
+void log_info(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2));
+void log_warning(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2));
+void log_warning_noprefix(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2));
+NPNR_NORETURN void log_error(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2), noreturn);
+NPNR_NORETURN void log_cmd_error(const char *format, ...) NPNR_ATTRIBUTE(format(printf, 1, 2), noreturn);
void log_break();
void log_flush();
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 094d6241..96511acf 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -41,6 +41,23 @@
#define USING_NEXTPNR_NAMESPACE
#endif
+#if defined(__GNUC__) || defined(__clang__)
+# define NPNR_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
+# define NPNR_NORETURN
+# define NPNR_DEPRECATED __attribute__((deprecated))
+# define NPNR_PACKED_STRUCT( ... ) __VA_ARGS__ __attribute__((packed))
+#elif defined(_MSC_VER)
+# define NPNR_ATTRIBUTE(...)
+# define NPNR_NORETURN __declspec(noreturn)
+# define NPNR_DEPRECATED __declspec(deprecated)
+# define NPNR_PACKED_STRUCT( ... ) __pragma(pack(push, 1)) __VA_ARGS__ __pragma(pack(pop))
+#else
+# define NPNR_ATTRIBUTE(...)
+# define NPNR_NORETURN
+# define NPNR_DEPRECATED
+# define NPNR_PACKED_STRUCT( ... ) __VA_ARGS__
+#endif
+
NEXTPNR_NAMESPACE_BEGIN
struct BaseCtx;
@@ -76,7 +93,7 @@ struct IdString
static std::unordered_set<BaseCtx *> global_ctx;
- const std::string &global_str() const __attribute__((deprecated))
+ NPNR_DEPRECATED const std::string &global_str() const
{
assert(global_ctx.size() == 1);
return str(*global_ctx.begin());
diff --git a/ice40/arch.h b/ice40/arch.h
index 9ed30f93..207e885c 100644
--- a/ice40/arch.h
+++ b/ice40/arch.h
@@ -43,12 +43,14 @@ template <typename T> struct RelPtr
const T *operator->() const { return get(); }
};
+NPNR_PACKED_STRUCT(
struct BelWirePOD
{
int32_t wire_index;
PortPin port;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct BelInfoPOD
{
RelPtr<char> name;
@@ -57,14 +59,16 @@ struct BelInfoPOD
RelPtr<BelWirePOD> bel_wires;
int8_t x, y, z;
int8_t padding_0;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct BelPortPOD
{
int32_t bel_index;
PortPin port;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct PipInfoPOD
{
int32_t src, dst;
@@ -72,8 +76,9 @@ struct PipInfoPOD
int8_t x, y;
int16_t switch_mask;
int32_t switch_index;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct WireInfoPOD
{
RelPtr<char> name;
@@ -87,20 +92,22 @@ struct WireInfoPOD
int8_t x, y;
WireType type;
int8_t padding_0;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct PackagePinPOD
{
RelPtr<char> name;
int32_t bel_index;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct PackageInfoPOD
{
RelPtr<char> name;
int32_t num_pins;
RelPtr<PackagePinPOD> pins;
-} __attribute__((packed));
+});
enum TileType : uint32_t
{
@@ -116,48 +123,55 @@ enum TileType : uint32_t
TILE_IPCON = 9
};
+NPNR_PACKED_STRUCT(
struct ConfigBitPOD
{
int8_t row, col;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct ConfigEntryPOD
{
RelPtr<char> name;
int32_t num_bits;
RelPtr<ConfigBitPOD> bits;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct TileInfoPOD
{
int8_t cols, rows;
int16_t num_config_entries;
RelPtr<ConfigEntryPOD> entries;
-} __attribute__((packed));
+});
static const int max_switch_bits = 5;
+NPNR_PACKED_STRUCT(
struct SwitchInfoPOD
{
int32_t num_bits;
int8_t x, y;
ConfigBitPOD cbits[max_switch_bits];
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct IerenInfoPOD
{
int8_t iox, ioy, ioz;
int8_t ierx, iery, ierz;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct BitstreamInfoPOD
{
int32_t num_switches, num_ierens;
RelPtr<TileInfoPOD> tiles_nonrouting;
RelPtr<SwitchInfoPOD> switches;
RelPtr<IerenInfoPOD> ierens;
-} __attribute__((packed));
+});
+NPNR_PACKED_STRUCT(
struct ChipInfoPOD
{
int32_t width, height;
@@ -169,7 +183,7 @@ struct ChipInfoPOD
RelPtr<TileType> tile_grid;
RelPtr<BitstreamInfoPOD> bits_info;
RelPtr<PackageInfoPOD> packages_data;
-} __attribute__((packed));
+});
extern const char chipdb_blob_384[];
extern const char chipdb_blob_1k[];
diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc
index 0b6e0d35..c739d3c9 100644
--- a/ice40/bitstream.cc
+++ b/ice40/bitstream.cc
@@ -18,6 +18,7 @@
*
*/
#include "bitstream.h"
+#include <cctype>
#include <vector>
#include "log.h"
diff --git a/ice40/pack.cc b/ice40/pack.cc
index 2484aa53..d1be4a29 100644
--- a/ice40/pack.cc
+++ b/ice40/pack.cc
@@ -20,6 +20,7 @@
#include "pack.h"
#include <algorithm>
+#include <iterator>
#include <unordered_set>
#include "cells.h"
#include "design_utils.h"
diff --git a/json/jsonparse.cc b/json/jsonparse.cc
index 418147e8..bf1760d3 100644
--- a/json/jsonparse.cc
+++ b/json/jsonparse.cc
@@ -28,6 +28,7 @@
#include <log.h>
#include <map>
#include <string>
+#include <iterator>
#include "nextpnr.h"
NEXTPNR_NAMESPACE_BEGIN