From: Nicolas Roche Date: Wed, 15 Apr 2009 10:06:20 +0000 (+0000) Subject: adaint.c: Add function __gnat_lwp_self that retrieves the LWP of the current thread. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=442dd5fb23f716aaabf465ead17b4dfb63421699;p=gcc.git adaint.c: Add function __gnat_lwp_self that retrieves the LWP of the current thread. 2009-04-15 Nicolas Roche * adaint.c: Add function __gnat_lwp_self that retrieves the LWP of the current thread. * s-osinte-linux.ads: Import the __gnat_lwp_self function as lwp_self * s-taprop-linux.adb (Enter_Task): Store the LWP in the TCB From-SVN: r146097 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 3ed5a382de6..5b7a12dba2d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2009-04-15 Nicolas Roche + + * adaint.c: Add function __gnat_lwp_self that retrieves the LWP of the + current thread. + + * s-osinte-linux.ads: Import the __gnat_lwp_self function as lwp_self + + * s-taprop-linux.adb (Enter_Task): Store the LWP in the TCB + 2009-04-15 Ed Schonberg * sem_ch4.adb: improve error message on exponentiation. diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c index 7d35f11b3e1..a6e74299aef 100644 --- a/gcc/ada/adaint.c +++ b/gcc/ada/adaint.c @@ -3346,3 +3346,13 @@ __gnat_pthread_setaffinity_np (pthread_t th ATTRIBUTE_UNUSED, } #endif #endif + +#if defined (linux) +/* There is no function in the glibc to retrieve the LWP of the current + thread. We need to do a system call in order to retrieve this + information. */ +#include +void *__gnat_lwp_self (void) { + return (void *) syscall (__NR_gettid); +} +#endif diff --git a/gcc/ada/s-osinte-linux.ads b/gcc/ada/s-osinte-linux.ads index bbaa0b4282e..a663aa8de9b 100644 --- a/gcc/ada/s-osinte-linux.ads +++ b/gcc/ada/s-osinte-linux.ads @@ -464,6 +464,9 @@ package System.OS_Interface is function pthread_self return pthread_t; pragma Import (C, pthread_self, "pthread_self"); + function lwp_self return System.Address; + pragma Import (C, lwp_self, "__gnat_lwp_self"); + -------------------------- -- POSIX.1c Section 17 -- -------------------------- diff --git a/gcc/ada/s-taprop-linux.adb b/gcc/ada/s-taprop-linux.adb index 08bbac10f40..addffde9bef 100644 --- a/gcc/ada/s-taprop-linux.adb +++ b/gcc/ada/s-taprop-linux.adb @@ -701,6 +701,7 @@ package body System.Task_Primitives.Operations is end if; Self_ID.Common.LL.Thread := pthread_self; + Self_ID.Common.LL.LWP := lwp_self; Specific.Set (Self_ID);