1 | /* |
2 | * PROGRAM: JRD Access Method |
3 | * MODULE: align.h |
4 | * DESCRIPTION: Maximum alignments for corresponding datatype |
5 | * |
6 | * The contents of this file are subject to the Interbase Public |
7 | * License Version 1.0 (the "License"); you may not use this file |
8 | * except in compliance with the License. You may obtain a copy |
9 | * of the License at http://www.Inprise.com/IPL.html |
10 | * |
11 | * Software distributed under the License is distributed on an |
12 | * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express |
13 | * or implied. See the License for the specific language governing |
14 | * rights and limitations under the License. |
15 | * |
16 | * The Original Code was created by Inprise Corporation |
17 | * and its predecessors. Portions created by Inprise Corporation are |
18 | * Copyright (C) Inprise Corporation. |
19 | * |
20 | * All Rights Reserved. |
21 | * Contributor(s): ______________________________________. |
22 | * |
23 | * 2002.10.28 Sean Leyne - Code cleanup, removed obsolete "MPEXL" port |
24 | * 2002.10.28 Sean Leyne - Code cleanup, removed obsolete "DecOSF" port |
25 | * |
26 | */ |
27 | |
28 | #ifndef JRD_ALIGN_H |
29 | #define JRD_ALIGN_H |
30 | |
31 | /* |
32 | Maximum alignments for corresponding data types are defined in dsc.h |
33 | */ |
34 | |
35 | #include "../jrd/blr.h" |
36 | |
37 | /* The following macro must be defined as the highest-numericly-valued |
38 | * blr which describes a datatype: arrays are sized based on this value. |
39 | * if a new blr is defined to represent a datatype in blr.h, and the new |
40 | * value is greater than blr_blob_id, be sure to change the next define, |
41 | * and also add the required entries to all of the arrays below. |
42 | */ |
43 | const unsigned char DTYPE_BLR_MAX = blr_blob_id; |
44 | |
45 | /* |
46 | the blr types are defined in blr.h |
47 | |
48 | No need to worry about blr_blob or ?blr_blob_id |
49 | |
50 | */ |
51 | |
52 | #include "../common/dsc.h" |
53 | #include "../jrd/RecordNumber.h" |
54 | |
55 | static const USHORT gds_cvt_blr_dtype[DTYPE_BLR_MAX + 1] = |
56 | { |
57 | 0, 0, 0, 0, 0, 0, 0, |
58 | dtype_short, /* blr_short == 7 */ |
59 | dtype_long, /* blr_long == 8 */ |
60 | dtype_quad, /* blr_quad == 9 */ |
61 | dtype_real, /* blr_float == 10 */ |
62 | dtype_d_float, /* blr_d_float == 11 */ |
63 | dtype_sql_date, /* blr_sql_date == 12 */ |
64 | dtype_sql_time, /* blr_sql_time == 13 */ |
65 | dtype_text, /* blr_text == 14 */ |
66 | dtype_text, /* blr_text2 == 15 */ |
67 | dtype_int64, /* blr_int64 == 16 */ |
68 | 0, 0, 0, 0, 0, 0, |
69 | dtype_boolean, // blr_bool == 23 |
70 | 0, 0, 0, |
71 | dtype_double, /* blr_double == 27 */ |
72 | 0, 0, 0, 0, 0, 0, 0, |
73 | dtype_timestamp, /* blr_timestamp == 35 */ |
74 | 0, |
75 | dtype_varying, /* blr_varying == 37 */ |
76 | dtype_varying, /* blr_varying2 == 38 */ |
77 | 0, |
78 | dtype_cstring, /* blr_cstring == 40 */ |
79 | dtype_cstring, /* blr_cstring == 41 */ |
80 | 0, 0, 0, 0 |
81 | }; |
82 | |
83 | static const USHORT type_alignments[DTYPE_TYPE_MAX] = |
84 | { |
85 | 0, |
86 | 0, /* dtype_text */ |
87 | 0, /* dtype_cstring */ |
88 | sizeof(SSHORT), /* dtype_varying */ |
89 | 0, /* unused */ |
90 | 0, /* unused */ |
91 | sizeof(SCHAR), /* dtype_packed */ |
92 | sizeof(SCHAR), /* dtype_byte */ |
93 | sizeof(SSHORT), /* dtype_short */ |
94 | sizeof(SLONG), /* dtype_long */ |
95 | sizeof(SLONG), /* dtype_quad */ |
96 | sizeof(float), /* dtype_real */ |
97 | FB_DOUBLE_ALIGN, /* dtype_double */ |
98 | FB_DOUBLE_ALIGN, /* dtype_d_float */ |
99 | sizeof(GDS_DATE), /* dtype_sql_date */ |
100 | sizeof(GDS_TIME), /* dtype_sql_time */ |
101 | sizeof(GDS_DATE), /* dtype_timestamp */ |
102 | sizeof(SLONG), /* dtype_blob */ |
103 | sizeof(SLONG), /* dtype_array */ |
104 | sizeof(SINT64), /* dtype_int64 */ |
105 | sizeof(ULONG), /* dtype_dbkey */ |
106 | sizeof(UCHAR) /* dtype_boolean */ |
107 | }; |
108 | |
109 | static const USHORT type_lengths[DTYPE_TYPE_MAX] = |
110 | { |
111 | 0, |
112 | 0, /* dtype_text */ |
113 | 0, /* dtype_cstring */ |
114 | 0, /* dtype_varying */ |
115 | 0, /* unused */ |
116 | 0, /* unused */ |
117 | 0, /* dtype_packed */ |
118 | sizeof(SCHAR), /* dtype_byte */ |
119 | sizeof(SSHORT), /* dtype_short */ |
120 | sizeof(SLONG), /* dtype_long */ |
121 | sizeof(ISC_QUAD), /* dtype_quad */ |
122 | sizeof(float), /* dtype_real */ |
123 | sizeof(double), /* dtype_double */ |
124 | sizeof(double), /* dtype_d_float */ |
125 | sizeof(GDS_DATE), /* dtype_sql_date */ |
126 | sizeof(GDS_TIME), /* dtype_sql_time */ |
127 | sizeof(GDS_TIMESTAMP), /* dtype_timestamp */ |
128 | sizeof(ISC_QUAD), /* dtype_blob */ |
129 | sizeof(ISC_QUAD), /* dtype_array */ |
130 | sizeof(SINT64), /* dtype_int64 */ |
131 | sizeof(RecordNumber::Packed), /*dtype_dbkey */ |
132 | sizeof(UCHAR) /* dtype_boolean */ |
133 | }; |
134 | |
135 | |
136 | // This table is only used by gpre's cme.cpp. |
137 | // float, double are numbers from IEEE floating-point standard (IEEE 754) |
138 | static const USHORT type_significant_bits[DTYPE_TYPE_MAX] = |
139 | { |
140 | 0, |
141 | 0, /* dtype_text */ |
142 | 0, /* dtype_cstring */ |
143 | 0, /* dtype_varying */ |
144 | 0, /* unused */ |
145 | 0, /* unused */ |
146 | 0, /* dtype_packed */ |
147 | sizeof(SCHAR) * 8, /* dtype_byte */ |
148 | sizeof(SSHORT) * 8, /* dtype_short */ |
149 | sizeof(SLONG) * 8, /* dtype_long */ |
150 | sizeof(ISC_QUAD) * 8, /* dtype_quad */ |
151 | 23, /* dtype_real, 23 sign. bits = 7 sign. digits */ |
152 | 52, /* dtype_double, 52 sign. bits = 15 sign. digits */ |
153 | 52, /* dtype_d_float, 52 sign. bits = 15 sign. digits */ |
154 | sizeof(GDS_DATE) * 8, /* dtype_sql_date */ |
155 | sizeof(GDS_TIME) * 8, /* dtype_sql_time */ |
156 | sizeof(GDS_TIMESTAMP) * 8, /* dtype_timestamp */ |
157 | sizeof(ISC_QUAD) * 8, /* dtype_blob */ |
158 | sizeof(ISC_QUAD) * 8, /* dtype_array */ |
159 | sizeof(SINT64) * 8, /* dtype_int64 */ |
160 | 0, // dtype_dbkey |
161 | 0 // dtype_boolean |
162 | }; |
163 | |
164 | #endif /* JRD_ALIGN_H */ |
165 | |