X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/8282072df0158ef38743dcff9730a3223efb47a2..f0c52873e4c1e3a16bb2d5a086df2526f698e4ac:/mptypes.c diff --git a/mptypes.c b/mptypes.c index 922eae4..eb8b975 100644 --- a/mptypes.c +++ b/mptypes.c @@ -7,7 +7,7 @@ * (c) 1999 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Catacomb. * @@ -15,12 +15,12 @@ * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. - * + * * Catacomb is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU Library General Public * License along with Catacomb; if not, write to the Free * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -30,6 +30,8 @@ /*----- Header files ------------------------------------------------------*/ #define _GNU_SOURCE +#include "config.h" + #include #include #if __STDC_VERSION__ >= 199900l @@ -60,7 +62,7 @@ typedef uintmax_t umax; # define P_UMAX PRIuMAX #elif defined(ULLONG_MAX) - __extension__ typedef unsigned long long umax; + EXT typedef unsigned long long umax; # define P_UMAX "llu" #else typedef unsigned long umax; @@ -105,6 +107,7 @@ int main(int argc, char *argv[]) itype *i; itype *largest, *mpw, *mpd; const static char *extstr = "CATACOMB_MPTYPES_EXTENSION "; + unsigned p2; /* --- Find the bitcounts --- */ @@ -123,6 +126,17 @@ int main(int argc, char *argv[]) * which is twice as big as that one. */ +#if defined(FORCE_MPW_CUSSID) + largest = mpd = &tytab[3]; + mpw = &tytab[2]; + mpw->bits = 19; mpw->max = 0x7ffff; + mpd->bits = 38; mpd->max = 0x3fffffffffll; +#elif defined(FORCE_MPW_SHORT) + largest = mpd = &tytab[2]; + mpw = &tytab[1]; + mpw->bits = 16; mpw->max = 0xffff; + mpd->bits = 32; mpd->max = 0xffffffff; +#else largest = tytab; for (i = tytab; i->name; i++) { if (i->bits > largest->bits) @@ -144,7 +158,9 @@ int main(int argc, char *argv[]) w.bits /= 2; w.max = ~(~((umax)0) << w.bits); d.bits = w.bits * 2; d.max = ~(~((umax)0) << d.bits); mpw = &w; mpd = &d; - } + } +#endif + for (p2 = 1; (p2 << 1) < mpw->bits; p2 <<= 1); /* --- Output time --- */ @@ -176,6 +192,7 @@ int main(int argc, char *argv[]) printf("\ %stypedef %s mpw;\n\ #define MPW_BITS %u\n\ +#define MPW_P2 %u\n\ #define MPW_MAX %s%" P_UMAX "%s\n\ \n\ %stypedef %s mpd;\n\ @@ -185,7 +202,7 @@ int main(int argc, char *argv[]) #endif\n\ ", mpw->flags & f_ext ? extstr : "", mpw->name, - mpw->bits, + mpw->bits, p2, mpw->flags & f_ext ? extstr : "", mpw->max, mpw->suff, mpd->flags & f_ext ? extstr : "", mpd->name, mpd->bits,