mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-06 08:15:59 +02:00
Apple fixes
This commit is contained in:
parent
43b69023f6
commit
9f3fded709
23 changed files with 847 additions and 425 deletions
|
@ -867,6 +867,7 @@ uint8* Beefy::LoadBinaryData(const StringImpl& path, int* size)
|
|||
|
||||
uint8* data = new uint8[aSize];
|
||||
int readSize = (int)fread(data, 1, aSize, fP);
|
||||
(void)readSize;
|
||||
fclose(fP);
|
||||
if (size)
|
||||
*size = aSize;
|
||||
|
@ -897,6 +898,7 @@ char* Beefy::LoadTextData(const StringImpl& path, int* size)
|
|||
data[dataLen] = 0;
|
||||
data[dataLen + 1] = 0;
|
||||
int readSize = (int)fread(data + 1, 1, dataLen - 1, fP);
|
||||
(void)readSize;
|
||||
fclose(fP);
|
||||
|
||||
// UTF16
|
||||
|
@ -921,6 +923,7 @@ char* Beefy::LoadTextData(const StringImpl& path, int* size)
|
|||
if (size != NULL)
|
||||
*size = strLen;
|
||||
int readSize = (int)fread(data, 1, strLen, fP);
|
||||
(void)readSize;
|
||||
fclose(fP);
|
||||
return data;
|
||||
}
|
||||
|
@ -934,6 +937,7 @@ char* Beefy::LoadTextData(const StringImpl& path, int* size)
|
|||
if (strLen > 3)
|
||||
{
|
||||
int readSize = (int)fread(data + 3, 1, strLen - 3, fP);
|
||||
(void)readSize;
|
||||
}
|
||||
fclose(fP);
|
||||
return data;
|
||||
|
|
|
@ -123,6 +123,22 @@ BFP_EXPORT int64 BFP_CALLTYPE BfpSystem_GetCPUTickFreq();
|
|||
BFP_EXPORT void BFP_CALLTYPE BfpSystem_CreateGUID(BfpGUID* outGuid);
|
||||
BFP_EXPORT void BFP_CALLTYPE BfpSystem_GetComputerName(char* outStr, int* inOutStrSize, BfpSystemResult* outResult);
|
||||
|
||||
#ifdef BFP_INTPTR_UNIQUE
|
||||
|
||||
#ifdef BF32
|
||||
#define BfpSystem_InterlockedExchangePtr(ptr, val) BfpSystem_InterlockedExchange32((uint32*)(ptr), (uint32)(val))
|
||||
#define BfpSystem_InterlockedExchangeAddPtr(ptr, val) BfpSystem_InterlockedExchangeAdd32((uint32*)(ptr), (uint32)(val))
|
||||
#define BfpSystem_InterlockedCompareExchangePtr(ptr, oldVal, newVal) BfpSystem_InterlockedCompareExchange32((uint32*)(ptr), (uint32)(oldVal), (uint32)(newVal))
|
||||
#define BfpSystem_EndianSwapPtr(val) BfpSystem_EndianSwap32((uint32)(val))
|
||||
#else
|
||||
#define BfpSystem_InterlockedExchangePtr(ptr, val) BfpSystem_InterlockedExchange64((uint64*)(ptr), (uint64)(val))
|
||||
#define BfpSystem_InterlockedExchangeAddPtr(ptr, val) BfpSystem_InterlockedExchangeAdd64((uint64*)(ptr), (uint64)(val))
|
||||
#define BfpSystem_InterlockedCompareExchangePtr(ptr, oldVal, newVal) BfpSystem_InterlockedCompareExchange64((uint64*)(ptr), (uint64)(oldVal), (uint64)(newVal))
|
||||
#define BfpSystem_EndianSwapPtr(val) BfpSystem_EndianSwap64((uint64)(val))
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef BF32
|
||||
#define BfpSystem_InterlockedExchangePtr BfpSystem_InterlockedExchange32
|
||||
#define BfpSystem_InterlockedExchangeAddPtr BfpSystem_InterlockedExchangeAdd32
|
||||
|
@ -135,6 +151,8 @@ BFP_EXPORT void BFP_CALLTYPE BfpSystem_GetComputerName(char* outStr, int* inOutS
|
|||
#define BfpSystem_EndianSwapPtr BfpSystem_EndianSwap64
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
enum BfpProcessResult
|
||||
{
|
||||
BfpProcessResult_Ok = BfpResult_Ok,
|
||||
|
|
|
@ -6,4 +6,13 @@
|
|||
#define lseek64 lseek
|
||||
#define ftruncate64 ftruncate
|
||||
|
||||
#include "../posix/PosixCommon.cpp"
|
||||
#include "../posix/PosixCommon.cpp"
|
||||
|
||||
char* itoa(int value, char* str, int base)
|
||||
{
|
||||
if (base == 16)
|
||||
sprintf(str, "%X", value);
|
||||
else
|
||||
sprintf(str, "%d", value);
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,8 @@ typedef int16_t int16;
|
|||
typedef int8_t int8;
|
||||
typedef unsigned int uint;
|
||||
|
||||
#define BFP_INTPTR_UNIQUE
|
||||
|
||||
//#define BF_PLATFORM_SDL
|
||||
|
||||
#define NOP
|
||||
|
@ -146,388 +148,4 @@ typedef void* HMODULE;
|
|||
#define DIR_SEP_CHAR '/'
|
||||
#define DIR_SEP_CHAR_ALT '\\'
|
||||
|
||||
static char* itoa(int value, char* str, int base)
|
||||
{
|
||||
if (base == 16)
|
||||
sprintf(str, "%X", value);
|
||||
else
|
||||
sprintf(str, "%d", value);
|
||||
return str;
|
||||
}
|
||||
|
||||
inline uint32 InterlockedCompareExchange(volatile uint32* dest, uint32 exch, uint32 comp)
|
||||
{
|
||||
return __sync_val_compare_and_swap(dest, comp, exch);
|
||||
}
|
||||
|
||||
inline uint64 InterlockedCompareExchange64(volatile int64* dest, int64 exch, int64 comp)
|
||||
{
|
||||
return __sync_val_compare_and_swap(dest, comp, exch);
|
||||
}
|
||||
|
||||
inline void* InterlockedCompareExchangePointer(void* volatile* dest, void* exch, void* comp)
|
||||
{
|
||||
return __sync_val_compare_and_swap(dest, comp, exch);
|
||||
}
|
||||
|
||||
inline uint32 InterlockedExchange(volatile uint32* dest, uint32 val)
|
||||
{
|
||||
return __sync_lock_test_and_set(dest, val);
|
||||
}
|
||||
|
||||
inline uint64 InterlockedExchange64(volatile int64* dest, int64 val)
|
||||
{
|
||||
return __sync_lock_test_and_set(dest, val);
|
||||
}
|
||||
|
||||
inline uint32 InterlockedExchangeAdd(volatile uint32* dest, uint32 val)
|
||||
{
|
||||
return __sync_add_and_fetch(dest, val);
|
||||
}
|
||||
|
||||
inline int32 InterlockedIncrement(volatile uint32* val)
|
||||
{
|
||||
return __sync_add_and_fetch(val, 1);
|
||||
}
|
||||
|
||||
inline int64 InterlockedIncrement64(volatile int64* val)
|
||||
{
|
||||
return __sync_add_and_fetch(val, 1);
|
||||
}
|
||||
|
||||
inline int32 InterlockedDecrement(volatile uint32* val)
|
||||
{
|
||||
return __sync_add_and_fetch(val, -1);
|
||||
}
|
||||
|
||||
inline int64 InterlockedDecrement64(volatile int64* val)
|
||||
{
|
||||
return __sync_add_and_fetch(val, -1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __LP64__
|
||||
#define BF64
|
||||
#else
|
||||
#define BF32
|
||||
#endif
|
||||
|
||||
#define BOOST_DETAIL_NO_CONTAINER_FWD
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <sys/time.h>
|
||||
#include <libkern/OSAtomic.h>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
#include <math.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#define FFI_BUILDING
|
||||
#include "third_party/libffi/x86_64-apple-darwin12.5.0/include/ffi.h"
|
||||
}
|
||||
|
||||
#define FFI_STDCALL FFI_DEFAULT_ABI
|
||||
#define FFI_THISCALL FFI_DEFAULT_ABI
|
||||
#define FFI_FASTCALL FFI_DEFAULT_ABI
|
||||
|
||||
typedef uint64_t uint64;
|
||||
typedef uint32_t uint32;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint8_t uint8;
|
||||
typedef int64_t int64;
|
||||
typedef int32_t int32;
|
||||
typedef int16_t int16;
|
||||
typedef int8_t int8;
|
||||
typedef unsigned int uint;
|
||||
|
||||
#define BF_PLATFORM_DARWIN
|
||||
#define BF_PLATFORM_SDL
|
||||
|
||||
#define NOP
|
||||
//#define BF_NOTHROW throw ()
|
||||
//#define BF_NOTHROW noexcept
|
||||
#define BF_NOTHROW
|
||||
|
||||
#ifdef BF64
|
||||
typedef int64 intptr;
|
||||
typedef uint64 uintptr;
|
||||
#else
|
||||
typedef int32 intptr;
|
||||
typedef uint32 uintptr;
|
||||
#endif
|
||||
|
||||
typedef wchar_t* BSTR;
|
||||
typedef int HRESULT;
|
||||
typedef uint32 DWORD;
|
||||
typedef int32 LONG;
|
||||
|
||||
typedef pthread_key_t BFTlsKey;
|
||||
typedef pthread_t BF_THREADID;
|
||||
|
||||
int64 abs(int64 val) noexcept;
|
||||
|
||||
struct IID
|
||||
{
|
||||
unsigned long Data1;
|
||||
unsigned short Data2;
|
||||
unsigned short Data3;
|
||||
unsigned char Data4[ 8 ];
|
||||
};
|
||||
|
||||
typedef void* HANDLE;
|
||||
typedef void* HMODULE;
|
||||
|
||||
#include "../notwin/NotWin.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define _DEBUG
|
||||
#endif
|
||||
|
||||
//ARM
|
||||
|
||||
#if defined(__x86_64__) || defined(__i386__)
|
||||
#define BF_FULL_MEMORY_FENCE() __asm__ __volatile__("mfence": : :"memory")
|
||||
#define BF_SPINWAIT_NOP() __asm__ volatile ("pause\n" : : : "memory" );
|
||||
#else
|
||||
#define BF_FULL_MEMORY_FENCE() __sync_synchronize()
|
||||
#define BF_SPINWAIT_NOP() ((void) 0)
|
||||
#endif
|
||||
|
||||
#define BF_COMPILER_FENCE() __asm__ __volatile__("": : :"memory")
|
||||
#define BF_THREAD_YIELD() sched_yield()
|
||||
|
||||
#define BF_ASSERT assert
|
||||
#define BF_FATAL(msg) assert(msg == 0)
|
||||
|
||||
#define BF_NOINLINE __attribute__ ((noinline))
|
||||
#define BF_NAKED
|
||||
|
||||
#define _alloca alloca
|
||||
|
||||
namespace Beefy
|
||||
{
|
||||
|
||||
class CritSect
|
||||
{
|
||||
private:
|
||||
pthread_mutex_t mCriticalSection;
|
||||
|
||||
public:
|
||||
CritSect(void)
|
||||
{
|
||||
pthread_mutexattr_t attributes;
|
||||
|
||||
pthread_mutexattr_init(&attributes);
|
||||
pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_RECURSIVE);
|
||||
pthread_mutex_init(&mCriticalSection, &attributes);
|
||||
pthread_mutexattr_destroy(&attributes);
|
||||
}
|
||||
|
||||
~CritSect(void)
|
||||
{
|
||||
pthread_mutex_destroy(&mCriticalSection);
|
||||
}
|
||||
|
||||
bool TryLock()
|
||||
{
|
||||
return pthread_mutex_trylock( &mCriticalSection ) == 0;
|
||||
}
|
||||
|
||||
void Lock()
|
||||
{
|
||||
pthread_mutex_lock( &mCriticalSection );
|
||||
}
|
||||
|
||||
void Unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&mCriticalSection);
|
||||
}
|
||||
};
|
||||
|
||||
class SyncEvent
|
||||
{
|
||||
private:
|
||||
pthread_mutex_t mMutex;
|
||||
pthread_cond_t mCondition;
|
||||
uint32 mSet;
|
||||
bool mManualReset;
|
||||
|
||||
bool mInitialState;
|
||||
int mSetCount;
|
||||
int mWaitForCountFail;
|
||||
int mWaitForCountSucceed;
|
||||
|
||||
public:
|
||||
SyncEvent(bool manualReset = false, bool initialState = false)
|
||||
{
|
||||
mManualReset = manualReset;
|
||||
mSet = initialState;
|
||||
int result = pthread_mutex_init(&mMutex, NULL);
|
||||
BF_ASSERT(result == 0);
|
||||
result = pthread_cond_init(&mCondition, NULL);
|
||||
BF_ASSERT(result == 0);
|
||||
|
||||
mInitialState = initialState;
|
||||
mSetCount = 0;
|
||||
mWaitForCountFail = 0;
|
||||
mWaitForCountSucceed = 0;
|
||||
}
|
||||
|
||||
~SyncEvent()
|
||||
{
|
||||
pthread_cond_destroy(&mCondition);
|
||||
pthread_mutex_destroy(&mMutex);
|
||||
}
|
||||
|
||||
void Set()
|
||||
{
|
||||
pthread_mutex_lock(&mMutex);
|
||||
mSet = true;
|
||||
pthread_cond_signal(&mCondition);
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
|
||||
mSetCount++;
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
mSet = false;
|
||||
}
|
||||
|
||||
bool WaitFor(uint32 timeout)
|
||||
{
|
||||
int result = pthread_mutex_lock(&mMutex);
|
||||
BF_ASSERT(result == 0);
|
||||
while (!mSet)
|
||||
{
|
||||
struct timespec ts;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
uint64 nsec = (uint64)timeout * 1000000;
|
||||
ts.tv_nsec = tv.tv_usec * 1000;
|
||||
ts.tv_sec = tv.tv_sec;
|
||||
|
||||
ts.tv_nsec += nsec % 1000000000;
|
||||
ts.tv_sec += nsec / 1000000000;
|
||||
|
||||
ts.tv_sec += (ts.tv_nsec / 1000000000);
|
||||
ts.tv_nsec %= 1000000000;
|
||||
|
||||
result = pthread_cond_timedwait(&mCondition, &mMutex, &ts);
|
||||
|
||||
if (timeout == (uint32)-1)
|
||||
BF_ASSERT(result == 0);
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
// Timeout
|
||||
mWaitForCountFail++;
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!mManualReset)
|
||||
mSet = false;
|
||||
mWaitForCountSucceed++;
|
||||
pthread_mutex_unlock(&mMutex);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
inline uint32 InterlockedCompareExchange(volatile uint32* dest, uint32 exch, uint32 comp)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (OSAtomicCompareAndSwap32Barrier((int32)comp, (int32)exch, (volatile int32*)dest))
|
||||
return comp;
|
||||
// We don't want to return *dest being equal to 'comp' if the CAS result was false
|
||||
uint32 oldVal = *dest;
|
||||
if (oldVal != comp)
|
||||
return oldVal;
|
||||
}
|
||||
}
|
||||
|
||||
inline uint64 InterlockedCompareExchange64(volatile int64* dest, int64 exch, int64 comp)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (OSAtomicCompareAndSwap64Barrier((int64)comp, (int64)exch, (volatile int64*)dest))
|
||||
return comp;
|
||||
// We don't want to return *dest being equal to 'comp' if the CAS result was false
|
||||
uint64 oldVal = *dest;
|
||||
if (oldVal != comp)
|
||||
return oldVal;
|
||||
}
|
||||
}
|
||||
|
||||
inline void* InterlockedCompareExchangePointer(void* volatile* dest, void* exch, void* comp)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (OSAtomicCompareAndSwapPtrBarrier(comp, exch, dest))
|
||||
return comp;
|
||||
// We don't want to return *dest being equal to 'comp' if the CAS result was false
|
||||
void* oldVal = *dest;
|
||||
if (oldVal != comp)
|
||||
return oldVal;
|
||||
}
|
||||
}
|
||||
|
||||
inline uint32 InterlockedExchange(volatile uint32* dest, uint32 val)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
uint32 oldVal = *dest;
|
||||
if (OSAtomicCompareAndSwap32Barrier((int32)oldVal, (int32)val, (volatile int32*)dest))
|
||||
return oldVal;
|
||||
}
|
||||
}
|
||||
|
||||
inline uint64 InterlockedExchange64(volatile int64* dest, int64 val)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
uint64 oldVal = *dest;
|
||||
if (OSAtomicCompareAndSwap64Barrier((int64)oldVal, (int64)val, (volatile int64*)dest))
|
||||
return oldVal;
|
||||
}
|
||||
}
|
||||
|
||||
inline uint32 InterlockedExchangeAdd(volatile uint32* dest, uint32 val)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int32 InterlockedIncrement(volatile uint32* val)
|
||||
{
|
||||
return OSAtomicIncrement32Barrier((int32*)val);
|
||||
}
|
||||
|
||||
inline int64 InterlockedIncrement64(volatile int64* val)
|
||||
{
|
||||
return OSAtomicIncrement64Barrier(val);
|
||||
}
|
||||
|
||||
inline int32 InterlockedDecrement(volatile uint32* val)
|
||||
{
|
||||
return OSAtomicDecrement32Barrier((int32*)val);
|
||||
}
|
||||
|
||||
inline int64 InterlockedDecrement64(volatile int64* val)
|
||||
{
|
||||
return OSAtomicDecrement64Barrier(val);
|
||||
}
|
||||
|
||||
#endif
|
||||
char* itoa(int value, char* str, int base);
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "../darwin/DarwinCommon.h"
|
||||
#include "TargetConditionals.h"
|
||||
#include <string>
|
||||
|
||||
#ifndef __IPHONEOS__
|
||||
#define __IPHONEOS__
|
||||
|
@ -13,6 +14,8 @@
|
|||
#define BF_PLATFORM_POSIX
|
||||
#define BF_PLATFORM_OPENGL_ES2
|
||||
#define BF_PLATFORM_FULLSCREEN
|
||||
#define BF_PLATFORM_DARWIN
|
||||
#define BF_PLATFORM_NAME "BF_PLATFORM_IOS"
|
||||
|
||||
#if !TARGET_IPHONE_SIMULATOR
|
||||
#ifdef __LP64__
|
||||
|
@ -43,12 +46,15 @@
|
|||
|
||||
#endif
|
||||
|
||||
#define BF_IMPORT extern "C"
|
||||
|
||||
#ifdef BFSYSLIB_DYNAMIC
|
||||
#define BF_EXPORT extern "C" __declspec(dllexport)
|
||||
#define BF_EXPORT extern "C"
|
||||
#define BF_CALLTYPE
|
||||
#else
|
||||
#define BF_EXPORT extern "C"
|
||||
#define BF_CALLTYPE
|
||||
#define BF_RESOURCES_REL_DIR "../Resources"
|
||||
#endif
|
||||
|
||||
#ifdef BF_PLATFORM_ARM32
|
||||
|
@ -59,3 +65,6 @@
|
|||
#define BF_REGISTER_COUNT 15
|
||||
#endif
|
||||
|
||||
#define BF_DEBUG_BREAK()
|
||||
|
||||
#include "../PlatformInterface.h"
|
|
@ -1,12 +1,16 @@
|
|||
#include "Common.h"
|
||||
#include "BFPlatform.h"
|
||||
#include <sys/stat.h>
|
||||
#ifndef BF_PLATFORM_DARWIN
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
#include <sys/wait.h>
|
||||
#include <wchar.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#ifdef BFP_HAS_DLINFO
|
||||
#include <link.h>
|
||||
#endif
|
||||
#include <dirent.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
@ -148,9 +152,7 @@ int64 Beefy::GetFileTimeWrite(const StringImpl& path)
|
|||
int result = stat(path.c_str(), &statbuf);
|
||||
if (result == -1)
|
||||
return 0;
|
||||
|
||||
//int64 fileTime = 0;
|
||||
//BFSystemTimeToFileTime(statbuf.st_mtime, 0, &fileTime);
|
||||
|
||||
return statbuf.st_mtime;
|
||||
}
|
||||
|
||||
|
@ -785,7 +787,7 @@ BFP_EXPORT BfpSpawn* BFP_CALLTYPE BfpSpawn_Create(const char* inTargetPath, cons
|
|||
{
|
||||
Beefy::Array<Beefy::StringView> stringViews;
|
||||
|
||||
//printf("Executing: %s %s %x\n", inTargetPath, args, flags);
|
||||
//printf("BfpSpawn_Create: %s %s %x\n", inTargetPath, args, flags);
|
||||
|
||||
if ((workingDir != NULL) && (workingDir[0] != 0))
|
||||
{
|
||||
|
@ -989,12 +991,25 @@ BFP_EXPORT BfpSpawn* BFP_CALLTYPE BfpSpawn_Create(const char* inTargetPath, cons
|
|||
else if (pid == 0) // Child
|
||||
{
|
||||
if ((flags & BfpSpawnFlag_RedirectStdInput) != 0)
|
||||
{
|
||||
close(stdInFD[1]);
|
||||
while ((dup2(stdInFD[0], STDIN_FILENO) == -1) && (errno == EINTR)) {}
|
||||
if ((flags & BfpSpawnFlag_RedirectStdOutput) != 0)
|
||||
while ((dup2(stdOutFD[1], STDOUT_FILENO) == -1) && (errno == EINTR)) {}
|
||||
if ((flags & BfpSpawnFlag_RedirectStdError) != 0)
|
||||
while ((dup2(stdErrFD[1], STDERR_FILENO) == -1) && (errno == EINTR)) {}
|
||||
close(stdInFD[0]);
|
||||
}
|
||||
|
||||
if ((flags & BfpSpawnFlag_RedirectStdOutput) != 0)
|
||||
{
|
||||
close(stdOutFD[0]);
|
||||
while ((dup2(stdOutFD[1], STDOUT_FILENO) == -1) && (errno == EINTR)) {}
|
||||
close(stdOutFD[1]);
|
||||
}
|
||||
if ((flags & BfpSpawnFlag_RedirectStdError) != 0)
|
||||
{
|
||||
close(stdErrFD[0]);
|
||||
while ((dup2(stdErrFD[1], STDERR_FILENO) == -1) && (errno == EINTR)) {}
|
||||
close(stdErrFD[0]);
|
||||
}
|
||||
|
||||
// If successful then this shouldn't return at all:
|
||||
int result;
|
||||
|
||||
|
@ -2280,20 +2295,32 @@ BFP_EXPORT void BFP_CALLTYPE BfpFindFileData_GetFileName(BfpFindFileData* findDa
|
|||
|
||||
BFP_EXPORT BfpTimeStamp BFP_CALLTYPE BfpFindFileData_GetTime_LastWrite(BfpFindFileData* findData)
|
||||
{
|
||||
GetStat(findData);
|
||||
GetStat(findData);
|
||||
#ifdef BF_PLATFORM_DARWIN
|
||||
return BfpToTimeStamp(findData->mStat.st_mtimespec);
|
||||
#else
|
||||
return BfpToTimeStamp(findData->mStat.st_mtim);
|
||||
#endif
|
||||
}
|
||||
|
||||
BFP_EXPORT BfpTimeStamp BFP_CALLTYPE BfpFindFileData_GetTime_Created(BfpFindFileData* findData)
|
||||
{
|
||||
GetStat(findData);
|
||||
#ifdef BF_PLATFORM_DARWIN
|
||||
return BfpToTimeStamp(findData->mStat.st_ctimespec);
|
||||
#else
|
||||
return BfpToTimeStamp(findData->mStat.st_ctim);
|
||||
#endif
|
||||
}
|
||||
|
||||
BFP_EXPORT BfpTimeStamp BFP_CALLTYPE BfpFindFileData_GetTime_Access(BfpFindFileData* findData)
|
||||
{
|
||||
GetStat(findData);
|
||||
#ifdef BF_PLATFORM_DARWIN
|
||||
return BfpToTimeStamp(findData->mStat.st_atimespec);
|
||||
#else
|
||||
return BfpToTimeStamp(findData->mStat.st_atim);
|
||||
#endif
|
||||
}
|
||||
|
||||
BFP_EXPORT BfpFileAttributes BFP_CALLTYPE BfpFindFileData_GetFileAttributes(BfpFindFileData* findData)
|
||||
|
|
|
@ -361,28 +361,28 @@ int Beefy::u8_read_escape_sequence(char *str, uint32 *dest)
|
|||
do {
|
||||
digs[dno++] = str[i++];
|
||||
} while (octal_digit(str[i]) && dno < 3);
|
||||
ch = strtol(digs, NULL, 8);
|
||||
ch = (uint32)strtol(digs, NULL, 8);
|
||||
}
|
||||
else if (str[0] == 'x') {
|
||||
while (hex_digit(str[i]) && dno < 2) {
|
||||
digs[dno++] = str[i++];
|
||||
}
|
||||
if (dno > 0)
|
||||
ch = strtol(digs, NULL, 16);
|
||||
ch = (uint32)strtol(digs, NULL, 16);
|
||||
}
|
||||
else if (str[0] == 'u') {
|
||||
while (hex_digit(str[i]) && dno < 4) {
|
||||
digs[dno++] = str[i++];
|
||||
}
|
||||
if (dno > 0)
|
||||
ch = strtol(digs, NULL, 16);
|
||||
ch = (uint32)strtol(digs, NULL, 16);
|
||||
}
|
||||
else if (str[0] == 'U') {
|
||||
while (hex_digit(str[i]) && dno < 8) {
|
||||
digs[dno++] = str[i++];
|
||||
}
|
||||
if (dno > 0)
|
||||
ch = strtol(digs, NULL, 16);
|
||||
ch = (uint32)strtol(digs, NULL, 16);
|
||||
}
|
||||
*dest = ch;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue