|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982 Regents of the University of California ! 3: * @(#)asnumber.h 4.3 2/14/82 ! 4: */ ! 5: ! 6: union Ib_int{ /* byte */ ! 7: u_char Ib_uchar[1]; ! 8: char Ichar; ! 9: }; ! 10: union Iw_int{ /* word */ ! 11: u_char Iw_uchar[2]; ! 12: u_short Iw_ushort[1]; ! 13: short Iw_short; ! 14: }; ! 15: union Il_int{ /* long word */ ! 16: u_char Il_uchar[4]; ! 17: u_short Il_ushort[2]; ! 18: u_int Il_ulong[1]; ! 19: int Il_long; ! 20: }; ! 21: ! 22: union Iq_int{ /* quad word */ ! 23: u_char Iq_uchar[8]; ! 24: u_short Iq_ushort[4]; ! 25: u_int Iq_ulong[2]; ! 26: }; ! 27: ! 28: ! 29: union Ff_float{ ! 30: u_char Ff_uchar[4]; ! 31: u_short Ff_ushort[2]; ! 32: u_int Ff_ulong[1]; ! 33: float Ff_value; ! 34: }; ! 35: ! 36: union Fd_float{ ! 37: u_char Fd_uchar[8]; ! 38: u_short Fd_ushort[4]; ! 39: u_int Fd_ulong[2]; ! 40: double Fd_value; ! 41: }; ! 42: ! 43: ! 44: struct as_number{ ! 45: union { ! 46: union Ib_int numIb_int; ! 47: union Iw_int numIw_int; ! 48: union Il_int numIl_int; ! 49: union Iq_int numIq_int; ! 50: union Ff_float numFf_float; ! 51: union Fd_float numFd_float; ! 52: }num_num; ! 53: char num_tag; /* the key field: TYPB..TYPUNPACKED */ ! 54: char num_sign; /* the sign */ ! 55: short num_exponent; /* the unexcessed exp */ ! 56: }; ! 57: typedef struct as_number Bignum; ! 58: ! 59: extern Bignum Znumber; /* one all zero'ed out */ ! 60: ! 61: #define num_uchar num_num.numIq_int.Iq_uchar ! 62: #define num_uint num_num.numIq_int.Iq_ulong ! 63: #define num_ulong num_num.numIq_int.Iq_ulong ! 64: #define num_ushort num_num.numIq_int.Iq_ushort ! 65: /* ! 66: * The following definitions must all be consistent. ! 67: * They define the granularity of working on longs and quad ! 68: * words. Currently, the granularity is as large as it can be: 32 bits ! 69: * in a chunk. ! 70: */ ! 71: #define CH_N 2 /* number of pieces */ ! 72: #define CH_BITS 32 /* number of bits per piece */ ! 73: #define CH_FIELD(x) ((x).num_num.numIq_int.Iq_ulong) ! 74: typedef u_int *chptr; /* basic data type */ ! 75: #define SIGNBIT 0x80000000 ! 76: ! 77: #define HOC (CH_N - 1) /* high order chunk */ ! 78: #if 0 ! 79: #define MAXINT_1 ((unsigned)(1<<(CH_BITS - 1))) ! 80: #define MAXINT_10 ((unsigned)((MAXINT_1/(unsigned)10))) ! 81: #define MAXINT_5 ((unsigned)((MAXINT_1/(unsigned)5))) ! 82: #else not 0 ! 83: /* ! 84: * These values were computed using dc, so are exact. ! 85: * Only MAXINT_10 and MAXINT_5 are used in the programs. ! 86: */ ! 87: #define MAXINT_1 2147483648 ! 88: #define MAXINT_10 214748364 ! 89: #define MAXINT_5 429496729 ! 90: #endif not 0 ! 91: ! 92: Bignum as_atoi(); /* converts string to integer */ ! 93: Bignum as_atof(); /* converts string to float */ ! 94: ! 95: /* ! 96: * Definitions for overflows. ! 97: */ ! 98: typedef u_int Ovf; ! 99: ! 100: #define OVF_ADDV (1<<0) /* integer: adding two vectors overflowed */ ! 101: #define OVF_LSHIFT (1<<1) /* integer: left shifting a vector lost bits */ ! 102: #define OVF_POSOVF (1<<2) /* integer: positive number overflowed */ ! 103: #define OVF_MAXINT (1<<3) /* integer: the number was the maxint + 1*/ ! 104: #define OVF_F (1<<4) /* float: F overflow */ ! 105: #define OVF_D (1<<5) /* float: D overflow */ ! 106: #define OVF_OVERFLOW (1<<9) /* overflow in conversion */ ! 107: #define OVF_UNDERFLOW (1<<10) /* underflow in conversion */ ! 108: ! 109: Ovf posovf(); ! 110: Ovf numclear(); ! 111: Ovf numshift(); ! 112: Ovf numaddv(); ! 113: Ovf numaddd(); ! 114: Ovf num1comp(); ! 115: Ovf numnegate(); ! 116: /* ! 117: * Bit manipulations ! 118: */ ! 119: #define ONES(n) ((1 << (n)) - 1) ! 120: /* ! 121: * Assertions ! 122: */ ! 123: #if 1 ! 124: #define assert(x, str) if (!(x)) panic("%s%s\n", "x", str) ! 125: #else ! 126: #define assert(x, str) ! 127: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.