mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-04-20 22:05:06 +00:00
Compilation fix
This commit is contained in:
parent
22b78fec71
commit
2823953489
5 changed files with 90 additions and 81 deletions
|
|
@ -388,7 +388,7 @@ union _CRT_ALIGN(16) u128
|
|||
}
|
||||
};
|
||||
|
||||
static __forceinline u128 __sync_val_compare_and_swap(volatile u128* dest, u128 comp, u128 exch)
|
||||
static __forceinline u128 sync_val_compare_and_swap(volatile u128* dest, u128 comp, u128 exch)
|
||||
{
|
||||
#if !defined(_MSC_VER)
|
||||
auto res = __sync_val_compare_and_swap((volatile __int128_t*)dest, (__int128_t&)comp, (__int128_t&)exch);
|
||||
|
|
@ -399,7 +399,7 @@ static __forceinline u128 __sync_val_compare_and_swap(volatile u128* dest, u128
|
|||
#endif
|
||||
}
|
||||
|
||||
static __forceinline bool __sync_bool_compare_and_swap(volatile u128* dest, u128 comp, u128 exch)
|
||||
static __forceinline bool sync_bool_compare_and_swap(volatile u128* dest, u128 comp, u128 exch)
|
||||
{
|
||||
#if !defined(_MSC_VER)
|
||||
return __sync_bool_compare_and_swap((volatile __int128_t*)dest, (__int128_t&)comp, (__int128_t&)exch);
|
||||
|
|
@ -408,39 +408,39 @@ static __forceinline bool __sync_bool_compare_and_swap(volatile u128* dest, u128
|
|||
#endif
|
||||
}
|
||||
|
||||
static __forceinline u128 __sync_lock_test_and_set(volatile u128* dest, u128 value)
|
||||
static __forceinline u128 sync_lock_test_and_set(volatile u128* dest, u128 value)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const u128 old = *(u128*)dest;
|
||||
if (__sync_bool_compare_and_swap(dest, old, value)) return old;
|
||||
if (sync_bool_compare_and_swap(dest, old, value)) return old;
|
||||
}
|
||||
}
|
||||
|
||||
static __forceinline u128 __sync_fetch_and_or(volatile u128* dest, u128 value)
|
||||
static __forceinline u128 sync_fetch_and_or(volatile u128* dest, u128 value)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const u128 old = *(u128*)dest;
|
||||
if (__sync_bool_compare_and_swap(dest, old, value | old)) return old;
|
||||
if (sync_bool_compare_and_swap(dest, old, value | old)) return old;
|
||||
}
|
||||
}
|
||||
|
||||
static __forceinline u128 __sync_fetch_and_and(volatile u128* dest, u128 value)
|
||||
static __forceinline u128 sync_fetch_and_and(volatile u128* dest, u128 value)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const u128 old = *(u128*)dest;
|
||||
if (__sync_bool_compare_and_swap(dest, old, value & old)) return old;
|
||||
if (sync_bool_compare_and_swap(dest, old, value & old)) return old;
|
||||
}
|
||||
}
|
||||
|
||||
static __forceinline u128 __sync_fetch_and_xor(volatile u128* dest, u128 value)
|
||||
static __forceinline u128 sync_fetch_and_xor(volatile u128* dest, u128 value)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
const u128 old = *(u128*)dest;
|
||||
if (__sync_bool_compare_and_swap(dest, old, value ^ old)) return old;
|
||||
if (sync_bool_compare_and_swap(dest, old, value ^ old)) return old;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ bool fs::stat(const std::string& path, stat_t& info)
|
|||
info.mtime = to_time_t(attrs.ftLastWriteTime);
|
||||
info.ctime = to_time_t(attrs.ftCreationTime);
|
||||
#else
|
||||
struct stat64 file_info;
|
||||
if (stat64(path.c_str(), &file_info) < 0)
|
||||
struct stat file_info;
|
||||
if (stat(path.c_str(), &file_info) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -174,8 +174,8 @@ bool fs::is_file(const std::string& file)
|
|||
|
||||
return (attrs & FILE_ATTRIBUTE_DIRECTORY) == 0;
|
||||
#else
|
||||
struct stat64 file_info;
|
||||
if (stat64(file.c_str(), &file_info) < 0)
|
||||
struct stat file_info;
|
||||
if (stat(file.c_str(), &file_info) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -195,8 +195,8 @@ bool fs::is_dir(const std::string& dir)
|
|||
|
||||
return (attrs & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
#else
|
||||
struct stat64 file_info;
|
||||
if (stat64(dir.c_str(), &file_info) < 0)
|
||||
struct stat file_info;
|
||||
if (stat(dir.c_str(), &file_info) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -364,7 +364,7 @@ bool fs::truncate_file(const std::string& file, u64 length)
|
|||
#ifdef _WIN32
|
||||
if (!::truncate_file(file, length))
|
||||
#else
|
||||
if (truncate64(file.c_str(), length))
|
||||
if (::truncate(file.c_str(), length))
|
||||
#endif
|
||||
{
|
||||
LOG_WARNING(GENERAL, "Error resizing file '%s' to 0x%llx: 0x%llx", file, length, GET_API_ERROR);
|
||||
|
|
@ -480,7 +480,7 @@ bool fs::file::trunc(u64 size) const
|
|||
|
||||
return true; // TODO
|
||||
#else
|
||||
return !ftruncate64(m_fd, size);
|
||||
return !::ftruncate(m_fd, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -501,8 +501,8 @@ bool fs::file::stat(stat_t& info) const
|
|||
info.mtime = to_time_t(basic_info.ChangeTime);
|
||||
info.ctime = to_time_t(basic_info.CreationTime);
|
||||
#else
|
||||
struct stat64 file_info;
|
||||
if (fstat64(m_fd, &file_info) < 0)
|
||||
struct stat file_info;
|
||||
if (fstat(m_fd, &file_info) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -580,7 +580,7 @@ u64 fs::file::seek(u64 offset, u32 mode) const
|
|||
|
||||
return pos.QuadPart;
|
||||
#else
|
||||
return lseek64(m_fd, offset, mode);
|
||||
return ::lseek(m_fd, offset, mode);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -595,8 +595,8 @@ u64 fs::file::size() const
|
|||
|
||||
return size.QuadPart;
|
||||
#else
|
||||
struct stat64 file_info;
|
||||
if (fstat64(m_fd, &file_info) < 0)
|
||||
struct stat file_info;
|
||||
if (::fstat(m_fd, &file_info) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -766,8 +766,8 @@ bool fs::dir::get_next(std::string& name, stat_t& info)
|
|||
#else
|
||||
const auto found = ::readdir((DIR*)m_dd);
|
||||
|
||||
struct stat64 file_info;
|
||||
if (!found || fstatat64(::dirfd((DIR*)m_dd), found->d_name, &file_info, 0) < 0)
|
||||
struct stat file_info;
|
||||
if (!found || ::fstatat(::dirfd((DIR*)m_dd), found->d_name, &file_info, 0) < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,180 +78,189 @@ int clock_gettime(int foo, struct timespec *ts);
|
|||
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#define sync_val_compare_and_swap __sync_val_compare_and_swap
|
||||
#define sync_bool_compare_and_swap __sync_bool_compare_and_swap
|
||||
#define sync_lock_test_and_set __sync_lock_test_and_set
|
||||
#define sync_fetch_and_add __sync_fetch_and_add
|
||||
#define sync_fetch_and_sub __sync_fetch_and_sub
|
||||
#define sync_fetch_and_or __sync_fetch_and_or
|
||||
#define sync_fetch_and_and __sync_fetch_and_and
|
||||
#define sync_fetch_and_xor __sync_fetch_and_xor
|
||||
|
||||
#endif /* __GNUG__ */
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
// atomic compare and swap functions
|
||||
|
||||
static __forceinline uint8_t __sync_val_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch)
|
||||
static __forceinline uint8_t sync_val_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch)
|
||||
{
|
||||
return _InterlockedCompareExchange8((volatile char*)dest, exch, comp);
|
||||
}
|
||||
|
||||
static __forceinline uint16_t __sync_val_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch)
|
||||
static __forceinline uint16_t sync_val_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch)
|
||||
{
|
||||
return _InterlockedCompareExchange16((volatile short*)dest, exch, comp);
|
||||
}
|
||||
|
||||
static __forceinline uint32_t __sync_val_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch)
|
||||
static __forceinline uint32_t sync_val_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch)
|
||||
{
|
||||
return _InterlockedCompareExchange((volatile long*)dest, exch, comp);
|
||||
}
|
||||
|
||||
static __forceinline uint64_t __sync_val_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch)
|
||||
static __forceinline uint64_t sync_val_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch)
|
||||
{
|
||||
return _InterlockedCompareExchange64((volatile long long*)dest, exch, comp);
|
||||
}
|
||||
|
||||
static __forceinline bool __sync_bool_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch)
|
||||
static __forceinline bool sync_bool_compare_and_swap(volatile uint8_t* dest, uint8_t comp, uint8_t exch)
|
||||
{
|
||||
return (uint8_t)_InterlockedCompareExchange8((volatile char*)dest, exch, comp) == comp;
|
||||
}
|
||||
|
||||
static __forceinline bool __sync_bool_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch)
|
||||
static __forceinline bool sync_bool_compare_and_swap(volatile uint16_t* dest, uint16_t comp, uint16_t exch)
|
||||
{
|
||||
return (uint16_t)_InterlockedCompareExchange16((volatile short*)dest, exch, comp) == comp;
|
||||
}
|
||||
|
||||
static __forceinline bool __sync_bool_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch)
|
||||
static __forceinline bool sync_bool_compare_and_swap(volatile uint32_t* dest, uint32_t comp, uint32_t exch)
|
||||
{
|
||||
return (uint32_t)_InterlockedCompareExchange((volatile long*)dest, exch, comp) == comp;
|
||||
}
|
||||
|
||||
static __forceinline bool __sync_bool_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch)
|
||||
static __forceinline bool sync_bool_compare_and_swap(volatile uint64_t* dest, uint64_t comp, uint64_t exch)
|
||||
{
|
||||
return (uint64_t)_InterlockedCompareExchange64((volatile long long*)dest, exch, comp) == comp;
|
||||
}
|
||||
|
||||
// atomic exchange functions
|
||||
|
||||
static __forceinline uint8_t __sync_lock_test_and_set(volatile uint8_t* dest, uint8_t value)
|
||||
static __forceinline uint8_t sync_lock_test_and_set(volatile uint8_t* dest, uint8_t value)
|
||||
{
|
||||
return _InterlockedExchange8((volatile char*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint16_t __sync_lock_test_and_set(volatile uint16_t* dest, uint16_t value)
|
||||
static __forceinline uint16_t sync_lock_test_and_set(volatile uint16_t* dest, uint16_t value)
|
||||
{
|
||||
return _InterlockedExchange16((volatile short*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint32_t __sync_lock_test_and_set(volatile uint32_t* dest, uint32_t value)
|
||||
static __forceinline uint32_t sync_lock_test_and_set(volatile uint32_t* dest, uint32_t value)
|
||||
{
|
||||
return _InterlockedExchange((volatile long*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint64_t __sync_lock_test_and_set(volatile uint64_t* dest, uint64_t value)
|
||||
static __forceinline uint64_t sync_lock_test_and_set(volatile uint64_t* dest, uint64_t value)
|
||||
{
|
||||
return _InterlockedExchange64((volatile long long*)dest, value);
|
||||
}
|
||||
|
||||
// atomic add functions
|
||||
|
||||
static __forceinline uint8_t __sync_fetch_and_add(volatile uint8_t* dest, uint8_t value)
|
||||
static __forceinline uint8_t sync_fetch_and_add(volatile uint8_t* dest, uint8_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd8((volatile char*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint16_t __sync_fetch_and_add(volatile uint16_t* dest, uint16_t value)
|
||||
static __forceinline uint16_t sync_fetch_and_add(volatile uint16_t* dest, uint16_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd16((volatile short*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint32_t __sync_fetch_and_add(volatile uint32_t* dest, uint32_t value)
|
||||
static __forceinline uint32_t sync_fetch_and_add(volatile uint32_t* dest, uint32_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd((volatile long*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint64_t __sync_fetch_and_add(volatile uint64_t* dest, uint64_t value)
|
||||
static __forceinline uint64_t sync_fetch_and_add(volatile uint64_t* dest, uint64_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd64((volatile long long*)dest, value);
|
||||
}
|
||||
|
||||
// atomic sub functions
|
||||
|
||||
static __forceinline uint8_t __sync_fetch_and_sub(volatile uint8_t* dest, uint8_t value)
|
||||
static __forceinline uint8_t sync_fetch_and_sub(volatile uint8_t* dest, uint8_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd8((volatile char*)dest, -(char)value);
|
||||
}
|
||||
|
||||
static __forceinline uint16_t __sync_fetch_and_sub(volatile uint16_t* dest, uint16_t value)
|
||||
static __forceinline uint16_t sync_fetch_and_sub(volatile uint16_t* dest, uint16_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd16((volatile short*)dest, -(short)value);
|
||||
}
|
||||
|
||||
static __forceinline uint32_t __sync_fetch_and_sub(volatile uint32_t* dest, uint32_t value)
|
||||
static __forceinline uint32_t sync_fetch_and_sub(volatile uint32_t* dest, uint32_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd((volatile long*)dest, -(long)value);
|
||||
}
|
||||
|
||||
static __forceinline uint64_t __sync_fetch_and_sub(volatile uint64_t* dest, uint64_t value)
|
||||
static __forceinline uint64_t sync_fetch_and_sub(volatile uint64_t* dest, uint64_t value)
|
||||
{
|
||||
return _InterlockedExchangeAdd64((volatile long long*)dest, -(long long)value);
|
||||
}
|
||||
|
||||
// atomic bitwise or functions
|
||||
|
||||
static __forceinline uint8_t __sync_fetch_and_or(volatile uint8_t* dest, uint8_t value)
|
||||
static __forceinline uint8_t sync_fetch_and_or(volatile uint8_t* dest, uint8_t value)
|
||||
{
|
||||
return _InterlockedOr8((volatile char*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint16_t __sync_fetch_and_or(volatile uint16_t* dest, uint16_t value)
|
||||
static __forceinline uint16_t sync_fetch_and_or(volatile uint16_t* dest, uint16_t value)
|
||||
{
|
||||
return _InterlockedOr16((volatile short*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint32_t __sync_fetch_and_or(volatile uint32_t* dest, uint32_t value)
|
||||
static __forceinline uint32_t sync_fetch_and_or(volatile uint32_t* dest, uint32_t value)
|
||||
{
|
||||
return _InterlockedOr((volatile long*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint64_t __sync_fetch_and_or(volatile uint64_t* dest, uint64_t value)
|
||||
static __forceinline uint64_t sync_fetch_and_or(volatile uint64_t* dest, uint64_t value)
|
||||
{
|
||||
return _InterlockedOr64((volatile long long*)dest, value);
|
||||
}
|
||||
|
||||
// atomic bitwise and functions
|
||||
|
||||
static __forceinline uint8_t __sync_fetch_and_and(volatile uint8_t* dest, uint8_t value)
|
||||
static __forceinline uint8_t sync_fetch_and_and(volatile uint8_t* dest, uint8_t value)
|
||||
{
|
||||
return _InterlockedAnd8((volatile char*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint16_t __sync_fetch_and_and(volatile uint16_t* dest, uint16_t value)
|
||||
static __forceinline uint16_t sync_fetch_and_and(volatile uint16_t* dest, uint16_t value)
|
||||
{
|
||||
return _InterlockedAnd16((volatile short*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint32_t __sync_fetch_and_and(volatile uint32_t* dest, uint32_t value)
|
||||
static __forceinline uint32_t sync_fetch_and_and(volatile uint32_t* dest, uint32_t value)
|
||||
{
|
||||
return _InterlockedAnd((volatile long*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint64_t __sync_fetch_and_and(volatile uint64_t* dest, uint64_t value)
|
||||
static __forceinline uint64_t sync_fetch_and_and(volatile uint64_t* dest, uint64_t value)
|
||||
{
|
||||
return _InterlockedAnd64((volatile long long*)dest, value);
|
||||
}
|
||||
|
||||
// atomic bitwise xor functions
|
||||
|
||||
static __forceinline uint8_t __sync_fetch_and_xor(volatile uint8_t* dest, uint8_t value)
|
||||
static __forceinline uint8_t sync_fetch_and_xor(volatile uint8_t* dest, uint8_t value)
|
||||
{
|
||||
return _InterlockedXor8((volatile char*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint16_t __sync_fetch_and_xor(volatile uint16_t* dest, uint16_t value)
|
||||
static __forceinline uint16_t sync_fetch_and_xor(volatile uint16_t* dest, uint16_t value)
|
||||
{
|
||||
return _InterlockedXor16((volatile short*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint32_t __sync_fetch_and_xor(volatile uint32_t* dest, uint32_t value)
|
||||
static __forceinline uint32_t sync_fetch_and_xor(volatile uint32_t* dest, uint32_t value)
|
||||
{
|
||||
return _InterlockedXor((volatile long*)dest, value);
|
||||
}
|
||||
|
||||
static __forceinline uint64_t __sync_fetch_and_xor(volatile uint64_t* dest, uint64_t value)
|
||||
static __forceinline uint64_t sync_fetch_and_xor(volatile uint64_t* dest, uint64_t value)
|
||||
{
|
||||
return _InterlockedXor64((volatile long long*)dest, value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue