Files
fastfetch/src/detection/internal.h
T

24 lines
536 B
C
Raw Normal View History

2022-09-04 22:20:12 +02:00
#pragma once
#ifndef FF_INCLUDED_detection_internal
#define FF_INCLUDED_detection_internal
#include "common/thread.h"
2022-09-04 22:20:12 +02:00
#define FF_DETECTION_INTERNAL_GUARD(ResultType, ...) \
static FFThreadMutex mutex = FF_THREAD_MUTEX_INITIALIZER; \
2022-09-04 22:20:12 +02:00
static ResultType result; \
static bool init = false; \
ffThreadMutexLock(&mutex); \
2022-09-04 22:20:12 +02:00
if(init) \
{ \
ffThreadMutexUnlock(&mutex); \
2022-09-04 22:20:12 +02:00
return &result; \
} \
init = true; \
__VA_ARGS__; \
ffThreadMutexUnlock(&mutex); \
2022-09-04 22:20:12 +02:00
return &result; \
#endif