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)  

fpif.c
Go to the documentation of this file.
1 /* mpfr_fpif -- Binary export & import of MPFR numbers
2  (floating-point interchange format)
3 
4 Copyright 2012-2020 Free Software Foundation, Inc.
5 Contributed by Olivier Demengeon.
6 
7 This file is part of the GNU MPFR Library.
8 
9 The GNU MPFR Library is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13 
14 The GNU MPFR Library is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17 License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public License
20 along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
21 https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
22 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
23 
24 #include "mpfr-impl.h"
25 
26 #if !defined (HAVE_BIG_ENDIAN) && !defined (HAVE_LITTLE_ENDIAN)
27 #error "Endianness is unknown. Not supported yet."
28 #endif
29 
30 /* The format is described as follows. Any multi-byte number is encoded
31  in little endian.
32 
33  1. We first store the precision p (this format is able to represent
34  any precision from 1 to 2^64 + 248).
35  Let B be the first byte (0 <= B <= 255).
36  * If B >= 8, the precision p is B-7.
37  Here, the condition is equivalent to 1 <= p <= 248.
38  * If B <= 7, the next B+1 bytes contain p-249.
39  Here, the condition is equivalent to 249 <= p <= 2^64 + 248.
40  We will use the following macros:
41  * MPFR_MAX_PRECSIZE = 7
42  * MPFR_MAX_EMBEDDED_PRECISION = 255 - 7 = 248
43 
44  2. Then we store the sign bit and exponent related information
45  (possibly a special value). We first have byte A = [seeeeeee],
46  where s is the sign bit and E = [eeeeeee] such that:
47  * If 0 <= E <= 94, then the exponent e is E-47 (-47 <= e <= 47).
48  * If 95 <= E <= 110, the exponent is stored in the next E-94 bytes
49  (1 to 16 bytes) in sign + absolute value representation,
50  where the absolute value is increased by 47 (e <= -47 or 47 <= e).
51  * If 111 <= E <= 118, the exponent size S is stored in the next
52  E-110 bytes (1 to 8), then the exponent itself is stored in the
53  next S bytes. [Not implemented yet]
54  * If 119 <= E <= 127, we have a special value:
55  E = 119 (MPFR_KIND_ZERO) for a signed zero;
56  E = 120 (MPFR_KIND_INF) for a signed infinity;
57  E = 121 (MPFR_KIND_NAN) for NaN.
58 
59  3. Then we store the significand (for regular values).
60 
61  The sign bit is preserved by the import/export functions, even for NaN.
62 
63  Note: When a size is stored, it must be minimal, i.e. a number cannot
64  start with a null byte. Otherwise the import may fail.
65 */
66 
67 #define MPFR_MAX_PRECSIZE 7
68 #define MPFR_MAX_EMBEDDED_PRECISION (255 - MPFR_MAX_PRECSIZE)
69 
70 #define MPFR_KIND_ZERO 119
71 #define MPFR_KIND_INF 120
72 #define MPFR_KIND_NAN 121
73 #define MPFR_MAX_EMBEDDED_EXPONENT 47
74 #define MPFR_EXTERNAL_EXPONENT 94
75 
76 /* Begin: Low level helper functions */
77 
78 /* storage must have an unsigned type */
79 #define COUNT_NB_BYTE(storage, size) \
80  do \
81  { \
82  (storage) >>= 8; \
83  (size)++; \
84  } \
85  while ((storage) != 0)
86 
87 #define ALLOC_RESULT(buffer, buffer_size, wanted_size) \
88  do \
89  { \
90  if ((buffer) == NULL || *(buffer_size) < (wanted_size)) \
91  { \
92  (buffer) = (unsigned char *) mpfr_reallocate_func \
93  ((buffer), *(buffer_size), (wanted_size)); \
94  MPFR_ASSERTN((buffer) != 0); \
95  } \
96  *(buffer_size) = (wanted_size); \
97  } \
98  while (0)
99 
100 /*
101  * size in byte of a MPFR number in a binary object of a variable size
102  */
103 #define MAX_VARIABLE_STORAGE(exponent_size, precision) \
104  ((size_t)(((precision) >> 3) + (exponent_size) + \
105  ((precision) > 248 ? sizeof(mpfr_prec_t) : 0) + 3))
106 
107 /* copy in result[] the values in data[] with a different endianness,
108  where data_size might be smaller than data_max_size, so that we only
109  copy data_size bytes from the end of data[]. */
110 static void
111 #if defined (HAVE_BIG_ENDIAN)
112 putLittleEndianData (unsigned char *result, unsigned char *data,
113  size_t data_max_size, size_t data_size)
114 #elif defined (HAVE_LITTLE_ENDIAN)
115 putBigEndianData (unsigned char *result, unsigned char *data,
116  size_t data_max_size, size_t data_size)
117 #endif
118 {
119  size_t j;
120 
121  MPFR_ASSERTD (data_size <= data_max_size);
122  for (j = 0; j < data_size; j++)
123  result[j] = data[data_max_size - j - 1];
124 }
125 
126 /* copy in result[] the values in data[] with the same endianness */
127 static void
128 #if defined (HAVE_BIG_ENDIAN)
129 putBigEndianData (unsigned char *result, unsigned char *data,
130  size_t data_max_size, size_t data_size)
131 #elif defined (HAVE_LITTLE_ENDIAN)
132 putLittleEndianData (unsigned char *result, unsigned char *data,
133  size_t data_max_size, size_t data_size)
134 #endif
135 {
136  MPFR_ASSERTD (data_size <= data_max_size);
137  memcpy (result, data, data_size);
138 }
139 
140 /* copy in result[] the values in data[] with a different endianness;
141  the data are written at the end of the result[] buffer (if
142  data_size < data_max_size, the first bytes of result[] are
143  left untouched). */
144 static void
145 #if defined (HAVE_BIG_ENDIAN)
146 getLittleEndianData (unsigned char *result, unsigned char *data,
147  size_t data_max_size, size_t data_size)
148 #elif defined (HAVE_LITTLE_ENDIAN)
149 getBigEndianData (unsigned char *result, unsigned char *data,
150  size_t data_max_size, size_t data_size)
151 #endif
152 {
153  size_t j;
154 
155  MPFR_ASSERTD (data_size <= data_max_size);
156  for (j = 0; j < data_size; j++)
157  result[data_max_size - j - 1] = data[j];
158 }
159 
160 /* copy in result[] the values in data[] with the same endianness */
161 static void
162 #if defined (HAVE_BIG_ENDIAN)
163 getBigEndianData (unsigned char *result, unsigned char *data,
164  size_t data_max_size, size_t data_size)
165 #elif defined (HAVE_LITTLE_ENDIAN)
166 getLittleEndianData (unsigned char *result, unsigned char *data,
167  size_t data_max_size, size_t data_size)
168 #endif
169 {
170  MPFR_ASSERTD (data_size <= data_max_size);
171  memcpy (result, data, data_size);
172 }
173 
174 /* End: Low level helper functions */
175 
176 /* Internal Function */
177 /*
178  * buffer : OUT : store the precision in binary format, can be null
179  * (may be reallocated if too small)
180  * buffer_size : IN/OUT : size of the buffer => size used in the buffer
181  * precision : IN : precision to store
182  * return pointer to a buffer storing the precision in binary format
183  */
184 static unsigned char *
187 {
188  unsigned char *result;
189  size_t size_precision;
190 
191  MPFR_ASSERTD (precision >= 1);
192  size_precision = 0;
193 
195  {
196  mpfr_uprec_t copy_precision;
197 
198  copy_precision = precision - (MPFR_MAX_EMBEDDED_PRECISION + 1);
199  COUNT_NB_BYTE(copy_precision, size_precision);
200  }
201 
202  result = buffer;
203  ALLOC_RESULT(result, buffer_size, size_precision + 1);
204 
206  {
207  result[0] = size_precision - 1;
209  putLittleEndianData (result + 1, (unsigned char *) &precision,
210  sizeof(mpfr_prec_t), size_precision);
211  }
212  else
214 
215  return result;
216 }
217 
218 #define BUFFER_SIZE 8
219 
220 /*
221  * fh : IN : file handler
222  * return the precision stored in the binary buffer, 0 in case of error
223  */
224 static mpfr_prec_t
226 {
228  size_t precision_size;
229  unsigned char buffer[BUFFER_SIZE];
230 
231  if (fh == NULL)
232  return 0;
233 
234  if (fread (buffer, 1, 1, fh) != 1)
235  return 0;
236 
237  precision_size = buffer[0];
238  if (precision_size > MPFR_MAX_PRECSIZE)
239  return precision_size - MPFR_MAX_PRECSIZE;
240 
241  precision_size++;
242  MPFR_ASSERTD (precision_size <= BUFFER_SIZE);
243 
244  /* Read the precision in little-endian format. */
245  if (fread (buffer, precision_size, 1, fh) != 1)
246  return 0;
247 
248  /* Justification of the #if below. */
249  MPFR_ASSERTD (precision_size <= MPFR_MAX_PRECSIZE + 1);
250 
251 #if (MPFR_MAX_PRECSIZE + 1) * CHAR_BIT > MPFR_PREC_BITS
252  while (precision_size > sizeof(mpfr_prec_t))
253  {
254  if (buffer[precision_size-1] != 0)
255  return 0; /* the read precision doesn't fit in a mpfr_prec_t */
256  precision_size--;
257  }
258 #endif
259 
260  /* To detect bugs affecting particular platforms (thus MPFR_ASSERTN)... */
261  MPFR_ASSERTN (precision_size <= sizeof(mpfr_prec_t));
262 
263  /* Since mpfr_prec_t is signed, one also needs to check that the
264  most significant bit of the corresponding unsigned value is 0. */
265  if (precision_size == sizeof(mpfr_prec_t) &&
266  buffer[precision_size-1] >= 0x80)
267  return 0; /* the read precision doesn't fit in a mpfr_prec_t */
268 
269  precision = 0; /* to pad with 0's if data_size < data_max_size */
270 
271  /* On big-endian machines, the data must be copied at the end of the
272  precision object in the memory; thus data_max_size (3rd argument)
273  must be sizeof(mpfr_prec_t). */
274  getLittleEndianData ((unsigned char *) &precision, buffer,
275  sizeof(mpfr_prec_t), precision_size);
276 
277  return precision + (MPFR_MAX_EMBEDDED_PRECISION + 1);
278 }
279 
280 /*
281  * buffer : OUT : store the kind of the MPFR number x, its sign, the size of
282  * its exponent and its exponent value in a binary format,
283  * can be null (may be reallocated if too small)
284  * buffer_size : IN/OUT : size of the buffer => size used in the buffer
285  * x : IN : MPFR number
286  * return pointer to a buffer storing the kind of the MPFR number x, its sign,
287  * the size of its exponent and its exponent value in a binary format,
288  */
289 /* TODO
290  * Exponents that use more than 16 bytes are not managed (not an issue
291  * until one has integer types larger than 128 bits).
292  */
293 static unsigned char*
295 {
296  unsigned char *result;
297  mpfr_uexp_t uexp;
298  size_t exponent_size;
299 
300  exponent_size = 0;
301 
302  if (MPFR_IS_PURE_FP (x))
303  {
304  mpfr_exp_t exponent = MPFR_GET_EXP (x);
305 
306  if (exponent > MPFR_MAX_EMBEDDED_EXPONENT ||
307  exponent < -MPFR_MAX_EMBEDDED_EXPONENT)
308  {
309  mpfr_uexp_t copy_exponent, exp_sign_bit;
310 
311  uexp = SAFE_ABS (mpfr_uexp_t, exponent)
313 
314  /* Shift uexp to take the sign bit of the exponent into account.
315  Because of constraints on the valid exponents, this cannot
316  overflow (check with an MPFR_ASSERTD). */
317  copy_exponent = uexp << 1;
318  MPFR_ASSERTD (copy_exponent > uexp);
319  COUNT_NB_BYTE(copy_exponent, exponent_size);
320  MPFR_ASSERTN (exponent_size <= 16); /* see TODO */
321 
322  /* Sign bit of the exponent. */
323  exp_sign_bit = (mpfr_uexp_t) 1 << (8 * exponent_size - 1);
324  MPFR_ASSERTD (uexp < exp_sign_bit);
325  if (exponent < 0)
326  uexp |= exp_sign_bit;
327  }
328  else
329  uexp = exponent + MPFR_MAX_EMBEDDED_EXPONENT;
330  }
331 
332  result = buffer;
333  ALLOC_RESULT(result, buffer_size, exponent_size + 1);
334 
335  if (MPFR_IS_PURE_FP (x))
336  {
337  if (exponent_size == 0)
338  result[0] = uexp;
339  else
340  {
341  result[0] = MPFR_EXTERNAL_EXPONENT + exponent_size;
342 
343  putLittleEndianData (result + 1, (unsigned char *) &uexp,
344  sizeof(mpfr_exp_t), exponent_size);
345  }
346  }
347  else if (MPFR_IS_ZERO (x))
348  result[0] = MPFR_KIND_ZERO;
349  else if (MPFR_IS_INF (x))
350  result[0] = MPFR_KIND_INF;
351  else
352  {
354  result[0] = MPFR_KIND_NAN;
355  }
356 
357  /* Set the sign, even for NaN. */
358  if (MPFR_IS_NEG (x))
359  result[0] |= 0x80;
360 
361  return result;
362 }
363 
364 /*
365  * x : OUT : MPFR number extracted from the binary buffer
366  * fh : IN : file handler (should not be NULL)
367  * return 0 if successful
368  */
369 /* TODO
370  * Exponents that use more than 16 bytes are not managed (this is not
371  * an issue if the data were written by MPFR with mpfr_exp_t not larger
372  * than 128 bits).
373  */
374 static int
376 {
377  mpfr_exp_t exponent;
378  mpfr_uexp_t uexp;
379  size_t exponent_size;
380  int sign;
381  unsigned char buffer[sizeof(mpfr_exp_t)];
382 
383  MPFR_ASSERTD(fh != NULL);
384 
385  if (fread (buffer, 1, 1, fh) != 1)
386  return 1;
387 
388  /* sign value that can be used with MPFR_SET_SIGN,
389  mpfr_set_zero and mpfr_set_inf */
390  sign = (buffer[0] & 0x80) ? MPFR_SIGN_NEG : MPFR_SIGN_POS;
391  /* Set the sign, even for NaN. */
392  MPFR_SET_SIGN (x, sign);
393 
394  exponent = buffer[0] & 0x7F;
395  exponent_size = 1;
396 
397  if (exponent > MPFR_EXTERNAL_EXPONENT && exponent < MPFR_KIND_ZERO)
398  {
399  mpfr_uexp_t exp_sign_bit;
400 
401  exponent_size = exponent - MPFR_EXTERNAL_EXPONENT;
402 
403  /* A failure is acceptable when the exponent starts with leading zeros,
404  even if it would fit in mpfr_exp_t (see format description). */
405  if (MPFR_UNLIKELY (exponent_size > 16 /* see TODO */ ||
406  exponent_size > sizeof(mpfr_exp_t)))
407  return 1;
408 
409  if (MPFR_UNLIKELY (fread (buffer, exponent_size, 1, fh) != 1))
410  return 1;
411 
412  uexp = 0;
413  getLittleEndianData ((unsigned char *) &uexp, buffer,
414  sizeof(mpfr_exp_t), exponent_size);
415 
416  /* Sign bit of the exponent. */
417  exp_sign_bit = uexp & ((mpfr_uexp_t) 1 << (8 * exponent_size - 1));
418 
419  uexp &= ~~exp_sign_bit;
421  if (MPFR_UNLIKELY (uexp > MPFR_EMAX_MAX && uexp > -MPFR_EMIN_MIN))
422  return 1;
423 
424  exponent = exp_sign_bit ? - (mpfr_exp_t) uexp : (mpfr_exp_t) uexp;
425  if (MPFR_UNLIKELY (! MPFR_EXP_IN_RANGE (exponent)))
426  return 1;
427  MPFR_SET_EXP (x, exponent);
428 
429  exponent_size++;
430  }
431  else if (exponent == MPFR_KIND_ZERO)
432  MPFR_SET_ZERO (x);
433  else if (exponent == MPFR_KIND_INF)
434  MPFR_SET_INF (x);
435  else if (exponent == MPFR_KIND_NAN)
436  MPFR_SET_NAN (x);
437  else if (exponent <= MPFR_EXTERNAL_EXPONENT)
438  {
439  exponent -= MPFR_MAX_EMBEDDED_EXPONENT;
440  if (MPFR_UNLIKELY (! MPFR_EXP_IN_RANGE (exponent)))
441  return 1;
442  MPFR_SET_EXP (x, exponent);
443  }
444  else
445  return 1;
446 
447  return 0;
448 }
449 
450 /*
451  * buffer : OUT : store the limb of the MPFR number x in a binary format,
452  * can be null (may be reallocated if too small)
453  * buffer_size : IN/OUT : size of the buffer => size used in the buffer
454  * x : IN : MPFR number
455  * return pointer to a buffer storing the limb of the MPFR number x in a binary
456  * format
457  */
458 static unsigned char*
459 mpfr_fpif_store_limbs (unsigned char *buffer, size_t *buffer_size, mpfr_t x)
460 {
461  unsigned char *result;
463  size_t nb_byte;
464  size_t nb_limb, mp_bytes_per_limb;
465  size_t nb_partial_byte;
466  size_t i, j;
467 
469  nb_byte = (precision + 7) >> 3;
470  mp_bytes_per_limb = mp_bits_per_limb >> 3;
471  nb_partial_byte = nb_byte % mp_bytes_per_limb;
472  nb_limb = (nb_byte + mp_bytes_per_limb - 1) / mp_bytes_per_limb;
473 
474  result = buffer;
475  ALLOC_RESULT(result, buffer_size, nb_byte);
476 
477  putBigEndianData (result, (unsigned char*) MPFR_MANT(x),
478  sizeof(mp_limb_t), nb_partial_byte);
479  for (i = nb_partial_byte, j = (nb_partial_byte == 0) ? 0 : 1; j < nb_limb;
480  i += mp_bytes_per_limb, j++)
481  putLittleEndianData (result + i, (unsigned char*) (MPFR_MANT(x) + j),
482  sizeof(mp_limb_t), sizeof(mp_limb_t));
483 
484  return result;
485 }
486 
487 /*
488  * x : OUT : MPFR number extracted from the binary buffer, should have the same
489  * precision than the number in the binary format
490  * buffer : IN : limb of the MPFR number x in a binary format
491  * nb_byte : IN : size of the buffer (in bytes)
492  * Assume buffer is not NULL.
493  */
494 static void
495 mpfr_fpif_read_limbs (mpfr_t x, unsigned char *buffer, size_t nb_byte)
496 {
497  size_t mp_bytes_per_limb;
498  size_t nb_partial_byte;
499  size_t i, j;
500 
501  MPFR_ASSERTD (buffer != NULL);
502 
503  mp_bytes_per_limb = mp_bits_per_limb >> 3;
504  nb_partial_byte = nb_byte % mp_bytes_per_limb;
505 
506  if (nb_partial_byte > 0)
507  {
508  memset (MPFR_MANT(x), 0, sizeof(mp_limb_t));
509  getBigEndianData ((unsigned char*) MPFR_MANT(x), buffer,
510  sizeof(mp_limb_t), nb_partial_byte);
511  }
512  for (i = nb_partial_byte, j = (nb_partial_byte == 0) ? 0 : 1; i < nb_byte;
513  i += mp_bytes_per_limb, j++)
514  getLittleEndianData ((unsigned char*) (MPFR_MANT(x) + j), buffer + i,
515  sizeof(mp_limb_t), sizeof(mp_limb_t));
516 }
517 
518 /* External Function */
519 /*
520  * fh : IN : file handler
521  * x : IN : MPFR number to put in the file
522  * return 0 if successful
523  */
524 int
525 mpfr_fpif_export (FILE *fh, mpfr_t x)
526 {
527  int status;
528  unsigned char *buf;
529  unsigned char *bufResult;
530  size_t used_size, buf_size;
531 
532  if (fh == NULL)
533  return -1;
534 
536  buf = (unsigned char*) mpfr_allocate_func (buf_size);
537  MPFR_ASSERTN(buf != NULL);
538 
539  used_size = buf_size;
540  buf = mpfr_fpif_store_precision (buf, &used_size, mpfr_get_prec (x));
541  used_size > buf_size ? buf_size = used_size : 0;
542  status = fwrite (buf, used_size, 1, fh);
543  if (status != 1)
544  {
546  return -1;
547  }
548  used_size = buf_size;
549  bufResult = mpfr_fpif_store_exponent (buf, &used_size, x);
550  /* bufResult cannot be NULL: if reallocation failed in
551  mpfr_fpif_store_exponent, an assertion failed */
552  buf = bufResult;
553  used_size > buf_size ? buf_size = used_size : 0;
554  status = fwrite (buf, used_size, 1, fh);
555  if (status != 1)
556  {
558  return -1;
559  }
560 
561  if (mpfr_regular_p (x))
562  {
563  used_size = buf_size;
564  buf = mpfr_fpif_store_limbs (buf, &used_size, x);
565  used_size > buf_size ? buf_size = used_size : 0;
566  status = fwrite (buf, used_size, 1, fh);
567  if (status != 1)
568  {
570  return -1;
571  }
572  }
573 
575  return 0;
576 }
577 
578 /*
579  * x : IN/OUT : MPFR number extracted from the file, its precision is reset to
580  * be able to hold the number
581  * fh : IN : file handler
582  * Return 0 if the import was successful.
583  */
584 int
585 mpfr_fpif_import (mpfr_t x, FILE *fh)
586 {
587  int status;
589  unsigned char *buffer;
590  size_t used_size;
591 
593  if (precision == 0) /* precision = 0 means an error */
594  return -1;
595  MPFR_ASSERTD(fh != NULL); /* checked by mpfr_fpif_read_precision_from_file */
596  if (precision > MPFR_PREC_MAX)
597  return -1;
598  MPFR_STAT_STATIC_ASSERT (MPFR_PREC_MIN == 1); /* as specified */
600 
602  if (status != 0)
603  {
604  mpfr_set_nan (x);
605  return -1;
606  }
607 
608  /* Warning! The significand of x is not set yet. Thus use MPFR_IS_SINGULAR
609  for the test. */
610  if (!MPFR_IS_SINGULAR (x))
611  {
612  /* For portability, we need to consider bytes with only 8 significant
613  bits in the interchange format. That's OK because CHAR_BIT >= 8.
614  But the implementation is currently not clear when CHAR_BIT > 8.
615  This may have never been tested. For safety, require CHAR_BIT == 8,
616  and test/adapt the code if this ever fails. */
618  MPFR_STAT_STATIC_ASSERT ((MPFR_PREC_MAX + 7) >> 3 <= (size_t) -1);
619  used_size = (precision + 7) >> 3; /* ceil(precision/8) */
620  buffer = (unsigned char*) mpfr_allocate_func (used_size);
622  status = fread (buffer, used_size, 1, fh);
623  if (status != 1)
624  {
625  mpfr_free_func (buffer, used_size);
626  mpfr_set_nan (x);
627  return -1;
628  }
629  mpfr_fpif_read_limbs (x, buffer, used_size);
630  mpfr_free_func (buffer, used_size);
631  }
632 
633  return 0;
634 }
#define CHAR_BIT
Definition: ChkTeX.h:91
Definition: asl.h:63
#define fread
Definition: xxstdio.h:25
struct rect data
Definition: dvipdfm.c:64
#define MAX_VARIABLE_STORAGE(exponent_size, precision)
Definition: fpif.c:103
#define MPFR_KIND_ZERO
Definition: fpif.c:70
#define MPFR_KIND_INF
Definition: fpif.c:71
static unsigned char * mpfr_fpif_store_exponent(unsigned char *buffer, size_t *buffer_size, mpfr_t x)
Definition: fpif.c:294
#define BUFFER_SIZE
Definition: fpif.c:218
#define MPFR_EXTERNAL_EXPONENT
Definition: fpif.c:74
static unsigned char * mpfr_fpif_store_limbs(unsigned char *buffer, size_t *buffer_size, mpfr_t x)
Definition: fpif.c:459
memcpy(result, data, data_size)
#define COUNT_NB_BYTE(storage, size)
Definition: fpif.c:79
static mpfr_prec_t mpfr_fpif_read_precision_from_file(FILE *fh)
Definition: fpif.c:225
static int mpfr_fpif_read_exponent_from_file(mpfr_t x, FILE *fh)
Definition: fpif.c:375
#define MPFR_MAX_PRECSIZE
Definition: fpif.c:67
#define MPFR_KIND_NAN
Definition: fpif.c:72
#define MPFR_MAX_EMBEDDED_EXPONENT
Definition: fpif.c:73
#define MPFR_MAX_EMBEDDED_PRECISION
Definition: fpif.c:68
static unsigned char * mpfr_fpif_store_precision(unsigned char *buffer, size_t *buffer_size, mpfr_prec_t precision)
Definition: fpif.c:185
#define ALLOC_RESULT(buffer, buffer_size, wanted_size)
Definition: fpif.c:87
static void mpfr_fpif_read_limbs(mpfr_t x, unsigned char *buffer, size_t nb_byte)
Definition: fpif.c:495
#define mp_bits_per_limb
Definition: gmp.h:486
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
#define buf
#define buf_size
Definition: ctangleboot.c:104
Code related to b fwrite(a, sizeof(char), b, stdout) @d C_printf(c
void mpfr_free_func(void *ptr, size_t size)
Definition: mpfr-gmp.c:330
void * mpfr_allocate_func(size_t alloc_size)
Definition: mpfr-gmp.c:308
#define MPFR_IS_INF(x)
Definition: mpfr-impl.h:1082
#define MPFR_SET_EXP(x, e)
Definition: mpfr-impl.h:1059
#define MPFR_SET_NAN(x)
Definition: mpfr-impl.h:1081
#define MPFR_UNLIKELY(x)
Definition: mpfr-impl.h:1490
#define MPFR_IS_NAN(x)
Definition: mpfr-impl.h:1080
#define MPFR_EMIN_MIN
Definition: mpfr-impl.h:1031
#define MPFR_IS_PURE_FP(x)
Definition: mpfr-impl.h:1108
#define MPFR_IS_NEG(x)
Definition: mpfr-impl.h:1140
#define MPFR_EMAX_MAX
Definition: mpfr-impl.h:1034
#define MPFR_SIGN_POS
Definition: mpfr-impl.h:1134
#define MPFR_GET_EXP(x)
Definition: mpfr-impl.h:1058
#define MPFR_SIGN_NEG
Definition: mpfr-impl.h:1135
#define MPFR_SET_ZERO(x)
Definition: mpfr-impl.h:1085
#define MPFR_IS_ZERO(x)
Definition: mpfr-impl.h:1084
#define MPFR_EXP_IN_RANGE(e)
Definition: mpfr-impl.h:1049
#define MPFR_SET_INF(x)
Definition: mpfr-impl.h:1083
#define MPFR_ASSERTN(expr)
Definition: mpfr-impl.h:495
#define SAFE_ABS(type, x)
Definition: mpfr-impl.h:1624
#define MPFR_ASSERTD(expr)
Definition: mpfr-impl.h:516
#define MPFR_IS_SINGULAR(x)
Definition: mpfr-impl.h:1100
#define MPFR_SET_SIGN(x, s)
Definition: mpfr-impl.h:1151
#define MPFR_MANT(x)
Definition: mpfr-impl.h:960
#define MPFR_STAT_STATIC_ASSERT(c)
Definition: mpfr-sassert.h:69
void mpfr_set_nan(mpfr_ptr)
Definition: set_nan.c:27
unsigned long mpfr_uexp_t
Definition: mpfr.h:196
unsigned long mpfr_uprec_t
Definition: mpfr.h:169
long mpfr_prec_t
Definition: mpfr.h:168
__mpfr_struct mpfr_t[1]
Definition: mpfr.h:250
#define mpfr_regular_p(_x)
Definition: mpfr.h:840
#define mpfr_get_prec(_x)
Definition: mpfr.h:848
#define MPFR_PREC_MAX
Definition: mpfr.h:181
#define MPFR_PREC_MIN
Definition: mpfr.h:180
long mpfr_exp_t
Definition: mpfr.h:195
void mpfr_set_prec(mpfr_ptr, mpfr_prec_t)
Definition: set_prec.c:26
float x
Definition: cordic.py:15
Precision precision(skeleton::StemEnum stem)
#define sign(x)
bstring c int memset(void *s, int c, int length)
#define status
static int32 buffer_size
Definition: rate.c:83
Definition: utils.c:300
#define FILE
Definition: t1stdio.h:34
int j
Definition: t4ht.c:1589
#define buffer
Definition: xmlparse.c:611