VirtualBox

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

Last change on this file since 77108 was 77108, checked in by vboxsync, 6 years ago

ExtPacks/VBoxDTrace: FreeBSD compile fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: VBoxDTraceLibCWrappers.h 77108 2019-02-01 10:35:33Z 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-2019 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 VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceLibCWrappers_h
21#define VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceLibCWrappers_h
22#ifndef RT_WITHOUT_PRAGMA_ONCE
23# pragma once
24#endif
25
26#include <assert.h>
27#include <stdlib.h>
28#include <string.h>
29#ifdef RT_OS_WINDOWS
30# include <process.h>
31#else
32# include <sys/types.h>
33# include <limits.h> /* Workaround for syslimit.h bug in gcc 4.8.3 on gentoo. */
34# ifdef RT_OS_DARWIN
35# include <sys/syslimits.h> /* PATH_MAX */
36# elif !defined(RT_OS_SOLARIS) && !defined(RT_OS_FREEBSD)
37# include <syslimits.h> /* PATH_MAX */
38# endif
39# include <libgen.h> /* basename */
40# include <unistd.h>
41# include <strings.h> /* bzero & bcopy.*/
42#endif
43
44#include <iprt/mem.h>
45#include <iprt/process.h>
46#include <iprt/param.h>
47#include <iprt/alloca.h>
48#include <iprt/assert.h>
49#include <iprt/mem.h>
50#include <iprt/string.h>
51#include <iprt/time.h>
52
53
54#undef gethrtime
55#define gethrtime() RTTimeNanoTS()
56#undef strcasecmp
57#define strcasecmp(a_psz1, a_psz2) RTStrICmp(a_psz1, a_psz2)
58#undef strncasecmp
59#define strncasecmp(a_psz1, a_psz2, a_cch) RTStrNICmp(a_psz1, a_psz2, a_cch)
60#undef strlcpy
61#define strlcpy(a_pszDst, a_pszSrc, a_cbDst) ((void)RTStrCopy(a_pszDst, a_cbDst, a_pszSrc))
62
63#undef assert
64#define assert(expr) Assert(expr)
65
66#undef PATH_MAX
67#define PATH_MAX RTPATH_MAX
68
69#undef getpid
70#define getpid RTProcSelf
71
72#undef basename
73#define basename(a_pszPath) RTPathFilename(a_pszPath)
74
75#undef malloc
76#define malloc(a_cb) RTMemAlloc(a_cb)
77#undef calloc
78#define calloc(a_cItems, a_cb) RTMemAllocZ((size_t)(a_cb) * (a_cItems))
79#undef realloc
80#define realloc(a_pvOld, a_cbNew) RTMemRealloc(a_pvOld, a_cbNew)
81#undef free
82#define free(a_pv) RTMemFree(a_pv)
83
84/* Not using RTStrDup and RTStrNDup here because the allocation won't be freed
85 by RTStrFree and thus may cause trouble when using the efence. */
86#undef strdup
87#define strdup(a_psz) ((char *)RTMemDup(a_psz, strlen(a_psz) + 1))
88#undef strndup
89#define strndup(a_psz, a_cchMax) ((char *)RTMemDupEx(a_psz, RTStrNLen(a_psz, a_cchMax), 1))
90
91/* For various stupid reasons, these are duplicated in VBoxDTraceTypes.h. */
92#undef bcopy
93#define bcopy(a_pSrc, a_pDst, a_cb) ((void)memmove(a_pDst, a_pSrc, a_cb))
94#undef bzero
95#define bzero(a_pDst, a_cb) ((void)memset(a_pDst, 0, a_cb))
96#undef bcmp
97#define bcmp(a_p1, a_p2, a_cb) (memcmp(a_p1, a_p2, a_cb))
98
99#endif /* !VBOX_INCLUDED_SRC_VBoxDTrace_include_VBoxDTraceLibCWrappers_h */
100
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