|
From: <pa...@us...> - 2003-08-22 19:48:43
|
Update of /cvsroot/emc/rtapi/src/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv31749 Modified Files: rtapi.h rtapi_common.h rtapi_proc.h Added Files: procfs_macros.h Log Message: Small change for proc_fs macros --- NEW FILE: procfs_macros.h --- #ifndef PROCFS_MACROS_H #define PROCFS_MACROS_H /*********************************************************************** * PROC_FS MACROS * ************************************************************************/ #ifdef CONFIG_PROC_FS #include <linux/proc_fs.h> /* proc print macros - Contributed by: Erwin Rol (er...@mu...) and shamelessly ripped from rtai_proc_fs.h, part of the RTAI project. See http://www.rtai.org for more details. macro that holds the local variables that we use in the PROC_PRINT_* macros. We have this macro so we can add variables with out changing the users of this macro, of course only when the names don't colide! */ #define PROC_PRINT_VARS \ off_t pos = 0; \ off_t begin = 0; \ int len = 0 /* no ";" */ /* macro that prints in the procfs read buffer. this macro expects the function arguments to be named as follows. static int FOO(char *page, char **start, off_t off, int count, int *eof, void *data) */ #define PROC_PRINT(fmt,args...) \ len += sprintf(page + len , fmt, ##args); \ pos += len; \ if(pos < off) { \ len = 0; \ begin = pos; \ } \ if(pos > off + count) \ goto done; /* macro to leave the read function from another place than at the end. */ #define PROC_PRINT_RETURN \ *eof = 1; \ goto done // no ";" /* macro that should only used once at the end of the read function, to return from another place in the read function use the PROC_PRINT_RETURN macro. */ #define PROC_PRINT_DONE \ *eof = 1; \ done: \ *start = page + (off - begin); \ len -= (off - begin); \ if(len > count) \ len = count; \ if(len < 0) \ len = 0; \ return len // no ";" #endif /* PROC_FS */ #endif /* PROCFS_MACROS_H */ Index: rtapi.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** rtapi.h 20 Aug 2003 19:46:38 -0000 1.27 --- rtapi.h 22 Aug 2003 19:48:38 -0000 1.28 *************** *** 485,547 **** extern unsigned char rtapi_inb(unsigned int port); - /*********************************************************************** - * PROC_FS MACROS * - ************************************************************************/ - #ifdef CONFIG_PROC_FS - /* Before using these macros, you MUST include linux/proc_fs.h - pior to rtapi.h */ - - /* proc print macros - Contributed by: Erwin Rol (er...@mu...) - and shamelessly ripped from rtai_proc_fs.h, part of the RTAI - project. See http://www.rtai.org for more details. - - macro that holds the local variables that - we use in the PROC_PRINT_* macros. We have - this macro so we can add variables with out - changing the users of this macro, of course - only when the names don't colide! - */ - - #define PROC_PRINT_VARS \ - off_t pos = 0; \ - off_t begin = 0; \ - int len = 0 /* no ";" */ - - /* macro that prints in the procfs read buffer. - this macro expects the function arguments to be - named as follows. - static int FOO(char *page, char **start, - off_t off, int count, int *eof, void *data) */ - - #define PROC_PRINT(fmt,args...) \ - len += sprintf(page + len , fmt, ##args); \ - pos += len; \ - if(pos < off) { \ - len = 0; \ - begin = pos; \ - } \ - if(pos > off + count) \ - goto done; - - /* macro to leave the read function from another - place than at the end. */ - #define PROC_PRINT_RETURN \ - *eof = 1; \ - goto done // no ";" - - /* macro that should only used once at the end of the - read function, to return from another place in the - read function use the PROC_PRINT_RETURN macro. */ - #define PROC_PRINT_DONE \ - *eof = 1; \ - done: \ - *start = page + (off - begin); \ - len -= (off - begin); \ - if(len > count) \ - len = count; \ - if(len < 0) \ - len = 0; \ - return len // no ";" - - #endif /* RTAPI_H */ --- 485,487 ---- Index: rtapi_common.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi_common.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rtapi_common.h 20 Aug 2003 03:16:21 -0000 1.2 --- rtapi_common.h 22 Aug 2003 19:48:38 -0000 1.3 *************** *** 53,61 **** /* These structs hold data associated with objects like tasks, etc. */ ! typedef enum { EMPTY = 0, ! PAUSED, ! PERIODIC, ! FREERUN, ! ENDED } task_state_t; typedef struct { --- 53,62 ---- /* These structs hold data associated with objects like tasks, etc. */ ! typedef enum { EMPTY = 0, ! PAUSED, ! PERIODIC, ! FREERUN, ! ENDED ! } task_state_t; typedef struct { *************** *** 81,87 **** typedef enum { UNUSED = 0, ! HAS_READER = 1, ! HAS_WRITER = 2, ! HAS_BOTH = 3 } fifo_state_t; /* used as bitmasks */ typedef struct { --- 82,89 ---- typedef enum { UNUSED = 0, ! HAS_READER = 1, ! HAS_WRITER = 2, ! HAS_BOTH = 3 ! } fifo_state_t; /* used as bitmasks */ typedef struct { *************** *** 123,135 **** int timer_running; /* state of HW timer */ long int timer_period; /* HW timer period */ ! task_data task_array[RTAPI_MAX_TASKS+1]; /* data for tasks */ ! shmem_data shmem_array[RTAPI_MAX_SHMEMS+1]; /* data for shared memory */ ! sem_data sem_array[RTAPI_MAX_SEMS+1]; /* data for semaphores */ ! fifo_data fifo_array[RTAPI_MAX_FIFOS+1]; /* data for fifos */ ! irq_data irq_array[RTAPI_MAX_IRQS+1]; /* data for hooked irqs */ } rtapi_data_t; ! #define RTAPI_KEY 0x90280A48 /* key used to open RTAPI shared memory */ ! #define RTAPI_MAGIC 0x12601409 /* magic number used to verify shmem */ /* these pointers are initialized at startup to point --- 125,137 ---- int timer_running; /* state of HW timer */ long int timer_period; /* HW timer period */ ! task_data task_array[RTAPI_MAX_TASKS + 1]; /* data for tasks */ ! shmem_data shmem_array[RTAPI_MAX_SHMEMS + 1]; /* data for shared memory */ ! sem_data sem_array[RTAPI_MAX_SEMS + 1]; /* data for semaphores */ ! fifo_data fifo_array[RTAPI_MAX_FIFOS + 1]; /* data for fifos */ ! irq_data irq_array[RTAPI_MAX_IRQS + 1]; /* data for hooked irqs */ } rtapi_data_t; ! #define RTAPI_KEY 0x90280A48 /* key used to open RTAPI shared memory */ ! #define RTAPI_MAGIC 0x12601409 /* magic number used to verify shmem */ /* these pointers are initialized at startup to point *************** *** 143,152 **** */ ! rtapi_data_t *rtapi_data = NULL; ! task_data *task_array = NULL; ! shmem_data *shmem_array = NULL; ! sem_data *sem_array = NULL; ! fifo_data *fifo_array = NULL; ! irq_data *irq_array = NULL; /* Lightweight Mutexes - These functions are used to prevent --- 145,154 ---- */ ! rtapi_data_t *rtapi_data = NULL; ! task_data *task_array = NULL; ! shmem_data *shmem_array = NULL; ! sem_data *sem_array = NULL; ! fifo_data *fifo_array = NULL; ! irq_data *irq_array = NULL; /* Lightweight Mutexes - These functions are used to prevent *************** *** 176,180 **** static void mutex_get(int *mutex) { ! while ( test_and_set_bit(0, mutex) ) { /* somebody else has the mutex, yield the CPU and try again later */ schedule(); --- 178,182 ---- static void mutex_get(int *mutex) { ! while (test_and_set_bit(0, mutex)) { /* somebody else has the mutex, yield the CPU and try again later */ schedule(); *************** *** 187,191 **** static void mutex_get(int *mutex) { ! while ( test_and_set_bit(0, mutex) ) { /* somebody else has the mutex, yield the CPU and try again later */ sched_yield(); --- 189,193 ---- static void mutex_get(int *mutex) { ! while (test_and_set_bit(0, mutex)) { /* somebody else has the mutex, yield the CPU and try again later */ sched_yield(); *************** *** 195,209 **** #endif ! static void init_rtapi_data ( rtapi_data_t *data ) { int n; /* has the block already been initialized? */ ! if ( data->magic == RTAPI_MAGIC ) { /* yes, nothing to do */ return; ! } /* no, we need to init it, grab mutex unconditionally */ ! mutex_try ( &(data->mutex) ); /* set magic number so nobody else init's the block */ data->magic = RTAPI_MAGIC; --- 197,211 ---- #endif ! static void init_rtapi_data(rtapi_data_t * data) { int n; /* has the block already been initialized? */ ! if (data->magic == RTAPI_MAGIC) { /* yes, nothing to do */ return; ! } /* no, we need to init it, grab mutex unconditionally */ ! mutex_try(&(data->mutex)); /* set magic number so nobody else init's the block */ data->magic = RTAPI_MAGIC; *************** *** 243,247 **** } /* done, release the mutex */ ! mutex_give ( &(data->mutex) ); return; } --- 245,249 ---- } /* done, release the mutex */ ! mutex_give(&(data->mutex)); return; } Index: rtapi_proc.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi_proc.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** rtapi_proc.h 20 Aug 2003 19:46:38 -0000 1.2 --- rtapi_proc.h 22 Aug 2003 19:48:38 -0000 1.3 *************** *** 53,58 **** information, go to www.linuxcnc.org. */ ! ! #include <linux/proc_fs.h> /* Internal function for the proc_fs system. */ --- 53,57 ---- information, go to www.linuxcnc.org. */ ! #include "procfs_macros.h" /* Internal function for the proc_fs system. */ *************** *** 64,67 **** --- 63,67 ---- series kernel.. */ + #ifdef CONFIG_PROC_FS static struct proc_dir_entry *rtapi_dir = 0; /* /proc/rtapi directory */ |