Skip to content

Commit ed555fe

Browse files
committed
windows support (? untested)
1 parent 26cdba0 commit ed555fe

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/gc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,16 @@ static __attribute__((noinline)) void *malloc_page(void)
459459
heaps_lb[heap_i] = i;
460460
if (heaps_ub[heap_i] < i)
461461
heaps_ub[heap_i] = i;
462-
int j = (ffs(heap->freemap[i]) - 1);
462+
463+
#ifdef __MINGW32__
464+
int j = __builtin_ffs(heap->freemap[i]) - 1;
465+
#elif _MSC_VER
466+
int j;
467+
_BitScanForward(&j, heap->freemap[i]);
468+
#else
469+
int j = ffs(heap->freemap[i]) - 1;
470+
#endif
471+
463472
heap->freemap[i] &= ~(uint32_t)(1 << j);
464473
if (j == 0) { // reserve a page for metadata (every 31 data pages)
465474
j++;

0 commit comments

Comments
 (0)