Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/common.din2
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/include/pthread.h2
-rw-r--r--winsup/cygwin/release/2.6.01
-rw-r--r--winsup/cygwin/thread.cc65
-rw-r--r--winsup/cygwin/thread.h1
-rw-r--r--winsup/doc/new-features.xml4
-rw-r--r--winsup/doc/posix.xml2
8 files changed, 78 insertions, 2 deletions
diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din
index d54b70abb..8f7a282f4 100644
--- a/winsup/cygwin/common.din
+++ b/winsup/cygwin/common.din
@@ -1046,6 +1046,7 @@ pthread_exit SIGFE
pthread_getattr_np SIGFE
pthread_getconcurrency SIGFE
pthread_getcpuclockid SIGFE
+pthread_getname_np SIGFE
pthread_getschedparam SIGFE
pthread_getsequence_np SIGFE
pthread_getspecific SIGFE
@@ -1086,6 +1087,7 @@ pthread_self SIGFE
pthread_setcancelstate SIGFE
pthread_setcanceltype SIGFE
pthread_setconcurrency SIGFE
+pthread_setname_np SIGFE
pthread_setschedparam SIGFE
pthread_setschedprio SIGFE
pthread_setspecific SIGFE
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 2782c32b3..a1b8a6219 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -467,12 +467,13 @@ details. */
strtoull_l, wcstod_l, wcstof_l, wcstol_l, wcstold_l, wcstoll_l,
wcstoul_l, wcstoull_l.
302: Export nl_langinfo_l.
+ 303: Export pthread_getname_np, pthread_setname_np.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 302
+#define CYGWIN_VERSION_API_MINOR 303
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared
diff --git a/winsup/cygwin/include/pthread.h b/winsup/cygwin/include/pthread.h
index 609eac2bd..47ee6bd65 100644
--- a/winsup/cygwin/include/pthread.h
+++ b/winsup/cygwin/include/pthread.h
@@ -222,6 +222,8 @@ void pthread_testcancel (void);
#if __GNU_VISIBLE
int pthread_getattr_np (pthread_t, pthread_attr_t *);
+int pthread_getname_np (pthread_t, char *, size_t) __attribute__((nonnull(2)));
+int pthread_setname_np (pthread_t, const char *) __attribute__((nonnull(2)));
int pthread_sigqueue (pthread_t *, int, const union sigval);
int pthread_yield (void);
#endif
diff --git a/winsup/cygwin/release/2.6.0 b/winsup/cygwin/release/2.6.0
index 3f64577d0..825545095 100644
--- a/winsup/cygwin/release/2.6.0
+++ b/winsup/cygwin/release/2.6.0
@@ -20,6 +20,7 @@ What's new:
- locale(1) now supports a -i/--input option to fetch the current input
locale (this is basically equivalent to the current keyboard layout setting).
+- New API: pthread_getname_np, pthread_setname_np.
What changed:
-------------
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 4414785ad..e8622f9b9 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -1106,7 +1106,7 @@ pthread::resume ()
pthread_attr::pthread_attr ():verifyable_object (PTHREAD_ATTR_MAGIC),
joinable (PTHREAD_CREATE_JOINABLE), contentionscope (PTHREAD_SCOPE_PROCESS),
inheritsched (PTHREAD_INHERIT_SCHED), stackaddr (NULL), stacksize (0),
-guardsize (wincap.def_guard_page_size ())
+guardsize (wincap.def_guard_page_size ()), name (NULL)
{
schedparam.sched_priority = 0;
}
@@ -2576,6 +2576,69 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
return 0;
}
+/* For Linux compatibility, the length of a thread name is 16 characters. */
+#define THRNAMELEN 16
+
+extern "C" int
+pthread_getname_np (pthread_t thread, char *buf, size_t buflen)
+{
+ char *name;
+
+ if (!pthread::is_good_object (&thread))
+ return ESRCH;
+
+ if (!thread->attr.name)
+ name = program_invocation_short_name;
+ else
+ name = thread->attr.name;
+
+ /* Return ERANGE if the provided buffer is less than THRNAMELEN. Truncate
+ and zero-terminate the name to fit in buf. This means we always return
+ something if the buffer is THRNAMELEN or larger, but there is no way to
+ tell if we have the whole name. */
+ if (buflen < THRNAMELEN)
+ return ERANGE;
+
+ int ret = 0;
+ __try
+ {
+ strlcpy (buf, name, buflen);
+ }
+ __except (NO_ERROR)
+ {
+ ret = EFAULT;
+ }
+ __endtry
+
+ return ret;
+}
+
+extern "C" int
+pthread_setname_np (pthread_t thread, const char *name)
+{
+ char *oldname, *cp;
+
+ if (!pthread::is_good_object (&thread))
+ return ESRCH;
+
+ if (strlen (name) > THRNAMELEN)
+ return ERANGE;
+
+ cp = strdup (name);
+ if (!cp)
+ return ENOMEM;
+
+ oldname = thread->attr.name;
+ thread->attr.name = cp;
+
+ if (oldname)
+ free (oldname);
+
+ return 0;
+}
+
+#undef THRNAMELEN
+
/* provided for source level compatability.
See http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_getconcurrency.html
*/
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index 5d5191320..48fb6fbb9 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -240,6 +240,7 @@ public:
void *stackaddr;
size_t stacksize;
size_t guardsize;
+ char *name;
pthread_attr ();
~pthread_attr ();
diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml
index e3c4dedb5..7e39316d2 100644
--- a/winsup/doc/new-features.xml
+++ b/winsup/doc/new-features.xml
@@ -64,6 +64,10 @@ Support AzureAD accounts.
"nobody" account support for WinFSP.
</para></listitem>
+<listitem><para>
+New API: pthread_getname_np, pthread_setname_np.
+</para></listitem>
+
</itemizedlist>
</sect2>
diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml
index 8d86a1214..babf11573 100644
--- a/winsup/doc/posix.xml
+++ b/winsup/doc/posix.xml
@@ -1337,6 +1337,8 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
pow10l
ppoll
pthread_getattr_np
+ pthread_getname_np
+ pthread_setname_np
pthread_sigqueue
ptsname_r
putwc_unlocked