The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
wrapper.c
Go to the documentation of this file.
1 
30 #include <stdlib.h>
31 #include <string.h>
32 #include <core/timer.h>
33 #include <scheduler/scheduler.h>
34 #include <mm/dymelor.h>
35 
36 // Definitions to functions which will be wrapped by the linker
37 char *__real_strcpy(char *, const char *);
38 char *__real_strncpy(char *, const char *, size_t);
39 char *__real_strcat(char *, const char *);
40 char *__real_strncat(char *, const char *, size_t);
41 void *__real_memcpy(void *, const void *, size_t);
42 void *__real_memmove(void *, const void *, size_t);
43 void *__real_memset(void *, int, size_t);
44 
45 // Actual wrappers
46 char *__wrap_strcpy(char *s, const char *ct)
47 {
48  dirty_mem(s, -1);
49  return __real_strcpy(s, ct);
50 }
51 
52 char *__wrap_strncpy(char *s, const char *ct, size_t n)
53 {
54  dirty_mem((void *)s, n);
55  return __real_strncpy(s, ct, n);
56 }
57 
58 char *__wrap_strcat(char *s, const char *ct)
59 {
60  dirty_mem(s, -1);
61  return __real_strcat(s, ct);
62 }
63 
64 char *__wrap_strncat(char *s, const char *ct, size_t n)
65 {
66  dirty_mem(s, n);
67  return __real_strncat(s, ct, n);
68 }
69 
70 void *__wrap_memcpy(void *s, const void *ct, size_t n)
71 {
72  dirty_mem(s, n);
73  return __real_memcpy(s, ct, n);
74 }
75 
76 void *__wrap_memmove(void *s, const void *ct, size_t n)
77 {
78  dirty_mem(s, n);
79  return __real_memmove(s, ct, n);
80 }
81 
82 void *__wrap_memset(void *s, int c, size_t n)
83 {
84  dirty_mem(s, n);
85  return __real_memset(s, c, n);
86 }
87 
88 char *__wrap_strdup(const char *s)
89 {
90  char *ret = (char *)__wrap_malloc(strlen(s) + 1);
91  __real_strcpy(ret, s);
92  dirty_mem(ret, strlen(s));
93  return ret;
94 }
95 
96 char *__wrap_strndup(const char *s, size_t n)
97 {
98  char *ret = (char *)__wrap_malloc(n);
99  __real_strncpy(ret, s, n);
100  dirty_mem(ret, n);
101  return ret;
102 }
void dirty_mem(void *base, int size)
Definition: dymelor.c:453
Dynamic Memory Logger and Restorer (DyMeLoR)
Timers.
The ROOT-Sim scheduler main module header.
void * __wrap_malloc(size_t size)
Definition: dymelor.c:566