/[dtapublic]/projs/trunk/shared_source/c_datd/esrg_int_def.h
ViewVC logotype

Contents of /projs/trunk/shared_source/c_datd/esrg_int_def.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 71 - (show annotations) (download)
Sat Nov 5 11:07:06 2016 UTC (8 years, 1 month ago) by dashley
File MIME type: text/plain
File size: 5277 byte(s)
Set EOL properties appropriately to facilitate simultaneous Linux and Windows development.
1 //$Header$
2 //-------------------------------------------------------------------------------------------------
3 //This file is part of "David T. Ashley's Shared Source Code", a set of shared components
4 //integrated into many of David T. Ashley's projects.
5 //-------------------------------------------------------------------------------------------------
6 //This source code and any program in which it is compiled/used is provided under the MIT License,
7 //reproduced below.
8 //-------------------------------------------------------------------------------------------------
9 //Permission is hereby granted, free of charge, to any person obtaining a copy of
10 //this software and associated documentation files(the "Software"), to deal in the
11 //Software without restriction, including without limitation the rights to use,
12 //copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the
13 //Software, and to permit persons to whom the Software is furnished to do so,
14 //subject to the following conditions :
15 //
16 //The above copyright notice and this permission notice shall be included in all
17 //copies or substantial portions of the Software.
18 //
19 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
22 //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 //SOFTWARE.
26 //-------------------------------------------------------------------------------------------------
27 /* This module defines the default integer used by the Tcl/Tk interpreters
28 ** and by other software which does not explicitly deal with arbitrary length
29 ** integers. The hope is that, over time, the Tcl core can be migrated to use
30 ** this functionality. What should happen is that, with the flip of a preprocessor
31 ** switch, the default integer size can be changed.
32 **
33 ** The only real guideline for the size is that it must be at least as large
34 ** as the maximum size of a file.
35 **
36 ** It is felt at the present time that 128-bit integers should be adequate for
37 ** just about everything.
38 */
39 //--------------------------------------------------------------------------------
40 #ifndef ESRG_INT_DEF_H_INCLUDED
41 #define ESRG_INT_DEF_H_INCLUDED
42
43 #ifdef MODULE_ESRG_INT_DEF
44 #define DECMOD_ESRG_INT_DEF
45 #else
46 #define DECMOD_ESRG_INT_DEF extern
47 #endif
48
49 //Configuration constants.
50 #define ESRG_INT_DEF_BITSIZE (128)
51 //The size, in bits, of each integer. This must be a multiple of the machines
52 //native integer size.
53 #define ESRG_INT_DEF_NATIVE_BITSIZE (32)
54 //The size, in bits, of the native int of the machine. This may be
55 //any positive integer.
56 #define ESRG_INT_DEF_NLIMBS (ESRG_INT_DEF_BITSIZE/ESRG_INT_DEF_NATIVE_BITSIZE)
57 //The number of native integers required for each of the default
58 //integers.
59
60 struct ESRG_INT_DEF_struct
61 {
62 unsigned int flags;
63 //The flags, as defined below.
64 #define ESRG_INT_DEF_FLAG_IS_SIGNED (0x00000001)
65 //Integer is signed. Defined at creation time and not changed.
66 #define ESRG_INT_DEF_FLAG_NEG_ROLL (0x00000002)
67 #define ESRG_INT_DEF_FLAG_POS_ROLL (0x00000004)
68 //TRUE if has rolled over in a negative way or positive way.
69 //Depending on what is being done, this may mean result is invalid.
70 #define ESRG_INT_DEF_FLAG_NAN (0x00000008)
71 //TRUE if the result is not a number. This may be from division by zero,
72 //square root of a negative number, etc.
73 unsigned int limbs[ESRG_INT_DEF_NLIMBS];
74 //The limbs of the integer. These are arranged with the least significant
75 //limb as [0], i.e. things are arranged least-significant component first.
76 //If the integer is signed, it is a concatenated two's complement representation--
77 //same as the ideal, but spread over multiple native ints.
78 };
79
80 typedef struct ESRG_INT_DEF_struct ESRG_INT_DEF_INT;
81
82 //Required initialization before doing anything.
83 //Destruction is not required--only initialization before
84 //the first assignment or use.
85 DECMOD_ESRG_INT_DEF void ESRG_INT_DEF_Create
86 ( ESRG_INT_DEF_INT *arg ,
87 int is_signed);
88
89 //Assigns a machine native unsigned integer to the value.
90 DECMOD_ESRG_INT_DEF void ESRG_INT_DEF_AssignU
91 ( ESRG_INT_DEF_INT *arg ,
92 unsigned int aval);
93
94 //Assigns a machine native signed integer to the value.
95 DECMOD_ESRG_INT_DEF void ESRG_INT_DEF_AssignS
96 ( ESRG_INT_DEF_INT *arg,
97 int aval);
98
99 //Compares two values to see their relative relationship.
100 //Returned values are -1 if a<b, 0 if a==b, and 1 if a>b.
101 //All cases of signed/unsigned mixes are handled. Only the
102 //bit patterns of the operands are considered--whether they
103 //are the result of rollovers, etc., is not considered.
104 DECMOD_ESRG_INT_DEF int ESRG_INT_DEF_Cmp
105 ( ESRG_INT_DEF_INT *a,
106 ESRG_INT_DEF_INT *b );
107
108 #endif
109
110 //End of esrg_int_def.h.

Properties

Name Value
svn:eol-style native
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25