25
|
1 |
support Fedora8, timerfd check in configure, macro improvements, fix the issue of scandir imcompatibility
|
|
2 |
|
26
|
3 |
diff -r ce273c5b2ef9 model/dce-dirent.cc
|
|
4 |
--- a/model/dce-dirent.cc Thu Sep 20 10:12:35 2012 +0900
|
|
5 |
+++ b/model/dce-dirent.cc Thu Sep 20 10:13:19 2012 +0900
|
25
|
6 |
@@ -236,9 +236,16 @@
|
|
7 |
rewinddir (dirp);
|
|
8 |
ds->fd = saveFd;
|
|
9 |
}
|
|
10 |
+
|
|
11 |
+#ifdef USE_SCANDIR_VOIDPTR
|
|
12 |
+int dce_scandir (const char *dirp, struct dirent ***namelist,
|
|
13 |
+ int (*filter)(const struct dirent *),
|
|
14 |
+ int (*compar)(const void *, const void *))
|
|
15 |
+#else
|
|
16 |
int dce_scandir (const char *dirp, struct dirent ***namelist,
|
|
17 |
int (*filter)(const struct dirent *),
|
|
18 |
int (*compar)(const struct dirent **, const struct dirent **))
|
|
19 |
+#endif
|
|
20 |
{
|
|
21 |
NS_LOG_FUNCTION (Current () << UtilsGetNodeId () );
|
|
22 |
NS_ASSERT (Current () != 0);
|
26
|
23 |
diff -r ce273c5b2ef9 model/dce-dirent.h
|
|
24 |
--- a/model/dce-dirent.h Thu Sep 20 10:12:35 2012 +0900
|
|
25 |
+++ b/model/dce-dirent.h Thu Sep 20 10:13:19 2012 +0900
|
25
|
26 |
@@ -35,9 +35,24 @@
|
|
27 |
int dce_closedir (DIR *dirp);
|
|
28 |
int dce_dirfd (DIR *dirp);
|
|
29 |
void dce_rewinddir (DIR *dirp);
|
|
30 |
+
|
|
31 |
+// For the compatibility of 4th argument of scandir()
|
|
32 |
+#define USE_SCANDIR_VOIDPTR
|
|
33 |
+#if defined( __GLIBC_PREREQ )
|
|
34 |
+# if __GLIBC_PREREQ(2,10)
|
|
35 |
+# undef USE_SCANDIR_VOIDPTR
|
|
36 |
+# endif
|
|
37 |
+#endif
|
|
38 |
+
|
|
39 |
+#ifdef USE_SCANDIR_VOIDPTR
|
|
40 |
+int dce_scandir (const char *dirp, struct dirent ***namelist,
|
|
41 |
+ int (*filter)(const struct dirent *),
|
|
42 |
+ int (*compar)(const void *, const void *));
|
|
43 |
+#else
|
|
44 |
int dce_scandir (const char *dirp, struct dirent ***namelist,
|
|
45 |
int (*filter)(const struct dirent *),
|
|
46 |
int (*compar)(const struct dirent **, const struct dirent **));
|
|
47 |
+#endif
|
|
48 |
|
|
49 |
#ifdef __cplusplus
|
|
50 |
}
|
26
|
51 |
diff -r ce273c5b2ef9 model/libc-dce.cc
|
|
52 |
--- a/model/libc-dce.cc Thu Sep 20 10:12:35 2012 +0900
|
|
53 |
+++ b/model/libc-dce.cc Thu Sep 20 10:13:19 2012 +0900
|
25
|
54 |
@@ -12,7 +12,9 @@
|
|
55 |
#include "sys/dce-mman.h"
|
|
56 |
#include "sys/dce-stat.h"
|
|
57 |
#include "sys/dce-select.h"
|
|
58 |
+#ifdef HAVE_SYS_TIMER_H
|
|
59 |
#include "sys/dce-timerfd.h"
|
|
60 |
+#endif
|
|
61 |
#include "dce-unistd.h"
|
|
62 |
#include "dce-netdb.h"
|
|
63 |
#include "dce-pthread.h"
|
26
|
64 |
@@ -68,7 +70,9 @@
|
25
|
65 |
#include <sys/ioctl.h>
|
|
66 |
#include <sys/io.h>
|
|
67 |
#include <sys/mman.h>
|
|
68 |
+#ifdef HAVE_SYS_TIMER_H
|
|
69 |
#include <sys/timerfd.h>
|
|
70 |
+#endif
|
|
71 |
#include <sys/time.h>
|
|
72 |
#include <sys/types.h>
|
|
73 |
#include <sys/resource.h>
|
26
|
74 |
@@ -146,6 +150,7 @@
|
25
|
75 |
#define DCE(name) (*libc)->name ## _fn = (func_t)(__typeof(&name))dce_ ## name;
|
|
76 |
#define DCET(rtype,name) DCE(name)
|
|
77 |
#define DCE_EXPLICIT(name,rtype,...) (*libc)->name ## _fn = dce_ ## name;
|
|
78 |
+#define NATIVE_EXPLICIT2(name,rtype,...) (*libc)->name ## _fn = name;
|
|
79 |
|
|
80 |
#define NATIVE(name) \
|
|
81 |
(*libc)->name ## _fn = (func_t)name;
|
26
|
82 |
diff -r ce273c5b2ef9 model/libc-ns3.h
|
|
83 |
--- a/model/libc-ns3.h Thu Sep 20 10:12:35 2012 +0900
|
|
84 |
+++ b/model/libc-ns3.h Thu Sep 20 10:13:19 2012 +0900
|
25
|
85 |
@@ -108,7 +108,7 @@
|
|
86 |
NATIVE (strerror_r)
|
|
87 |
NATIVE (strcoll)
|
|
88 |
NATIVE (memset)
|
|
89 |
-NATIVE (memcpy)
|
|
90 |
+NATIVE_EXPLICIT2 (memcpy, void *, void *, const void *, size_t)
|
|
91 |
NATIVE (bcopy)
|
|
92 |
NATIVE (memcmp)
|
|
93 |
NATIVE (memmove)
|
26
|
94 |
@@ -440,11 +440,14 @@
|
25
|
95 |
// CTYPE.H
|
|
96 |
NATIVE (toupper)
|
|
97 |
NATIVE (tolower)
|
|
98 |
+NATIVE (_tolower)
|
|
99 |
|
|
100 |
// SYS/TIMERFD.H
|
|
101 |
+#ifdef HAVE_SYS_TIMER_H
|
|
102 |
DCE (timerfd_create)
|
|
103 |
DCE (timerfd_settime)
|
|
104 |
DCE (timerfd_gettime)
|
|
105 |
+#endif /* HAVE_SYS_TIMER_H */
|
|
106 |
|
|
107 |
// NET/IF.H
|
|
108 |
DCE (if_nametoindex)
|
26
|
109 |
@@ -570,6 +573,7 @@
|
25
|
110 |
#undef NATIVE_WITH_ALIAS
|
|
111 |
#undef NATIVE_WITH_ALIAS2
|
|
112 |
#undef NATIVE_EXPLICIT
|
|
113 |
+#undef NATIVE_EXPLICIT2
|
|
114 |
#undef DCE_WITH_ALIAS
|
|
115 |
#undef DCE_WITH_ALIAS2
|
|
116 |
|
26
|
117 |
diff -r ce273c5b2ef9 model/libc.cc
|
|
118 |
--- a/model/libc.cc Thu Sep 20 10:12:35 2012 +0900
|
|
119 |
+++ b/model/libc.cc Thu Sep 20 10:13:19 2012 +0900
|
25
|
120 |
@@ -79,6 +79,12 @@
|
|
121 |
GCC_BUILTIN_APPLY(internal,name) \
|
|
122 |
weak_alias(internal, name);
|
|
123 |
|
|
124 |
+#define NATIVE_EXPLICIT2(name,rtype,...) \
|
|
125 |
+ rtype name (FULL_ARGS(__VA_ARGS__)) \
|
|
126 |
+ { \
|
|
127 |
+ return g_libc.name ## _fn (ARGS(__VA_ARGS__)); \
|
|
128 |
+ }
|
|
129 |
+
|
|
130 |
|
|
131 |
// Note: it looks like that the stdio.h header does
|
|
132 |
// not define putc and getc as macros if you include
|
26
|
133 |
diff -r ce273c5b2ef9 model/libc.h
|
|
134 |
--- a/model/libc.h Thu Sep 20 10:12:35 2012 +0900
|
|
135 |
+++ b/model/libc.h Thu Sep 20 10:13:19 2012 +0900
|
25
|
136 |
@@ -13,6 +13,7 @@
|
|
137 |
#define DCET(rtype, name) DCE(name)
|
|
138 |
|
|
139 |
#define DCE_EXPLICIT(name,rtype,...) rtype (*name ## _fn)(__VA_ARGS__);
|
|
140 |
+#define NATIVE_EXPLICIT2(name,rtype,...) rtype (*name ## _fn)(__VA_ARGS__);
|
|
141 |
#include "libc-ns3.h"
|
|
142 |
|
26
|
143 |
char* (*strpbrk_fn) (const char *s, const char *accept);
|
|
144 |
diff -r ce273c5b2ef9 test/dce-manager-test.cc
|
|
145 |
--- a/test/dce-manager-test.cc Thu Sep 20 10:12:35 2012 +0900
|
|
146 |
+++ b/test/dce-manager-test.cc Thu Sep 20 10:13:19 2012 +0900
|
|
147 |
@@ -163,7 +163,9 @@
|
25
|
148 |
{ "test-netdb", 3600, "", true },
|
|
149 |
{ "test-env", 0, "", false },
|
|
150 |
{ "test-cond", 0, "", false},
|
|
151 |
+#ifdef HAVE_SYS_TIMER_H
|
|
152 |
{ "test-timer-fd", 0, "", false},
|
|
153 |
+#endif
|
|
154 |
{ "test-stdlib", 0, "", false},
|
|
155 |
{ "test-fork", 0, "", false },
|
|
156 |
{ "test-select", 3600, "", true },
|
26
|
157 |
diff -r ce273c5b2ef9 test/test-poll.cc
|
|
158 |
--- a/test/test-poll.cc Thu Sep 20 10:12:35 2012 +0900
|
|
159 |
+++ b/test/test-poll.cc Thu Sep 20 10:13:19 2012 +0900
|
25
|
160 |
@@ -1,7 +1,6 @@
|
|
161 |
#include <stdlib.h>
|
|
162 |
#include <sys/time.h>
|
|
163 |
#include <sys/types.h>
|
|
164 |
-#include <sys/timerfd.h>
|
|
165 |
#include <unistd.h>
|
|
166 |
#include <pthread.h>
|
|
167 |
#include <stdio.h>
|
26
|
168 |
diff -r ce273c5b2ef9 test/test-select.cc
|
|
169 |
--- a/test/test-select.cc Thu Sep 20 10:12:35 2012 +0900
|
|
170 |
+++ b/test/test-select.cc Thu Sep 20 10:13:19 2012 +0900
|
25
|
171 |
@@ -2,7 +2,9 @@
|
|
172 |
#include <sys/time.h>
|
|
173 |
#include <sys/types.h>
|
|
174 |
#include <sys/select.h>
|
|
175 |
+#ifdef HAVE_SYS_TIMER_H
|
|
176 |
#include <sys/timerfd.h>
|
|
177 |
+#endif
|
|
178 |
#include <unistd.h>
|
|
179 |
#include <pthread.h>
|
|
180 |
#include <stdio.h>
|
|
181 |
@@ -18,6 +20,7 @@
|
|
182 |
#include "test-macros.h"
|
|
183 |
|
|
184 |
// test, that select () with timeout={0,0} exits immediately
|
|
185 |
+#ifdef HAVE_SYS_TIMER_H
|
|
186 |
static void
|
|
187 |
test_select_null_null (void)
|
|
188 |
{
|
|
189 |
@@ -58,6 +61,7 @@
|
|
190 |
|
|
191 |
close (timerfd);
|
|
192 |
}
|
|
193 |
+#endif
|
|
194 |
|
|
195 |
static bool
|
|
196 |
test_select_read (int fd, int timeOutSec, bool needSuccess)
|
|
197 |
@@ -771,6 +775,7 @@
|
|
198 |
TEST_ASSERT (FD_ISSET (sockfd, &wfds));
|
|
199 |
}
|
|
200 |
|
|
201 |
+#ifdef HAVE_SYS_TIMER_H
|
|
202 |
// test, that select () returns correctly if there is two fds for reading and only one available
|
|
203 |
// solved with else mustWait=false
|
|
204 |
static void test_select_rfds (void)
|
|
205 |
@@ -804,6 +809,7 @@
|
|
206 |
// no fds must be ready and select() should complete without errors
|
|
207 |
TEST_ASSERT_EQUAL (nfds, 1);
|
|
208 |
}
|
|
209 |
+#endif
|
|
210 |
|
|
211 |
int
|
|
212 |
main (int argc, char *argv[])
|
|
213 |
@@ -815,10 +821,14 @@
|
|
214 |
{
|
|
215 |
test_select_stdin ();
|
|
216 |
test_select_stdout_stdin ();
|
|
217 |
+#ifdef HAVE_SYS_TIMER_H
|
|
218 |
test_select_null_null ();
|
|
219 |
+#endif
|
|
220 |
test_select_stdout ();
|
|
221 |
test_select_rfds_wfds ();
|
|
222 |
+#ifdef HAVE_SYS_TIMER_H
|
|
223 |
test_select_rfds ();
|
|
224 |
+#endif
|
|
225 |
launch (client1, server1);
|
|
226 |
launch (client2, server2);
|
|
227 |
launch (client3, server3);
|
26
|
228 |
diff -r ce273c5b2ef9 wscript
|
|
229 |
--- a/wscript Thu Sep 20 10:12:35 2012 +0900
|
|
230 |
+++ b/wscript Thu Sep 20 10:13:19 2012 +0900
|
|
231 |
@@ -46,6 +46,7 @@
|
25
|
232 |
conf.check(header_name='sys/types.h', define_name='HAVE_SYS_TYPES_H', mandatory=False)
|
|
233 |
conf.check(header_name='sys/stat.h', define_name='HAVE_SYS_STAT_H', mandatory=False)
|
|
234 |
conf.check(header_name='dirent.h', define_name='HAVE_DIRENT_H', mandatory=False)
|
|
235 |
+ conf.check(header_name='sys/timerfd.h', define_name='HAVE_SYS_TIMER_H', mandatory=False)
|
|
236 |
|
26
|
237 |
if Options.options.enable_mpi:
|
|
238 |
conf.env.append_value ('DEFINES', 'DCE_MPI=1')
|
|
239 |
@@ -104,7 +105,9 @@
|
25
|
240 |
|
|
241 |
if Options.options.kernel_stack is not None and os.path.isdir(Options.options.kernel_stack):
|
|
242 |
conf.check(header_name='sim.h',
|
|
243 |
- includes=os.path.join(Options.options.kernel_stack, 'sim/include'))
|
|
244 |
+ includes=[os.path.join(Options.options.kernel_stack, 'sim/include'),
|
|
245 |
+ os.path.join(Options.options.kernel_stack, 'net-next-2.6/include')])
|
|
246 |
+
|
|
247 |
# conf.check()
|
|
248 |
conf.env['KERNEL_STACK'] = Options.options.kernel_stack
|
|
249 |
|
26
|
250 |
@@ -189,7 +192,6 @@
|
25
|
251 |
['test-netdb', []],
|
|
252 |
['test-env', []],
|
|
253 |
['test-cond', ['PTHREAD']],
|
|
254 |
- ['test-timer-fd', []],
|
|
255 |
['test-stdlib', []],
|
|
256 |
['test-select', ['PTHREAD']],
|
|
257 |
['test-random', []],
|
26
|
258 |
@@ -211,6 +213,10 @@
|
25
|
259 |
['test-tsearch', []],
|
|
260 |
['test-signal', []],
|
|
261 |
]
|
|
262 |
+
|
|
263 |
+ if module._bld.env['HAVE_SYS_TIMER_H']:
|
|
264 |
+ tests = tests + [['test-timer-fd', []]]
|
|
265 |
+
|
|
266 |
for name,uselib in tests:
|
|
267 |
module.add_test(**dce_kw(target='bin_dce/' + name, source = ['test/' + name + '.cc'],
|
|
268 |
use = uselib + ['lib/test']))
|
26
|
269 |
@@ -218,7 +224,6 @@
|
25
|
270 |
def build_dce_examples(module):
|
|
271 |
dce_examples = [['udp-server', []],
|
|
272 |
['udp-client', []],
|
|
273 |
- ['udp-perf', ['m']],
|
|
274 |
['tcp-server', []],
|
|
275 |
['tcp-client', []],
|
|
276 |
['tcp-loopback', []],
|
26
|
277 |
@@ -228,6 +233,9 @@
|
25
|
278 |
['udp-echo-client', []],
|
|
279 |
# ['little-cout', []],
|
|
280 |
]
|
|
281 |
+ if module._bld.env['HAVE_SYS_TIMER_H']:
|
|
282 |
+ dce_examples = dce_examples + [['udp-perf', ['m']]]
|
|
283 |
+
|
|
284 |
for name,lib in dce_examples:
|
|
285 |
module.add_example(**dce_kw(target = 'bin_dce/' + name,
|
|
286 |
source = ['example/' + name + '.cc'],
|
26
|
287 |
@@ -376,7 +384,6 @@
|
25
|
288 |
'model/dce-string.cc',
|
|
289 |
'model/dce-env.cc',
|
|
290 |
'model/dce-pthread-cond.cc',
|
|
291 |
- 'model/dce-timerfd.cc',
|
|
292 |
'model/dce-time.cc',
|
|
293 |
'model/dce-stat.cc',
|
|
294 |
'model/dce-syslog.cc',
|
26
|
295 |
@@ -443,6 +450,10 @@
|
25
|
296 |
'helper/linux-stack-helper.h',
|
|
297 |
'helper/ipv4-dce-routing-helper.h',
|
|
298 |
]
|
|
299 |
+
|
|
300 |
+ if bld.env['HAVE_SYS_TIMER_H']:
|
|
301 |
+ module_source = module_source + ['model/dce-timerfd.cc']
|
|
302 |
+
|
|
303 |
module_source = module_source + kernel_source
|
|
304 |
module_headers = module_headers + kernel_headers
|
|
305 |
uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet', 'netlink'])
|