~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/sys/gen/vector.h

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)Vector handling headers
  2 */
  3 
  4 #ifndef VECTOR_HEADS_DEFINED
  5 #define VECTOR_HEADS_DEFINED
  6 
  7 /* vector data structure */
  8 
  9 typedef struct vector
 10 {
 11     Ts_id ts_id;                /* Tina structure identifier */
 12     Vartype vtype;
 13     int n;
 14     void *data;
 15 } Vector;
 16 #define VECTOR_SWAP_STRING "iip"
 17 
 18 /** various vector subscript macros **/
 19 
 20 #define VECTOR_CHAR(_v, _i)       (((char *) (_v)->data)[(_i)])
 21 #define VECTOR_UCHAR(_v, _i)      (((unsigned char *) (_v)->data)[(_i)])
 22 #define VECTOR_SHORT(_v, _i)      (((short *) (_v)->data)[(_i)])
 23 #define VECTOR_USHORT(_v, _i)     (((unsigned short *)(_v)->data)[(_i)])
 24 #define VECTOR_INT(_v, _i)        (((int *)(_v)->data)[(_i)])
 25 #define VECTOR_UINT(_v, _i)       (((unsigned int *)(_v)->data)[(_i)])
 26 #define VECTOR_FLOAT(_v, _i)      (((float *) (_v)->data)[(_i)])
 27 #define VECTOR_DOUBLE(_v, _i)     (((double *) (_v)->data)[(_i)])
 28 #define VECTOR_COMPLEX(_v, _i)    (((Complex *) (_v)->data)[(_i)])
 29 #define VECTOR_PTR(_v, _i)        (((void **) (_v)->data)[(_i)])
 30 
 31 #define VECTOR_GET(_v, _i, _vi) \
 32         switch ((_v)->vtype) \
 33         {\
 34              case char_v: (_vi) = (char) VECTOR_CHAR((_v), (_i));\
 35                           break;\
 36              case uchar_v: (_vi) = (unsigned char) VECTOR_UCHAR((_v), (_i));\
 37                           break;\
 38              case short_v: (_vi) = (short) VECTOR_SHORT((_v), (_i));\
 39                  break;\
 40              case ushort_v: (_vi) = (unsigned short) VECTOR_USHORT((_v), (_i));\
 41                           break;\
 42              case int_v: (_vi) = (int) VECTOR_INT((_v), (_i));\
 43                           break;\
 44              case uint_v: (_vi) = (unsigned int) VECTOR_UINT((_v), (_i));\
 45                           break;\
 46              case float_v: (_vi) = (float) VECTOR_FLOAT((_v), (_i));\
 47                           break;\
 48              case double_v: (_vi) = (double) VECTOR_DOUBLE((_v), (_i));\
 49                           break;\
 50              case complex_v: (_vi) = (double) VECTOR_COMPLEX((_v), (_i)).x;\
 51                           break;\
 52              case ptr_v: (_vi) = (int) VECTOR_PTR((_v), (_i));\
 53                           break;\
 54              default:\
 55                           (_vi) = 0; /* dummy init: stops warnings */\
 56                           break;\
 57         }
 58 
 59 #define VECTOR_GETP(_v, _i, _vi) \
 60         switch ((_v)->vtype) \
 61         {\
 62              case char_v: (_vi) = &VECTOR_CHAR((_v), (_i));\
 63                           break;\
 64              case uchar_v: (_vi) = &VECTOR_UCHAR((_v), (_i));\
 65                           break;\
 66              case short_v: (_vi) = &VECTOR_SHORT((_v), (_i));\
 67                           break;\
 68              case ushort_v: (_vi) = &VECTOR_USHORT((_v), (_i));\
 69                           break;\
 70              case int_v: (_vi) = &VECTOR_INT((_v), (_i));\
 71                           break;\
 72              case uint_v: (_vi) = &VECTOR_UINT((_v), (_i));\
 73                           break;\
 74              case float_v: (_vi) = &VECTOR_FLOAT((_v), (_i));\
 75                           break;\
 76              case double_v: (_vi) = &VECTOR_DOUBLE((_v), (_i));\
 77                           break;\
 78              case complex_v: (_vi) = &VECTOR_COMPLEX((_v), (_i)).x;\
 79                           break;\
 80              case ptr_v: (_vi) = VECTOR_PTR((_v), (_i));\
 81                           break;\
 82              default:\
 83                           (_vi) = NULL; /* dummy init: stops warnings */\
 84                           break;\
 85         }
 86 
 87 #define VECTOR_GETZ(_v, _i, _vi) \
 88     {\
 89         if ((_v)->vtype == complex_v)\
 90             (_vi) = VECTOR_COMPLEX((_v), (_i));\
 91         else\
 92         {\
 93             VECTOR_GET((_v), (_i), (_vi).x);\
 94             (_vi).y = 0.0;\
 95         }\
 96     }
 97 
 98 #define VECTOR_SET(_v, _i, _vi) \
 99         switch ((_v)->vtype) \
