mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-10 11:59:58 -05:00
Initial community commit
This commit is contained in:
104
Src/replicant/foundation/win-amd64/atomics.h
Normal file
104
Src/replicant/foundation/win-amd64/atomics.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
|
||||
Win64 (amd64) implementation
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "../../foundation/types.h"
|
||||
#include <Windows.h>
|
||||
#include <intrin.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define NX_ATOMIC_INLINE inline
|
||||
#else
|
||||
#define NX_ATOMIC_INLINE
|
||||
#endif
|
||||
|
||||
NX_ATOMIC_INLINE static size_t nx_atomic_inc(volatile size_t *addr)
|
||||
{
|
||||
return (size_t)_InterlockedIncrement64((volatile LONGLONG *)addr);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static size_t nx_atomic_dec(volatile size_t *addr)
|
||||
{
|
||||
return (size_t)_InterlockedDecrement64((volatile LONGLONG *)addr);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static size_t nx_atomic_dec_release(volatile size_t *addr)
|
||||
{
|
||||
return (size_t)_InterlockedDecrement64((volatile LONGLONG *)addr);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static void nx_atomic_write(size_t value, volatile size_t *addr)
|
||||
{
|
||||
InterlockedExchange64((volatile LONG64 *)addr, value);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static void nx_atomic_write_pointer(void *value, void* volatile *addr)
|
||||
{
|
||||
InterlockedExchangePointer(addr, value);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static size_t nx_atomic_add(size_t value, volatile size_t* addr)
|
||||
{
|
||||
return (size_t)InterlockedExchangeAdd64 ((volatile LONGLONG *)addr, (LONGLONG)value);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static size_t nx_atomic_sub(size_t value, volatile size_t* addr)
|
||||
{
|
||||
return (size_t)InterlockedExchangeAdd64((volatile LONGLONG *)addr, -(LONGLONG)value);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static void *nx_atomic_swap_pointer(void *value, void* volatile *addr)
|
||||
{
|
||||
return InterlockedExchangePointer(addr, value);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static int nx_atomic_cmpxchg_pointer(void *oldvalue, void *newvalue, void* volatile *addr)
|
||||
{
|
||||
return InterlockedCompareExchangePointer(addr, newvalue, oldvalue) == oldvalue;
|
||||
}
|
||||
/*
|
||||
NX_ATOMIC_INLINE static int nx_atomic_cmpxchg2(size_t *oldvalue, size_t *newvalue, volatile size_t *addr)
|
||||
{
|
||||
return InterlockedCompare64Exchange128((LONG64 volatile *)addr, (LONG64)newvalue[1], (LONG64)newvalue[0], (LONG64)oldvalue[0]) == oldvalue[0];
|
||||
}
|
||||
*/
|
||||
#if 0
|
||||
NX_ATOMIC_INLINE static size_t atomic_increment(volatile size_t *val)
|
||||
{
|
||||
return (size_t)InterlockedIncrement((volatile LONG *)val);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static size_t atomic_decrement(volatile size_t *val)
|
||||
{
|
||||
return (size_t)InterlockedDecrement((volatile LONG *)val);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static void atomic_add(volatile size_t *val, size_t add)
|
||||
{
|
||||
InterlockedExchangeAdd64((volatile LONGLONG *)val, (LONGLONG)add);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static void atomic_sub(volatile size_t *val, size_t sub)
|
||||
{
|
||||
InterlockedExchangeAdd64((volatile LONGLONG *)val, -((LONGLONG)sub));
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static void *atomic_exchange_pointer(void* volatile *target, void *value)
|
||||
{
|
||||
return InterlockedExchangePointer(target, value);
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static bool atomic_compare_exchange_pointer(void* volatile *destination, void *exchange, void *compare)
|
||||
{
|
||||
return InterlockedCompareExchangePointer(destination, exchange, compare) == compare;
|
||||
}
|
||||
|
||||
NX_ATOMIC_INLINE static void atomic_write(volatile size_t *dest, size_t src)
|
||||
{
|
||||
InterlockedExchange64((volatile LONG64 *)dest, src);
|
||||
}
|
||||
|
||||
#endif
|
||||
92
Src/replicant/foundation/win-amd64/types.h
Normal file
92
Src/replicant/foundation/win-amd64/types.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#pragma once
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
#include <wchar.h>
|
||||
// first, some standard int types
|
||||
typedef unsigned int UINT;
|
||||
typedef signed int SINT;
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
typedef signed char SCHAR;
|
||||
|
||||
typedef unsigned long ARGB32;
|
||||
typedef unsigned long RGB32;
|
||||
|
||||
typedef unsigned long ARGB24;
|
||||
typedef unsigned long RGB24;
|
||||
|
||||
typedef unsigned short ARGB16;
|
||||
typedef unsigned short RGB16;
|
||||
|
||||
typedef unsigned long FOURCC;
|
||||
|
||||
typedef wchar_t nsxml_char_t;
|
||||
typedef wchar_t ns_char_t;
|
||||
typedef wchar_t nsfilename_char_t;
|
||||
|
||||
typedef int socklen_t;
|
||||
|
||||
#if defined(_WIN64) && !defined(__GNUC__)
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// since windows doesn't have stdint.h
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int16 int16_t;
|
||||
|
||||
#ifdef _M_IX86
|
||||
typedef int64_t intptr2_t;
|
||||
#elif defined(_M_IX64)
|
||||
typedef unsigned __int128 uint128_t;
|
||||
typedef __int128 int128_t;
|
||||
typedef int128_t intptr2_t
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#ifndef GUID_DEFINED
|
||||
#define GUID_DEFINED
|
||||
|
||||
typedef struct _GUID
|
||||
{
|
||||
uint32_t Data1;
|
||||
uint16_t Data2;
|
||||
uint16_t Data3;
|
||||
uint8_t Data4[8];
|
||||
} GUID;
|
||||
/*
|
||||
#ifndef _REFCLSID_DEFINED
|
||||
#define REFGUID const GUID &
|
||||
#define _REFCLSID_DEFINED
|
||||
#endif
|
||||
*/
|
||||
#endif
|
||||
|
||||
// this is for GUID == and !=
|
||||
#include <objbase.h>
|
||||
#ifndef GUID_EQUALS_DEFINED
|
||||
#define GUID_EQUALS_DEFINED
|
||||
#endif
|
||||
|
||||
typedef SSIZE_T ssize_t;
|
||||
#ifdef NULL
|
||||
#undef NULL
|
||||
#endif
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
typedef int intptr_t;
|
||||
#endif
|
||||
Reference in New Issue
Block a user