server: Moved the tkill function to ptrace.c.
diff --git a/server/context_alpha.c b/server/context_alpha.c
index 118bff7..979e52d 100644
--- a/server/context_alpha.c
+++ b/server/context_alpha.c
@@ -334,14 +334,6 @@
return (void *)context.Fir;
}
-/* send a signal to a specific thread */
-int tkill( int tgid, int pid, int sig )
-{
- /* FIXME: should do something here */
- errno = ENOSYS;
- return -1;
-}
-
/* retrieve the thread context */
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
{
diff --git a/server/context_i386.c b/server/context_i386.c
index 7285905..b8efb9e 100644
--- a/server/context_i386.c
+++ b/server/context_i386.c
@@ -550,34 +550,6 @@
return (void *)context.Eip;
}
-/* send a signal to a specific thread */
-int tkill( int tgid, int pid, int sig )
-{
-#ifdef __linux__
- int ret;
-
- __asm__( "pushl %%ebx\n\t"
- "movl %2,%%ebx\n\t"
- "int $0x80\n\t"
- "popl %%ebx\n\t"
- : "=a" (ret)
- : "0" (270) /*SYS_tgkill*/, "r" (tgid), "c" (pid), "d" (sig) );
- if (ret == -ENOSYS)
- __asm__( "pushl %%ebx\n\t"
- "movl %2,%%ebx\n\t"
- "int $0x80\n\t"
- "popl %%ebx\n\t"
- : "=a" (ret)
- : "0" (238) /*SYS_tkill*/, "r" (pid), "c" (sig) );
- if (ret >= 0) return ret;
- errno = -ret;
- return -1;
-#else
- errno = ENOSYS;
- return -1;
-#endif
-}
-
/* retrieve the thread context */
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
{
diff --git a/server/context_powerpc.c b/server/context_powerpc.c
index 8cf1424..517bc4e 100644
--- a/server/context_powerpc.c
+++ b/server/context_powerpc.c
@@ -273,14 +273,6 @@
return (void *)context.Iar;
}
-/* send a signal to a specific thread */
-int tkill( int tgid, int pid, int sig )
-{
- /* FIXME: should do something here */
- errno = ENOSYS;
- return -1;
-}
-
/* retrieve the thread context */
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
{
diff --git a/server/context_sparc.c b/server/context_sparc.c
index 805fd7e..843eb11 100644
--- a/server/context_sparc.c
+++ b/server/context_sparc.c
@@ -172,14 +172,6 @@
return (void *)context.pc;
}
-/* send a signal to a specific thread */
-int tkill( int tgid, int pid, int sig )
-{
- /* FIXME: should do something here */
- errno = ENOSYS;
- return -1;
-}
-
/* retrieve the thread context */
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
{
diff --git a/server/context_x86_64.c b/server/context_x86_64.c
index ee9665e..a4ec07c 100644
--- a/server/context_x86_64.c
+++ b/server/context_x86_64.c
@@ -261,22 +261,6 @@
return (void *)context.Rip;
}
-/* send a signal to a specific thread */
-int tkill( int tgid, int pid, int sig )
-{
-#ifdef __linux__
- int ret;
- __asm__( "syscall" : "=a" (ret)
- : "0" (200) /*SYS_tkill*/, "D" (pid), "S" (sig) );
- if (ret >= 0) return ret;
- errno = -ret;
- return -1;
-#else
- errno = ENOSYS;
- return -1;
-#endif
-}
-
/* retrieve the thread context */
void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags )
{
diff --git a/server/ptrace.c b/server/ptrace.c
index 817b0ec..9f8441f 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -173,6 +173,37 @@
return thread->unix_pid;
}
+/* send a signal to a specific thread */
+static inline int tkill( int tgid, int pid, int sig )
+{
+ int ret = -ENOSYS;
+
+#ifdef __linux__
+# ifdef __i386__
+ __asm__( "pushl %%ebx\n\t"
+ "movl %2,%%ebx\n\t"
+ "int $0x80\n\t"
+ "popl %%ebx\n\t"
+ : "=a" (ret)
+ : "0" (270) /*SYS_tgkill*/, "r" (tgid), "c" (pid), "d" (sig) );
+ if (ret == -ENOSYS)
+ __asm__( "pushl %%ebx\n\t"
+ "movl %2,%%ebx\n\t"
+ "int $0x80\n\t"
+ "popl %%ebx\n\t"
+ : "=a" (ret)
+ : "0" (238) /*SYS_tkill*/, "r" (pid), "c" (sig) );
+# elif defined(__x86_64__)
+ __asm__( "syscall" : "=a" (ret)
+ : "0" (200) /*SYS_tkill*/, "D" (pid), "S" (sig) );
+# endif
+#endif /* __linux__ */
+
+ if (ret >= 0) return ret;
+ errno = -ret;
+ return -1;
+}
+
/* send a Unix signal to a specific thread */
int send_thread_signal( struct thread *thread, int sig )
{
diff --git a/server/thread.h b/server/thread.h
index 6b4818c..8c5c0f7 100644
--- a/server/thread.h
+++ b/server/thread.h
@@ -126,7 +126,6 @@
extern void *get_thread_ip( struct thread *thread );
extern void get_thread_context( struct thread *thread, CONTEXT *context, unsigned int flags );
extern void set_thread_context( struct thread *thread, const CONTEXT *context, unsigned int flags );
-extern int tkill( int tgid, int pid, int sig );
extern int send_thread_signal( struct thread *thread, int sig );
extern void get_selector_entry( struct thread *thread, int entry, unsigned int *base,
unsigned int *limit, unsigned char *flags );