Introduce cosmo_futex_wait and cosmo_futex_wake

Cosmopolitan Futexes are now exposed as a public API.
This commit is contained in:
Justine Tunney 2024-11-22 11:08:29 -08:00
parent 729f7045e3
commit 9ddbfd921e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
66 changed files with 886 additions and 917 deletions

View file

@ -109,8 +109,9 @@
#include "third_party/lua/lgc.h"
#include "third_party/lua/lua.h"
#include "third_party/lua/luaconf.h"
#include "third_party/nsync/futex.internal.h"
#include "libc/sysv/consts/clock.h"
#include "libc/cosmo.h"
#include "libc/cosmo.h"
#include "tool/net/luacheck.h"
#define DNS_NAME_MAX 253
@ -2855,7 +2856,7 @@ static int LuaUnixMemoryWait(lua_State *L) {
deadline = &ts;
}
BEGIN_CANCELATION_POINT;
rc = nsync_futex_wait_((atomic_int *)GetWord(L), expect,
rc = cosmo_futex_wait((atomic_int *)GetWord(L), expect,
PTHREAD_PROCESS_SHARED, CLOCK_REALTIME, deadline);
END_CANCELATION_POINT;
if (rc < 0) errno = -rc, rc = -1;
@ -2867,7 +2868,7 @@ static int LuaUnixMemoryWait(lua_State *L) {
static int LuaUnixMemoryWake(lua_State *L) {
int count, woken;
count = luaL_optinteger(L, 3, INT_MAX);
woken = nsync_futex_wake_((atomic_int *)GetWord(L), count,
woken = cosmo_futex_wake((atomic_int *)GetWord(L), count,
PTHREAD_PROCESS_SHARED);
npassert(woken >= 0);
return ReturnInteger(L, woken);