AFHBA404
AFHBA404 connects ACQ2106 to PCI-Express
local.h
Go to the documentation of this file.
1
2
#ifndef _LOCAL_H_
3
#define _LOCAL_H_
4
5
6
/*
7
* String Handling
8
*/
9
10
#ifndef __KERNEL__
11
#include <string.h>
12
#endif
13
14
#define STREQ( s1, s2 ) (strcmp( s1, s2 ) == 0)
15
#define STREQN( s1, s2, n ) (strncmp( s1, s2, n ) == 0)
16
#define STREQNL( s1, s2 ) (strncmp( s1, s2, strlen(s2) ) == 0)
17
18
/*
19
* Range Checking and simple math
20
*/
21
22
#define IN_RANGE(xx,ll,rr) ((xx)>=(ll)&&(xx)<=(rr))
23
#define CLAMP(xx,ll,rr) ((xx) = (xx)<(ll)? (ll): (xx)>(rr)? (rr): (xx))
24
#define SWAP(aa,bb,tt) ( tt = aa, aa = bb, bb = tt )
25
26
#define MAX(aa,bb) ((aa)>=(bb)?(aa):(bb))
27
#define MIN(aa,bb) ((aa)<=(bb)?(aa):(bb))
28
29
30
#define ABS(aa) ((aa)>0?(aa):-(aa))
31
#define SQR(aa) ((aa)*(aa))
32
#define SIGN(aa) ((aa)>=0? 1: -1)
33
34
35
/*
36
* boolean values
37
*/
38
39
#ifndef OK
40
#define OK 0
41
#endif
42
#ifndef ERR
43
#define ERR -1
44
#endif
45
#ifndef FALSE
46
#define FALSE 0
47
#endif
48
#ifndef TRUE
49
#define TRUE 1
50
#endif
51
#ifndef ON
52
#define ON 1
53
#endif
54
#ifndef OFF
55
#define OFF 0
56
#endif
57
58
59
#define __U32__
60
typedef
unsigned
u32
;
61
typedef
unsigned
short
u16
;
62
typedef
unsigned
char
u8
;
63
64
#if defined __cplusplus
65
extern
"C"
{
66
#endif
67
68
extern
int
acq200_debug
;
69
70
#if defined __cplusplus
71
};
72
#endif
73
74
75
#ifndef FN
76
#define FN __FUNCTION__
77
#endif
78
79
#include <sys/syslog.h>
80
81
82
#ifndef PROCLOGNAME
83
#define PROCLOGNAME "acq200control"
84
#endif
85
86
#define ACQ200_SYSLOG_SCREEN 1
87
#define ACQ200_SYSLOG_SYSLOG 2
88
89
#ifndef ACQ200_SYSLOG_MODE
90
#define ACQ200_SYSLOG_MODE (ACQ200_SYSLOG_SCREEN|ACQ200_SYSLOG_SYSLOG)
91
#endif
92
93
#if ((ACQ200_SYSLOG_MODE & ACQ200_SYSLOG_SCREEN) != 0)
94
#define _ACQ200_SYSLOG_SCREEN(pri, fmt, args...) fprintf(stderr, fmt, ##args)
95
#else
96
#define _ACQ200_SYSLOG_SCREEN(pri, fmt, args...)
97
#endif
98
99
#if ((ACQ200_SYSLOG_MODE & ACQ200_SYSLOG_SYSLOG) != 0)
100
#define _ACQ200_SYSLOG_SYSLOG(pri, fmt, args...)\
101
do { \
102
openlog(PROCLOGNAME, 0, LOG_USER); \
103
syslog(pri, fmt, ## args); \
104
closelog(); \
105
} while (0)
106
#else
107
#define _ACQ200_SYSLOG_SYSLOG(pri, fmt, args...)
108
#endif
109
110
111
#define ACQ200_SYSLOG(pri, fmt, args...) \
112
do { \
113
_ACQ200_SYSLOG_SCREEN(pri, fmt, ## args); \
114
_ACQ200_SYSLOG_SYSLOG(pri, fmt, ## args); \
115
}while(0)
116
117
//#define info(fmt, arg...) printf("%s:" fmt "\n", FN, ## arg)
118
#define info(format, arg...) \
119
ACQ200_SYSLOG(LOG_INFO, "%s " format "\n", FN, ## arg )
120
121
#define err(format, arg...) \
122
ACQ200_SYSLOG(LOG_ERR, "%s ERROR:" format "\n", FN, ## arg )
123
124
#define dbg(lvl, format, arg...) \
125
do { \
126
if(acq200_debug>=lvl ){ \
127
if (lvl <= 1){ \
128
ACQ200_SYSLOG( LOG_DEBUG, \
129
"%s " format "\n", \
130
FN, ## arg ); \
131
}else{ \
132
fprintf(stderr, \
133
"deb(%d) %s " format "\n", \
134
lvl, FN, ## arg ); \
135
} \
136
} \
137
} while(0)
138
139
static
inline
char
* chomp(
char
*src) {
140
char
*plast = src + strlen(src) - 1;
141
while
(*plast ==
'\n'
|| *plast ==
'\r'
){
142
*plast-- =
'\0'
;
143
if
(plast == src){
144
break
;
145
}
146
}
147
return
src;
148
}
149
150
static
inline
char
* tr(
char
*src,
char
c1,
char
c2){
151
int
ii = 0;
152
int
i2 = strlen(src);
153
for
(ii = 0; ii < i2; ii++){
154
if
(src[ii] == c1){
155
src[ii] = c2;
156
}
157
}
158
return
src;
159
}
160
161
#define dbgnl(lvl, format, arg...) \
162
do { \
163
if(acq200_debug>=lvl ){ \
164
if (lvl <= 1) \
165
ACQ200_SYSLOG( LOG_DEBUG, "%s " format, \
166
FN, ## arg ); \
167
fprintf(stderr, \
168
"deb(%d) %s " format, \
169
lvl, FN, ## arg ); \
170
} \
171
} while(0)
172
173
174
175
176
177
#endif
u16
unsigned short u16
Definition:
local.h:61
acq200_debug
int acq200_debug
Definition:
mmap.c:76
u8
unsigned char u8
Definition:
local.h:62
u32
unsigned u32
Definition:
local.h:60
Generated by
1.8.18