base/include/rtai_proc_fs.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1999-2003 Paolo Mantegazza <mantegazza@aero.polimi.it>
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_PROC_FS_H
00020 #define _RTAI_PROC_FS_H
00021 
00022 #define LIMIT (PAGE_SIZE - 80)
00023 
00024 extern struct proc_dir_entry *rtai_proc_root;
00025 
00026 // proc print macros - Contributed by: Erwin Rol (erwin@muffin.org)
00027 
00028 // macro that holds the local variables that
00029 // we use in the PROC_PRINT_* macros. We have
00030 // this macro so we can add variables with out
00031 // changing the users of this macro, of course
00032 // only when the names don't colide!
00033 #define PROC_PRINT_VARS                                 \
00034     off_t pos = 0;                                      \
00035     off_t begin = 0;                                    \
00036     int len = 0 /* no ";" */            
00037 
00038 // macro that prints in the procfs read buffer.
00039 // this macro expects the function arguments to be 
00040 // named as follows.
00041 // static int FOO(char *page, char **start, 
00042 //                off_t off, int count, int *eof, void *data)
00043 
00044 #define PROC_PRINT(fmt,args...) \
00045 do {    \
00046     len += sprintf(page + len , fmt, ##args);           \
00047     pos += len;                                         \
00048     if(pos < off) {                                     \
00049         len = 0;                                        \
00050         begin = pos;                                    \
00051     }                                                   \
00052     if(pos > off + count)                               \
00053         goto done; \
00054 } while(0)
00055 
00056 // macro to leave the read function for a other
00057 // place than at the end. 
00058 #define PROC_PRINT_RETURN                              \
00059 do {    \
00060     *eof = 1;                                          \
00061     goto done; \
00062 } while(0)
00063 
00064 // macro that should only used ones at the end of the
00065 // read function, to return from a other place in the 
00066 // read function use the PROC_PRINT_RETURN macro. 
00067 #define PROC_PRINT_DONE                                 \
00068 do {    \
00069         *eof = 1;                                       \
00070     done:                                               \
00071         *start = page + (off - begin);                  \
00072         len -= (off - begin);                           \
00073         if(len > count)                                 \
00074             len = count;                                \
00075         if(len < 0)                                     \
00076             len = 0;                                    \
00077         return len; \
00078 } while(0)
00079 
00080 // End of proc print macros
00081 
00082 #endif  /* !_RTAI_PROC_FS_H */

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