Skip to content

Commit 1317863

Browse files
authored
Merge pull request #1537 from ampli/windows-fixes
Windows fixes
2 parents 1a4775a + 3c23a1c commit 1317863

11 files changed

+50
-507
lines changed

Makefile.am

-4
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,14 @@ EXTRA_DIST = \
4646
msvc/LGlib-features.props \
4747
msvc/LinkGenerator.vcxproj \
4848
msvc/LinkGrammarExe.vcxproj \
49-
msvc/LinkGrammarExe.vcxproj.filters \
5049
msvc/LinkGrammarJava.vcxproj \
51-
msvc/LinkGrammarJava.vcxproj.filters \
5250
msvc/LinkGrammar.sln \
5351
msvc/LinkGrammar.vcxproj \
54-
msvc/LinkGrammar.vcxproj.filters \
5552
msvc/Local.props \
5653
msvc/confvar.bat \
5754
msvc/MSVC-common.props \
5855
msvc/post-build.bat \
5956
msvc/Python3.vcxproj \
60-
msvc/Python3.vcxproj.filters \
6157
msvc/README.md \
6258
msvc/make-check.py \
6359
TODO

link-grammar/error.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "link-includes.h"
1717
#include "externs.h" // verbosity
18-
#include "utilities.h" // GNUC_NORETURN, STRINGIFY
18+
#include "utilities.h" // NORETURN, STRINGIFY
1919

2020
/* User verbosity levels are 1-4, to be used for user info/debug.
2121
* For now hard-coded numbers are still used instead of D_USER_BASIC/TIMES. */
@@ -97,8 +97,9 @@ void lg_lib_failure(void);
9797

9898
extern void (* assert_failure_trap)(void);
9999
#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)
100+
NORETURN
100101
void assert_failure(const char[], const char[], const char *, const char *, ...)
101-
GNUC_PRINTF(4,5) GNUC_NORETURN;
102+
GNUC_PRINTF(4,5);
102103

103104
/* Define a private version of assert() with a printf-like error
104105
* message. The C one is not used. */

