VirtualBox

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

Last change on this file since 4173 was 4173, checked in by vboxsync, 17 years ago

Make it build in the linux kernel environment.

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