include/nucleus/types.h

00001 /*
00002  * Copyright (C) 2001,2002,2003 Philippe Gerum <rpm@xenomai.org>.
00003  *
00004  * Xenomai is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published
00006  * by the Free Software Foundation; either version 2 of the License,
00007  * or (at your option) any later version.
00008  *
00009  * Xenomai is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with Xenomai; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017  * 02111-1307, USA.
00018  */
00019 
00020 #ifndef _XENO_NUCLEUS_TYPES_H
00021 #define _XENO_NUCLEUS_TYPES_H
00022 
00023 #ifdef __KERNEL__
00024 #include <linux/errno.h>
00025 #ifdef CONFIG_PREEMPT_RT
00026 #define linux_semaphore compat_semaphore
00027 #else /* CONFIG_PREEMPT_RT */
00028 #define linux_semaphore semaphore
00029 #endif /* !CONFIG_PREEMPT_RT */
00030 #else /* !__KERNEL__ */
00031 #include <sys/types.h>
00032 #include <errno.h>
00033 #ifndef BITS_PER_LONG
00034 #include <stdint.h>
00035 #define BITS_PER_LONG __WORDSIZE
00036 #endif /* !BITS_PER_LONG */
00037 #endif /* __KERNEL__ */
00038 
00039 #include <asm/xenomai/system.h>
00040 #include <nucleus/compiler.h>
00041 
00042 typedef unsigned long xnsigmask_t;
00043 
00044 typedef unsigned long long xnticks_t;
00045 
00046 typedef long long xnsticks_t;
00047 
00048 typedef unsigned long long xntime_t; /* ns */
00049 
00050 typedef long long xnstime_t;
00051 
00052 typedef unsigned long xnhandle_t;
00053 
00054 #define XN_NO_HANDLE ((xnhandle_t)0)
00055 
00056 struct xnintr;
00057 
00058 typedef int (*xnisr_t)(struct xnintr *intr);
00059 
00060 typedef int (*xniack_t)(unsigned irq);
00061 
00062 #define XN_INFINITE   (0)
00063 #define XN_NONBLOCK   ((xnticks_t)-1)
00064 
00065 #define XN_APERIODIC_TICK  0
00066 #define XN_NO_TICK         ((xnticks_t)-1)
00067 
00068 #define testbits(flags,mask) ((flags) & (mask))
00069 #define setbits(flags,mask)  xnarch_atomic_set_mask(&(flags),mask)
00070 #define clrbits(flags,mask)  xnarch_atomic_clear_mask(&(flags),mask)
00071 #define __testbits(flags,mask) testbits(flags,mask)
00072 #define __setbits(flags,mask)  do { (flags) |= (mask); } while(0)
00073 #define __clrbits(flags,mask)  do { (flags) &= ~(mask); } while(0)
00074 
00075 typedef atomic_flags_t xnflags_t;
00076 
00077 #ifndef NULL
00078 #define NULL 0
00079 #endif
00080 
00081 #define XNOBJECT_NAME_LEN 32
00082 
00083 static inline void xnobject_copy_name(char *dst, const char *src)
00084 {
00085     if (src)
00086         strncpy(dst, src, XNOBJECT_NAME_LEN);
00087     else
00088         *dst = '\0';
00089 }
00090 
00091 #define xnobject_create_name(dst, n, obj) \
00092     snprintf(dst, n, "%p", obj)
00093 
00094 #define minval(a,b) ((a) < (b) ? (a) : (b))
00095 #define maxval(a,b) ((a) > (b) ? (a) : (b))
00096 
00097 #ifdef __cplusplus
00098 extern "C" {
00099 #endif
00100 
00101 const char *xnpod_fatal_helper(const char *format, ...);
00102 
00103 int __xeno_user_init(void);
00104 
00105 void __xeno_user_exit(void);
00106 
00107 #ifdef __cplusplus
00108 }
00109 #endif
00110 
00111 #define xnprintf(fmt,args...)  xnarch_printf(fmt , ##args)
00112 #define xnloginfo(fmt,args...) xnarch_loginfo(fmt , ##args)
00113 #define xnlogwarn(fmt,args...) xnarch_logwarn(fmt , ##args)
00114 #define xnlogerr(fmt,args...)  xnarch_logerr(fmt , ##args)
00115 
00116 #define xnpod_fatal(format,args...) \
00117 do { \
00118     const char *panic; \
00119     xnarch_trace_panic_freeze(); \
00120     panic = xnpod_fatal_helper(format,##args); \
00121     xnarch_halt(panic); \
00122 } while (0)
00123 
00124 #ifdef __XENO_SIM__
00125 #define SKIN_INIT(name)  __xeno_skin_init(void)
00126 #define SKIN_EXIT(name)  __xeno_skin_exit(void)
00127 #else /* !__XENO_SIM__ */
00128 #define SKIN_INIT(name)  __ ## name ## _skin_init(void)
00129 #define SKIN_EXIT(name)  __ ## name ## _skin_exit(void)
00130 #endif /* __XENO_SIM__ */
00131 
00132 #define root_thread_init __xeno_user_init
00133 #define root_thread_exit __xeno_user_exit
00134 
00135 #endif /* !_XENO_NUCLEUS_TYPES_H */

Generated on Sun Dec 9 10:37:17 2007 for Xenomai API by  doxygen 1.5.3