]> rtime.felk.cvut.cz Git - lincan.git/blobdiff - lincan/src/kthread.c
Adjust LinCAN sources to compile for 3.x Linux kernel.
[lincan.git] / lincan / src / kthread.c
index 4e574a9e9c42af9f2d3cebd94490f00792ef785c..d92a1a96c9cd998ca2cc90d10fb051719a2fd681 100644 (file)
@@ -1,5 +1,7 @@
-#include <linux/config.h>
 #include <linux/version.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
+#include <linux/config.h>
+#endif
 
 #if defined(MODVERSIONS)
 #include <linux/modversions.h>
 #include <linux/signal.h>
 #include <linux/interrupt.h>
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
+  #include <asm/semaphore.h>
+#else
+  #include <linux/semaphore.h>
+#endif
 
-#include <asm/semaphore.h>
-#include <linux/smp_lock.h>
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
+  #include <linux/smp_lock.h>
+#endif
 
 #include "../include/kthread.h"
 
@@ -101,7 +109,7 @@ void stop_kthread(kthread_t *kthread)
     sema_init(&kthread->startstop_sem,0);
 
     /* We need to do a memory barrier here to be sure that
-       the flags are visible on all CPUs. 
+       the flags are visible on all CPUs.
     */
     mb();
 
@@ -109,10 +117,16 @@ void stop_kthread(kthread_t *kthread)
     kthread->terminate = 1;
 
     /* We need to do a memory barrier here to be sure that
-       the flags are visible on all CPUs. 
+       the flags are visible on all CPUs.
     */
     mb();
+#warning The local code for kernel thread support is not more needed for recent 2.6 kernels
+#warning and code should be modified to emulate same interface for older kernels
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
     kill_proc(kthread->thread->pid, SIGKILL, 1);
+#else /* >= 2,6,20 */
+    send_sig(SIGKILL, kthread->thread, 1);
+#endif /* >= 2,6,20 */
 
     /* block till thread terminated */
     down(&kthread->startstop_sem);
@@ -123,7 +137,9 @@ void stop_kthread(kthread_t *kthread)
     /* now we are sure the thread is in zombie state. We
        notify keventd to clean the process up.
     */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
     kill_proc(2, SIGCHLD, 1);
+#endif /* >= 2,6,20 */
 
 }