OpenScop  0.9.0
int.h
Go to the documentation of this file.
00001 
00002     /*+-----------------------------------------------------------------**
00003      **                       OpenScop Library                          **
00004      **-----------------------------------------------------------------**
00005      **                             int.h                               **
00006      **-----------------------------------------------------------------**
00007      **                   First version: 18/07/2011                     **
00008      **-----------------------------------------------------------------**
00009 
00010  
00011  *****************************************************************************
00012  * OpenScop: Structures and formats for polyhedral tools to talk together    *
00013  *****************************************************************************
00014  *    ,___,,_,__,,__,,__,,__,,_,__,,_,__,,__,,___,_,__,,_,__,                *
00015  *    /   / /  //  //  //  // /   / /  //  //   / /  // /  /|,_,             *
00016  *   /   / /  //  //  //  // /   / /  //  //   / /  // /  / / /\             *
00017  *  |~~~|~|~~~|~~~|~~~|~~~|~|~~~|~|~~~|~~~|~~~|~|~~~|~|~~~|/_/  \            *
00018  *  | G |C| P | = | L | P |=| = |C| = | = | = |=| = |=| C |\  \ /\           *
00019  *  | R |l| o | = | e | l |=| = |a| = | = | = |=| = |=| L | \# \ /\          *
00020  *  | A |a| l | = | t | u |=| = |n| = | = | = |=| = |=| o | |\# \  \         *
00021  *  | P |n| l | = | s | t |=| = |d| = | = | = | |   |=| o | | \# \  \        *
00022  *  | H | | y |   | e | o | | = |l|   |   | = | |   | | G | |  \  \  \       *
00023  *  | I | |   |   | e |   | |   | |   |   |   | |   | |   | |   \  \  \      *
00024  *  | T | |   |   |   |   | |   | |   |   |   | |   | |   | |    \  \  \     *
00025  *  | E | |   |   |   |   | |   | |   |   |   | |   | |   | |     \  \  \    *
00026  *  | * |*| * | * | * | * |*| * |*| * | * | * |*| * |*| * | /      \* \  \   *
00027  *  | O |p| e | n | S | c |o| p |-| L | i | b |r| a |r| y |/        \  \ /   *
00028  *  '---'-'---'---'---'---'-'---'-'---'---'---'-'---'-'---'          '--'    *
00029  *                                                                           *
00030  * Copyright (C) 2008 University Paris-Sud 11 and INRIA                      *
00031  *                                                                           *
00032  * (3-clause BSD license)                                                    *
00033  * Redistribution and use in source  and binary forms, with or without       *
00034  * modification, are permitted provided that the following conditions        *
00035  * are met:                                                                  *
00036  *                                                                           *
00037  * 1. Redistributions of source code must retain the above copyright notice, *
00038  *    this list of conditions and the following disclaimer.                  *
00039  * 2. Redistributions in binary form must reproduce the above copyright      *
00040  *    notice, this list of conditions and the following disclaimer in the    *
00041  *    documentation and/or other materials provided with the distribution.   *
00042  * 3. The name of the author may not be used to endorse or promote products  *
00043  *    derived from this software without specific prior written permission.  *
00044  *                                                                           *
00045  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR      *
00046  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *
00047  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.   *
00048  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,          *
00049  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT  *
00050  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
00051  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY     *
00052  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT       *
00053  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF  *
00054  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.         *
00055  *                                                                           *
00056  * OpenScop Library, a library to manipulate OpenScop formats and data       *
00057  * structures. Written by:                                                   *
00058  * Cedric Bastoul     <Cedric.Bastoul@u-psud.fr> and                         *
00059  * Louis-Noel Pouchet <Louis-Noel.pouchet@inria.fr>                          *
00060  *                                                                           *
00061  *****************************************************************************/
00062 
00063 
00064 #ifndef OSL_INT_H
00065 # define OSL_INT_H
00066 
00067 # ifdef OSL_GMP_IS_HERE
00068 #  include <gmp.h>
00069 # endif
00070 
00071 # if defined(__cplusplus)
00072 extern "C"
00073   {
00074 # endif
00075 
00079 union osl_int {
00080   long int  sp; 
00081   long long dp; 
00082 #ifdef OSL_GMP_IS_HERE
00083   mpz_t*    mp; 
00084 #else
00085   void*     mp; 
00086 #endif
00087 };
00088 typedef union osl_int               osl_int_t;
00089 typedef union osl_int       *       osl_int_p;
00090 typedef union osl_int const         osl_const_int_t;
00091 typedef union osl_int       * const osl_int_const_p;
00092 typedef union osl_int const *       osl_const_int_p;
00093 typedef union osl_int const * const osl_const_int_const_p;
00094 
00095 
00096 /*+***************************************************************************
00097  *                                Basic Functions                            *
00098  *****************************************************************************/
00099 
00100 
00101 int       osl_int_is_precision_supported(int);
00102 void      osl_int_dump_precision(FILE *, int);
00103 void      osl_int_init(int, osl_int_const_p);
00104 osl_int_p osl_int_malloc(int);
00105 void      osl_int_assign(int, osl_int_const_p, osl_const_int_t);
00106 void      osl_int_set_si(int, osl_int_const_p, int);
00107 int       osl_int_get_si(int, osl_const_int_t);
00108 double    osl_int_get_d(int, osl_const_int_t);
00109 void      osl_int_init_set(int, osl_int_const_p, osl_const_int_t);
00110 void      osl_int_init_set_si(int, osl_int_const_p, int);
00111 void      osl_int_swap(int, osl_int_const_p, osl_int_const_p);
00112 void      osl_int_clear(int, osl_int_const_p);
00113 void      osl_int_free(int, osl_int_const_p);
00114 void      osl_int_print(FILE *, int, osl_const_int_t);
00115 void      osl_int_sprint(char *, int, osl_const_int_t);
00116 void      osl_int_sprint_txt(char *, int, osl_const_int_t);
00117 int       osl_int_sscanf(char*, int, osl_int_const_p);
00118 void      osl_int_sread(char **, int, osl_int_const_p);
00119 
00120 
00121 /*+***************************************************************************
00122  *                            Arithmetic Operations                          *
00123  *****************************************************************************/
00124 
00125 
00126 void      osl_int_increment(int, osl_int_const_p, osl_const_int_t);
00127 void      osl_int_decrement(int, osl_int_const_p, osl_const_int_t);
00128 void      osl_int_add(int, osl_int_const_p, osl_const_int_t, osl_const_int_t);
00129 void      osl_int_add_si(int, osl_int_const_p, osl_const_int_t, int);
00130 void      osl_int_sub(int, osl_int_const_p, osl_const_int_t, osl_const_int_t);
00131 void      osl_int_mul(int, osl_int_const_p, osl_const_int_t, osl_const_int_t);
00132 void      osl_int_mul_si(int, osl_int_const_p, osl_const_int_t, int);
00133 void      osl_int_div_exact(int const, osl_int_const_p,
00134                                        osl_const_int_t, osl_const_int_t);
00135 void      osl_int_floor_div_q(int const, osl_int_const_p,
00136                                          osl_const_int_t, osl_const_int_t);
00137 void      osl_int_floor_div_r(int const, osl_int_const_p,
00138                                          osl_const_int_t, osl_const_int_t);
00139 void      osl_int_floor_div_q_r(int const, osl_int_const_p, osl_int_const_p,
00140                                            osl_const_int_t, osl_const_int_t);
00141 void      osl_int_mod(int const, osl_int_const_p,
00142                                  osl_const_int_t, osl_const_int_t);
00143 void      osl_int_gcd(int const, osl_int_const_p,
00144                                  osl_const_int_t, osl_const_int_t);
00145 void      osl_int_oppose(int, osl_int_const_p, osl_const_int_t);
00146 void      osl_int_abs(int, osl_int_const_p, osl_const_int_t);
00147 size_t    osl_int_size_in_base_2(int const, osl_const_int_t);
00148 size_t    osl_int_size_in_base_10(int const, osl_const_int_t);
00149 
00150 
00151 /*+***************************************************************************
00152  *                            Conditional Operations                         *
00153  *****************************************************************************/
00154 
00155 
00156 int       osl_int_eq(int, osl_const_int_t, osl_const_int_t);
00157 int       osl_int_ne(int, osl_const_int_t, osl_const_int_t);
00158 int       osl_int_pos(int, osl_const_int_t);
00159 int       osl_int_neg(int, osl_const_int_t);
00160 int       osl_int_zero(int, osl_const_int_t);
00161 int       osl_int_one(int, osl_const_int_t);
00162 int       osl_int_mone(int, osl_const_int_t);
00163 int       osl_int_divisible(int, osl_const_int_t, osl_const_int_t);
00164 
00165 
00166 # if defined(__cplusplus)
00167   }
00168 # endif
00169 
00170 #endif /* define OSL_INT_H */