--- pth_lib.c 2002/10/24 14:01:37 1.52
+++ pth_lib.c 2002/10/24 15:21:13 1.53
@@ -63,7 +63,7 @@
/* support for implicit initialization calls
and to prevent multiple explict initialization, too */
if (pth_initialized)
- return_errno(FALSE, EPERM);
+ return pth_error(FALSE, EPERM);
else
pth_initialized = TRUE;
@@ -91,7 +91,7 @@
pth_attr_set(t_attr, PTH_ATTR_STACK_ADDR, NULL);
pth_sched = pth_spawn(t_attr, pth_scheduler, NULL);
if (pth_sched == NULL) {
- errno_shield {
+ pth_shield {
pth_attr_destroy(t_attr);
pth_scheduler_kill();
}
@@ -107,7 +107,7 @@
pth_attr_set(t_attr, PTH_ATTR_STACK_ADDR, NULL);
pth_main = pth_spawn(t_attr, (void *(*)(void *))(-1), NULL);
if (pth_main == NULL) {
- errno_shield {
+ pth_shield {
pth_attr_destroy(t_attr);
pth_scheduler_kill();
}
@@ -134,7 +134,7 @@
int pth_kill(void)
{
if (pth_current != pth_main)
- return_errno(FALSE, EPERM);
+ return pth_error(FALSE, EPERM);
pth_debug1("pth_kill: enter");
pth_thread_cleanup(pth_main);
pth_scheduler_kill();
@@ -192,7 +192,7 @@
rc = -1;
va_end(ap);
if (rc == -1)
- return_errno(-1, EINVAL);
+ return pth_error(-1, EINVAL);
return rc;
}
@@ -221,7 +221,7 @@
/* consistency */
if (func == NULL)
- return_errno(NULL, EINVAL);
+ return pth_error((pth_t)NULL, EINVAL);
/* support the special case of main() */
if (func == (void *(*)(void *))(-1))
@@ -231,7 +231,7 @@
stacksize = (attr == PTH_ATTR_DEFAULT ? 64*1024 : attr->a_stacksize);
stackaddr = (attr == PTH_ATTR_DEFAULT ? NULL : attr->a_stackaddr);
if ((t = pth_tcb_alloc(stacksize, stackaddr)) == NULL)
- return NULL;
+ return pth_error((pth_t)NULL, errno);
/* configure remaining attributes */
if (attr != PTH_ATTR_DEFAULT) {
@@ -299,8 +299,8 @@
if (t->stacksize > 0) { /* the "main thread" (indicated by == 0) is special! */
if (!pth_mctx_set(&t->mctx, pth_spawn_trampoline,
t->stack, ((char *)t->stack+t->stacksize))) {
- errno_shield { pth_tcb_free(t); }
- return NULL;
+ pth_shield { pth_tcb_free(t); }
+ return pth_error((pth_t)NULL, errno);
}
}
@@ -330,7 +330,7 @@
struct sigaction sa;
if (t == NULL || t == pth_current || (sig < 0 || sig > PTH_NSIG))
- return_errno(FALSE, EINVAL);
+ return pth_error(FALSE, EINVAL);
if (sig == 0)
/* just test whether thread exists */
return pth_thread_exists(t);
@@ -357,7 +357,7 @@
if (!pth_pqueue_contains(&pth_WQ, t))
if (!pth_pqueue_contains(&pth_SQ, t))
if (!pth_pqueue_contains(&pth_DQ, t))
- return_errno(FALSE, ESRCH); /* not found */
+ return pth_error(FALSE, ESRCH); /* not found */
return TRUE;
}
@@ -458,11 +458,11 @@
pth_debug2("pth_join: joining thread \"%s\"", tid == NULL ? "-ANY-" : tid->name);
if (tid == pth_current)
- return_errno(FALSE, EDEADLK);
+ return pth_error(FALSE, EDEADLK);
if (tid != NULL && !tid->joinable)
- return_errno(FALSE, EINVAL);
+ return pth_error(FALSE, EINVAL);
if (pth_ctrl(PTH_CTRL_GETTHREADS) == 1)
- return_errno(FALSE, EDEADLK);
+ return pth_error(FALSE, EDEADLK);
if (tid == NULL)
tid = pth_pqueue_head(&pth_DQ);
if (tid == NULL || (tid != NULL && tid->state != PTH_STATE_DEAD)) {
@@ -472,7 +472,7 @@
if (tid == NULL)
tid = pth_pqueue_head(&pth_DQ);
if (tid == NULL || (tid != NULL && tid->state != PTH_STATE_DEAD))
- return_errno(FALSE, EIO);
+ return pth_error(FALSE, EIO);
if (value != NULL)
*value = tid->join_arg;
pth_pqueue_delete(&pth_DQ, tid);
@@ -495,7 +495,7 @@
default: q = NULL;
}
if (q == NULL || !pth_pqueue_contains(q, to))
- return_errno(FALSE, EINVAL);
+ return pth_error(FALSE, EINVAL);
}
/* give a favored thread maximum priority in his queue */
@@ -521,9 +521,9 @@
pth_pqueue_t *q;
if (t == NULL)
- return_errno(FALSE, EINVAL);
+ return pth_error(FALSE, EINVAL);
if (t == pth_sched || t == pth_current)
- return_errno(FALSE, EPERM);
+ return pth_error(FALSE, EPERM);
switch (t->state) {
case PTH_STATE_NEW: q = &pth_NQ; break;
case PTH_STATE_READY: q = &pth_RQ; break;
@@ -531,9 +531,9 @@
default: q = NULL;
}
if (q == NULL)
- return_errno(FALSE, EPERM);
+ return pth_error(FALSE, EPERM);
if (!pth_pqueue_contains(q, t))
- return_errno(FALSE, ESRCH);
+ return pth_error(FALSE, ESRCH);
pth_pqueue_delete(q, t);
pth_pqueue_insert(&pth_SQ, PTH_PRIO_STD, t);
pth_debug2("pth_suspend: suspend thread \"%s\"\n", t->name);
@@ -546,11 +546,11 @@
pth_pqueue_t *q;
if (t == NULL)
- return_errno(FALSE, EINVAL);
+ return pth_error(FALSE, EINVAL);
if (t == pth_sched || t == pth_current)
- return_errno(FALSE, EPERM);
+ return pth_error(FALSE, EPERM);
if (!pth_pqueue_contains(&pth_SQ, t))
- return_errno(FALSE, EPERM);
+ return pth_error(FALSE, EPERM);
pth_pqueue_delete(&pth_SQ, t);
switch (t->state) {
case PTH_STATE_NEW: q = &pth_NQ; break;
@@ -569,7 +569,7 @@
int fdmode;
int oldmode;
- /* retrieve old mode (usually cheap) */
+ /* retrieve old mode (usually a very cheap operation) */
if ((fdmode = fcntl(fd, F_GETFL, NULL)) == -1)
oldmode = PTH_FDMODE_ERROR;
else if (fdmode & O_NONBLOCKING)
@@ -577,7 +577,7 @@
else
oldmode = PTH_FDMODE_BLOCK;
- /* set new mode (usually expensive) */
+ /* set new mode (usually a more expensive operation) */
if (oldmode == PTH_FDMODE_BLOCK && newmode == PTH_FDMODE_NONBLOCK)
fcntl(fd, F_SETFL, (fdmode | O_NONBLOCKING));
if (oldmode == PTH_FDMODE_NONBLOCK && newmode == PTH_FDMODE_BLOCK)
@@ -595,7 +595,7 @@
static pth_key_t ev_key = PTH_KEY_INIT;
if (pth_time_cmp(&naptime, PTH_TIME_ZERO) == 0)
- return_errno(FALSE, EINVAL);
+ return pth_error(FALSE, EINVAL);
pth_time_set(&until, PTH_TIME_NOW);
pth_time_add(&until, &naptime);
ev = pth_event(PTH_EVENT_TIME|PTH_MODE_STATIC, &ev_key, until);
@@ -607,7 +607,7 @@
int pth_once(pth_once_t *oncectrl, void (*constructor)(void *), void *arg)
{
if (oncectrl == NULL || constructor == NULL)
- return_errno(FALSE, EINVAL);
+ return pth_error(FALSE, EINVAL);
if (*oncectrl != TRUE)
constructor(arg);
*oncectrl = TRUE;
|