--- a/model/libc-dce.cc Thu Jul 12 14:01:05 2012 +0900
+++ b/model/libc-dce.cc Thu Jul 12 19:47:19 2012 +0900
@@ -141,6 +141,7 @@
#define DCE(name) (*libc)->name ## _fn = (func_t)(__typeof(&name))dce_ ## name;
#define DCET(rtype,name) DCE(name)
+#define DCE_EXPLICIT(name,rtype,...) (*libc)->name ## _fn = dce_ ## name;
#define NATIVE(name) \
(*libc)->name ## _fn = (func_t)name;
--- a/model/libc-ns3.h Thu Jul 12 14:01:05 2012 +0900
+++ b/model/libc-ns3.h Thu Jul 12 19:47:19 2012 +0900
@@ -316,8 +316,7 @@
NATIVE_WITH_ALIAS2 (gmtime_r, localtime_r)
NATIVE (mktime)
NATIVE (strftime)
-//DCE_WITH_ALIAS2 (clock_gettime, __vdso_clock_gettime)
-DCE (clock_gettime)
+DCE_EXPLICIT (clock_gettime, int, clockid_t, struct timespec *)
// SYS/TIME.H
DCE (gettimeofday)
@@ -367,8 +366,8 @@
DCE (pthread_key_delete)
DCE (pthread_mutex_destroy)
DCE (pthread_mutex_init)
-DCE (pthread_mutex_lock)
-DCE (pthread_mutex_unlock)
+DCE_EXPLICIT (pthread_mutex_lock, int, pthread_mutex_t *)
+DCE_EXPLICIT (pthread_mutex_unlock, int, pthread_mutex_t *)
DCE (pthread_mutex_trylock)
DCE (pthread_mutexattr_init)
DCE (pthread_mutexattr_destroy)
@@ -381,8 +380,8 @@
DCE (pthread_cond_init)
DCE (pthread_cond_broadcast)
DCE (pthread_cond_signal)
-DCE (pthread_cond_timedwait)
-DCE (pthread_cond_wait)
+DCE_EXPLICIT (pthread_cond_timedwait, int, pthread_cond_t*, pthread_mutex_t*, const struct timespec *)
+DCE_EXPLICIT (pthread_cond_wait, int, pthread_cond_t*, pthread_mutex_t*)
DCE (pthread_condattr_destroy)
DCE (pthread_condattr_init)
NATIVE (pthread_rwlock_init)
@@ -537,6 +536,7 @@
#undef DCE
#undef DCET
+#undef DCE_EXPLICIT
#undef NATIVE
#undef NATIVE_WITH_ALIAS
#undef NATIVE_WITH_ALIAS2
--- a/model/libc.cc Thu Jul 12 14:01:05 2012 +0900
+++ b/model/libc.cc Thu Jul 12 19:47:19 2012 +0900
@@ -38,6 +38,38 @@
#define DCET(rtype,name) \
GCC_BUILTIN_APPLYT(rtype,name,name)
+/* From gcc/testsuite/gcc.dg/cpp/vararg2.c */
+/* C99 __VA_ARGS__ versions */
+#define c99_count(...) _c99_count1 ( , ##__VA_ARGS__)/* If only ## worked.*/
+#define _c99_count1(...) _c99_count2 (__VA_ARGS__,10,9,8,7,6,5,4,3,2,1,0)
+#define _c99_count2(_,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,n,...) n
+
+#define FULL_ARGS_0()
+#define FULL_ARGS_1(X0) X0 a0
+#define FULL_ARGS_2(X0,X1) X0 a0, X1 a1
+#define FULL_ARGS_3(X0,X1,X2) X0 a0, X1 a1, X2 a2
+#define FULL_ARGS_4(X0,X1,X2,X3) X0 a0, X1 a1, X2 a2, X3 a3
+#define FULL_ARGS_5(X0,X1,X2,X3,X4) X0 a0, X1 a1, X2 a2, X3 a3, X4 a4
+
+#define _ARGS_0()
+#define _ARGS_1(X0) a0
+#define _ARGS_2(X0,X1) a0, a1
+#define _ARGS_3(X0,X1,X2) a0, a1, a2
+#define _ARGS_4(X0,X1,X2,X3) a0, a1, a2, a3
+#define _ARGS_5(X0,X1,X2,X3,X4) a0, a1, a2, a3, a4
+
+#define CAT(a, ...) PRIMITIVE_CAT(a, __VA_ARGS__)
+#define PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
+
+#define FULL_ARGS(...) CAT(FULL_ARGS_,c99_count (__VA_ARGS__))(__VA_ARGS__)
+#define ARGS(...) CAT(_ARGS_,c99_count (__VA_ARGS__))(__VA_ARGS__)
+
+
+#define DCE_EXPLICIT(name,rtype,...) \
+ rtype name (FULL_ARGS(__VA_ARGS__)) \
+ { \
+ return g_libc.name ## _fn (ARGS(__VA_ARGS__)); \
+ }
#define DCE_WITH_ALIAS(name) \
GCC_BUILTIN_APPLY(__ ## name,name) \
--- a/model/libc.h Thu Jul 12 14:01:05 2012 +0900
+++ b/model/libc.h Thu Jul 12 19:47:19 2012 +0900
@@ -1,6 +1,10 @@
#ifndef LIBC_H
#define LIBC_H
+#define _SYS_SELECT_H
+#include <sys/types.h>
+#undef _SYS_SELECT_H
+
struct Libc
{
@@ -8,6 +12,7 @@
#define DCET(rtype, name) DCE(name)
+#define DCE_EXPLICIT(name,rtype,...) rtype (*name ## _fn)(__VA_ARGS__);
#include "libc-ns3.h"
};