mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Rename semaphore_* to sphore_*
Previous naming conflicted with Mach kernel definitions.
This commit is contained in:
parent
cd3038315b
commit
cd386488e2
|
@ -138,8 +138,8 @@ void dbg_msg_thread(void *v)
|
|||
int num;
|
||||
while(1)
|
||||
{
|
||||
semaphore_wait(&log_queue.notempty);
|
||||
semaphore_wait(&log_queue.mutex);
|
||||
sphore_wait(&log_queue.notempty);
|
||||
sphore_wait(&log_queue.mutex);
|
||||
|
||||
if(queue_empty(&log_queue))
|
||||
{
|
||||
|
@ -154,10 +154,10 @@ void dbg_msg_thread(void *v)
|
|||
}
|
||||
|
||||
if(!queue_empty(&log_queue) || log_queue.skipped > 0)
|
||||
semaphore_signal(&log_queue.notempty);
|
||||
sphore_signal(&log_queue.notempty);
|
||||
|
||||
num = num_loggers;
|
||||
semaphore_signal(&log_queue.mutex);
|
||||
sphore_signal(&log_queue.mutex);
|
||||
|
||||
for(i = 0; i < num; i++)
|
||||
loggers[i](str);
|
||||
|
@ -173,9 +173,9 @@ void dbg_enable_threaded()
|
|||
q->begin = 0;
|
||||
q->end = 0;
|
||||
q->skipped = 0;
|
||||
semaphore_init(&q->mutex);
|
||||
semaphore_init(&q->notempty);
|
||||
semaphore_signal(&q->mutex);
|
||||
sphore_init(&q->mutex);
|
||||
sphore_init(&q->notempty);
|
||||
sphore_signal(&q->mutex);
|
||||
|
||||
dbg_msg_threaded = 1;
|
||||
|
||||
|
@ -195,7 +195,7 @@ void dbg_msg(const char *sys, const char *fmt, ...)
|
|||
|
||||
if(dbg_msg_threaded)
|
||||
{
|
||||
semaphore_wait(&log_queue.mutex);
|
||||
sphore_wait(&log_queue.mutex);
|
||||
|
||||
if(queue_full(&log_queue))
|
||||
{
|
||||
|
@ -221,10 +221,10 @@ void dbg_msg(const char *sys, const char *fmt, ...)
|
|||
log_queue.end = (log_queue.end + 1) % QUEUE_SIZE;
|
||||
|
||||
if(e)
|
||||
semaphore_signal(&log_queue.notempty);
|
||||
sphore_signal(&log_queue.notempty);
|
||||
}
|
||||
|
||||
semaphore_signal(&log_queue.mutex);
|
||||
sphore_signal(&log_queue.mutex);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -278,13 +278,13 @@ static void logger_file(const char *line)
|
|||
void dbg_logger(DBG_LOGGER logger)
|
||||
{
|
||||
if(dbg_msg_threaded)
|
||||
semaphore_wait(&log_queue.mutex);
|
||||
sphore_wait(&log_queue.mutex);
|
||||
|
||||
loggers[num_loggers] = logger;
|
||||
num_loggers++;
|
||||
|
||||
if(dbg_msg_threaded)
|
||||
semaphore_signal(&log_queue.mutex);
|
||||
sphore_signal(&log_queue.mutex);
|
||||
}
|
||||
|
||||
void dbg_logger_stdout() { dbg_logger(logger_stdout); }
|
||||
|
@ -648,25 +648,25 @@ void lock_unlock(LOCK lock)
|
|||
}
|
||||
|
||||
#if defined(CONF_FAMILY_UNIX) && !defined(CONF_PLATFORM_MACOSX)
|
||||
void semaphore_init(SEMAPHORE *sem) { sem_init(sem, 0, 0); }
|
||||
void semaphore_wait(SEMAPHORE *sem) { sem_wait(sem); }
|
||||
void semaphore_signal(SEMAPHORE *sem) { sem_post(sem); }
|
||||
void semaphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); }
|
||||
void sphore_init(SEMAPHORE *sem) { sem_init(sem, 0, 0); }
|
||||
void sphore_wait(SEMAPHORE *sem) { sem_wait(sem); }
|
||||
void sphore_signal(SEMAPHORE *sem) { sem_post(sem); }
|
||||
void sphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); }
|
||||
#elif defined(CONF_FAMILY_WINDOWS)
|
||||
void semaphore_init(SEMAPHORE *sem) { *sem = CreateSemaphore(0, 0, 10000, 0); }
|
||||
void semaphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, INFINITE); }
|
||||
void semaphore_signal(SEMAPHORE *sem) { ReleaseSemaphore((HANDLE)*sem, 1, NULL); }
|
||||
void semaphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); }
|
||||
void sphore_init(SEMAPHORE *sem) { *sem = CreateSemaphore(0, 0, 10000, 0); }
|
||||
void sphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, INFINITE); }
|
||||
void sphore_signal(SEMAPHORE *sem) { ReleaseSemaphore((HANDLE)*sem, 1, NULL); }
|
||||
void sphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); }
|
||||
#elif defined(CONF_PLATFORM_MACOSX)
|
||||
void semaphore_init(SEMAPHORE *sem)
|
||||
void sphore_init(SEMAPHORE *sem)
|
||||
{
|
||||
char aBuf[64];
|
||||
str_format(aBuf, sizeof(aBuf), "/%d-ddphore-%p", pid(), (void *)sem);
|
||||
*sem = sem_open(aBuf, O_CREAT | O_EXCL, S_IRWXU | S_IRWXG, 0);
|
||||
}
|
||||
void semaphore_wait(SEMAPHORE *sem) { sem_wait(*sem); }
|
||||
void semaphore_signal(SEMAPHORE *sem) { sem_post(*sem); }
|
||||
void semaphore_destroy(SEMAPHORE *sem) { sem_close(*sem); }
|
||||
void sphore_wait(SEMAPHORE *sem) { sem_wait(*sem); }
|
||||
void sphore_signal(SEMAPHORE *sem) { sem_post(*sem); }
|
||||
void sphore_destroy(SEMAPHORE *sem) { sem_close(*sem); }
|
||||
#else
|
||||
#error not implemented on this platform
|
||||
#endif
|
||||
|
|
|
@ -438,10 +438,10 @@ void lock_unlock(LOCK lock);
|
|||
#error not implemented on this platform
|
||||
#endif
|
||||
|
||||
void semaphore_init(SEMAPHORE *sem);
|
||||
void semaphore_wait(SEMAPHORE *sem);
|
||||
void semaphore_signal(SEMAPHORE *sem);
|
||||
void semaphore_destroy(SEMAPHORE *sem);
|
||||
void sphore_init(SEMAPHORE *sem);
|
||||
void sphore_wait(SEMAPHORE *sem);
|
||||
void sphore_signal(SEMAPHORE *sem);
|
||||
void sphore_destroy(SEMAPHORE *sem);
|
||||
|
||||
/* Group: Timer */
|
||||
#ifdef __GNUC__
|
||||
|
|
|
@ -70,10 +70,10 @@
|
|||
{
|
||||
SEMAPHORE sem;
|
||||
public:
|
||||
semaphore() { semaphore_init(&sem); }
|
||||
~semaphore() { semaphore_destroy(&sem); }
|
||||
void wait() { semaphore_wait(&sem); }
|
||||
void signal() { semaphore_signal(&sem); }
|
||||
semaphore() { sphore_init(&sem); }
|
||||
~semaphore() { sphore_destroy(&sem); }
|
||||
void wait() { sphore_wait(&sem); }
|
||||
void signal() { sphore_signal(&sem); }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ CFetcher::CFetcher()
|
|||
m_pStorage = NULL;
|
||||
m_pHandle = NULL;
|
||||
m_Lock = lock_create();
|
||||
semaphore_init(&m_Queued);
|
||||
sphore_init(&m_Queued);
|
||||
m_pFirst = NULL;
|
||||
m_pLast = NULL;
|
||||
m_Running = true;
|
||||
|
@ -34,11 +34,11 @@ CFetcher::~CFetcher()
|
|||
if(m_pThHandle)
|
||||
{
|
||||
m_Running = false;
|
||||
semaphore_signal(&m_Queued);
|
||||
sphore_signal(&m_Queued);
|
||||
thread_wait(m_pThHandle);
|
||||
}
|
||||
lock_destroy(m_Lock);
|
||||
semaphore_destroy(&m_Queued);
|
||||
sphore_destroy(&m_Queued);
|
||||
|
||||
if(m_pHandle)
|
||||
curl_easy_cleanup(m_pHandle);
|
||||
|
@ -75,7 +75,7 @@ void CFetcher::QueueAdd(CFetchTask *pTask, const char *pUrl, const char *pDest,
|
|||
}
|
||||
pTask->m_State = CFetchTask::STATE_QUEUED;
|
||||
lock_unlock(m_Lock);
|
||||
semaphore_signal(&m_Queued);
|
||||
sphore_signal(&m_Queued);
|
||||
}
|
||||
|
||||
void CFetcher::Escape(char *pBuf, size_t size, const char *pStr)
|
||||
|
@ -91,7 +91,7 @@ void CFetcher::FetcherThread(void *pUser)
|
|||
dbg_msg("fetcher", "thread started...");
|
||||
while(pFetcher->m_Running)
|
||||
{
|
||||
semaphore_wait(&pFetcher->m_Queued);
|
||||
sphore_wait(&pFetcher->m_Queued);
|
||||
lock_wait(pFetcher->m_Lock);
|
||||
CFetchTask *pTask = pFetcher->m_pFirst;
|
||||
if(pTask)
|
||||
|
|
Loading…
Reference in a new issue