mirror of
https://github.com/bkaradzic/bx.git
synced 2026-10-29 20:15:38 +00:00
Added Android memoryMap, DirectoryReader, process memory, and NEON signbitsmask. (#479)
This commit is contained in:
@@ -987,13 +987,32 @@ namespace bx
|
||||
template<>
|
||||
BX_SIMD_FORCE_INLINE int simd128_x32_signbitsmask(simd128_neon_t _a)
|
||||
{
|
||||
return simd_x32_signbitsmask_ni(_a);
|
||||
const uint32x4_t a = vreinterpretq_u32_f32(_a);
|
||||
const uint32x4_t msb = vshrq_n_u32(a, 31);
|
||||
const int32x2_t shiftLo = vcreate_s32(UINT64_C(0x0000000100000000) );
|
||||
const int32x2_t shiftHi = vcreate_s32(UINT64_C(0x0000000300000002) );
|
||||
const int32x4_t shift = vcombine_s32(shiftLo, shiftHi);
|
||||
const uint32x4_t bits = vshlq_u32(msb, shift);
|
||||
const uint64x2_t sum = vpaddlq_u32(bits);
|
||||
const uint64_t lo = vgetq_lane_u64(sum, 0);
|
||||
const uint64_t hi = vgetq_lane_u64(sum, 1);
|
||||
return int(lo | hi);
|
||||
}
|
||||
|
||||
template<>
|
||||
BX_SIMD_FORCE_INLINE int simd128_x8_signbitsmask(simd128_neon_t _a)
|
||||
{
|
||||
return simd_x8_signbitsmask_ni(_a);
|
||||
const uint8x16_t a = vreinterpretq_u8_f32(_a);
|
||||
const uint8x16_t msb = vshrq_n_u8(a, 7);
|
||||
const int8x8_t shiftLo = vcreate_s8(UINT64_C(0x0706050403020100) );
|
||||
const int8x16_t shift = vcombine_s8(shiftLo, shiftLo);
|
||||
const uint8x16_t bits = vshlq_u8(msb, shift);
|
||||
const uint16x8_t sum16 = vpaddlq_u8(bits);
|
||||
const uint32x4_t sum32 = vpaddlq_u16(sum16);
|
||||
const uint64x2_t sum64 = vpaddlq_u32(sum32);
|
||||
const uint64_t lo = vgetq_lane_u64(sum64, 0);
|
||||
const uint64_t hi = vgetq_lane_u64(sum64, 1);
|
||||
return int(lo | (hi << 8) );
|
||||
}
|
||||
|
||||
template<>
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
#endif // BX_CONFIG_CRT_FILE_READER_WRITER
|
||||
|
||||
#ifndef BX_CONFIG_CRT_DIRECTORY_READER
|
||||
# define BX_CONFIG_CRT_DIRECTORY_READER (BX_PLATFORM_OS_DESKTOP && !BX_CRT_NONE)
|
||||
# define BX_CONFIG_CRT_DIRECTORY_READER ( (BX_PLATFORM_OS_DESKTOP || BX_PLATFORM_ANDROID) && !BX_CRT_NONE)
|
||||
#endif // BX_CONFIG_CRT_DIRECTORY_READER
|
||||
|
||||
#if BX_CRT_NONE
|
||||
|
||||
+7
-9
@@ -34,7 +34,8 @@
|
||||
# endif // !BX_PLATFORM_PS4 && !BX_PLATFORM_PS5
|
||||
|
||||
# if BX_PLATFORM_ANDROID
|
||||
# include <malloc.h> // mallinfo
|
||||
# include <stdio.h> // fopen
|
||||
# include <sys/mman.h>
|
||||
# elif BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_RPI
|
||||
# include <stdio.h> // fopen
|
||||
@@ -157,10 +158,7 @@ namespace bx
|
||||
|
||||
size_t getProcessMemoryUsed()
|
||||
{
|
||||
#if BX_PLATFORM_ANDROID
|
||||
struct mallinfo mi = mallinfo();
|
||||
return mi.uordblks;
|
||||
#elif BX_PLATFORM_LINUX
|
||||
#if BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX
|
||||
FILE* file = fopen("/proc/self/statm", "r");
|
||||
if (NULL == file)
|
||||
{
|
||||
@@ -504,7 +502,7 @@ namespace bx
|
||||
|
||||
namespace
|
||||
{
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
#if BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
static int32_t toPosixProt(uint32_t _protect)
|
||||
{
|
||||
switch (_protect)
|
||||
@@ -557,7 +555,7 @@ namespace bx
|
||||
BX_ASSERT(_alignment <= granularity, "Alignments greater than the allocation granularity are not implemented (requested %zu, granularity %zu).", _alignment, granularity);
|
||||
BX_UNUSED(_alignment, granularity);
|
||||
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
#if BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
if (NULL == _address)
|
||||
{
|
||||
if (0 == (state & Memory::Reserve) )
|
||||
@@ -737,7 +735,7 @@ namespace bx
|
||||
{
|
||||
BX_ERROR_SCOPE(_err);
|
||||
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
#if BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
int32_t result = munmap(_address, _size);
|
||||
|
||||
if (-1 == result)
|
||||
@@ -768,7 +766,7 @@ namespace bx
|
||||
{
|
||||
const uint32_t page = _flags & Memory::PageMask;
|
||||
|
||||
#if BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
#if BX_PLATFORM_ANDROID || BX_PLATFORM_LINUX || BX_PLATFORM_OSX
|
||||
if (0 != (page & Memory::PageHuge) )
|
||||
{
|
||||
return 1ull << 30; // 1 GiB nominal
|
||||
|
||||
Reference in New Issue
Block a user