1 | /* $Id: platform.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Platform Header for all VirtualBox targets.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2022-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef VBOX_INCLUDED_SRC_vbox_platform_h
|
---|
29 | #define VBOX_INCLUDED_SRC_vbox_platform_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* For RT_LITTLE_ENDIAN, RT_ARCH_XXX and more: */
|
---|
35 | #include <iprt/cdefs.h>
|
---|
36 |
|
---|
37 | /* Build config: */
|
---|
38 | #define SOFTFLOAT_FAST_INT64 /**< We use functions guarded by this, so must be defined regardless of truthiness. */
|
---|
39 | #define SOFTFLOAT_ROUND_ODD /** @todo Skip this? */
|
---|
40 |
|
---|
41 | /* IPRT should detect endianness correctly: */
|
---|
42 | #ifdef RT_LITTLE_ENDIAN
|
---|
43 | # define LITTLEENDIAN 1
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | /* Compiler/host configuration bits: */
|
---|
47 | #define SOFTFLOAT_FAST_DIV32TO16
|
---|
48 | #if ARCH_BITS > 32 || defined(RT_ARCH_X86)
|
---|
49 | # define SOFTFLOAT_FAST_DIV64TO32
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | /* See DECLINLINE for guidance: */
|
---|
53 | #ifdef __GNUC__
|
---|
54 | # define INLINE static __inline__
|
---|
55 | #elif defined(__cplusplus)
|
---|
56 | # define INLINE static inline
|
---|
57 | #elif defined(_MSC_VER)
|
---|
58 | # define INLINE static _inline
|
---|
59 | #else
|
---|
60 | # error "Port me!"
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | /* Generic IPRT asm.h based optimizations: */
|
---|
64 | #if !defined(__GNUC__)
|
---|
65 | # include <iprt/asm.h>
|
---|
66 | # define softfloat_countLeadingZeros16 softfloat_iprt_countLeadingZeros16
|
---|
67 | DECLINLINE(uint_fast8_t) softfloat_iprt_countLeadingZeros16(uint16_t uVal)
|
---|
68 | {
|
---|
69 | return 16 - ASMBitLastSetU16(uVal);
|
---|
70 | }
|
---|
71 | # define softfloat_countLeadingZeros32 softfloat_iprt_countLeadingZeros32
|
---|
72 | DECLINLINE(uint_fast8_t) softfloat_iprt_countLeadingZeros32(uint32_t uVal)
|
---|
73 | {
|
---|
74 | return 32 - ASMBitLastSetU32(uVal);
|
---|
75 | }
|
---|
76 | # define softfloat_countLeadingZeros64 softfloat_iprt_countLeadingZeros64
|
---|
77 | DECLINLINE(uint_fast8_t) softfloat_iprt_countLeadingZeros64(uint64_t uVal)
|
---|
78 | {
|
---|
79 | return 64 - ASMBitLastSetU64(uVal);
|
---|
80 | }
|
---|
81 | #endif
|
---|
82 |
|
---|
83 | /* Include GCC optimizations: */
|
---|
84 | #ifdef __GNUC__
|
---|
85 | # ifndef softfloat_countLeadingZeros16
|
---|
86 | # define SOFTFLOAT_BUILTIN_CLZ 1
|
---|
87 | # endif
|
---|
88 | # if ARCH_BITS > 32 && defined(__SIZEOF_INT128__)
|
---|
89 | # define SOFTFLOAT_INTRINSIC_INT128 1
|
---|
90 | # endif
|
---|
91 | # include "opts-GCC.h"
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | /* We've eliminated the global variables and need no TLS variable tricks. */
|
---|
95 | #ifndef THREAD_LOCAL
|
---|
96 | # if 1
|
---|
97 | # define THREAD_LOCAL
|
---|
98 | # else
|
---|
99 | # ifdef _MSC_VER
|
---|
100 | # define THREAD_LOCAL __declspec(thread)
|
---|
101 | # else
|
---|
102 | # define THREAD_LOCAL __thread
|
---|
103 | # endif
|
---|
104 | # endif
|
---|
105 | #endif
|
---|
106 |
|
---|
107 | #endif /* !VBOX_INCLUDED_SRC_vbox_platform_h */
|
---|