ns-3 Direct Code Execution
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
libc-dce.cc
Go to the documentation of this file.
1 #define _GNU_SOURCE 1
2 #undef __OPTIMIZE__
3 #define _LARGEFILE64_SOURCE 1
4 
5 #include "libc-dce.h"
6 #include "libc.h"
7 
8 #include "arpa/dce-inet.h"
9 #include "sys/dce-socket.h"
10 #include "sys/dce-time.h"
11 #include "sys/dce-ioctl.h"
12 #include "sys/dce-mman.h"
13 #include "sys/dce-stat.h"
14 #include "sys/dce-select.h"
15 #include "sys/dce-timerfd.h"
16 #include "dce-unistd.h"
17 #include "dce-netdb.h"
18 #include "dce-pthread.h"
19 #include "dce-stdio.h"
20 #include "dce-stdarg.h"
21 #include "dce-errno.h"
22 #include "dce-libc-private.h"
23 #include "dce-fcntl.h"
24 #include "dce-sched.h"
25 #include "dce-poll.h"
26 #include "dce-signal.h"
27 #include "dce-stdlib.h"
28 #include "dce-time.h"
29 #include "dce-semaphore.h"
30 #include "dce-cxa.h"
31 #include "dce-string.h"
32 #include "dce-global-variables.h"
33 #include "dce-random.h"
34 #include "dce-umask.h"
35 #include "dce-misc.h"
36 #include "dce-wait.h"
37 #include "dce-locale.h"
38 #include "net/dce-if.h"
39 #include "dce-syslog.h"
40 #include "dce-pwd.h"
41 #include "dce-dirent.h"
42 #include "dce-vfs.h"
43 #include "dce-termio.h"
44 
45 #include <arpa/inet.h>
46 #include <ctype.h>
47 #include <fcntl.h>
48 #include <getopt.h>
49 #include <grp.h>
50 #include <ifaddrs.h>
51 #include <sys/uio.h>
52 #include <libgen.h>
53 #include <locale.h>
54 #include <netdb.h>
55 #include <net/if.h>
56 #include <netinet/in.h>
57 #include <poll.h>
58 #include <semaphore.h>
59 #include <signal.h>
60 #include <stdio.h>
61 #include <stdio_ext.h>
62 #include <stddef.h>
63 #include <stdarg.h>
64 #include <stdint.h>
65 #include <stdlib.h>
66 #include <string.h>
67 #include <syslog.h>
68 #include <sys/dir.h>
69 #include <sys/ioctl.h>
70 #include <sys/io.h>
71 #include <sys/mman.h>
72 #include <sys/timerfd.h>
73 #include <sys/time.h>
74 #include <sys/types.h>
75 #include <sys/resource.h>
76 #include <sys/socket.h>
77 #include <sys/stat.h>
78 #include <sys/utsname.h>
79 #include <sys/wait.h>
80 #include <pthread.h>
81 #include <pwd.h>
82 #include <time.h>
83 #include <unistd.h>
84 #include <wchar.h>
85 #include <wctype.h>
86 #include <xlocale.h>
87 #include <errno.h>
88 #include <setjmp.h>
89 #include <libintl.h>
90 #include <pwd.h>
91 #include <inttypes.h>
92 #include <error.h>
93 #include <netinet/ether.h>
94 #include <search.h>
95 #include <fnmatch.h>
96 #include <langinfo.h>
97 #include <sys/vfs.h>
98 #include <termio.h>
99 #include <math.h>
100 #include <assert.h>
101 
102 extern void __cxa_finalize (void *d);
103 extern int __cxa_atexit (void (*func)(void *), void *arg, void *d);
104 
105 extern int (*__gxx_personality_v0)(int a, int b,
106  unsigned c,
107  struct _Unwind_Exception *d,
108  struct _Unwind_Context *e);
109 
110 // extern int __gxx_personality_v0 (int a, int b,
111 // unsigned c, struct _Unwind_Exception *d, struct _Unwind_Context *e);
112 // extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen);
113 extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen);
114 
115 // from glibc's string.h
116 extern char * __strcpy_chk (char *__restrict __dest,
117  const char *__restrict __src,
118  size_t __destlen);
119 // from glibc's stdio.h
120 extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
121 extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
122 __THROW;
123 extern int __vsprintf_chk (char *, int, size_t, const char *,
124  _G_va_list) __THROW;
125 extern int __vsnprintf_chk (char *, size_t, int, size_t, const char *,
126  _G_va_list) __THROW;
127 extern int __printf_chk (int, const char *, ...);
128 extern int __fprintf_chk (FILE *, int, const char *, ...);
129 extern int __vprintf_chk (int, const char *, _G_va_list);
130 extern int __vfprintf_chk (FILE *, int, const char *, _G_va_list);
131 extern char * __fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp);
132 extern char * __fgets_chk (char *buf, size_t size, int n, FILE *fp);
133 extern int __asprintf_chk (char **, int, const char *, ...) __THROW;
134 extern int __vasprintf_chk (char **, int, const char *, _G_va_list) __THROW;
135 extern int __dprintf_chk (int, int, const char *, ...);
136 extern int __vdprintf_chk (int, int, const char *, _G_va_list);
137 extern int __obstack_printf_chk (struct obstack *, int, const char *, ...)
138 __THROW;
139 extern int __obstack_vprintf_chk (struct obstack *, int, const char *,
140  _G_va_list) __THROW;
141 
142 typedef void (*func_t)(...);
143 
144 extern "C" {
145 
146 void libc_dce (struct Libc **libc)
147 {
148  *libc = new Libc;
149 
150 #define DCE(name) (*libc)->name ## _fn = (func_t)(__typeof (&name))dce_ ## name;
151 #define DCET(rtype,name) DCE (name)
152 #define DCE_EXPLICIT(name,rtype,...) (*libc)->name ## _fn = dce_ ## name;
153 
154 #define NATIVE(name) \
155  (*libc)->name ## _fn = (func_t)name;
156 #define NATIVET(rtype, name) NATIVE(name)
157 
158 #define NATIVE_EXPLICIT(name, type) \
159  (*libc)->name ## _fn = (func_t)((type)name);
160 
161 #include "libc-ns3.h"
162 
163  (*libc)->strpbrk_fn = dce_strpbrk;
164  (*libc)->strstr_fn = dce_strstr;
165  (*libc)->vsnprintf_fn = dce_vsnprintf;
166 }
167 } // extern "C"
168