diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/log.h | 21 | ||||
-rw-r--r-- | common/nextpnr.h | 19 |
2 files changed, 26 insertions, 14 deletions
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()); |