00001 // Copyright (C) 2011 CNRS - Ecole Polytechnique - INRIA. 00002 // 00003 // This file is part of TIFA. 00004 // 00005 // TIFA is free software; you can redistribute it and/or modify it under the 00006 // terms of the GNU Lesser General Public License as published by the Free 00007 // Software Foundation; either version 2.1 of the License, or (at your option) 00008 // any later version. 00009 // 00010 // TIFA is distributed in the hope that it will be useful, but WITHOUT ANY 00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00013 // more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, 00017 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 00032 #if !defined(_TIFA_BITSTRING_T_H_) 00033 00037 #define _TIFA_BITSTRING_T_H_ 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 // 00044 // _NOTE_: This header file defines symbol that should be kept internal to the 00045 // TIFA code to avoid namespace pollution (or too many TIFA_* symbol 00046 // that don't need to be external). Do not include this header 00047 // in another TIFA header! 00048 // 00049 00050 // 00051 // tifa_config.h is included to get the type TIFA_BITSTRING_T. This type 00052 // could alternatively be defined here but it may be of interest to users 00053 // of precompiled packages, so it is kept exposed in the public 00054 // tifa_config.h headers. 00055 // 00056 #include "tifa_config.h" 00057 00058 // 00059 // sizeof and number of bits of the native C type used to represent sets 00060 // of bits. These are merely aliases to TIFA_SIZEOF_BITSTRING_T and 00061 // TIFA_BITSTRING_T_BITSIZE to try to keep macro names not too long... 00062 // 00063 #define SIZEOF_BITSTRING_T TIFA_SIZEOF_BITSTRING_T 00064 #define BITSTRING_T_BITSIZE TIFA_BITSTRING_T_BITSIZE 00065 00066 // 00067 // If BITSTRING_T_BITSIZE is a power of two (and that will almost always 00068 // be the case unless one chose a weird underlying type to represent sets of 00069 // bits), define BITSTRING_T_SIZE_IS_POW_OF_TWO to 1 and assign that power 00070 // to POW_TWO_BITSTRING_T_SIZE 00071 // 00072 #if ( (BITSTRING_T_BITSIZE == 8) || (BITSTRING_T_BITSIZE == 16) \ 00073 || (BITSTRING_T_BITSIZE == 32) || (BITSTRING_T_BITSIZE == 64) \ 00074 || (BITSTRING_T_BITSIZE == 128) || (BITSTRING_T_BITSIZE == 256) \ 00075 || (BITSTRING_T_BITSIZE == 512) || (BITSTRING_T_BITSIZE == 1024) \ 00076 ) 00077 #define BITSTRING_T_SIZE_IS_POW_OF_TWO 1 00078 #else 00079 #define BITSTRING_T_SIZE_IS_POW_OF_TWO 0 00080 #endif 00081 00082 #if BITSTRING_T_SIZE_IS_POW_OF_TWO 00083 // 00084 // BITSTRING_T_BITSIZE = 2 ^ POW_TWO_BITSTRING_T_SIZE 00085 // 00086 #if (BITSTRING_T_BITSIZE == 8) 00087 #define POW_TWO_BITSTRING_T_SIZE 3 00088 00089 #elif (BITSTRING_T_BITSIZE == 16) 00090 #define POW_TWO_BITSTRING_T_SIZE 4 00091 00092 #elif (BITSTRING_T_BITSIZE == 32) 00093 #define POW_TWO_BITSTRING_T_SIZE 5 00094 00095 #elif (BITSTRING_T_BITSIZE == 64) 00096 #define POW_TWO_BITSTRING_T_SIZE 6 00097 00098 #elif (BITSTRING_T_BITSIZE == 128) 00099 #define POW_TWO_BITSTRING_T_SIZE 7 00100 00101 #elif (BITSTRING_T_BITSIZE == 256) 00102 #define POW_TWO_BITSTRING_T_SIZE 8 00103 00104 #elif (BITSTRING_T_BITSIZE == 512) 00105 #define POW_TWO_BITSTRING_T_SIZE 9 00106 00107 #elif (BITSTRING_T_BITSIZE == 1024) 00108 #define POW_TWO_BITSTRING_T_SIZE 10 00109 00110 #endif 00111 #endif 00112 00113 #ifdef __cplusplus 00114 } 00115 #endif 00116 00117 #endif 00118