00001 /* File: box_defines.h 00002 ** Author(s): Rojo 00003 ** Contact: xsb-contact@cs.sunysb.edu 00004 ** 00005 ** Copyright (C) The Research Foundation of SUNY, 1986, 1993-1998 00006 ** Copyright (C) ECRC, Germany, 1990 00007 ** 00008 ** XSB is free software; you can redistribute it and/or modify it under the 00009 ** terms of the GNU Library General Public License as published by the Free 00010 ** Software Foundation; either version 2 of the License, or (at your option) 00011 ** any later version. 00012 ** 00013 ** XSB is distributed in the hope that it will be useful, but WITHOUT ANY 00014 ** WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00015 ** FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for 00016 ** more details. 00017 ** 00018 ** You should have received a copy of the GNU Library General Public License 00019 ** along with XSB; if not, write to the Free Software Foundation, 00020 ** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00021 ** 00022 */ 00023 00024 #ifndef BOX_DEFINES_H 00025 #define BOX_DEFINES_H 00026 00027 #include "xsb_config.h" 00028 00029 00030 /*16 to give space for the most significant 16 bits of 64bit numbers when using boxed representation.*/ 00031 #define BOX_ID_OFFSET 16 00032 00033 /********************************** 00034 * BOX ID's, to be placed in the 24th through 17th least significant 00035 * bits of the first integer in a boxed value. 00036 ***********************************/ 00037 #define ID_BOXED_INT 1 00038 #define ID_BOXED_FLOAT 2 00039 00040 //TODO: define different shift constants in the BIT extracting macros below and alternate 00041 //depending on architecture implementation of ints, doubles, floats, etc... 00042 #define LOW_24_BITS_MASK 0xffffff 00043 #define LOW_16_BITS_MASK 0xffff 00044 00045 #define INT_LOW_24_BITS(value) (((unsigned)(value)) >> 24) 00046 00047 00048 #ifndef FAST_FLOATS 00049 //The below macros expect "float" to be a double float variable local to the thread it is envoked in. 00050 // Any caller must ensure that it isn't something such as a macro that produces a function call, 00051 // a constant, an expression, or a static/global variable (for thread-safe safety) 00052 #define FLOAT_HIGH_16_BITS(float) ((((UInteger)(*((UInteger *)((void *)(& float)))))>>16) & LOW_16_BITS_MASK) 00053 #define FLOAT_MIDDLE_24_BITS(float) \ 00054 ( (((UInteger)(*(((UInteger *)((void *)(& float)))+1)))>>24) \ 00055 | (((UInteger)(*((UInteger *)((void *)&(float)))) & LOW_16_BITS_MASK)<<8) \ 00056 ) 00057 #define FLOAT_LOW_24_BITS(float) (((UInteger)(*(((UInteger *)((void *)(& float)))+1))) & LOW_24_BITS_MASK) 00058 00059 #endif 00060 00061 #endif