quad.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1992, 1993
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * This software was developed by the Computer Systems Engineering group
00006  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
00007  * contributed to Berkeley.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 3. All advertising materials mentioning features or use of this software
00018  *    must display the following acknowledgement:
00019  *      This product includes software developed by the University of
00020  *      California, Berkeley and its contributors.
00021  * 4. Neither the name of the University nor the names of its contributors
00022  *    may be used to endorse or promote products derived from this software
00023  *    without specific prior written permission.
00024  *
00025  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00026  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00029  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00031  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00032  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00034  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00035  * SUCH DAMAGE.
00036  *
00037  *      @(#)quad.h      8.1 (Berkeley) 6/4/93
00038  */
00039 #ifndef __QUAD_QUAD_H__
00040 #define __QUAD_QUAD_H__ 1
00041 
00042 /*
00043  * Quad arithmetic.
00044  *
00045  * This library makes the following assumptions:
00046  *
00047  *  - The type long long (aka quad_t) exists.
00048  *
00049  *  - A quad variable is exactly twice as long as `long'.
00050  *
00051  *  - The machine's arithmetic is two's complement.
00052  *
00053  * This library can provide 128-bit arithmetic on a machine with 128-bit
00054  * quads and 64-bit longs, for instance, or 96-bit arithmetic on machines
00055  * with 48-bit longs.
00056  */
00057 
00058 #include <libc.h>
00059 
00060 /*
00061  * Depending on the desired operation, we view a `long long' (aka quad_t) in
00062  * one or more of the following formats.
00063  */
00064 union uu {
00065         quad_t  q;              /* as a (signed) quad */
00066         u_quad_t uq;            /* as an unsigned quad */
00067         long    sl[2];          /* as two signed longs */
00068         u_long  ul[2];          /* as two unsigned longs */
00069 };
00070 
00071 /*
00072  * Define high and low longwords.
00073  */
00074 #define H               _QUAD_HIGHWORD
00075 #define L               _QUAD_LOWWORD
00076 
00077 /*
00078  * Total number of bits in a quad_t and in the pieces that make it up.
00079  * These are used for shifting, and also below for halfword extraction
00080  * and assembly.
00081  */
00082 #define QUAD_BITS       (sizeof(quad_t) * CHAR_BIT)
00083 #define LONG_BITS       (sizeof(long) * CHAR_BIT)
00084 #define HALF_BITS       (sizeof(long) * CHAR_BIT / 2)
00085 
00086 /*
00087  * Extract high and low shortwords from longword, and move low shortword of
00088  * longword to upper half of long, i.e., produce the upper longword of
00089  * ((quad_t)(x) << (number_of_bits_in_long/2)).  (`x' must actually be u_long.)
00090  *
00091  * These are used in the multiply code, to split a longword into upper
00092  * and lower halves, and to reassemble a product as a quad_t, shifted left
00093  * (sizeof(long)*CHAR_BIT/2).
00094  */
00095 #define HHALF(x)        ((u_long)(x) >> HALF_BITS)
00096 #define LHALF(x)        ((u_long)(x) & (((long)1 << HALF_BITS) - 1))
00097 #define LHUP(x)         ((u_long)(x) << HALF_BITS)
00098 
00099 typedef unsigned int    qshift_t;
00100 
00101 quad_t __adddi3(quad_t, quad_t);
00102 quad_t __anddi3(quad_t, quad_t);
00103 quad_t __ashldi3(quad_t, qshift_t);
00104 quad_t __ashrdi3(quad_t, qshift_t);
00105 int __cmpdi2(quad_t, quad_t );
00106 quad_t __divdi3(quad_t, quad_t);
00107 quad_t __fixdfdi(double);
00108 quad_t __fixsfdi(float);
00109 u_quad_t __fixunsdfdi(double);
00110 u_quad_t __fixunssfdi(float);
00111 double __floatdidf(quad_t);
00112 float __floatdisf(quad_t);
00113 double __floatunsdidf(u_quad_t);
00114 quad_t __iordi3(quad_t, quad_t);
00115 quad_t __lshldi3(quad_t, qshift_t);
00116 quad_t __lshrdi3(quad_t, qshift_t);
00117 quad_t __moddi3(quad_t, quad_t);
00118 quad_t __muldi3(quad_t, quad_t);
00119 quad_t __negdi2(quad_t);
00120 quad_t __one_cmpldi2(quad_t);
00121 u_quad_t __qdivrem(u_quad_t, u_quad_t, u_quad_t *);
00122 quad_t __subdi3(quad_t, quad_t);
00123 int __ucmpdi2(u_quad_t, u_quad_t);
00124 u_quad_t __udivdi3(u_quad_t, u_quad_t );
00125 u_quad_t __umoddi3(u_quad_t, u_quad_t );
00126 quad_t __xordi3(quad_t, quad_t);
00127 
00128 #endif

Generated on Wed May 24 23:04:17 2006 for LSE/OS by  doxygen 1.4.6