VirtualBox

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

Last change on this file since 830 was 830, checked in by vboxsync, 18 years ago

Made it built (but currently disabled).

  • Property svn:eol-style set to native
File size: 5.3 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/*
39 * Quad arithmetic.
40 *
41 * This library makes the following assumptions:
42 *
43 * - The type long long (aka quad_t) exists.
44 *
45 * - A quad variable is exactly twice as long as `int'.
46 *
47 * - The machine's arithmetic is two's complement.
48 *
49 * This library can provide 128-bit arithmetic on a machine with 128-bit
50 * quads and 64-bit ints, for instance, or 96-bit arithmetic on machines
51 * with 48-bit ints.
52 */
53
54#if 0 /* bird */
55#include <sys/types.h>
56#if !defined(_KERNEL) && !defined(_STANDALONE)
57#include <limits.h>
58#else
59#include <machine/limits.h>
60#endif
61#else /* bird */
62# include <iprt/types.h>
63# include <limits.h>
64# define __P(a) a
65# define __GNUC_PREREQ__(m1,m2) 1
66# if 1 /* ASSUMES: little endian */
67# define _QUAD_HIGHWORD 1
68# define _QUAD_LOWWORD 0
69# else
70# define _QUAD_HIGHWORD 0
71# define _QUAD_LOWWORD 1
72# endif
73 typedef unsigned int u_int;
74 typedef int64_t quad_t;
75 typedef uint64_t u_quad_t;
76 typedef quad_t *qaddr_t;
77#endif /* bird */
78
79/*
80 * Depending on the desired operation, we view a `long long' (aka quad_t) in
81 * one or more of the following formats.
82 */
83union uu {
84 quad_t q; /* as a (signed) quad */
85 u_quad_t uq; /* as an unsigned quad */
86 int sl[2]; /* as two signed ints */
87 u_int ul[2]; /* as two unsigned ints */
88};
89
90/*
91 * Define high and low parts of a quad_t.
92 */
93#define H _QUAD_HIGHWORD
94#define L _QUAD_LOWWORD
95
96/*
97 * Total number of bits in a quad_t and in the pieces that make it up.
98 * These are used for shifting, and also below for halfword extraction
99 * and assembly.
100 */
101#define QUAD_BITS (sizeof(quad_t) * CHAR_BIT)
102#define INT_BITS (sizeof(int) * CHAR_BIT)
103#define HALF_BITS (sizeof(int) * CHAR_BIT / 2)
104
105/*
106 * Extract high and low shortwords from longword, and move low shortword of
107 * longword to upper half of long, i.e., produce the upper longword of
108 * ((quad_t)(x) << (number_of_bits_in_int/2)). (`x' must actually be u_int.)
109 *
110 * These are used in the multiply code, to split a longword into upper
111 * and lower halves, and to reassemble a product as a quad_t, shifted left
112 * (sizeof(int)*CHAR_BIT/2).
113 */
114#define HHALF(x) ((u_int)(x) >> HALF_BITS)
115#define LHALF(x) ((u_int)(x) & (((int)1 << HALF_BITS) - 1))
116#define LHUP(x) ((u_int)(x) << HALF_BITS)
117
118/*
119 * XXX
120 * Compensate for gcc 1 vs gcc 2. Gcc 1 defines ?sh?di3's second argument
121 * as u_quad_t, while gcc 2 correctly uses int. Unfortunately, we still use
122 * both compilers.
123 */
124#if __GNUC_PREREQ__(2, 0) || defined(lint)
125typedef unsigned int qshift_t;
126#else
127typedef u_quad_t qshift_t;
128#endif
129
130__BEGIN_DECLS
131quad_t __adddi3 __P((quad_t, quad_t));
132quad_t __anddi3 __P((quad_t, quad_t));
133quad_t __ashldi3 __P((quad_t, qshift_t));
134quad_t __ashrdi3 __P((quad_t, qshift_t));
135int __cmpdi2 __P((quad_t, quad_t ));
136quad_t __divdi3 __P((quad_t, quad_t));
137quad_t __fixdfdi __P((double));
138quad_t __fixsfdi __P((float));
139u_quad_t __fixunsdfdi __P((double));
140u_quad_t __fixunssfdi __P((float));
141double __floatdidf __P((quad_t));
142float __floatdisf __P((quad_t));
143double __floatunsdidf __P((u_quad_t));
144quad_t __iordi3 __P((quad_t, quad_t));
145quad_t __lshldi3 __P((quad_t, qshift_t));
146quad_t __lshrdi3 __P((quad_t, qshift_t));
147quad_t __moddi3 __P((quad_t, quad_t));
148quad_t __muldi3 __P((quad_t, quad_t));
149quad_t __negdi2 __P((quad_t));
150quad_t __one_cmpldi2 __P((quad_t));
151u_quad_t __qdivrem __P((u_quad_t, u_quad_t, u_quad_t *));
152quad_t __subdi3 __P((quad_t, quad_t));
153int __ucmpdi2 __P((u_quad_t, u_quad_t));
154u_quad_t __udivdi3 __P((u_quad_t, u_quad_t ));
155u_quad_t __umoddi3 __P((u_quad_t, u_quad_t ));
156quad_t __xordi3 __P((quad_t, quad_t));
157__END_DECLS
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