mailing list of musl libc
 help / color / mirror / code / Atom feed
9c14fa0b900956be9441425c58b045650f0682ea blob 1087 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
#include <futex.h>
#include <stdarg.h>
#include <errno.h>
#include "syscall.h"

// Wasm doesn't *yet* have futex(), but it's being planned as part of the
// threaded-Wasm support in Spring 2018.
//
// For now, Wasm is single-threaded and we simply assert that the lock is not
// held, and abort if a wait would be required (assume it's a corrupted lock).

long __syscall_futex(long arg1, ...)
{
  va_list va;
  va_start(va, arg1);

  volatile int* addr = (volatile int*)arg1;
  long op = va_arg(va, long);

  op &= ~FUTEX_PRIVATE;

  if (op == FUTEX_WAIT) {
    int val = (int)va_arg(va, long);
    // arg4 would be the timeout as a timespec*
    va_end(va);

    if (*addr == val) {
      // trap, Wasm can't block
      // TODO use a WebAssembly futex builtin, when those arrive!
      __builtin_unreachable();
    }
    return 0;
  }
  if (op == FUTEX_WAKE) {
    // arg3 would be the number of waiters to wake as an int
    va_end(va);

    // Wasm can't block/wait
    // TODO use a WebAssembly futex builtin, when those arrive!
    return 0;
  }

  va_end(va);
  return -ENOSYS;
}
debug log:

solving 9c14fa0b ...
found 9c14fa0b in https://inbox.vuxu.org/musl/VI1PR0502MB38851CB41BB1DA99B673004EE73A0@VI1PR0502MB3885.eurprd05.prod.outlook.com/

applying [1/1] https://inbox.vuxu.org/musl/VI1PR0502MB38851CB41BB1DA99B673004EE73A0@VI1PR0502MB3885.eurprd05.prod.outlook.com/
diff --git a/src/internal/wasm/syscall_futex.c b/src/internal/wasm/syscall_futex.c
new file mode 100644
index 00000000..9c14fa0b

Checking patch src/internal/wasm/syscall_futex.c...
Applied patch src/internal/wasm/syscall_futex.c cleanly.

index at:
100644 9c14fa0b900956be9441425c58b045650f0682ea	src/internal/wasm/syscall_futex.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).