VirtualBox

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

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

shut up.

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