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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.70  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25