-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Memory64] pthread libc changes for 64-bit #15229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,13 +83,18 @@ typedef long suseconds_t; | |
|
||
|
||
#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) | ||
typedef struct { | ||
union { | ||
int __i[10]; | ||
volatile int __vi[10]; | ||
unsigned __s[10]; | ||
} __u; | ||
#ifdef __EMSCRIPTEN__ | ||
// For canvas transfer implementation in Emscripten, use an extra 11th control field | ||
// to pass a pointer to a string denoting the WebGL canvases to transfer. | ||
typedef struct { union { int __i[11]; volatile int __vi[11]; unsigned __s[11]; } __u; } pthread_attr_t; | ||
#else | ||
typedef struct { union { int __i[10]; volatile int __vi[10]; unsigned __s[10]; } __u; } pthread_attr_t; | ||
// For canvas transfer implementation in Emscripten, use an extra control field | ||
// to pass a pointer to a string denoting the WebGL canvases to transfer. | ||
const char *_a_transferredcanvases; | ||
#endif | ||
} pthread_attr_t; | ||
#define __DEFINED_pthread_attr_t | ||
#endif | ||
|
||
|
@@ -114,7 +119,7 @@ typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __ | |
#endif | ||
|
||
#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) | ||
typedef struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; | ||
typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the new constants 14 and 7? I can't see how doubling a pointer size leads to such things, so I'm missing something... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, this is from upstream: https://git.musl-libc.org/cgit/musl/tree/include/alltypes.h.in |
||
#define __DEFINED_pthread_rwlock_t | ||
#endif | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,18 +33,15 @@ | |
#include <emscripten.h> | ||
#include <emscripten/threading.h> | ||
|
||
// Extra pthread_attr_t field: | ||
#define _a_transferredcanvases __u.__s[9] | ||
|
||
void __pthread_testcancel(); | ||
|
||
int emscripten_pthread_attr_gettransferredcanvases(const pthread_attr_t* a, const char** str) { | ||
*str = (const char*)a->_a_transferredcanvases; | ||
*str = a->_a_transferredcanvases; | ||
return 0; | ||
} | ||
|
||
int emscripten_pthread_attr_settransferredcanvases(pthread_attr_t* a, const char* str) { | ||
a->_a_transferredcanvases = (int)str; | ||
a->_a_transferredcanvases = str; | ||
return 0; | ||
} | ||
|
||
|
@@ -163,7 +160,7 @@ static void _do_call(em_queued_call* q) { | |
break; | ||
case EM_PROXIED_JS_FUNCTION: | ||
q->returnValue.d = | ||
emscripten_receive_on_main_thread_js((int)q->functionPtr, q->args[0].i, &q->args[1].d); | ||
emscripten_receive_on_main_thread_js((int)(size_t)q->functionPtr, q->args[0].i, &q->args[1].d); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On 64-bit, |
||
break; | ||
case EM_FUNC_SIG_V: | ||
((em_func_v)q->functionPtr)(); | ||
|
@@ -654,7 +651,8 @@ double emscripten_run_in_main_runtime_thread_js(int index, int num_args, int64_t | |
} | ||
c->calleeDelete = 1-sync; | ||
c->functionEnum = EM_PROXIED_JS_FUNCTION; | ||
c->functionPtr = (void*)index; | ||
// Index not needed to ever be more than 32-bit. | ||
c->functionPtr = (void*)(size_t)index; | ||
assert(num_args+1 <= EM_QUEUED_JS_CALL_MAX_ARGS); | ||
// The types are only known at runtime in these calls, so we store values that | ||
// must be able to contain any valid JS value, including a 64-bit BigInt if | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the 11 change to 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 11 field is the pointer below.