mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-23 02:50:29 +00:00
Introduce #include <cosmo.h>
to toolchain users
This change improves the way internal APIs are being hidden behind the `COSMO` define. The cosmo.h header will take care of defining that, so that a separate define statement isn't needed. This change also does a lot more to define which APIs are standard, and which belong to Cosmo.
This commit is contained in:
parent
9b55dbe417
commit
4a59210008
115 changed files with 699 additions and 422 deletions
|
@ -27,7 +27,7 @@
|
|||
errno_t pthread_attr_init(pthread_attr_t *attr) {
|
||||
*attr = (pthread_attr_t){
|
||||
.__stacksize = GetStackSize(),
|
||||
.__guardsize = GUARDSIZE,
|
||||
.__guardsize = APE_GUARDSIZE,
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -174,12 +174,12 @@ static errno_t pthread_create_impl(pthread_t *thread,
|
|||
pt->flags = PT_OWNSTACK;
|
||||
pt->attr.__stacksize = MAX(pt->attr.__stacksize, GetStackSize());
|
||||
pt->attr.__stacksize = _roundup2pow(pt->attr.__stacksize);
|
||||
pt->attr.__guardsize = ROUNDUP(pt->attr.__guardsize, GUARDSIZE);
|
||||
if (pt->attr.__guardsize + GUARDSIZE >= pt->attr.__stacksize) {
|
||||
pt->attr.__guardsize = ROUNDUP(pt->attr.__guardsize, APE_GUARDSIZE);
|
||||
if (pt->attr.__guardsize + APE_GUARDSIZE >= pt->attr.__stacksize) {
|
||||
_pthread_free(pt);
|
||||
return EINVAL;
|
||||
}
|
||||
if (pt->attr.__guardsize == GUARDSIZE) {
|
||||
if (pt->attr.__guardsize == APE_GUARDSIZE) {
|
||||
// user is wisely using smaller stacks with default guard size
|
||||
pt->attr.__stackaddr =
|
||||
mmap(0, pt->attr.__stacksize, PROT_READ | PROT_WRITE,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define COSMOPOLITAN_LIBC_THREAD_THREAD_H_
|
||||
|
||||
#define PTHREAD_KEYS_MAX 128
|
||||
#define PTHREAD_STACK_MIN FRAMESIZE
|
||||
#define PTHREAD_STACK_MIN 65536
|
||||
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
|
||||
|
||||
#define PTHREAD_BARRIER_SERIAL_THREAD 31337
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue