#pragma once

#include "../../../threadlib/include/winEmul.h"
#ifdef WIN32
 #define uni
#else
 #define uni win_emul
 #if defined(__APPLE__) && defined(__MACH__)
    #include <libkern/OSAtomic.h>
    #ifdef __LP64__
         #define InterlockedIncrement(A) (long)OSAtomicIncrement64((volatile int64_t *)A)
         #define InterlockedDecrement(A) (long)OSAtomicDecrement64((volatile int64_t *)A)
    #else
         #define InterlockedIncrement(A) (long)OSAtomicIncrement32((volatile int32_t *)A)
         #define InterlockedDecrement(A) (long)OSAtomicDecrement32((volatile int32_t *)A)
    #endif
  #else  // linux and similar
         #define InterlockedIncrement(A) (long)__sync_add_and_fetch(A, 1L)
         #define InterlockedDecrement(A) (long)__sync_sub_and_fetch(A, 1L)
  #endif
#endif

