1 | /* $Id: VBoxDTraceLibCWrappers.h 53974 2015-01-27 17:50:17Z 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-2015 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 |
|
---|
21 | #ifndef ___VBoxDTraceLibCWrappers_h___
|
---|
22 | #define ___VBoxDTraceLibCWrappers_h___
|
---|
23 |
|
---|
24 | #include <assert.h>
|
---|
25 | #include <stdlib.h>
|
---|
26 | #include <string.h>
|
---|
27 | #ifdef RT_OS_WINDOWS
|
---|
28 | # include <process.h>
|
---|
29 | #else
|
---|
30 | # include <sys/types.h>
|
---|
31 | # include <limits.h> /* Workaround for syslimit.h bug in gcc 4.8.3 on gentoo. */
|
---|
32 | # include <syslimits.h> /* PATH_MAX */
|
---|
33 | # include <libgen.h> /* basename */
|
---|
34 | # include <unistd.h>
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #include <iprt/mem.h>
|
---|
38 | #include <iprt/process.h>
|
---|
39 | #include <iprt/param.h>
|
---|
40 | #include <iprt/alloca.h>
|
---|
41 | #include <iprt/assert.h>
|
---|
42 | #include <iprt/mem.h>
|
---|
43 | #include <iprt/string.h>
|
---|
44 | #include <iprt/time.h>
|
---|
45 |
|
---|
46 |
|
---|
47 | #undef gethrtime
|
---|
48 | #define gethrtime() RTTimeNanoTS()
|
---|
49 | #undef strcasecmp
|
---|
50 | #define strcasecmp(a_psz1, a_psz2) RTStrICmp(a_psz1, a_psz2)
|
---|
51 | #undef strncasecmp
|
---|
52 | #define strncasecmp(a_psz1, a_psz2, a_cch) RTStrNICmp(a_psz1, a_psz2, a_cch)
|
---|
53 | #undef strlcpy
|
---|
54 | #define strlcpy(a_pszDst, a_pszSrc, a_cbDst) ((void)RTStrCopy(a_pszDst, a_cbDst, a_pszSrc))
|
---|
55 |
|
---|
56 | #undef assert
|
---|
57 | #define assert(expr) Assert(expr)
|
---|
58 |
|
---|
59 | #undef PATH_MAX
|
---|
60 | #define PATH_MAX RTPATH_MAX
|
---|
61 |
|
---|
62 | #undef getpid
|
---|
63 | #define getpid RTProcSelf
|
---|
64 |
|
---|
65 | #undef basename
|
---|
66 | #define basename(a_pszPath) RTPathFilename(a_pszPath)
|
---|
67 |
|
---|
68 | #undef malloc
|
---|
69 | #define malloc(a_cb) RTMemAlloc(a_cb)
|
---|
70 | #undef calloc
|
---|
71 | #define calloc(a_cItems, a_cb) RTMemAllocZ((size_t)(a_cb) * (a_cItems))
|
---|
72 | #undef realloc
|
---|
73 | #define realloc(a_pvOld, a_cbNew) RTMemRealloc(a_pvOld, a_cbNew)
|
---|
74 | #undef free
|
---|
75 | #define free(a_pv) RTMemFree(a_pv)
|
---|
76 |
|
---|
77 | /* Not using RTStrDup and RTStrNDup here because the allocation won't be freed
|
---|
78 | by RTStrFree and thus may cause trouble when using the efence. */
|
---|
79 | #undef strdup
|
---|
80 | #define strdup(a_psz) ((char *)RTMemDup(a_psz, strlen(a_psz) + 1))
|
---|
81 | #undef strndup
|
---|
82 | #define strndup(a_psz, a_cchMax) ((char *)RTMemDupEx(a_psz, RTStrNLen(a_psz, a_cchMax), 1))
|
---|
83 |
|
---|
84 | #endif
|
---|
85 |
|
---|