link-grammar/parse/count.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,10 @@ static Count_bin table_store(count_context_t *ctxt,
576576
Count_bin *e = table_lookup(ctxt, lw, rw, le, re, null_count, NULL);
577577
if (e != NULL)
578578
{
579-
assert((e == NULL) || (hist_total(&c) == hist_total(e)),
580-
"Inconsistent count for w(%d,%d) tracon_id(%d,%d)",
581-
lw, rw, l_id, r_id);
582-
return c;
579+
assert((hist_total(&c) == hist_total(e)),
580+
"Inconsistent count for w(%d,%d) tracon_id(%d,%d): %zd != %zd",
581+
lw, rw, l_id, r_id, (ssize_t)hist_total(&c), (ssize_t)hist_total(e));
582+
return *e;
583583
}
584584

585585
// The count is still stored, for the above consistency check
@@ -957,7 +957,7 @@ static Count_bin table_count(count_context_t * ctxt,
957957
int lw, int rw, Connector *le, Connector *re,
958958
unsigned int null_count)
959959
{
960-
if (!USE_TABLE_TRACON) return true;
960+
if (!USE_TABLE_TRACON) return count_unknown;
961961

962962
/* This check is not necessary for correctness, but it saves CPU time.
963963
* If a cross link would result, we know that the count would be 0.

link-grammar/parse/extract-links.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ static void record_choice(
157157
static int estimate_log2_table_size(Sentence sent)
158158
{
159159
/* Size estimate based on measurements (see #1402) */
160-
double lscale = log2(sent->num_disjuncts + 1.0) - 0.5 * log2(sent->length);
160+
double lscale = log2((double)sent->num_disjuncts + 1.0) -
161+
0.5 * log2((double)sent->length);
161162
double lo_est = lscale + 4.0;
162163
double hi_est = 1.5 * lscale;
163164
double dj_est = fmax(lo_est, hi_est);
@@ -166,10 +167,10 @@ static int estimate_log2_table_size(Sentence sent)
166167
* pex->Pset_bucket_pool is almost exactly equal to the num elts
167168
* issued for sent->Table_tracon_pool. This provides a better
168169
* estimate when parsing with MST, when the above is too low. */
169-
double ntracon = pool_num_elements_issued(sent->Table_tracon_pool);
170+
double ntracon = (double)pool_num_elements_issued(sent->Table_tracon_pool);
170171
double ltra = log2(ntracon) + 1.0; // + 1.0 because floor()
171172

172-
int log2_table_size = floor(fmax(dj_est, ltra));
173+
int log2_table_size = (int)floor(fmax(dj_est, ltra));
173174

174175
// Enforce min and max sizes.
175176
if (log2_table_size < 4) log2_table_size = 4;

link-grammar/parse/fast-match.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ form_match_list(fast_matcher_t *ctxt, int w,
595595
}
596596

597597
#ifdef VERIFY_MATCH_LIST
598-
static _Atomic(uint16_t) id = 0;
599-
uint16_t lid = ++id; /* A local copy, for multi-threading support. */
598+
static uint16_t id = 0;
599+
uint16_t lid = ++id; /* A stable local copy, for multi-threading support. */
600600
#else
601601
const uint16_t lid = 0;
602602
#endif

link-grammar/utilities.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,13 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n)
253253
* support C11. So it already supports all the features below. */
254254

255255
/* Optimizations etc. that only gcc understands */
256-
/* FIXME: Change to ATTR_* and define also for MSVC. */
256+
/* FIXME: Define also for MSVC. */
257257
#if __GNUC__
258258
#define GCC_DIAGNOSTIC
259259
#define UNREACHABLE(x) (__extension__ ({if (x) __builtin_unreachable();}))
260260
#define GNUC_MALLOC __attribute__ ((__malloc__))
261261
#define GNUC_UNUSED __attribute__ ((__unused__))
262-
#define GNUC_NORETURN __attribute__ ((__noreturn__))
262+
#define NORETURN __attribute__ ((__noreturn__))
263263
#define ATTR_PURE __attribute__ ((__pure__))
264264
#define NO_SAN __attribute__ ((no_sanitize_address, no_sanitize_undefined))
265265

@@ -271,7 +271,6 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n)
271271
#else
272272
#define NO_SAN_DICT
273273
#endif
274-
275274
#ifndef DONT_EXPECT
276275
#define likely(x) __builtin_expect(!!(x), 1)
277276
#define unlikely(x) __builtin_expect(!!(x), 0)
@@ -281,14 +280,18 @@ static inline char *_strndupa3(char *new_s, const char *s, size_t n)
281280
#define UNREACHABLE(x)
282281
#define GNUC_MALLOC
283282
#define GNUC_UNUSED
284-
#define GNUC_NORETURN
283+
#define NORETURN
285284
#define ATTR_PURE
286285
#define NO_SAN_DICT
287286

288287
#define likely(x) x
289288
#define unlikely(x) x
290289
#endif
291290

291+
#ifdef _MSC_VER
292+
#undef NORETURN
293+
#define NORETURN __declspec(noreturn)
294+
#endif
292295

