Differences From Artifact [4bb0d2efdf]:
- File
src/thread_pthread.m
— part of check-in
[5358e9ea6a]
at
2019-08-01 20:14:35
on branch trunk
— Split threading.[hm] into multiple files
This allows the runtime to only link against the parts it needs, without
pulling in unnecessary parts like thread spawning, TLS and conditions. (user: js, size: 3986) [annotate] [blame] [check-ins using]
To Artifact [e8b813b448]:
- File src/thread_pthread.m — part of check-in [d7fd999fee] at 2019-09-01 12:50:08 on branch trunk — {condition,mutex,thread}.m: Set errno on error (user: js, size: 3960) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #ifdef HAVE_PTHREAD_NP_H # include <pthread_np.h> #endif #ifdef OF_HAIKU # include <kernel/OS.h> | > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include <errno.h> #ifdef HAVE_PTHREAD_NP_H # include <pthread_np.h> #endif #ifdef OF_HAIKU # include <kernel/OS.h> |
︙ | ︙ | |||
110 111 112 113 114 115 116 | @try { struct thread_ctx *ctx; if (attr != NULL) { struct sched_param param; | | > > | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | @try { struct thread_ctx *ctx; if (attr != NULL) { struct sched_param param; if (attr->priority < -1 || attr->priority > 1) { errno = EINVAL; return false; } #ifdef HAVE_PTHREAD_ATTR_SETINHERITSCHED if (pthread_attr_setinheritsched(&pattr, PTHREAD_EXPLICIT_SCHED) != 0) return false; #endif |
︙ | ︙ | |||
137 138 139 140 141 142 143 | if (attr->stackSize > 0) { if (pthread_attr_setstacksize(&pattr, attr->stackSize) != 0) return false; } } | | > > | < < < < < < < | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | if (attr->stackSize > 0) { if (pthread_attr_setstacksize(&pattr, attr->stackSize) != 0) return false; } } if ((ctx = malloc(sizeof(*ctx))) == NULL) { errno = ENOMEM; return false; } ctx->function = function; ctx->object = object; ret = (pthread_create(thread, &pattr, functionWrapper, ctx) == 0); } @finally { pthread_attr_destroy(&pattr); } return ret; } bool of_thread_join(of_thread_t thread) { void *ret; return (pthread_join(thread, &ret) == 0); } bool of_thread_detach(of_thread_t thread) { return (pthread_detach(thread) == 0); } |
︙ | ︙ |