Skip to content

Commit 384d6d5

Browse files
author
Mike Pall
committed
Fix Clang build.
1 parent 18eef08 commit 384d6d5

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

src/lj_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static int has_segment_link(mstate m, msegmentptr ss)
597597
noncontiguous segments are added.
598598
*/
599599
#define TOP_FOOT_SIZE\
600-
(align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
600+
(align_offset(TWO_SIZE_T_SIZES)+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
601601

602602
/* ---------------------------- Indexing Bins ---------------------------- */
603603

src/lj_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ typedef uintptr_t BloomFilter;
120120
#define bloomset(b, x) ((b) |= bloombit((x)))
121121
#define bloomtest(b, x) ((b) & bloombit((x)))
122122

123-
#if defined(__GNUC__) || defined(__psp2__)
123+
#if defined(__GNUC__) || defined(__clang__) || defined(__psp2__)
124124

125125
#define LJ_NORET __attribute__((noreturn))
126126
#define LJ_ALIGN(n) __attribute__((aligned(n)))
@@ -182,7 +182,7 @@ static LJ_AINLINE uint64_t lj_bswap64(uint64_t x)
182182
{
183183
return ((uint64_t)lj_bswap((uint32_t)x)<<32) | lj_bswap((uint32_t)(x>>32));
184184
}
185-
#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
185+
#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __clang__
186186
static LJ_AINLINE uint32_t lj_bswap(uint32_t x)
187187
{
188188
return (uint32_t)__builtin_bswap32((int32_t)x);

src/lj_emit_x86.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static LJ_AINLINE MCode *emit_op(x86Op xo, Reg rr, Reg rb, Reg rx,
4545
*(uint32_t *)(p+delta-5) = (uint32_t)xo;
4646
return p+delta-5;
4747
}
48-
#if defined(__GNUC__)
48+
#if defined(__GNUC__) || defined(__clang__)
4949
if (__builtin_constant_p(xo) && n == -2)
5050
p[delta-2] = (MCode)(xo >> 24);
5151
else if (__builtin_constant_p(xo) && n == -3)

src/lj_err.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
** The POSIX/x64 interpreter only saves r12/r13 for INT (e.g. PS4).
6262
*/
6363

64-
#if defined(__GNUC__) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) && !LJ_NO_UNWIND
64+
#if (defined(__GNUC__) || defined(__clang__)) && (LJ_TARGET_X64 || defined(LUAJIT_UNWIND_EXTERNAL)) && !LJ_NO_UNWIND
6565
#define LJ_UNWIND_EXT 1
6666
#elif LJ_TARGET_WINDOWS
6767
#define LJ_UNWIND_EXT 1
@@ -184,7 +184,7 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode)
184184

185185
/* -- External frame unwinding -------------------------------------------- */
186186

187-
#if defined(__GNUC__) && !LJ_NO_UNWIND && !LJ_ABI_WIN
187+
#if (defined(__GNUC__) || defined(__clang__)) && !LJ_NO_UNWIND && !LJ_ABI_WIN
188188

189189
/*
190190
** We have to use our own definitions instead of the mandatory (!) unwind.h,

src/lj_ircall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ extern double lj_vm_sfmax(double a, double b);
334334
#endif
335335

336336
#if LJ_HASFFI && LJ_NEED_FP64 && !(LJ_TARGET_ARM && LJ_SOFTFP)
337-
#ifdef __GNUC__
337+
#if defined(__GNUC__) || defined(__clang__)
338338
#define fp64_l2d __floatdidf
339339
#define fp64_ul2d __floatundidf
340340
#define fp64_l2f __floatdisf

src/lj_mcode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void lj_mcode_sync(void *start, void *end)
4545
sys_icache_invalidate(start, (char *)end-(char *)start);
4646
#elif LJ_TARGET_PPC
4747
lj_vm_cachesync(start, end);
48-
#elif defined(__GNUC__)
48+
#elif defined(__GNUC__) || defined(__clang__)
4949
__clear_cache(start, end);
5050
#else
5151
#error "Missing builtin to flush instruction cache"

src/lj_strfmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ LJ_FUNC GCstr * LJ_FASTCALL lj_strfmt_obj(lua_State *L, cTValue *o);
118118
LJ_FUNC const char *lj_strfmt_pushvf(lua_State *L, const char *fmt,
119119
va_list argp);
120120
LJ_FUNC const char *lj_strfmt_pushf(lua_State *L, const char *fmt, ...)
121-
#ifdef __GNUC__
121+
#if defined(__GNUC__) || defined(__clang__)
122122
__attribute__ ((format (printf, 2, 3)))
123123
#endif
124124
;

src/lj_strscan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void strscan_double(uint64_t x, TValue *o, int32_t ex2, int32_t neg)
7979
/* Avoid double rounding for denormals. */
8080
if (LJ_UNLIKELY(ex2 <= -1075 && x != 0)) {
8181
/* NYI: all of this generates way too much code on 32 bit CPUs. */
82-
#if defined(__GNUC__) && LJ_64
82+
#if (defined(__GNUC__) || defined(__clang__)) && LJ_64
8383
int32_t b = (int32_t)(__builtin_clzll(x)^63);
8484
#else
8585
int32_t b = (x>>32) ? 32+(int32_t)lj_fls((uint32_t)(x>>32)) :

0 commit comments

Comments
 (0)