00001 #define pgm_getchar getchar
00002 #ifdef __arm
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 #ifndef _LOCAL_H_
00088 #define _LOCAL_H_
00089
00090
00091
00092
00093
00094
00095 #ifndef __KERNEL__
00096 #include <string.h>
00097 #endif
00098
00099 #define STREQ( s1, s2 ) (strcmp( s1, s2 ) == 0)
00100 #define STREQN( s1, s2, n ) (strncmp( s1, s2, n ) == 0)
00101 #define STREQNL( s1, s2 ) (strncmp( s1, s2, strlen(s2) ) == 0)
00102
00103 #define ATOL( s1 ) (unsigned)strtoul( s1, NULL, 0 )
00104
00105
00106
00107
00108
00109
00110 #define IN_RANGE(xx,ll,rr) ((xx)>=(ll)&&(xx)<=(rr))
00111 #define CLAMP(xx,ll,rr) ((xx) = (xx)<(ll)? (ll): (xx)>(rr)? (rr): (xx))
00112 #define SWAP(aa,bb,tt) ( tt = aa, aa = bb, bb = tt )
00113
00114 #define MAX(aa,bb) ((aa)>=(bb)?(aa):(bb))
00115 #define MIN(aa,bb) ((aa)<=(bb)?(aa):(bb))
00116
00117
00118 #define ABS(aa) ((aa)>0?(aa):-(aa))
00119 #define SQR(aa) ((aa)*(aa))
00120 #define SIGN(aa) ((aa)>=0? 1: -1)
00121
00122
00123
00124
00125
00126
00127 #ifndef OK
00128 #define OK 0
00129 #endif
00130 #ifndef ERR
00131 #define ERR -1
00132 #endif
00133 #ifndef FALSE
00134 #define FALSE 0
00135 #endif
00136 #ifndef TRUE
00137 #define TRUE 1
00138 #endif
00139 #ifndef ON
00140 #define ON 1
00141 #endif
00142 #ifndef OFF
00143 #define OFF 0
00144 #endif
00145
00146 extern int P_debug;
00147
00148 #define PRINTF if ( P_debug ) printf
00149 #define PRINTFL(n) if ( P_debug > n ) printf
00150 #define PRINTID PRINTF( __FILE__ ":%d\n", __LINE__ )
00151
00152 #define ST_PRINTF if ( P_debug<0) printf
00153
00154 #define SUCCESS 1
00155 #define FAIL (!SUCCESS)
00156
00157
00158
00159 extern void makeAssertion( char* file, int line );
00160
00161 #define ARM_ASSERT( cond ) \
00162 if (!(cond)) makeAssertion( __FILE__, __LINE__ )
00163
00164
00165
00166
00167
00168
00169 #define KB 0x400
00170 #define MB 0x100000
00171
00172
00173 #define WORKTODO (-1)
00174 #ifdef __arm
00175
00176 #ifndef NO_PGM_PRINTF
00177
00178 extern int pgm_printf( char fmt[], ... );
00179 extern int pgm_fgets( char buf[], int maxbuf );
00180
00181 #define printf pgm_printf
00182 #define fflush( stream )
00183 #define fgets( a, b, c ) pgm_fgets( a, b )
00184
00185 #endif // NO_PGM_PRINTF
00186
00187 #endif // __arm
00188
00189 typedef unsigned u32;
00190 typedef unsigned short u16;
00191 typedef unsigned char u8;
00192
00193 #endif
00194
00195
00196 #else // __arm ... the else is all but arm
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 #ifndef _LOCAL_H_
00266 #define _LOCAL_H_
00267
00268
00269 #ifdef __KERNEL__
00270 #include <linux/version.h>
00271
00272 #ifndef VERSION_CODE
00273 # define VERSION_CODE(vers,rel,seq) ( ((vers)<<16) | ((rel)<<8) | (seq) )
00274 #endif
00275
00276
00277
00278
00279
00280
00281
00282 #if LINUX_VERSION_CODE > VERSION_CODE(2,4,18)
00283 #define RH9
00284 #endif
00285
00286
00287
00288
00289
00290 #if (LINUX_VERSION_CODE < 0x020600)
00291 #error NO KERNEL_26
00292 #include <asm/current.h>
00293 #endif
00294 #endif
00295
00296
00297
00298 #ifndef __KERNEL__
00299 #include <string.h>
00300 #endif
00301
00302 #define STREQ( s1, s2 ) (strcmp( s1, s2 ) == 0)
00303 #define STREQN( s1, s2, n ) (strncmp( s1, s2, n ) == 0)
00304 #define STREQNL( s1, s2 ) (strncmp( s1, s2, strlen(s2) ) == 0)
00305
00306
00307
00308
00309
00310
00311 #define IN_RANGE(xx,ll,rr) ((xx)>=(ll)&&(xx)<=(rr))
00312 #define CLAMP(xx,ll,rr) ((xx) = (xx)<(ll)? (ll): (xx)>(rr)? (rr): (xx))
00313 #define SWAP(aa,bb,tt) ( tt = aa, aa = bb, bb = tt )
00314
00315 #define MAX(aa,bb) ((aa)>=(bb)?(aa):(bb))
00316 #define MIN(aa,bb) ((aa)<=(bb)?(aa):(bb))
00317
00318
00319 #define ABS(aa) ((aa)>=0?(aa):-(aa))
00320 #define SQR(aa) ((aa)*(aa))
00321 #define SIGN(aa) ((aa)>=0? 1: -1)
00322
00323
00324
00325
00326
00327
00328 #ifndef OK
00329 #define OK 0
00330 #endif
00331 #ifndef ERR
00332 #define ERR -1
00333 #endif
00334 #ifndef FALSE
00335 #define FALSE 0
00336 #endif
00337 #ifndef TRUE
00338 #define TRUE 1
00339 #endif
00340 #ifndef ON
00341 #define ON 1
00342 #endif
00343 #ifndef OFF
00344 #define OFF 0
00345 #endif
00346
00347
00348
00349
00350
00351
00352 #undef PDEBUG
00353
00354 #ifndef NDEBUG
00355 # ifdef __KERNEL__
00356
00357 # define PDEBUG(fmt, args...) printk( KERN_DEBUG "acq32: " fmt, ## args)
00358 # else
00359
00360 # define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
00361 # endif
00362 #else
00363 # define PDEBUG(fmt, args...)
00364 #endif
00365
00366 #undef PDEBUGG
00367 #define PDEBUGG(fmt, args...)
00368
00369
00370
00371
00372
00373
00374 #define KB 0x400
00375 #define MB 0x100000
00376
00377
00378
00379
00380
00381 #ifndef NDEBUG
00382 # ifdef __KERNEL__
00383
00384
00385
00386
00387
00388 # define ASSERT( cond ) \
00389 if ( !(cond) ){ \
00390 PDEBUG( "ASSERTION: %s %d", __FILE__, __LINE__ );\
00391 while(1) schedule();\
00392 }
00393 # else
00394 # define ASSERT( cond ) \
00395 if ( !(cond) ){ \
00396 fprintf( stderr, "ASSERTION: %s %d",__FILE__,__LINE__ );\
00397 exit( 1 );\
00398 }
00399 # endif
00400 #else
00401 # define ASSERT( cond )
00402 #endif // NDEBUG
00403
00404 #define WORKTODO (-1)
00405
00406 #endif
00407
00408
00409
00410 #endif //_arm
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422