[Partial] Build wasi-libc for Windows (#2338)

Build wasi-libc library on Windows since libuv may be not supported. This PR is a first step
to make it working, but there's still a number of changes to get it fully working.
This commit is contained in:
Marcin Kolny
2023-07-13 14:02:29 +01:00
committed by GitHub
parent 81f0371f63
commit 662e38e9b0
19 changed files with 428 additions and 139 deletions

View File

@ -57,6 +57,11 @@ typedef void *korp_tid;
typedef void *korp_mutex;
typedef void *korp_sem;
typedef struct {
SRWLOCK lock;
bool exclusive;
} korp_rwlock;
/**
* Create the mutex when os_mutex_lock is called, and no need to
* CloseHandle() for the static lock's lifetime, since

View File

@ -206,6 +206,14 @@ os_socket_inet_network(bool is_ipv4, const char *cp, bh_ip_addr_buffer_t *out)
return BHT_OK;
}
int
os_socket_connect(bh_socket_t socket, const char *addr, int port)
{
errno = ENOSYS;
return BHT_ERROR;
}
int
os_socket_addr_resolve(const char *host, const char *service,
uint8_t *hint_is_tcp, uint8_t *hint_is_ipv4,

View File

@ -541,6 +541,62 @@ os_mutex_unlock(korp_mutex *mutex)
return ReleaseMutex(*mutex) ? BHT_OK : BHT_ERROR;
}
int
os_rwlock_init(korp_rwlock *lock)
{
bh_assert(lock);
InitializeSRWLock(&(lock->lock));
lock->exclusive = false;
return BHT_OK;
}
int
os_rwlock_rdlock(korp_rwlock *lock)
{
bh_assert(lock);
AcquireSRWLockShared(&(lock->lock));
return BHT_OK;
}
int
os_rwlock_wrlock(korp_rwlock *lock)
{
bh_assert(lock);
AcquireSRWLockExclusive(&(lock->lock));
lock->exclusive = true;
return BHT_OK;
}
int
os_rwlock_unlock(korp_rwlock *lock)
{
bh_assert(lock);
if (lock->exclusive) {
lock->exclusive = false;
ReleaseSRWLockExclusive(&(lock->lock));
}
else {
ReleaseSRWLockShared(&(lock->lock));
}
return BHT_OK;
}
int
os_rwlock_destroy(korp_rwlock *lock)
{
(void)lock;
return BHT_OK;
}
int
os_cond_init(korp_cond *cond)
{