Skip to content

Commit a09bf7c

Browse files
Workaround lack of Windows support for stdatomic.h
1 parent 57f9209 commit a09bf7c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/err.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@
3131
#define WARN_UNUSED __attribute__((warn_unused_result))
3232
#define unlikely(expr) __builtin_expect(!!(expr), 0)
3333
#define likely(expr) __builtin_expect(!!(expr), 1)
34+
#include <stdatomic.h>
3435
#else
3536
/* On windows we don't do any perf related stuff */
3637
#define WARN_UNUSED
3738
#define restrict
39+
/* Although MSVS supports C11, it doesn't seem to include a working version of
40+
* stdatomic.h, so we can't use it portably. For this experiment we'll just
41+
* leave it out on Windows, as nobody is doing large-scale tsinfer'ing on
42+
* Windows. */
43+
#define _Atomic
3844
#define unlikely(expr) (expr)
3945
#define likely(expr) (expr)
4046
#endif
@@ -48,7 +54,6 @@ const char *tsi_strerror(int err);
4854
*/
4955

5056
#include "tskit.h"
51-
#include <stdatomic.h>
5257

5358
typedef struct {
5459
size_t chunk_size; /* number of bytes per chunk */

0 commit comments

Comments
 (0)