w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

asl.h
Go to the documentation of this file.
1 /* asl.h -- artificially small limbs support by means of C++ operator
2  overloading.
3 
4 Copyright 2016 Free Software Foundation, Inc.
5 
6 This file is part of the GNU MP Library.
7 
8 The GNU MP Library is free software; you can redistribute it and/or modify
9 it under the terms of either:
10 
11  * the GNU Lesser General Public License as published by the Free
12  Software Foundation; either version 3 of the License, or (at your
13  option) any later version.
14 
15 or
16 
17  * the GNU General Public License as published by the Free Software
18  Foundation; either version 2 of the License, or (at your option) any
19  later version.
20 
21 or both in parallel, as here.
22 
23 The GNU MP Library is distributed in the hope that it will be useful, but
24 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 for more details.
27 
28 You should have received copies of the GNU General Public License and the
29 GNU Lesser General Public License along with the GNU MP Library. If not,
30 see https://www.gnu.org/licenses/. */
31 
32 #include <iostream>
33 #include <cstdint>
34 #include <cstdlib>
35 // #include <stdexcept>
36 
37 #ifndef GMP_ASSERT_ALWAYS
38 #define GMP_ASSERT_ALWAYS(cc) do {if (!(cc)) abort();} while (0)
39 #endif
40 
41 // Missing: post++ post-- ++pre --prec bool(limb) !limb
42 
43 #ifndef GMP_LIMB_BITS
44 #define GMP_LIMB_BITS 4
45 #endif
46 
47 #define GMP_NUMB_MASK (2 * (1ul << (GMP_LIMB_BITS - 1)) - 1)
48 
49 #define BINOP_MASK(op, type) \
50  mp_limb_t& operator op##=(const type& rhs) { \
51  limbo = (limbo op rhs.limbo) & GMP_NUMB_MASK; \
52  return *this; \
53  }
54 #define BINOP_NOMASK(op, type) \
55  mp_limb_t& operator op##=(const type& rhs) { \
56  limbo = limbo op rhs.limbo; \
57  return *this; \
58  }
59 
62 
63 class mp_limb_t {
64 public:
65  mp_limb_t() {} // put random garbage in limbo?
66  mp_limb_t(const unsigned int rhs) { limbo = rhs & GMP_NUMB_MASK; }
67  // mp_limb_t(const mp_limb_t& rhs) { limbo = rhs.limbo; } // Causes havoc
76  mp_limb_t& operator<<=(const unsigned int rhs) {
78  limbo = (limbo << rhs) & GMP_NUMB_MASK;
79  return *this;
80  }
81  mp_limb_t& operator>>=(const unsigned int rhs) {
83  limbo = limbo >> rhs;
84  return *this;
85  }
87  return static_cast<mp_limb_t>((-limbo) & GMP_NUMB_MASK);
88  // mp_limb_t x; x.limbo = (-limbo) & GMP_NUMB_MASK; return x;
89  }
91  return static_cast<mp_limb_t>((~~limbo) & GMP_NUMB_MASK);
92  // mp_limb_t x; x.limbo = (~limbo) & GMP_NUMB_MASK; return x;
93  }
94  operator unsigned int() const { return limbo; }
95  operator int() const { return limbo; }
96 
97 #define RELOP(op) \
98  inline bool operator op(const mp_limb_t rhs) { \
99  return limbo op rhs.limbo; \
100  }
101  RELOP(==)
102  RELOP(!=)
103  RELOP(<)
104  RELOP(>)
105  RELOP(<=)
106  RELOP(>=)
107 
108 private:
110 };
111 
112 #define BINOP2(op, type) \
113  inline mp_limb_t operator op(mp_limb_t lhs, const type& rhs) { \
114  lhs op##= rhs; \
115  return lhs; \
116  }
117 
126 BINOP2(<<, unsigned int)
127 BINOP2(>>, unsigned int)
#define type(a)
Definition: aptex-macros.h:171
#define RELOP(op)
Definition: asl.h:97
#define GMP_ASSERT_ALWAYS(cc)
Definition: asl.h:38
#define GMP_LIMB_BITS
Definition: asl.h:44
std::conditional<((2 *(1ul<<(4 - 1)) - 1)<=0xffff), uint16_t, uint32_t >::type type24
Definition: asl.h:60
#define GMP_NUMB_MASK
Definition: asl.h:47
#define BINOP_NOMASK(op, type)
Definition: asl.h:54
#define BINOP2(op, type)
Definition: asl.h:112
#define BINOP_MASK(op, type)
Definition: asl.h:49
std::conditional<((2 *(1ul<<(4 - 1)) - 1)<=0xff), uint8_t, type24 >::type mtype
Definition: asl.h:61
Definition: asl.h:63
mtype limbo
Definition: asl.h:109
mp_limb_t()
Definition: asl.h:65
mp_limb_t operator-()
Definition: asl.h:86
mp_limb_t(const unsigned int rhs)
Definition: asl.h:66
mp_limb_t operator~()
Definition: asl.h:90
mp_limb_t & operator>>=(const unsigned int rhs)
Definition: asl.h:81
#define const
Definition: ftzconf.h:91
char conditional[20]
Definition: web2c-lexer.c:709
Definition: epdf.c:232
Definition: psfont.h:67
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)