diff --git a/Makefile.am b/Makefile.am index a6e9542d1..26929151a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,18 +46,14 @@ EXTRA_DIST = \ msvc/LGlib-features.props \ msvc/LinkGenerator.vcxproj \ msvc/LinkGrammarExe.vcxproj \ - msvc/LinkGrammarExe.vcxproj.filters \ msvc/LinkGrammarJava.vcxproj \ - msvc/LinkGrammarJava.vcxproj.filters \ msvc/LinkGrammar.sln \ msvc/LinkGrammar.vcxproj \ - msvc/LinkGrammar.vcxproj.filters \ msvc/Local.props \ msvc/confvar.bat \ msvc/MSVC-common.props \ msvc/post-build.bat \ msvc/Python3.vcxproj \ - msvc/Python3.vcxproj.filters \ msvc/README.md \ msvc/make-check.py \ TODO diff --git a/link-grammar/error.h b/link-grammar/error.h index 9114b182d..b81e4f57d 100644 --- a/link-grammar/error.h +++ b/link-grammar/error.h @@ -15,7 +15,7 @@ #include "link-includes.h" #include "externs.h" // verbosity -#include "utilities.h" // GNUC_NORETURN, STRINGIFY +#include "utilities.h" // NORETURN, STRINGIFY /* User verbosity levels are 1-4, to be used for user info/debug. * For now hard-coded numbers are still used instead of D_USER_BASIC/TIMES. */ @@ -97,8 +97,9 @@ void lg_lib_failure(void); extern void (* assert_failure_trap)(void); #define FILELINE __FILE__ ":" STRINGIFY(__LINE__) +NORETURN void assert_failure(const char[], const char[], const char *, const char *, ...) - GNUC_PRINTF(4,5) GNUC_NORETURN; + GNUC_PRINTF(4,5); /* Define a private version of assert() with a printf-like error * message. The C one is not used. */ diff --git a/link-grammar/parse/count.c b/link-grammar/parse/count.c index 8f90fe44f..1c636f672 100644 --- a/link-grammar/parse/count.c +++ b/link-grammar/parse/count.c @@ -576,10 +576,10 @@ static Count_bin table_store(count_context_t *ctxt, Count_bin *e = table_lookup(ctxt, lw, rw, le, re, null_count, NULL); if (e != NULL) { - assert((e == NULL) || (hist_total(&c) == hist_total(e)), - "Inconsistent count for w(%d,%d) tracon_id(%d,%d)", - lw, rw, l_id, r_id); - return c; + assert((hist_total(&c) == hist_total(e)), + "Inconsistent count for w(%d,%d) tracon_id(%d,%d): %zd != %zd", + lw, rw, l_id, r_id, (ssize_t)hist_total(&c), (ssize_t)hist_total(e)); + return *e; } // The count is still stored, for the above consistency check @@ -957,7 +957,7 @@ static Count_bin table_count(count_context_t * ctxt, int lw, int rw, Connector *le, Connector *re, unsigned int null_count) { - if (!USE_TABLE_TRACON) return true; + if (!USE_TABLE_TRACON) return count_unknown; /* This check is not necessary for correctness, but it saves CPU time. * If a cross link would result, we know that the count would be 0. diff --git a/link-grammar/parse/extract-links.c b/link-grammar/parse/extract-links.c index 98c186dbd..0e098f111 100644 --- a/link-grammar/parse/extract-links.c +++ b/link-grammar/parse/extract-links.c @@ -157,7 +157,8 @@ static void record_choice( static int estimate_log2_table_size(Sentence sent) { /* Size estimate based on measurements (see #1402) */ - double lscale = log2(sent->num_disjuncts + 1.0) - 0.5 * log2(sent->length); + double lscale = log2((double)sent->num_disjuncts + 1.0) - + 0.5 * log2((double)sent->length); double lo_est = lscale + 4.0; double hi_est = 1.5 * lscale; double dj_est = fmax(lo_est, hi_est); @@ -166,10 +167,10 @@ static int estimate_log2_table_size(Sentence sent) * pex->Pset_bucket_pool is almost exactly equal to the num elts * issued for sent->Table_tracon_pool. This provides a better * estimate when parsing with MST, when the above is too low. */ - double ntracon = pool_num_elements_issued(sent->Table_tracon_pool); + double ntracon = (double)pool_num_elements_issued(sent->Table_tracon_pool); double ltra = log2(ntracon) + 1.0; // + 1.0 because floor() - int log2_table_size = floor(fmax(dj_est, ltra)); + int log2_table_size = (int)floor(fmax(dj_est, ltra)); // Enforce min and max sizes. if (log2_table_size < 4) log2_table_size = 4; diff --git a/link-grammar/parse/fast-match.c b/link-grammar/parse/fast-match.c index d59d7dec1..a6e9d0e7f 100644 --- a/link-grammar/parse/fast-match.c +++ b/link-grammar/parse/fast-match.c @@ -595,8 +595,8 @@ form_match_list(fast_matcher_t *ctxt, int w, } #ifdef VERIFY_MATCH_LIST - static _Atomic(uint16_t) id = 0; - uint16_t lid = ++id; /* A local copy, for multi-threading support. */ + static uint16_t id = 0; + uint16_t lid = ++id; /* A stable local copy, for multi-threading support. */ #else const uint16_t lid = 0; #endif diff --git a/link-grammar/utilities.h b/link-grammar/utilities.h index dceed6d1b..116c3d625 100644 --- a/link-grammar/utilities.h +++ b/link-grammar/utilities.h @@ -253,13 +253,13 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n) * support C11. So it already supports all the features below. */ /* Optimizations etc. that only gcc understands */ -/* FIXME: Change to ATTR_* and define also for MSVC. */ +/* FIXME: Define also for MSVC. */ #if __GNUC__ #define GCC_DIAGNOSTIC #define UNREACHABLE(x) (__extension__ ({if (x) __builtin_unreachable();})) #define GNUC_MALLOC __attribute__ ((__malloc__)) #define GNUC_UNUSED __attribute__ ((__unused__)) -#define GNUC_NORETURN __attribute__ ((__noreturn__)) +#define NORETURN __attribute__ ((__noreturn__)) #define ATTR_PURE __attribute__ ((__pure__)) #define NO_SAN __attribute__ ((no_sanitize_address, no_sanitize_undefined)) @@ -271,7 +271,6 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n) #else #define NO_SAN_DICT #endif - #ifndef DONT_EXPECT #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) @@ -281,7 +280,7 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n) #define UNREACHABLE(x) #define GNUC_MALLOC #define GNUC_UNUSED -#define GNUC_NORETURN +#define NORETURN #define ATTR_PURE #define NO_SAN_DICT @@ -289,6 +288,10 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n) #define unlikely(x) x #endif +#ifdef _MSC_VER +#undef NORETURN +#define NORETURN __declspec(noreturn) +#endif /* Apply a pragma to a specific code section only. * XXX According to the GCC docs, we cannot use here something like diff --git a/msvc/LinkGrammar.vcxproj b/msvc/LinkGrammar.vcxproj index 9e0cf31b4..ce45ec113 100644 --- a/msvc/LinkGrammar.vcxproj +++ b/msvc/LinkGrammar.vcxproj @@ -235,14 +235,15 @@ - - + + + @@ -254,6 +255,10 @@ + + + + @@ -272,18 +277,18 @@ - + - + - + @@ -295,13 +300,13 @@ - + - - + - + + @@ -312,12 +317,20 @@ CompileAsCpp CompileAsCpp - + + + + + + + + + @@ -327,6 +340,7 @@ + @@ -341,13 +355,15 @@ - + - + + + @@ -394,4 +410,4 @@ - \ No newline at end of file + diff --git a/msvc/LinkGrammar.vcxproj.filters b/msvc/LinkGrammar.vcxproj.filters deleted file mode 100644 index d70cda19c..000000000 --- a/msvc/LinkGrammar.vcxproj.filters +++ /dev/null @@ -1,377 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - Source Files - - - \ No newline at end of file diff --git a/msvc/LinkGrammarExe.vcxproj.filters b/msvc/LinkGrammarExe.vcxproj.filters deleted file mode 100644 index 6cbab54d3..000000000 --- a/msvc/LinkGrammarExe.vcxproj.filters +++ /dev/null @@ -1,42 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/msvc/LinkGrammarJava.vcxproj.filters b/msvc/LinkGrammarJava.vcxproj.filters deleted file mode 100644 index 7b9b93052..000000000 --- a/msvc/LinkGrammarJava.vcxproj.filters +++ /dev/null @@ -1,27 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - - - Header Files - - - diff --git a/msvc/Python3.vcxproj.filters b/msvc/Python3.vcxproj.filters deleted file mode 100644 index b19bd20b5..000000000 --- a/msvc/Python3.vcxproj.filters +++ /dev/null @@ -1,28 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - - Source Files - - - \ No newline at end of file