From 819006a88b9473872fee91135b06f4e23231d97e Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 9 Jun 2012 19:53:29 -0400 Subject: add pthread_attr_setstack interface (and get) i originally omitted these (optional, per POSIX) interfaces because i considered them backwards implementation details. however, someone later brought to my attention a fairly legitimate use case: allocating thread stacks in memory that's setup for sharing and/or fast transfer between CPU and GPU so that the thread can move data to a GPU directly from automatic-storage buffers without having to go through additional buffer copies. perhaps there are other situations in which these interfaces are useful too. --- src/thread/pthread_attr_getstack.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/thread/pthread_attr_getstack.c (limited to 'src/thread/pthread_attr_getstack.c') diff --git a/src/thread/pthread_attr_getstack.c b/src/thread/pthread_attr_getstack.c new file mode 100644 index 00000000..07ac5926 --- /dev/null +++ b/src/thread/pthread_attr_getstack.c @@ -0,0 +1,10 @@ +#include "pthread_impl.h" + +int pthread_attr_getstack(const pthread_attr_t *a, void **addr, size_t *size) +{ + if (!a->_a_stackaddr) + return EINVAL; + *size = a->_a_stacksize + DEFAULT_STACK_SIZE; + *addr = (void *)(a->_a_stackaddr - *size); + return 0; +} -- cgit v1.2.1