diff options
| author | Robert Mustacchi <rm@joyent.com> | 2018-09-11 21:21:18 +0000 |
|---|---|---|
| committer | Robert Mustacchi <rm@joyent.com> | 2018-09-11 21:32:22 +0000 |
| commit | a1c95bbb7c9625aab345559b448cd77dad78b4b3 (patch) | |
| tree | ef63dc1c09fee5444552280179b6660c7b8fee80 /usr/src/lib/libc/port/threads | |
| parent | 6816448c8b777064c5a9cf6729bcfa0efeb29e4f (diff) | |
| download | illumos-joyent-a1c95bbb7c9625aab345559b448cd77dad78b4b3.tar.gz | |
backout OS-7200 would like thread name API (triggers OS-7240)
Reviewed by: John Levon <john.levon@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/lib/libc/port/threads')
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthr_attr.c | 61 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/pthread.c | 4 | ||||
| -rw-r--r-- | usr/src/lib/libc/port/threads/thr.c | 88 |
3 files changed, 10 insertions, 143 deletions
diff --git a/usr/src/lib/libc/port/threads/pthr_attr.c b/usr/src/lib/libc/port/threads/pthr_attr.c index 7cfc970120..b04bcdba7c 100644 --- a/usr/src/lib/libc/port/threads/pthr_attr.c +++ b/usr/src/lib/libc/port/threads/pthr_attr.c @@ -25,13 +25,11 @@ */ /* - * Copyright 2018, Joyent, Inc. + * Copyright 2015, Joyent, Inc. */ #include "lint.h" #include "thr_uberdata.h" -#include <sys/ctype.h> -#include <strings.h> #include <sched.h> /* @@ -50,8 +48,7 @@ def_thrattr(void) 0, /* prio */ SCHED_OTHER, /* policy */ PTHREAD_INHERIT_SCHED, /* inherit */ - 0, /* guardsize */ - { 0 } /* name */ + 0 /* guardsize */ }; if (thrattr.guardsize == 0) thrattr.guardsize = _sysconf(_SC_PAGESIZE); @@ -98,7 +95,7 @@ pthread_attr_clone(pthread_attr_t *attr, const pthread_attr_t *old_attr) { thrattr_t *ap; const thrattr_t *old_ap = - old_attr ? old_attr->__pthread_attrp : def_thrattr(); + old_attr? old_attr->__pthread_attrp : def_thrattr(); if (old_ap == NULL) return (EINVAL); @@ -117,8 +114,8 @@ pthread_attr_clone(pthread_attr_t *attr, const pthread_attr_t *old_attr) int pthread_attr_equal(const pthread_attr_t *attr1, const pthread_attr_t *attr2) { - const thrattr_t *ap1 = attr1 ? attr1->__pthread_attrp : def_thrattr(); - const thrattr_t *ap2 = attr2 ? attr2->__pthread_attrp : def_thrattr(); + const thrattr_t *ap1 = attr1? attr1->__pthread_attrp : def_thrattr(); + const thrattr_t *ap2 = attr2? attr2->__pthread_attrp : def_thrattr(); if (ap1 == NULL || ap2 == NULL) return (0); @@ -479,53 +476,6 @@ pthread_attr_getstack(const pthread_attr_t *attr, return (EINVAL); } -int -pthread_attr_setname_np(pthread_attr_t *attr, const char *name) -{ - thrattr_t *ap; - - if (attr == NULL || (ap = attr->__pthread_attrp) == NULL) - return (EINVAL); - - if (name == NULL) { - bzero(ap->name, sizeof (ap->name)); - return (0); - } - - if (strlen(name) >= sizeof (ap->name)) - return (ERANGE); - - /* - * We really want the ASCII version of isprint() here... - */ - for (size_t i = 0; name[i] != '\0'; i++) { - if (!ISPRINT(name[i])) - return (EINVAL); - } - - /* - * not having garbage after the end of the string simplifies attr - * comparison - */ - bzero(ap->name, sizeof (ap->name)); - (void) strlcpy(ap->name, name, sizeof (ap->name)); - return (0); -} - -int -pthread_attr_getname_np(pthread_attr_t *attr, char *buf, size_t len) -{ - thrattr_t *ap; - - if (buf == NULL || attr == NULL || - (ap = attr->__pthread_attrp) == NULL) - return (EINVAL); - - if (strlcpy(buf, ap->name, len) > len) - return (ERANGE); - return (0); -} - /* * This function is a common BSD extension to pthread which is used to obtain * the attributes of a thread that might have changed after its creation, for @@ -601,7 +551,6 @@ pthread_attr_get_np(pthread_t tid, pthread_attr_t *attr) ap->policy = target->ul_policy; ap->inherit = target->ul_ptinherit; ap->guardsize = target->ul_guardsize; - (void) pthread_getname_np(tid, ap->name, sizeof (ap->name)); ret = 0; out: diff --git a/usr/src/lib/libc/port/threads/pthread.c b/usr/src/lib/libc/port/threads/pthread.c index 34b4b4c73c..6a22995639 100644 --- a/usr/src/lib/libc/port/threads/pthread.c +++ b/usr/src/lib/libc/port/threads/pthread.c @@ -24,7 +24,7 @@ * Use is subject to license terms. */ /* - * Copyright 2018 Joyent, Inc. + * Copyright 2016 Joyent, Inc. */ #include "lint.h" @@ -128,7 +128,7 @@ pthread_create(pthread_t *thread, const pthread_attr_t *attr, flag = ap->scope | ap->detachstate | ap->daemonstate | THR_SUSPENDED; error = _thrp_create(ap->stkaddr, ap->stksize, start_routine, arg, - flag, &tid, ap->guardsize, ap->name); + flag, &tid, ap->guardsize); if (error == 0) { /* * Record the original inheritence value for diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c index 69c5f24981..b6580b3e3a 100644 --- a/usr/src/lib/libc/port/threads/thr.c +++ b/usr/src/lib/libc/port/threads/thr.c @@ -25,7 +25,7 @@ * Copyright (c) 2017 by The MathWorks, Inc. All rights reserved. */ /* - * Copyright 2018 Joyent, Inc. + * Copyright 2016 Joyent, Inc. */ #include "lint.h" @@ -562,7 +562,7 @@ find_lwp(thread_t tid) int _thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, - long flags, thread_t *new_thread, size_t guardsize, const char *name) + long flags, thread_t *new_thread, size_t guardsize) { ulwp_t *self = curthread; uberdata_t *udp = self->ul_uberdata; @@ -717,9 +717,6 @@ _thrp_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, exit_critical(self); - if (name != NULL) - (void) pthread_setname_np(tid, name); - if (!(flags & THR_SUSPENDED)) (void) _thrp_continue(tid, TSTP_REGULAR); @@ -730,8 +727,7 @@ int thr_create(void *stk, size_t stksize, void *(*func)(void *), void *arg, long flags, thread_t *new_thread) { - return (_thrp_create(stk, stksize, func, arg, flags, new_thread, 0, - NULL)); + return (_thrp_create(stk, stksize, func, arg, flags, new_thread, 0)); } /* @@ -2411,84 +2407,6 @@ __nthreads(void) return (curthread->ul_uberdata->nthreads); } -#pragma weak pthread_setname_np = thr_setname -int -thr_setname(pthread_t tid, const char *name) -{ - extern ssize_t __write(int, const void *, size_t); - char path[PATH_MAX]; - int saved_errno; - size_t len; - ssize_t n; - int fd; - - if (name == NULL) - name = ""; - - len = strlen(name) + 1; - if (len > THREAD_NAME_MAX) - return (ERANGE); - - /* "/proc/self/lwp/%u/lwpname" w/o stdio */ - (void) strlcpy(path, "/proc/self/lwp/", sizeof (path)); - ultos((uint64_t)tid, 10, path + strlen(path)); - (void) strlcat(path, "/lwpname", sizeof (path)); - - if ((fd = __open(path, O_WRONLY, 0)) < 0) { - if (errno == ENOENT) - errno = ESRCH; - return (errno); - } - - n = __write(fd, name, len); - saved_errno = errno; - (void) __close(fd); - - if (n < 0) - return (saved_errno); - if (n != len) - return (EFAULT); - return (0); -} - -#pragma weak pthread_getname_np = thr_getname -int -thr_getname(pthread_t tid, char *buf, size_t bufsize) -{ - extern ssize_t __read(int, void *, size_t); - char name[THREAD_NAME_MAX]; - char path[PATH_MAX]; - int saved_errno; - ssize_t n; - int fd; - - if (buf == NULL) - return (EINVAL); - - /* "/proc/self/lwp/%u/name" w/o stdio */ - (void) strlcpy(path, "/proc/self/lwp/", sizeof (path)); - ultos((uint64_t)tid, 10, path + strlen(path)); - (void) strlcat(path, "/lwpname", sizeof (path)); - - if ((fd = __open(path, O_RDONLY, 0)) < 0) { - if (errno == ENOENT) - errno = ESRCH; - return (errno); - } - - n = __read(fd, name, sizeof (name)); - saved_errno = errno; - (void) __close(fd); - - if (n < 0) - return (saved_errno); - if (n != sizeof (name)) - return (EFAULT); - if (strlcpy(buf, name, bufsize) >= bufsize) - return (ERANGE); - return (0); -} - /* * XXX * The remainder of this file implements the private interfaces to java for |
