1 | /* $Id: VBoxDTraceLibCWrappers.h 69500 2017-10-28 15:14:05Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxDTraceTLibCWrappers.h - IPRT wrappers/fake for lib C stuff.
|
---|
4 | *
|
---|
5 | * Contributed by: bird
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2012-2017 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the Common
|
---|
14 | * Development and Distribution License Version 1.0 (CDDL) only, as it
|
---|
15 | * comes in the "COPYING.CDDL" file of the VirtualBox OSE distribution.
|
---|
16 | * VirtualBox OSE is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #ifndef ___VBoxDTraceLibCWrappers_h___
|
---|
21 | #define ___VBoxDTraceLibCWrappers_h___
|
---|
22 |
|
---|
23 | #include <assert.h>
|
---|
24 | #include <stdlib.h>
|
---|
25 | #include <string.h>
|
---|
26 | #ifdef RT_OS_WINDOWS
|
---|
27 | # include <process.h>
|
---|
28 | #else
|
---|
29 | # include <sys/types.h>
|
---|
30 | # include <limits.h> /* Workaround for syslimit.h bug in gcc 4.8.3 on gentoo. */
|
---|
31 | # ifdef RT_OS_DARWIN
|
---|
32 | # include <sys/syslimits.h> /* PATH_MAX */
|
---|
33 | # elif !defined(RT_OS_SOLARIS)
|
---|
34 | # include <syslimits.h> /* PATH_MAX */
|
---|
35 | # endif
|
---|
36 | # include <libgen.h> /* basename */
|
---|
37 | # include <unistd.h>
|
---|
38 | # include <strings.h> /* bzero & bcopy.*/
|
---|
39 | #endif
|
---|
40 |
|
---|
41 | #include <iprt/mem.h>
|
---|
42 | #include <iprt/process.h>
|
---|
43 | #include <iprt/param.h>
|
---|
44 | #include <iprt/alloca.h>
|
---|
45 | #include <iprt/assert.h>
|
---|
46 | #include <iprt/mem.h>
|
---|
47 | #include <iprt/string.h>
|
---|
48 | #include <iprt/time.h>
|
---|
49 |
|
---|
50 |
|
---|
51 | #undef gethrtime
|
---|
52 | #define gethrtime() RTTimeNanoTS()
|
---|
53 | #undef strcasecmp
|
---|
54 | #define strcasecmp(a_psz1, a_psz2) RTStrICmp(a_psz1, a_psz2)
|
---|
55 | #undef strncasecmp
|
---|
56 | #define strncasecmp(a_psz1, a_psz2, a_cch) RTStrNICmp(a_psz1, a_psz2, a_cch)
|
---|
57 | #undef strlcpy
|
---|
58 | #define strlcpy(a_pszDst, a_pszSrc, a_cbDst) ((void)RTStrCopy(a_pszDst, a_cbDst, a_pszSrc))
|
---|
59 |
|
---|
60 | #undef assert
|
---|
61 | #define assert(expr) Assert(expr)
|
---|
62 |
|
---|
63 | #undef PATH_MAX
|
---|
64 | #define PATH_MAX RTPATH_MAX
|
---|
65 |
|
---|
66 | #undef getpid
|
---|
67 | #define getpid RTProcSelf
|
---|
68 |
|
---|
69 | #undef basename
|
---|
70 | #define basename(a_pszPath) RTPathFilename(a_pszPath)
|
---|
71 |
|
---|
72 | #undef malloc
|
---|
73 | #define malloc(a_cb) RTMemAlloc(a_cb)
|
---|
74 | #undef calloc
|
---|
75 | #define calloc(a_cItems, a_cb) RTMemAllocZ((size_t)(a_cb) * (a_cItems))
|
---|
76 | #undef realloc
|
---|
77 | #define realloc(a_pvOld, a_cbNew) RTMemRealloc(a_pvOld, a_cbNew)
|
---|
78 | #undef free
|
---|
79 | #define free(a_pv) RTMemFree(a_pv)
|
---|
80 |
|
---|
81 | /* Not using RTStrDup and RTStrNDup here because the allocation won't be freed
|
---|
82 | by RTStrFree and thus may cause trouble when using the efence. */
|
---|
83 | #undef strdup
|
---|
84 | #define strdup(a_psz) ((char *)RTMemDup(a_psz, strlen(a_psz) + 1))
|
---|
85 | #undef strndup
|
---|
86 | #define strndup(a_psz, a_cchMax) ((char *)RTMemDupEx(a_psz, RTStrNLen(a_psz, a_cchMax), 1))
|
---|
87 |
|
---|
88 | /* For various stupid reasons, these are duplicated in VBoxDTraceTypes.h. */
|
---|
89 | #undef bcopy
|
---|
90 | #define bcopy(a_pSrc, a_pDst, a_cb) ((void)memmove(a_pDst, a_pSrc, a_cb))
|
---|
91 | #undef bzero
|
---|
92 | #define bzero(a_pDst, a_cb) ((void)memset(a_pDst, 0, a_cb))
|
---|
93 | #undef bcmp
|
---|
94 | #define bcmp(a_p1, a_p2, a_cb) (memcmp(a_p1, a_p2, a_cb))
|
---|
95 |
|
---|
96 | #endif
|
---|
97 |
|
---|