100         {\
101              case char_v: VECTOR_CHAR((_v), (_i)) = (char) (_vi);\
102                           break;\
103              case uchar_v: VECTOR_UCHAR((_v), (_i)) = (unsigned char) (_vi);\
104                           break;\
105              case short_v: VECTOR_SHORT((_v), (_i)) = (short) (_vi);\
106                           break;\
107              case ushort_v: VECTOR_USHORT((_v), (_i)) = (unsigned short) (_vi);\
108                           break;\
109              case int_v: VECTOR_INT((_v), (_i)) = (int) (_vi);\
110                           break;\
111              case uint_v: VECTOR_UINT((_v), (_i)) = (unsigned int) (_vi);\
112                           break;\
113              case float_v: VECTOR_FLOAT((_v), (_i)) = (float) (_vi);\
114                           break;\
115              case double_v: VECTOR_DOUBLE((_v), (_i)) = (double) (_vi);\
116                           break;\
117              case complex_v: VECTOR_COMPLEX((_v), (_i)).x = (double) (_vi);\
118                           break;\
119              case ptr_v: VECTOR_PTR((_v), (_i)) = (void *) (int) (_vi);\
120                           break;\
121              default:\
122                           break;\
123         }
124 
125 #define VECTOR_SETP(_v, _i, _vi) \
126         switch ((_v)->vtype) \
127         {\
128              case char_v: VECTOR_CHAR((_v), (_i)) = *(char *)(_vi);\
129                           break;\
130              case uchar_v: VECTOR_UCHAR((_v), (_i)) = *(unsigned char *)(_vi);\
131                           break;\
132              case short_v: VECTOR_SHORT((_v), (_i)) = *(short *)(_vi);\
133                           break;\
134              case ushort_v: VECTOR_USHORT((_v), (_i)) = *(unsigned short *)(_vi);\
135                           break;\
136              case int_v: VECTOR_INT((_v), (_i)) = *(int *)(_vi);\
137                           break;\
138              case uint_v: VECTOR_UINT((_v), (_i)) = *(unsigned int *)(_vi);\
139                           break;\
140              case float_v: VECTOR_FLOAT((_v), (_i)) = *(float *)(_vi);\
141                           break;\
142              case double_v: VECTOR_DOUBLE((_v), (_i)) = *(double *)(_vi);\
143                           break;\
144              case complex_v: VECTOR_COMPLEX((_v), (_i)) = *(Complex *)(_vi);\
145                           break;\
146              case ptr_v: VECTOR_PTR((_v), (_i)) = (_vi);\
147                           break;\
148              default:\
149                           break;\
150         }
151 
152 #define VECTOR_SETZ(_v, _i, _vi)\
153     {\
154         if ((_v)->vtype == complex_v)\
155             VECTOR_COMPLEX((_v), (_i)) = (_vi);\
156         else\
157             VECTOR_SET((_v), (_i), (_vi).x);\
158     }
159 
160 #endif /*VECTOR_HEADS_DEFINED*/
161 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.