0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

Add atomic increment/decrement platform funcs

This commit is contained in:
jp9000 2014-03-16 16:23:11 -07:00
parent fd37d9e9a8
commit bb92d582bf
3 changed files with 23 additions and 1 deletions

View File

@ -116,3 +116,13 @@ int os_mkdir(const char *path)
return (errno == EEXIST) ? MKDIR_EXISTS : MKDIR_ERROR;
}
long atomic_inc_long(volatile long *val)
{
return __sync_fetch_and_add(val, 1);
}
long atomic_dec_long(volatile long *val)
{
return __sync_fetch_and_sub(val, 1);
}

View File

@ -185,6 +185,16 @@ int os_mkdir(const char *path)
return MKDIR_SUCCESS;
}
long atomic_inc_long(volatile long *val)
{
return InterlockedIncrement(val);
}
long atomic_dec_long(volatile long *val)
{
return InterlockedDecrement(val);
}
BOOL WINAPI DllMain(HINSTANCE hinst_dll, DWORD reason, LPVOID reserved)
{
@ -219,4 +229,3 @@ BOOL WINAPI DllMain(HINSTANCE hinst_dll, DWORD reason, LPVOID reserved)
return true;
}

View File

@ -76,6 +76,9 @@ EXPORT char *os_get_config_path(const char *name);
EXPORT bool os_file_exists(const char *path);
EXPORT long atomic_inc_long(volatile long *val);
EXPORT long atomic_dec_long(volatile long *val);
#define MKDIR_EXISTS 1
#define MKDIR_SUCCESS 0
#define MKDIR_ERROR -1