mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 07:29:23 +00:00
Add more sched.h content
This commit is contained in:
parent
f7cfe03888
commit
545a8f4cb0
3 changed files with 24 additions and 1 deletions
|
@ -24,6 +24,20 @@ void CPU_AND(cpu_set_t *, cpu_set_t *, cpu_set_t *);
|
|||
void CPU_OR(cpu_set_t *, cpu_set_t *, cpu_set_t *);
|
||||
void CPU_XOR(cpu_set_t *, cpu_set_t *, cpu_set_t *);
|
||||
|
||||
#define CPU_ALLOC_SIZE(n) \
|
||||
((((n) + (8 * sizeof(long) - 1)) & -(8 * sizeof(long))) / sizeof(long))
|
||||
#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1, CPU_ALLOC_SIZE(n)))
|
||||
#define CPU_FREE(set) free(set)
|
||||
#define CPU_ZERO_S(size, set) memset(set, 0, size)
|
||||
#define CPU_EQUAL_S(size, set1, set2) (!memcmp(set1, set2, size))
|
||||
#define _CPU_S(i, size, set, op) \
|
||||
((i) / 8U >= (size) ? 0 \
|
||||
: (((unsigned long *)(set))[(i) / 8 / sizeof(long)] op( \
|
||||
1UL << ((i) % (8 * sizeof(long))))))
|
||||
#define CPU_SET_S(i, size, set) _CPU_S(i, size, set, |=)
|
||||
#define CPU_CLR_S(i, size, set) _CPU_S(i, size, set, &= ~)
|
||||
#define CPU_ISSET_S(i, size, set) _CPU_S(i, size, set, &)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_CPUSET_H_ */
|
||||
|
|
|
@ -632,7 +632,9 @@ static dontinline bool foreign_compile(char exe[hasatleast PATH_MAX]) {
|
|||
return false;
|
||||
}
|
||||
int pid, ws;
|
||||
char *args[] = {"cc", "-pie", "-fPIC", src, "-o", tmp, 0};
|
||||
char *args[] = {
|
||||
"cc", "-pie", "-fPIC", src, "-o", tmp, IsNetbsd() ? 0 : "-ldl", 0,
|
||||
};
|
||||
errno_t err = posix_spawnp(&pid, args[0], NULL, NULL, args, environ);
|
||||
if (err) {
|
||||
unlink(tmp);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "libc/nt/enum/threadaccess.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/thread.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/thread/posixthread.internal.h"
|
||||
|
||||
|
@ -51,8 +52,14 @@ static dontinline textwindows int sys_pthread_setaffinity_nt(
|
|||
errno_t pthread_setaffinity_np(pthread_t thread, size_t size,
|
||||
const cpu_set_t *bitset) {
|
||||
int e, rc, tid;
|
||||
cpu_set_t bs = {0};
|
||||
struct PosixThread *pt;
|
||||
e = errno;
|
||||
if (size < sizeof(cpu_set_t)) {
|
||||
memcpy(&bs, bitset, size);
|
||||
bitset = &bs;
|
||||
size = sizeof(cpu_set_t);
|
||||
}
|
||||
pt = (struct PosixThread *)thread;
|
||||
tid = _pthread_tid(pt);
|
||||
if (size != sizeof(cpu_set_t)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue