aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Roche <roche@adacore.com>2009-04-15 10:06:20 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2009-04-15 12:06:20 +0200
commit442dd5fb23f716aaabf465ead17b4dfb63421699 (patch)
tree4469e171ddac22ee50aeea8398d926ae45ad780e
parentcbd8be94c2233082bb4af2074b7878c7f7797adc (diff)
downloadgcc-442dd5fb23f716aaabf465ead17b4dfb63421699.zip
gcc-442dd5fb23f716aaabf465ead17b4dfb63421699.tar.gz
gcc-442dd5fb23f716aaabf465ead17b4dfb63421699.tar.bz2
adaint.c: Add function __gnat_lwp_self that retrieves the LWP of the current thread.
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
-rw-r--r--gcc/ada/ChangeLog9
-rw-r--r--gcc/ada/adaint.c10
-rw-r--r--gcc/ada/s-osinte-linux.ads3
-rw-r--r--gcc/ada/s-taprop-linux.adb1
4 files changed, 23 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 3ed5a38..5b7a12d 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 7d35f11..a6e7429 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 <sys/syscall.h>
+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 bbaa0b4..a663aa8 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 08bbac1..addffde 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);