coan 4.2.4
|
00001 #ifndef INTEGER_OPS_H 00002 #define INTEGER_OPS_H 00003 /*************************************************************************** 00004 * Copyright (C) 2004, 2006 Symbian Software Ltd. * 00005 * All rights reserved. * 00006 * Copyright (C) 2007-2011 Mike Kinghan, imk@strudl.org * 00007 * All rights reserved. * 00008 * * 00009 * Contributed originally by Mike Kinghan, imk@strudl.org * 00010 * * 00011 * Redistribution and use in source and binary forms, with or without * 00012 * modification, are permitted provided that the following conditions * 00013 * are met: * 00014 * * 00015 * Redistributions of source code must retain the above copyright * 00016 * notice, this list of conditions and the following disclaimer. * 00017 * * 00018 * Redistributions in binary form must reproduce the above copyright * 00019 * notice, this list of conditions and the following disclaimer in the * 00020 * documentation and/or other materials provided with the distribution. * 00021 * * 00022 * Neither the name of Symbian Software Ltd. nor the names of its * 00023 * contributors may be used to endorse or promote products derived from * 00024 * this software without specific prior written permission. * 00025 * * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 00027 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 00028 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 00029 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 00030 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 00031 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 00032 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 00033 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * 00034 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,* 00035 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * 00036 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 00037 * DAMAGE. * 00038 * * 00039 **************************************************************************/ 00040 00041 00049 00057 typedef enum { 00058 INT_UNDEF = 0, 00059 INT_CHAR = (1 << 16) | (sizeof(char) << 8) | 1, 00060 INT_UCHAR = (1 << 16) | sizeof(char) << 8, 00061 INT_SHORT = (2 << 16) | (sizeof(short) << 8) | 1, 00062 INT_USHORT = (2 << 16) | sizeof(short) << 8, 00063 INT_INT = (3 << 16) | (sizeof(int) << 8) | 1, 00064 INT_UINT = (3 << 16) | sizeof(int) << 8, 00065 INT_LONG = (4 << 16) | (sizeof(long) << 8) | 1, 00066 INT_ULONG = (4 << 16) | sizeof(long) << 8, 00067 INT_LLONG = (5 << 16) | (sizeof(long long) << 8) | 1, 00068 INT_ULLONG = (5 << 16) | sizeof(long long) << 8, 00069 INT_TOO_BIG = 6 << 16, 00070 INT_INSOLUBLE = INT_TOO_BIG 00071 } int_type; 00072 00074 #define RANK(int_type) ((int_type) >> 16) 00075 00077 #define SIZEOF(int_type) (((int_type) >> 8) & ~0xff00) 00078 00080 #define IS_SIGNED(int_type) ((int_type) & 1) 00081 00083 #define MAKE_SIGNED(int_type) ((int_type) | 1) 00084 00086 #define MAKE_UNSIGNED(int_type) ((int_type) & ~1) 00087 00089 typedef struct int_spec { 00090 union { 00091 long long ll; 00092 unsigned long long ull; 00093 long l; 00094 unsigned long ul; 00095 int i; 00096 unsigned ui; 00097 } val; 00098 int_type type; 00099 } int_spec_t; 00100 00102 #define INT_UNION_INITOR {0LL} 00103 00105 #define INT_SPEC_INITOR {INT_UNION_INITOR,INT_UNDEF} 00106 00108 typedef int_spec_t (integer_bin_op_t)(int_spec_t const *, int_spec_t const *); 00109 00115 extern int_spec_t 00116 lt(int_spec_t const * l, int_spec_t const *r); 00117 00123 extern int_spec_t 00124 gt(int_spec_t const * l, int_spec_t const *r); 00125 00131 extern int_spec_t 00132 le(int_spec_t const * l, int_spec_t const *r); 00133 00139 extern int_spec_t 00140 ge(int_spec_t const * l, int_spec_t const *r); 00141 00147 extern int_spec_t 00148 eq(int_spec_t const * l, int_spec_t const *r); 00149 00155 extern int_spec_t 00156 ne(int_spec_t const * l, int_spec_t const *r); 00157 00163 extern int_spec_t 00164 bit_and(int_spec_t const * l, int_spec_t const *r); 00165 00171 extern int_spec_t 00172 bit_or(int_spec_t const * l, int_spec_t const *r); 00173 00179 extern int_spec_t 00180 bit_xor(int_spec_t const * l, int_spec_t const *r); 00181 00186 extern int_spec_t 00187 complement(int_spec_t const * int_spec); 00188 00193 extern int_spec_t 00194 minus(int_spec_t const * int_spec); 00195 00201 extern int_spec_t 00202 lshift(int_spec_t const * l, int_spec_t const *r); 00203 00209 extern int_spec_t 00210 rshift(int_spec_t const * l, int_spec_t const *r); 00211 00217 extern int_spec_t 00218 add(int_spec_t const * l, int_spec_t const *r); 00219 00225 extern int_spec_t 00226 subtract(int_spec_t const * l, int_spec_t const *r); 00227 00233 extern int_spec_t 00234 multiply(int_spec_t const * l, int_spec_t const *r); 00235 00241 extern int_spec_t 00242 divide(int_spec_t const * l, int_spec_t const *r); 00243 00249 extern int_spec_t 00250 modulus(int_spec_t const * l, int_spec_t const *r); 00251 00257 extern int_spec_t 00258 boolean_and(int_spec_t const * l, int_spec_t const *r); 00259 00260 00266 extern int_spec_t 00267 boolean_or(int_spec_t const * l, int_spec_t const *r); 00268 00269 00274 extern int_spec_t 00275 negate(int_spec_t const * int_spec); 00276 00279 #endif /* EOF*/ 00280 00281