base/include/rtai_wrappers.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Philippe Gerum <rpm@xenomai.org>
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef _RTAI_WRAPPERS_H
00020 #define _RTAI_WRAPPERS_H
00021 
00022 #ifdef __KERNEL__
00023 
00024 #include <linux/version.h>
00025 #ifndef __cplusplus
00026 #include <linux/module.h>
00027 #endif /* !__cplusplus */
00028 
00029 #include <linux/moduleparam.h>
00030 #define RTAI_MODULE_PARM(name, type) \
00031     module_param(name, type, 0444)
00032 
00033 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
00034 #define IRQF_SHARED  SA_SHIRQ
00035 #endif
00036 
00037 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
00038 
00039 #include <linux/bitops.h>
00040 
00041 #define CONFIG_MMU 1
00042 
00043 typedef int clockid_t;
00044 
00045 #ifndef TIMER_ABSTIME
00046 #define TIMER_ABSTIME  0x01
00047 #endif
00048 
00049 typedef int timer_t;
00050 
00051 #ifndef __deprecated
00052 #define container_of(ptr, type, member) \
00053     ({ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
00054         (type *)( (char *)__mptr - offsetof(type,member) );})
00055 #endif
00056 
00057 #ifndef __deprecated
00058 #define __deprecated  __attribute__((deprecated))
00059 #endif
00060 
00061 #define RTAI_MODULE_PARM_ARRAY(name, type, addr, size) \
00062         static inline void *__check_existence_##name(void) { return &name; } \
00063     MODULE_PARM(name, "1-" __MODULE_STRING(size) _MODULE_PARM_STRING_ ## type);
00064 #define _MODULE_PARM_STRING_charp "s"
00065 
00066 #define PID_MAX_LIMIT     PID_MAX
00067 #define num_online_cpus() smp_num_cpus
00068 #define mm_remap_page_range(vma,from,to,size,prot) remap_page_range(from,to,size,prot)
00069 #define __user
00070 
00071 #define set_tsk_need_resched(t) do { \
00072     (t)->need_resched = 1; \
00073 } while(0)
00074 
00075 #define clear_tsk_need_resched(t) do { \
00076     (t)->need_resched = 0; \
00077 } while(0)
00078 
00079 #define set_need_resched() set_tsk_need_resched(current)
00080 
00081 #define LIST_POISON1  NULL
00082 #define LIST_POISON2  NULL
00083 
00084 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) || __cplusplus
00085 typedef void irqreturn_t;
00086 #endif  /* LINUX_VERSION_CODE < KERNEL_VERSION(2,4,23) || __cplusplus */
00087 
00088 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28)
00089 #define msleep(delay) \
00090 do { \
00091     set_current_state(TASK_RTAISRVSLEEP); \
00092     schedule_timeout(((delay)*HZ)/1000); \
00093 } while(0)
00094 #endif
00095 
00096 #define get_tsk_addr_limit(t) ((t)->addr_limit.seg)
00097 
00098 #define task_cpu(t) ((t)->processor)
00099 
00100 #define self_daemonize(name) do { \
00101    strcpy(current->comm,"gatekeeper"); \
00102    daemonize(); \
00103 } while(0)
00104 
00105 #define get_thread_ptr(t)  (t)
00106 
00107 #define RTAI_LINUX_IRQ_HANDLED  /* i.e. "void" return */
00108 
00109 static inline unsigned long hweight_long(unsigned long w)
00110 {
00111         return sizeof(w) == 4 ? hweight32(w) : hweight32(w);
00112 }
00113 
00114 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
00115 
00116 #define RTAI_MODULE_PARM_ARRAY(name, type, addr, size) \
00117     module_param_array(name, type, addr, 0400);
00118 
00119 /* Basic class macros */
00120 
00121 #ifdef CONFIG_SYSFS
00122 #include <linux/device.h>
00123 #if  LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)
00124 typedef struct class class_t;
00125 
00126 #if  LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
00127 #define CLASS_DEVICE_CREATE(cls, devt, device, fmt, arg...)  device_create(cls, NULL, devt, NULL, fmt, ##arg)
00128 #else  /* < 2.6.27 */
00129 #define CLASS_DEVICE_CREATE(cls, devt, device, fmt, arg...)  device_create(cls, NULL, devt, fmt, ##arg)
00130 #endif  /* > 2.6.26 */
00131 
00132 #define class_device_destroy(a, b)  device_destroy(a, b)
00133 #else
00134 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
00135 typedef struct class class_t;
00136 #define CLASS_DEVICE_CREATE(cls, devt, device, fmt, arg...) class_device_create(cls, NULL, devt, device, fmt, ## arg)
00137 #else /* LINUX 2.6.0 - 2.6.14 */
00138 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) /* LINUX 2.6.13 - 2.6.14 */
00139 typedef struct class class_t;
00140 #define CLASS_DEVICE_CREATE class_device_create
00141 #else /* LINUX 2.6.0 - 2.6.12, class_simple */
00142 typedef struct class_simple class_t;
00143 #define CLASS_DEVICE_CREATE class_simple_device_add
00144 #define class_create class_simple_create
00145 #define class_destroy class_simple_destroy
00146 #define class_device_destroy(a, b) class_simple_device_remove(b)
00147 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) */
00148 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) */
00149 #endif
00150 #endif
00151 
00152 #define mm_remap_page_range(vma,from,to,size,prot) remap_page_range(vma,from,to,size,prot)
00153 
00154 #define get_tsk_addr_limit(t) ((t)->thread_info->addr_limit.seg)
00155 
00156 #define self_daemonize(name) daemonize(name)
00157 
00158 #define get_thread_ptr(t)  ((t)->thread_info)
00159 
00160 #define RTAI_LINUX_IRQ_HANDLED IRQ_HANDLED
00161 
00162 #ifndef MODULE_LICENSE
00163 #define MODULE_LICENSE(s)   /* For really old 2.4 kernels. */
00164 #endif /* !MODULE_LICENSE */
00165 
00166 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) */
00167 
00168 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,7)
00169 #define CPUMASK_T(name) (name)
00170 #define CPUMASK(name)   (name)
00171 #else /* LINUX_VERSION_CODE > KERNEL_VERSION(2,6,7) */
00172 #define CPUMASK_T(name)  ((cpumask_t){ { name } })
00173 #define CPUMASK(name)    (name.bits[0])
00174 #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,7) */
00175 
00176 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
00177 
00178 #include <linux/pid.h>
00179 
00180 #define find_task_by_pid(nr) \
00181     find_task_by_pid_type_ns(PIDTYPE_PID, nr, &init_pid_ns)
00182 #define kill_proc(pid, sig, priv)       \
00183   kill_proc_info(sig, (priv) ? SEND_SIG_PRIV : SEND_SIG_NOINFO, pid)
00184 
00185 #endif /* LINUX_VERSION_CODE <= 2.6.26 */
00186 
00187 #ifndef CONFIG_SYSFS
00188 typedef void * class_t;
00189 #define class_create(a,b)  ((void *)1)
00190 #define CLASS_DEVICE_CREATE(a, b, c, d, ...)  ((void *)1) 
00191 #define class_device_destroy(a, b)
00192 #define class_destroy(a)
00193 #endif
00194 
00195 #endif /* __KERNEL__ */
00196 
00197 #endif /* !_RTAI_WRAPPERS_H */

Generated on Tue Feb 2 17:46:05 2010 for RTAI API by  doxygen 1.4.7