summaryrefslogtreecommitdiff
path: root/src/libs/softfloat-3e/build/vbox/platform.h
blob: 2e5285900915206db0eed4e28c24ba42b9c6e936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* $Id$ */
/** @file
 * Platform Header for all VirtualBox targets.
 */

/*
 * Copyright (C) 2022 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 */

#ifndef VBOX_INCLUDED_SRC_vbox_platform_h
#define VBOX_INCLUDED_SRC_vbox_platform_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

/* For RT_LITTLE_ENDIAN, RT_ARCH_XXX and more: */
#include <iprt/cdefs.h>

/* Build config: */
#define SOFTFLOAT_FAST_INT64            /**< We use functions guarded by this, so must be defined regardless of truthiness. */
#define SOFTFLOAT_ROUND_ODD             /** @todo Skip this? */

/* IPRT should detect endianness correctly: */
#ifdef RT_LITTLE_ENDIAN
# define LITTLEENDIAN 1
#endif

/* Compiler/host configuration bits: */
#define SOFTFLOAT_FAST_DIV32TO16
#if ARCH_BITS > 32 || defined(RT_ARCH_X86)
# define SOFTFLOAT_FAST_DIV64TO32
#endif

/* See DECLINLINE for guidance: */
#ifdef __GNUC__
# define INLINE                         static __inline__
#elif defined(__cplusplus)
# define INLINE                         static inline
#elif defined(_MSC_VER)
# define INLINE                         static _inline
#else
# error "Port me!"
#endif

/* Generic IPRT asm.h based optimizations: */
#if !defined(__GNUC__)
# include <iprt/asm.h>
# define softfloat_countLeadingZeros16 softfloat_iprt_countLeadingZeros16
DECLINLINE(uint_fast8_t) softfloat_iprt_countLeadingZeros16(uint16_t uVal)
{
    return 16 - ASMBitLastSetU16(uVal);
}
# define softfloat_countLeadingZeros32 softfloat_iprt_countLeadingZeros32
DECLINLINE(uint_fast8_t) softfloat_iprt_countLeadingZeros32(uint32_t uVal)
{
    return 32 - ASMBitLastSetU32(uVal);
}
# define softfloat_countLeadingZeros64 softfloat_iprt_countLeadingZeros64
DECLINLINE(uint_fast8_t) softfloat_iprt_countLeadingZeros64(uint64_t uVal)
{
    return 64 - ASMBitLastSetU64(uVal);
}
#endif

/* Include GCC optimizations: */
#ifdef __GNUC__
# ifndef softfloat_countLeadingZeros16
#  define SOFTFLOAT_BUILTIN_CLZ         1
# endif
# if ARCH_BITS > 32
#  define SOFTFLOAT_INTRINSIC_INT128    1
# endif
# include "opts-GCC.h"
#endif

/* We've eliminated the global variables and need no TLS variable tricks. */
#ifndef THREAD_LOCAL
# if 1
#  define THREAD_LOCAL
# else
#  ifdef _MSC_VER
#   define THREAD_LOCAL                 __declspec(thread)
#  else
#   define THREAD_LOCAL                 __thread
#  endif
# endif
#endif

#endif /* !VBOX_INCLUDED_SRC_vbox_platform_h */