windows2linux.h 2.3 KB

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