Skip to content

Commit e25af35

Browse files
committed
bmalloc bun extras
1 parent ded1209 commit e25af35

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

Source/bmalloc/bmalloc/BunExtras.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <bit>
2+
3+
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L
4+
#define __bit_cast std::bit_cast
5+
#else
6+
template <
7+
typename Dest, typename Source,
8+
typename std::enable_if<sizeof(Dest) == sizeof(Source) &&
9+
std::is_trivially_copyable<Source>::value &&
10+
std::is_trivially_copyable<Dest>::value,
11+
int>::type = 0>
12+
inline constexpr Dest __bit_cast(const Source &source) {
13+
return __builtin_bit_cast(Dest, source);
14+
}
15+
#endif

Source/bmalloc/bmalloc/GigacageConfig.h

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "Algorithm.h"
2929
#include "GigacageKind.h"
30+
#include "BunExtras.h"
3031
#include <bit>
3132
#include <inttypes.h>
3233

Source/bmalloc/bmalloc/IsoHeapImplInlines.h

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "IsoTLSDeallocatorEntry.h"
3030
#include "IsoSharedHeapInlines.h"
3131
#include "IsoSharedPageInlines.h"
32+
#include "BunExtras.h"
3233

3334
#if !BUSE(LIBPAS)
3435

Source/bmalloc/bmalloc/IsoPageInlines.h

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "IsoHeapImpl.h"
3131
#include "IsoPage.h"
3232
#include "VMAllocate.h"
33+
#include "BunExtras.h"
3334
#include <bit>
3435

3536
#if !BUSE(LIBPAS)

Source/bmalloc/bmalloc/Packed.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#pragma once
2727

2828
#include "Algorithm.h"
29+
#include "BunExtras.h"
2930
#include <array>
3031
#include <bit>
3132

0 commit comments

Comments
 (0)