windows2linux.h
Go to the documentation of this file.
1 #ifndef __WINDOWS2LINUX_H__
2 #define __WINDOWS2LINUX_H__
3 
4 /*
5  * LINUX SPECIFIC DEFINITIONS
6 */
7 //
8 // Data types conversions
9 //
10 #include <stdlib.h>
11 #include <string.h>
13 
14 #ifdef __cplusplus
15 namespace avxsynth {
16 #endif // __cplusplus
17 //
18 // purposefully define the following MSFT definitions
19 // to mean nothing (as they do not mean anything on Linux)
20 //
21 #define __stdcall
22 #define __cdecl
23 #define noreturn
24 #define __declspec(x)
25 #define STDAPI extern "C" HRESULT
26 #define STDMETHODIMP HRESULT __stdcall
27 #define STDMETHODIMP_(x) x __stdcall
28 
29 #define STDMETHOD(x) virtual HRESULT x
30 #define STDMETHOD_(a, x) virtual a x
31 
32 #ifndef TRUE
33 #define TRUE true
34 #endif
35 
36 #ifndef FALSE
37 #define FALSE false
38 #endif
39 
40 #define S_OK (0x00000000)
41 #define S_FALSE (0x00000001)
42 #define E_NOINTERFACE (0X80004002)
43 #define E_POINTER (0x80004003)
44 #define E_FAIL (0x80004005)
45 #define E_OUTOFMEMORY (0x8007000E)
46 
47 #define INVALID_HANDLE_VALUE ((HANDLE)((LONG_PTR)-1))
48 #define FAILED(hr) ((hr) & 0x80000000)
49 #define SUCCEEDED(hr) (!FAILED(hr))
50 
51 
52 //
53 // Functions
54 //
55 #define MAKEDWORD(a,b,c,d) ((a << 24) | (b << 16) | (c << 8) | (d))
56 #define MAKEWORD(a,b) ((a << 8) | (b))
57 
58 #define lstrlen strlen
59 #define lstrcpy strcpy
60 #define lstrcmpi strcasecmp
61 #define _stricmp strcasecmp
62 #define InterlockedIncrement(x) __sync_fetch_and_add((x), 1)
63 #define InterlockedDecrement(x) __sync_fetch_and_sub((x), 1)
64 // Windows uses (new, old) ordering but GCC has (old, new)
65 #define InterlockedCompareExchange(x,y,z) __sync_val_compare_and_swap(x,z,y)
66 
67 #define UInt32x32To64(a, b) ( (uint64_t) ( ((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)) ) )
68 #define Int64ShrlMod32(a, b) ( (uint64_t) ( (uint64_t)(a) >> (b) ) )
69 #define Int32x32To64(a, b) ((__int64)(((__int64)((long)(a))) * ((long)(b))))
70 
71 #define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator))
72 
73 #ifdef __cplusplus
74 }; // namespace avxsynth
75 #endif // __cplusplus
76 
77 #endif // __WINDOWS2LINUX_H__