diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-04-02 12:11:46 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-04-02 12:11:46 +0000 |
commit | d9fa47ecc4f23142615a7a71f4d71d26333719b6 (patch) | |
tree | 558a8727df2791683312976d9cd3aedd21138876 | |
parent | 7acc0722db7e1a122feac7d1c80a44a071dcb1c8 (diff) | |
download | aports-d9fa47ecc4f23142615a7a71f4d71d26333719b6.tar.bz2 aports-d9fa47ecc4f23142615a7a71f4d71d26333719b6.tar.xz |
core/uclibc: add basic support for pthread_getattr_np
Needed by webkit
-rw-r--r-- | core/uclibc/APKBUILD | 4 | ||||
-rw-r--r-- | core/uclibc/uclibc-0.9.30.1-pthread_getattr_np.patch | 137 |
2 files changed, 140 insertions, 1 deletions
diff --git a/core/uclibc/APKBUILD b/core/uclibc/APKBUILD index 8632ef89..cab1cb38 100644 --- a/core/uclibc/APKBUILD +++ b/core/uclibc/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=uclibc pkgver=0.9.30.1 -pkgrel=3 +pkgrel=4 pkgdesc="C library for developing embedded Linux systems" url=http://uclibc.org license="LGPL-2" @@ -12,6 +12,7 @@ depends_dev="linux-headers" source="http://uclibc.org/downloads/$_mynamever.tar.bz2 $pkgname-0.9.30.1-resolv.patch + uclibc-0.9.30.1-pthread_getattr_np.patch uclibcconfig " @@ -44,4 +45,5 @@ build() { md5sums="1a4b84e5536ad8170563ffa88c34679c uClibc-0.9.30.1.tar.bz2 ea91460617601b6e084ead66bc3948f5 uclibc-0.9.30.1-resolv.patch +cf80c0d44a41e02f389be427ee615d61 uclibc-0.9.30.1-pthread_getattr_np.patch a4512d5594f1b450ffbf2ff9eda6263b uclibcconfig" diff --git a/core/uclibc/uclibc-0.9.30.1-pthread_getattr_np.patch b/core/uclibc/uclibc-0.9.30.1-pthread_getattr_np.patch new file mode 100644 index 00000000..28469be2 --- /dev/null +++ b/core/uclibc/uclibc-0.9.30.1-pthread_getattr_np.patch @@ -0,0 +1,137 @@ +--- uClibc-0.9.30.1.orig/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h 2009-03-30 15:01:48.000000000 +0000 ++++ uClibc-0.9.30.1/libpthread/linuxthreads.old/sysdeps/pthread/pthread.h 2009-03-30 15:48:16.000000000 +0000 +@@ -288,16 +288,12 @@ + __attr, size_t *__restrict __stacksize) + __THROW; + +-#if 0 +-/* Not yet implemented in uClibc! */ +- + #ifdef __USE_GNU + /* Initialize thread attribute *ATTR with attributes corresponding to the + already running thread TH. It shall be called on uninitialized ATTR + and destroyed with pthread_attr_destroy when no longer needed. */ + extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW; + #endif +-#endif + + /* Functions for scheduling control. */ + +@@ -599,6 +595,11 @@ + cancelled. */ + extern void pthread_testcancel (void); + ++/* Return the previously set address for the stack. */ ++extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr, ++ void **__restrict __stackaddr, ++ size_t *__restrict __stacksize) __THROW; ++ + + /* Install a cleanup handler: ROUTINE will be called with arguments ARG + when the thread is cancelled or calls pthread_exit. ROUTINE will also +--- a/libpthread/linuxthreads.old/attr.c.orig 2007-11-22 16:55:08.000000000 +0000 ++++ b/libpthread/linuxthreads.old/attr.c 2009-03-30 19:15:51.000000000 +0000 +@@ -38,6 +38,14 @@ + libpthread_hidden_proto(pthread_attr_getscope) + libpthread_hidden_proto(pthread_attr_setscope) + ++#include <sys/resource.h> ++#include <inttypes.h> ++#include <stdio.h> ++#include <stdio_ext.h> ++#include <stdlib.h> ++#include <sys/resource.h> ++ ++ + /* NOTE: With uClibc I don't think we need this versioning stuff. + * Therefore, define the function pthread_attr_init() here using + * a strong symbol. */ +@@ -235,4 +243,88 @@ + *stacksize = attr->__stacksize; + return 0; + } ++ ++ ++extern int *__libc_stack_end; ++ + weak_alias (__pthread_attr_getstacksize, pthread_attr_getstacksize) ++int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) ++{ ++ static void *stackBase = 0; ++ static size_t stackSize = 0; ++ int ret = 0; ++ /* Stack size limit. */ ++ struct rlimit rl; ++ ++ /* The safest way to get the top of the stack is to read ++ /proc/self/maps and locate the line into which ++ __libc_stack_end falls. */ ++ FILE *fp = fopen("/proc/self/maps", "rc"); ++ if (fp == NULL) ++ ret = errno; ++ /* We need the limit of the stack in any case. */ ++ else if (getrlimit (RLIMIT_STACK, &rl) != 0) ++ ret = errno; ++ else { ++ /* We need no locking. */ ++ __fsetlocking (fp, FSETLOCKING_BYCALLER); ++ ++ /* Until we found an entry (which should always be the case) ++ mark the result as a failure. */ ++ ret = ENOENT; ++ ++ char *line = NULL; ++ size_t linelen = 0; ++ uintptr_t last_to = 0; ++ ++ while (! feof_unlocked (fp)) { ++ if (getdelim (&line, &linelen, '\n', fp) <= 0) ++ break; ++ ++ uintptr_t from; ++ uintptr_t to; ++ if (sscanf (line, "%x-%x", &from, &to) != 2) ++ continue; ++ if (from <= (uintptr_t) __libc_stack_end ++ && (uintptr_t) __libc_stack_end < to) { ++ /* Found the entry. Now we have the info we need. */ ++ attr->__stacksize = rl.rlim_cur; ++#ifdef _STACK_GROWS_UP ++ /* Don't check to enforce a limit on the __stacksize */ ++ attr->__stackaddr = (void *) from; ++#else ++ attr->__stackaddr = (void *) to; ++ ++ /* The limit might be too high. */ ++ if ((size_t) attr->__stacksize > (size_t) attr->__stackaddr - last_to) ++ attr->__stacksize = (size_t) attr->__stackaddr - last_to; ++#endif ++ ++ /* We succeed and no need to look further. */ ++ ret = 0; ++ break; ++ } ++ last_to = to; ++ } ++ ++ fclose (fp); ++ free (line); ++ } ++ return ret; ++} ++ ++int __pthread_attr_getstack (const pthread_attr_t *attr, void **stackaddr, ++ size_t *stacksize) ++{ ++ /* XXX This function has a stupid definition. The standard specifies ++ no error value but what is if no stack address was set? We simply ++ return the value we have in the member. */ ++#ifndef _STACK_GROWS_UP ++ *stackaddr = (char *) attr->__stackaddr - attr->__stacksize; ++#else ++ *stackaddr = attr->__stackaddr; ++#endif ++ *stacksize = attr->__stacksize; ++ return 0; ++} ++weak_alias (__pthread_attr_getstack, pthread_attr_getstack) |