summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2011-03-21 22:34:14 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-06-15 14:00:31 +0200
commit59a1890c12a3b98d534dbf84575f821eafaacd77 (patch)
tree9bd049faf26ec1cf2b7580053c163352649604c4
parent9c373ffdda5fd81d2c0bb9a1a1038a792bf47f23 (diff)
_fpmaxtostr.c: move common to _fpmaxtostr.h
Signed-off-by: Peter S. Mazinger <ps.m@gmx.net> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
-rw-r--r--libc/stdio/_fpmaxtostr.c27
-rw-r--r--libc/stdio/_fpmaxtostr.h41
2 files changed, 46 insertions, 22 deletions
diff --git a/libc/stdio/_fpmaxtostr.c b/libc/stdio/_fpmaxtostr.c
index 1332a20e7..80b422d60 100644
--- a/libc/stdio/_fpmaxtostr.c
+++ b/libc/stdio/_fpmaxtostr.c
@@ -1,6 +1,7 @@
-/* Copyright (C) 2004 Manuel Novoa III <mjn3@codepoet.org>
+/*
+ * Copyright (C) 2000,2001,2003,2004 Manuel Novoa III <mjn3@codepoet.org>
*
- * GNU Library General Public License (LGPL) version 2 or later.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
@@ -9,15 +10,9 @@
#include <printf.h>
#include <float.h>
#include <locale.h>
-#include <bits/uClibc_fpmax.h>
+#include "_fpmaxtostr.h"
-
-typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
- intptr_t buf);
-
-
-/* Copyright (C) 2000, 2001, 2003 Manuel Novoa III
- *
+/*
* Function:
*
* ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
@@ -40,7 +35,6 @@ typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
* It should also be fairly portable, as no assumptions are made about the
* bit-layout of doubles. Of course, that does make it less efficient than
* it could be.
- *
*/
/*****************************************************************************/
@@ -67,9 +61,6 @@ typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
#define NUM_HEX_DIGITS ((FPMAX_MANT_DIG + 3)/ 4)
-/* WARNING: Adjust _fp_out_wide() below if this changes! */
-/* With 32 bit ints, we can get 9 decimal digits per block. */
-#define DIGITS_PER_BLOCK 9
#define HEX_DIGITS_PER_BLOCK 8
/* Maximum number of subcases to output double is...
@@ -87,15 +78,9 @@ typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len,
/*****************************************************************************/
-#define NUM_DIGIT_BLOCKS ((DECIMAL_DIG+DIGITS_PER_BLOCK-1)/DIGITS_PER_BLOCK)
#define NUM_HEX_DIGIT_BLOCKS \
((NUM_HEX_DIGITS+HEX_DIGITS_PER_BLOCK-1)/HEX_DIGITS_PER_BLOCK)
-/* WARNING: Adjust _fp_out_wide() below if this changes! */
-
-/* extra space for '-', '.', 'e+###', and nul */
-#define BUF_SIZE ( 3 + NUM_DIGIT_BLOCKS * DIGITS_PER_BLOCK )
-
/*****************************************************************************/
static const char fmt[] = "inf\0INF\0nan\0NAN\0.\0,";
@@ -200,8 +185,6 @@ static const __fpmax_t exp16_table[] = {
#define FPO_STR_PREC 'p'
ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
- __fp_outfunc_t fp_outfunc) attribute_hidden;
-ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
__fp_outfunc_t fp_outfunc)
{
#ifdef __UCLIBC_HAS_HEXADECIMAL_FLOATS__
diff --git a/libc/stdio/_fpmaxtostr.h b/libc/stdio/_fpmaxtostr.h
new file mode 100644
index 000000000..5adb9312a
--- /dev/null
+++ b/libc/stdio/_fpmaxtostr.h
@@ -0,0 +1,41 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Copyright (C) 2000,2001,2003,2004 Manuel Novoa III <mjn3@codepoet.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ *
+ * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
+ */
+
+#ifndef _FPMAXTOSTR_H
+#define _FPMAXTOSTR_H 1
+
+#include <features.h>
+#ifdef __UCLIBC_HAS_FLOATS__
+
+#define __need_size_t
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <printf.h>
+#include <sys/types.h>
+#include <float.h>
+#include <bits/uClibc_fpmax.h>
+
+/* WARNING: Adjust _fp_out_wide() in _vfprintf.c if this changes! */
+/* With 32 bit ints, we can get 9 decimal digits per block. */
+#define DIGITS_PER_BLOCK 9
+
+#define NUM_DIGIT_BLOCKS ((DECIMAL_DIG+DIGITS_PER_BLOCK-1)/DIGITS_PER_BLOCK)
+
+/* WARNING: Adjust _fp_out_wide() in _vfprintf.c if this changes! */
+/* extra space for '-', '.', 'e+###', and nul */
+#define BUF_SIZE ( 3 + NUM_DIGIT_BLOCKS * DIGITS_PER_BLOCK )
+
+typedef size_t (__fp_outfunc_t)(FILE *fp, intptr_t type, intptr_t len, intptr_t buf);
+
+extern ssize_t _fpmaxtostr(FILE * fp, __fpmax_t x, struct printf_info *info,
+ __fp_outfunc_t fp_outfunc) attribute_hidden;
+
+#endif /* __UCLIBC_HAS_FLOATS__ */
+#endif /* _FPMAXTOSTR_H */