VirtualBox

source: vbox/trunk/src/VBox/ExtPacks/VBoxDTrace/include/VBoxDTraceLibCWrappers.h@ 60441

Last change on this file since 60441 was 53998, checked in by vboxsync, 10 years ago

bzero/bcopy fixes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/* $Id: VBoxDTraceLibCWrappers.h 53998 2015-01-28 00:13:07Z 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# ifndef RT_OS_SOLARIS
33# include <syslimits.h> /* PATH_MAX */
34# endif
35# include <libgen.h> /* basename */
36# include <unistd.h>
37# include <strings.h> /* bzero & bcopy.*/
38#endif
39
40#include <iprt/mem.h>
41#include <iprt/process.h>
42#include <iprt/param.h>
43#include <iprt/alloca.h>
44#include <iprt/assert.h>
45#include <iprt/mem.h>
46#include <iprt/string.h>
47#include <iprt/time.h>
48
49
50#undef gethrtime
51#define gethrtime() RTTimeNanoTS()
52#undef strcasecmp
53#define strcasecmp(a_psz1, a_psz2) RTStrICmp(a_psz1, a_psz2)
54#undef strncasecmp
55#define strncasecmp(a_psz1, a_psz2, a_cch) RTStrNICmp(a_psz1, a_psz2, a_cch)
56#undef strlcpy
57#define strlcpy(a_pszDst, a_pszSrc, a_cbDst) ((void)RTStrCopy(a_pszDst, a_cbDst, a_pszSrc))
58
59#undef assert
60#define assert(expr) Assert(expr)
61
62#undef PATH_MAX
63#define PATH_MAX RTPATH_MAX
64
65#undef getpid
66#define getpid RTProcSelf
67
68#undef basename
69#define basename(a_pszPath) RTPathFilename(a_pszPath)
70
71#undef malloc
72#define malloc(a_cb) RTMemAlloc(a_cb)
73#undef calloc
74#define calloc(a_cItems, a_cb) RTMemAllocZ((size_t)(a_cb) * (a_cItems))
75#undef realloc
76#define realloc(a_pvOld, a_cbNew) RTMemRealloc(a_pvOld, a_cbNew)
77#undef free
78#define free(a_pv) RTMemFree(a_pv)
79
80/* Not using RTStrDup and RTStrNDup here because the allocation won't be freed
81 by RTStrFree and thus may cause trouble when using the efence. */
82#undef strdup
83#define strdup(a_psz) ((char *)RTMemDup(a_psz, strlen(a_psz) + 1))
84#undef strndup
85#define strndup(a_psz, a_cchMax) ((char *)RTMemDupEx(a_psz, RTStrNLen(a_psz, a_cchMax), 1))
86
87/* For various stupid reasons, these are duplicated in VBoxDTraceTypes.h. */
88#undef bcopy
89#define bcopy(a_pSrc, a_pDst, a_cb) ((void)memmove(a_pDst, a_pSrc, a_cb))
90#undef bzero
91#define bzero(a_pDst, a_cb) ((void)memset(a_pDst, 0, a_cb))
92#undef bcmp
93#define bcmp(a_p1, a_p2, a_cb) (memcmp(a_p1, a_p2, a_cb))
94
95#endif
96
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette