Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 146cb38

Browse files
committed
Work around issues in MinGW-64's setjmp/longjmp support.
It's hard to avoid the conclusion that there is something wrong with setjmp/longjmp on MinGW-64, as we have seen failures come and go after entirely-unrelated-looking changes in our own code. Other projects such as Ruby have given up and started using gcc's setjmp/longjmp builtins on that platform; this patch just follows that lead. Note that this is a pretty fundamental ABI break for functions containining either setjmp or longjmp, so we can't really consider a back-patch. Per reports from Regina Obe and Heath Lord, as well as recent failures on buildfarm member walleye, and less-recent failures on fairywren. Juan José Santamaría Flecha Discussion: https://postgr.es/m/000401d716a0$1ed0fc70$5c72f550$@pcorp.us Discussion: https://postgr.es/m/CA+BEBhvHhM-Bn628pf-LsjqRh3Ang7qCSBG0Ga+7KwhGqrNUPw@mail.gmail.com Discussion: https://postgr.es/m/f1caef93-9640-022e-9211-bbe8755a56b0@2ndQuadrant.com
1 parent eeb60e4 commit 146cb38

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/include/c.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,14 +1335,21 @@ extern unsigned long long strtoull(const char *str, char **endptr, int base);
13351335

13361336
/*
13371337
* When there is no sigsetjmp, its functionality is provided by plain
1338-
* setjmp. Incidentally, nothing provides setjmp's functionality in
1339-
* that case. We now support the case only on Windows.
1338+
* setjmp. We now support the case only on Windows. However, it seems
1339+
* that MinGW-64 has some longstanding issues in its setjmp support,
1340+
* so on that toolchain we cheat and use gcc's builtins.
13401341
*/
13411342
#ifdef WIN32
1343+
#ifdef __MINGW64__
1344+
typedef intptr_t sigjmp_buf[5];
1345+
#define sigsetjmp(x,y) __builtin_setjmp(x)
1346+
#define siglongjmp __builtin_longjmp
1347+
#else /* !__MINGW64__ */
13421348
#define sigjmp_buf jmp_buf
13431349
#define sigsetjmp(x,y) setjmp(x)
13441350
#define siglongjmp longjmp
1345-
#endif
1351+
#endif /* __MINGW64__ */
1352+
#endif /* WIN32 */
13461353

13471354
/* EXEC_BACKEND defines */
13481355
#ifdef EXEC_BACKEND

0 commit comments

Comments
 (0)