VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/math/gcc/quad.h@ 78906

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

VBoxGuest/linux: Try speed up GA installation by combining the IPRT and VBgl bits into two source files. [build fix]

  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
1/* $NetBSD: quad.h,v 1.17 2005/12/11 12:24:37 christos Exp $ */
2
3/*-
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)quad.h 8.1 (Berkeley) 6/4/93
36 */
37
38#ifndef IPRT_INCLUDED_COMMON_MATH_quad_h
39#define IPRT_INCLUDED_COMMON_MATH_quad_h
40#ifndef RT_WITHOUT_PRAGMA_ONCE
41# pragma once
42#endif
43
44/*
45 * Quad arithmetic.
46 *
47 * This library makes the following assumptions:
48 *
49 * - The type long long (aka quad_t) exists.
50 *
51 * - A quad variable is exactly twice as long as `int'.
52 *
53 * - The machine's arithmetic is two's complement.
54 *
55 * This library can provide 128-bit arithmetic on a machine with 128-bit
56 * quads and 64-bit ints, for instance, or 96-bit arithmetic on machines
57 * with 48-bit ints.
58 */
59
60#if 0 /* iprt */
61#include <sys/types.h>
62#if !defined(_KERNEL) && !defined(_STANDALONE)
63#include <limits.h>
64#else
65#include <machine/limits.h>
66#endif
67#else /* iprt */
68# include <iprt/types.h>
69# include <iprt/nocrt/limits.h>
70# undef __P
71# define __P(a) a
72# undef __GNUC_PREREQ__
73# define __GNUC_PREREQ__(m1,m2) 1
74# if 1 /* ASSUMES: little endian */
75# define _QUAD_HIGHWORD 1
76# define _QUAD_LOWWORD 0
77# else
78# define _QUAD_HIGHWORD 0
79# define _QUAD_LOWWORD 1
80# endif
81# if !defined(RT_OS_LINUX) || !defined(__KERNEL__) /* (linux/types.h defines u_int) */
82 typedef unsigned int u_int;
83# endif
84# if !defined(RT_OS_SOLARIS)
85 typedef int64_t quad_t;
86# else
87# define quad_t int64_t
88# endif
89 typedef uint64_t u_quad_t;
90 typedef quad_t *qaddr_t;
91#endif /* iprt */
92
93/*
94 * Depending on the desired operation, we view a `long long' (aka quad_t) in
95 * one or more of the following formats.
96 */
97union uu {
98 quad_t q; /* as a (signed) quad */
99 u_quad_t uq; /* as an unsigned quad */
100 int sl[2]; /* as two signed ints */
101 u_int ul[2]; /* as two unsigned ints */
102};
103
104/*
105 * Define high and low parts of a quad_t.
106 */
107#define H _QUAD_HIGHWORD
108#define L _QUAD_LOWWORD
109
110/*
111 * Total number of bits in a quad_t and in the pieces that make it up.
112 * These are used for shifting, and also below for halfword extraction
113 * and assembly.
114 */
115#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT)
116#define INT_BITS (sizeof(int) * CHAR_BIT)
117#define HALF_BITS (sizeof(int) * CHAR_BIT / 2)
118
119/*
120 * Extract high and low shortwords from longword, and move low shortword of
121 * longword to upper half of long, i.e., produce the upper longword of
122 * ((quad_t)(x) << (number_of_bits_in_int/2)). (`x' must actually be u_int.)
123 *
124 * These are used in the multiply code, to split a longword into upper
125 * and lower halves, and to reassemble a product as a quad_t, shifted left
126 * (sizeof(int)*CHAR_BIT/2).
127 */
128#define HHALF(x) ((u_int)(x) >> HALF_BITS)
129#define LHALF(x) ((u_int)(x) & (((int)1 << HALF_BITS) - 1))
130#define LHUP(x) ((u_int)(x) << HALF_BITS)
131
132/*
133 * XXX
134 * Compensate for gcc 1 vs gcc 2. Gcc 1 defines ?sh?di3's second argument
135 * as u_quad_t, while gcc 2 correctly uses int. Unfortunately, we still use
136 * both compilers.
137 */
138#if __GNUC_PREREQ__(2, 0) || defined(lint)
139typedef unsigned int qshift_t;
140#else
141typedef u_quad_t qshift_t;
142#endif
143
144RT_C_DECLS_BEGIN
145quad_t __adddi3 __P((quad_t, quad_t));
146quad_t __anddi3 __P((quad_t, quad_t));
147quad_t __ashldi3 __P((quad_t, qshift_t));
148quad_t __ashrdi3 __P((quad_t, qshift_t));
149int __cmpdi2 __P((quad_t, quad_t ));
150quad_t __divdi3 __P((quad_t, quad_t));
151quad_t __fixdfdi __P((double));
152quad_t __fixsfdi __P((float));
153u_quad_t __fixunsdfdi __P((double));
154u_quad_t __fixunssfdi __P((float));
155double __floatdidf __P((quad_t));
156float __floatdisf __P((quad_t));
157double __floatunsdidf __P((u_quad_t));
158quad_t __iordi3 __P((quad_t, quad_t));
159quad_t __lshldi3 __P((quad_t, qshift_t));
160quad_t __lshrdi3 __P((quad_t, qshift_t));
161quad_t __moddi3 __P((quad_t, quad_t));
162quad_t __muldi3 __P((quad_t, quad_t));
163quad_t __negdi2 __P((quad_t));
164quad_t __one_cmpldi2 __P((quad_t));
165u_quad_t __qdivrem __P((u_quad_t, u_quad_t, u_quad_t *));
166quad_t __subdi3 __P((quad_t, quad_t));
167int __ucmpdi2 __P((u_quad_t, u_quad_t));
168u_quad_t __udivdi3 __P((u_quad_t, u_quad_t ));
169u_quad_t __umoddi3 __P((u_quad_t, u_quad_t ));
170quad_t __xordi3 __P((quad_t, quad_t));
171RT_C_DECLS_END
172
173#endif
174
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