GNU/Linux: Add/fix comments.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2021-02-10 09:05:16 +09:00
parent 88909bab49
commit bd8f39f3c9

View File

@@ -27,6 +27,16 @@
* *
*/ */
/*
* NOTE: This code is not portable. It's intended for GNU/Linux.
*
* This implementation depends on the feature of SA_SIGINFO of Linux,
* which signal handler takes three arguments. Also, it depends on
* GNU C library for how to use the makecontext function on 64-bit
* machine.
*
*/
#include <unistd.h> #include <unistd.h>
#include <ucontext.h> #include <ucontext.h>
#include <signal.h> #include <signal.h>
@@ -314,18 +324,15 @@ chopstx_create_arch (uintptr_t stack_addr, size_t stack_size,
tp->tc.uc_link = NULL; tp->tc.uc_link = NULL;
/* /*
* makecontext is hard to use, actually. * makecontext is hard to use in a portable way, actually.
*
* On 32-bit machine, it is not accurate to specify ARGC = 4, because
* it's actually two, but it works.
* *
* On 64-bit machine, according to the standard, it should be coded * On 64-bit machine, according to the standard, it should be coded
* to specify (int == 32-bit) arguments that follow ARGC, so it is * to specify int (== 32-bit for LP64 machine) arguments that follow
* incorrect to specify ARGC=4 and two 64-bit arguments, but it * ARGC, so it is not that correct to specify two 64-bit arguments
* works (on x86-64). * here. However, GNU C library allows this.
*/ */
makecontext (&tp->tc, (void (*)(void))chx_thread_start, makecontext (&tp->tc, (void (*)(void))chx_thread_start,
4, thread_entry, arg); 2, thread_entry, arg);
chx_cpu_sched_unlock (); chx_cpu_sched_unlock ();
return tp; return tp;
} }