This commit is contained in:
bing
2026-04-02 23:18:28 +08:00
commit 6198e1b53c
112 changed files with 20893 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors.
// SPDX-License-Identifier: mit
#include "threads.h"
#include <stdlib.h>
DWORD pthread_self(void) { return GetCurrentThreadId(); }
int pthread_mutex_init(pthread_mutex_t *mutex, void *attr) {
if (!mutex) {
return 1;
}
InitializeSRWLock(mutex);
return 0;
}
int pthread_mutex_lock(pthread_mutex_t *mutex) {
if (!mutex) {
return 1;
}
AcquireSRWLockExclusive(mutex);
return 0;
}
int pthread_mutex_unlock(pthread_mutex_t *mutex) {
if (!mutex) {
return 1;
}
ReleaseSRWLockExclusive(mutex);
return 0;
}
int pthread_mutex_destroy(pthread_mutex_t *mutex) {
/* SRW's do not require destruction. */
return 0;
}

View File

@@ -0,0 +1,29 @@
// Copyright 2007 - 2021, Alan Antonuk and the rabbitmq-c contributors.
// SPDX-License-Identifier: mit
#ifndef AMQP_THREAD_H
#define AMQP_THREAD_H
#if !defined(WINVER) || defined(__MINGW32__) || defined(__MINGW64__)
#ifdef WINVER
#undef WINVER
#endif
/* Windows Vista or newer */
#define WINVER 0x0600
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
typedef SRWLOCK pthread_mutex_t;
#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT;
DWORD pthread_self(void);
int pthread_mutex_init(pthread_mutex_t *, void *attr);
int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);
int pthread_mutex_destroy(pthread_mutex_t *);
#endif /* AMQP_THREAD_H */