293296
/* Apply a pragma to a specific code section only.
294297
* XXX According to the GCC docs, we cannot use here something like

msvc/LinkGrammar.vcxproj

+29-13
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,15 @@
235235
<ClInclude Include="..\link-grammar\api-structures.h" />
236236
<ClInclude Include="..\link-grammar\api-types.h" />
237237
<ClInclude Include="..\link-grammar\connectors.h" />
238-
<ClInclude Include="..\link-grammar\dict-atomese\lookup-atomese.h" />
239-
<ClInclude Include="..\link-grammar\dict-atomese\read-atomese.h" />
240238
<ClInclude Include="..\link-grammar\dict-common\dialect.h" />
241239
<ClInclude Include="..\link-grammar\dict-common\dict-affix.h" />
240+
<ClInclude Include="..\link-grammar\dict-common\dict-affix-impl.h" />
242241
<ClInclude Include="..\link-grammar\dict-common\dict-api.h" />
243242
<ClInclude Include="..\link-grammar\dict-common\dict-common.h" />
244243
<ClInclude Include="..\link-grammar\dict-common\dict-defines.h" />
245244
<ClInclude Include="..\link-grammar\dict-common\dict-impl.h" />
245+
<ClInclude Include="..\link-grammar\dict-common\dict-internals.h" />
246+
<ClInclude Include="..\link-grammar\dict-common\dict-locale.h" />
246247
<ClInclude Include="..\link-grammar\dict-common\dict-structures.h" />
247248
<ClInclude Include="..\link-grammar\dict-common\dict-utils.h" />
248249
<ClInclude Include="..\link-grammar\dict-common\file-utils.h" />
@@ -254,6 +255,10 @@
254255
<ClInclude Include="..\link-grammar\dict-file\word-file.h" />
255256
<ClInclude Include="..\link-grammar\dict-ram\dict-ram.h" />
256257
<ClInclude Include="..\link-grammar\dict-sql\read-sql.h" />
258+
<ClInclude Include="..\link-grammar\dict-atomese\dict-atomese.h" />
259+
<ClInclude Include="..\link-grammar\dict-atomese\local-as.h" />
260+
<ClInclude Include="..\link-grammar\dict-atomese\lookup-atomese.h" />
261+
<ClInclude Include="..\link-grammar\dict-atomese\read-atomese.h" />
257262
<ClInclude Include="..\link-grammar\disjunct-utils.h" />
258263
<ClInclude Include="..\link-grammar\error.h" />
259264
<ClInclude Include="..\link-grammar\externs.h" />
@@ -272,18 +277,18 @@
272277
<ClInclude Include="..\link-grammar\parse\preparation.h" />
273278
<ClInclude Include="..\link-grammar\parse\prune.h" />
274279
<ClInclude Include="..\link-grammar\post-process\post-process.h" />
275-
<ClInclude Include="..\link-grammar\post-process\pp-structures.h" />
276280
<ClInclude Include="..\link-grammar\post-process\pp_knowledge.h" />
277281
<ClInclude Include="..\link-grammar\post-process\pp_lexer.h" />
278282
<ClInclude Include="..\link-grammar\post-process\pp_linkset.h" />
283+
<ClInclude Include="..\link-grammar\post-process\pp-structures.h" />
279284
<ClInclude Include="..\link-grammar\prepare\build-disjuncts.h" />
280285
<ClInclude Include="..\link-grammar\prepare\exprune.h" />
281-
<ClInclude Include="..\link-grammar\print\print-util.h" />
282286
<ClInclude Include="..\link-grammar\print\print.h" />
287+
<ClInclude Include="..\link-grammar\print\print-util.h" />
283288
<ClInclude Include="..\link-grammar\print\wcwidth.h" />
284289
<ClInclude Include="..\link-grammar\resources.h" />
285-
<ClInclude Include="..\link-grammar\string-id.h" />
286290
<ClInclude Include="..\link-grammar\string-set.h" />
291+
<ClInclude Include="..\link-grammar\string-id.h" />
287292
<ClInclude Include="..\link-grammar\tokenize\anysplit.h" />
288293
<ClInclude Include="..\link-grammar\tokenize\spellcheck.h" />
289294
<ClInclude Include="..\link-grammar\tokenize\tok-structures.h" />
@@ -295,13 +300,13 @@
295300
<ClInclude Include="link-grammar\link-features.h" />
296301
</ItemGroup>
297302
<ItemGroup>
298-
<ClCompile Include="..\link-grammar\api.c" />
303+
<ClCompile Include="..\link-grammar\config.c" />
299304
<ClCompile Include="..\link-grammar\connectors.c" />
300-
<ClCompile Include="..\link-grammar\dict-atomese\lookup-atomese.cc" />
301-
<ClCompile Include="..\link-grammar\dict-atomese\read-atomese.c" />
302305
<ClCompile Include="..\link-grammar\dict-common\dialect.c" />
306+
<ClCompile Include="..\link-grammar\dict-common\dict-affix-impl.c" />
303307
<ClCompile Include="..\link-grammar\dict-common\dict-common.c" />
304-
<ClCompile Include="..\link-grammar\dict-common\dict-impl.c" />
308+
<ClCompile Include="..\link-grammar\dict-common\dict-internals.c" />
309+
<ClCompile Include="..\link-grammar\dict-common\dict-locale.c" />
305310
<ClCompile Include="..\link-grammar\dict-common\dict-utils.c" />
306311
<ClCompile Include="..\link-grammar\dict-common\file-utils.c" />
307312
<ClCompile Include="..\link-grammar\dict-common\idiom.c" />
@@ -312,12 +317,20 @@
312317
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs>
313318
<CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">CompileAsCpp</CompileAs>
314319
</ClCompile>
315-
<ClCompile Include="..\link-grammar\dict-file\dictionary.c" />
316320
<ClCompile Include="..\link-grammar\dict-file\read-dialect.c" />
321+
<ClCompile Include="..\link-grammar\dict-file\dictionary.c" />
317322
<ClCompile Include="..\link-grammar\dict-file\read-dict.c" />
318323
<ClCompile Include="..\link-grammar\dict-file\read-regex.c" />
319324
<ClCompile Include="..\link-grammar\dict-file\word-file.c" />
320325
<ClCompile Include="..\link-grammar\dict-ram\dict-ram.c" />
326+
<ClCompile Include="..\link-grammar\dict-sql\read-sql.c" />
327+
<ClCompile Include="..\link-grammar\dict-atomese\read-atomese.c" />
328+
<ClCompile Include="..\link-grammar\dict-atomese\link-names.cc" />
329+
<ClCompile Include="..\link-grammar\dict-atomese\lookup-atomese.cc" />
330+
<ClCompile Include="..\link-grammar\dict-atomese\fetch-cats.cc" />
331+
<ClCompile Include="..\link-grammar\dict-atomese\sections.cc" />
332+
<ClCompile Include="..\link-grammar\dict-atomese\word-pairs.cc" />
333+
<ClCompile Include="..\link-grammar\dict-atomese\utils.cc" />
321334
<ClCompile Include="..\link-grammar\disjunct-utils.c" />
322335
<ClCompile Include="..\link-grammar\error.c" />
323336
<ClCompile Include="..\link-grammar\linkage\analyze-linkage.c" />
@@ -327,6 +340,7 @@
327340
<ClCompile Include="..\link-grammar\linkage\sane.c" />
328341
<ClCompile Include="..\link-grammar\linkage\score.c" />
329342
<ClCompile Include="..\link-grammar\memory-pool.c" />
343+
<ClCompile Include="..\link-grammar\options.c" />
330344
<ClCompile Include="..\link-grammar\parse\count.c" />
331345
<ClCompile Include="..\link-grammar\parse\extract-links.c" />
332346
<ClCompile Include="..\link-grammar\parse\fast-match.c" />
@@ -341,13 +355,15 @@
341355
<ClCompile Include="..\link-grammar\post-process\pp_linkset.c" />
342356
<ClCompile Include="..\link-grammar\prepare\build-disjuncts.c" />
343357
<ClCompile Include="..\link-grammar\prepare\exprune.c" />
344-
<ClCompile Include="..\link-grammar\print\print-util.c" />
345358
<ClCompile Include="..\link-grammar\print\print.c" />
359+
<ClCompile Include="..\link-grammar\print\print-util.c" />
346360
<ClCompile Include="..\link-grammar\print\wcwidth.c" />
347361
<ClCompile Include="..\link-grammar\resources.c" />
348-
<ClCompile Include="..\link-grammar\string-id.c" />
362+
<ClCompile Include="..\link-grammar\sentence.c" />
349363
<ClCompile Include="..\link-grammar\string-set.c" />
364+
<ClCompile Include="..\link-grammar\string-id.c" />
350365
<ClCompile Include="..\link-grammar\tokenize\anysplit.c" />
366+
<ClCompile Include="..\link-grammar\tokenize\lookup-exprs.c" />
351367
<ClCompile Include="..\link-grammar\tokenize\spellcheck-aspell.c" />
352368
<ClCompile Include="..\link-grammar\tokenize\spellcheck-hun.c" />
353369
<ClCompile Include="..\link-grammar\tokenize\tokenize.c" />
@@ -394,4 +410,4 @@
394410
<ImportGroup Label="ExtensionTargets" Condition="'$(WINFLEXBISON)'!=''">
395411
<Import Project="$(WINFLEXBISON)\custom_build_rules\win_flex_only\win_flex_custom_build.targets" />
396412
</ImportGroup>
397-
</Project>
413+
</Project>

0 commit comments

Comments
 (0)