adaint.c: Add function __gnat_lwp_self that retrieves the LWP of the current thread.
authorNicolas Roche <roche@adacore.com>
Wed, 15 Apr 2009 10:06:20 +0000 (10:06 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 15 Apr 2009 10:06:20 +0000 (12:06 +0200)
2009-04-15  Nicolas Roche  <roche@adacore.com>

* 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

gcc/ada/ChangeLog
gcc/ada/adaint.c
gcc/ada/s-osinte-linux.ads
gcc/ada/s-taprop-linux.adb

index 3ed5a382de67fa374520df224b2e85461fa64dc3..5b7a12dba2d8b964f21b2c02ab45b6ba7cd04bbb 100644 (file)
@@ -1,3 +1,12 @@
+2009-04-15  Nicolas Roche  <roche@adacore.com>
+
+       * 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  <schonberg@adacore.com>
 
        * sem_ch4.adb: improve error message on exponentiation.
index 7d35f11b3e140014cb57932fe2e641a3277a8c1a..a6e74299aef287c32a3dfbdd42ccad1e7e772cc8 100644 (file)
@@ -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 <sys/syscall.h>
+void *__gnat_lwp_self (void) {
+   return (void *) syscall (__NR_gettid);
+}
+#endif
index bbaa0b4282e772b2469694144fd70a23fcd9615e..a663aa8de9be9b9b6d156729fb9823b11893a70b 100644 (file)
@@ -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 --
    --------------------------
index 08bbac10f402bc4746ee85c8e5b61f74d6070eec..addffde9befbee7af1296adbfb6108ad9165bdc0 100644 (file)
@@ -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);