[PATCH 10/20] Convert the printf subdirectory to __GMP_*_DEFINE and include changes
Richard Henderson
rth at twiddle.net
Mon Mar 4 19:41:40 CET 2013
---
gmp-impl.h | 10 +++++-----
printf/asprintf.c | 10 +---------
printf/asprntffuns.c | 16 +++-------------
printf/doprnt.c | 33 ++-------------------------------
printf/doprntf.c | 16 +---------------
printf/doprnti.c | 14 +-------------
printf/fprintf.c | 12 +-----------
printf/obprintf.c | 16 ++--------------
printf/obprntffuns.c | 14 +-------------
printf/obvprintf.c | 11 +----------
printf/printf.c | 12 +-----------
printf/printffuns.c | 14 ++------------
printf/repl-vsnprintf.c | 33 +--------------------------------
printf/snprintf.c | 12 +-----------
printf/snprntffuns.c | 13 +------------
printf/sprintf.c | 12 +-----------
printf/sprintffuns.c | 14 +-------------
printf/vasprintf.c | 16 ++--------------
printf/vfprintf.c | 12 +-----------
printf/vprintf.c | 12 +-----------
printf/vsnprintf.c | 12 +-----------
printf/vsprintf.c | 12 +-----------
22 files changed, 32 insertions(+), 294 deletions(-)
diff --git a/gmp-impl.h b/gmp-impl.h
index 1c1451d..d1c756f 100644
--- a/gmp-impl.h
+++ b/gmp-impl.h
@@ -4501,11 +4501,11 @@ struct doprnt_funs_t {
doprnt_final_t final; /* NULL if not required */
};
-extern const struct doprnt_funs_t __gmp_fprintf_funs;
-extern const struct doprnt_funs_t __gmp_sprintf_funs;
-extern const struct doprnt_funs_t __gmp_snprintf_funs;
-extern const struct doprnt_funs_t __gmp_obstack_printf_funs;
-extern const struct doprnt_funs_t __gmp_ostream_funs;
+__GMP_INTERN_DATA (const struct doprnt_funs_t, __gmp_fprintf_funs);
+__GMP_INTERN_DATA (const struct doprnt_funs_t, __gmp_sprintf_funs);
+__GMP_INTERN_DATA (const struct doprnt_funs_t, __gmp_snprintf_funs);
+__GMP_INTERN_DATA (const struct doprnt_funs_t, __gmp_obstack_printf_funs);
+__GMP_INTERN_DATA (const struct doprnt_funs_t, __gmp_ostream_funs);
/* "buf" is a __gmp_allocate_func block of "alloc" many bytes. The first
"size" of these have been written. "alloc > size" is maintained, so
diff --git a/printf/asprintf.c b/printf/asprintf.c
index e2edef6..1f99d64 100644
--- a/printf/asprintf.c
+++ b/printf/asprintf.c
@@ -17,15 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -54,3 +45,4 @@ gmp_asprintf (va_alist)
va_end (ap);
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_asprintf)
diff --git a/printf/asprntffuns.c b/printf/asprntffuns.c
index 1a2b9e1..aa9f412 100644
--- a/printf/asprntffuns.c
+++ b/printf/asprntffuns.c
@@ -22,19 +22,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
operator<< routines can avoid dragging vsnprintf into the link (via
__gmp_asprintf_format). */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -46,6 +33,7 @@ __gmp_asprintf_memory (struct gmp_asprintf_t *d, const char *str, size_t len)
d->size += len;
return len;
}
+__GMP_INTERN_DEFINE (__gmp_asprintf_memory)
int
__gmp_asprintf_reps (struct gmp_asprintf_t *d, int c, int reps)
@@ -55,6 +43,7 @@ __gmp_asprintf_reps (struct gmp_asprintf_t *d, int c, int reps)
d->size += reps;
return reps;
}
+__GMP_INTERN_DEFINE (__gmp_asprintf_reps)
int
__gmp_asprintf_final (struct gmp_asprintf_t *d)
@@ -66,3 +55,4 @@ __gmp_asprintf_final (struct gmp_asprintf_t *d)
*d->result = buf;
return 0;
}
+__GMP_INTERN_DEFINE (__gmp_asprintf_final)
diff --git a/printf/doprnt.c b/printf/doprnt.c
index c1ee0a2..1d2bf27 100644
--- a/printf/doprnt.c
+++ b/printf/doprnt.c
@@ -21,45 +21,15 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#define _GNU_SOURCE /* for DECIMAL_POINT in glibc langinfo.h */
-
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <ctype.h> /* for isdigit */
-#include <stddef.h> /* for ptrdiff_t */
-#include <string.h>
-#include <stdio.h> /* for NULL */
-#include <stdlib.h>
-
-#if HAVE_INTTYPES_H
-# include <inttypes.h> /* for intmax_t */
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
+#include "gmp-impl.h"
#if HAVE_LANGINFO_H
#include <langinfo.h> /* for nl_langinfo */
#endif
-
#if HAVE_LOCALE_H
#include <locale.h> /* for localeconv */
#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h> /* for quad_t */
-#endif
-
-#include "gmp.h"
-#include "gmp-impl.h"
-
/* change this to "#define TRACE(x) x" for diagnostics */
#define TRACE(x)
@@ -619,3 +589,4 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
retval = -1;
goto done;
}
+__GMP_INTERN_DEFINE (__gmp_doprnt)
diff --git a/printf/doprntf.c b/printf/doprntf.c
index 49e7013..25ff096 100644
--- a/printf/doprntf.c
+++ b/printf/doprntf.c
@@ -21,22 +21,7 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
-#else
-#include <varargs.h>
-#endif
-
-#include <ctype.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
-#include "longlong.h"
/* change this to "#define TRACE(x) x" for diagnostics */
@@ -384,3 +369,4 @@ __gmp_doprnt_mpf (const struct doprnt_funs_t *funs,
retval = -1;
goto done;
}
+__GMP_INTERN_DEFINE (__gmp_doprnt_mpf)
diff --git a/printf/doprnti.c b/printf/doprnti.c
index df474df..52e2db1 100644
--- a/printf/doprnti.c
+++ b/printf/doprnti.c
@@ -21,19 +21,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
-#else
-#include <varargs.h>
-#endif
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -131,3 +118,4 @@ __gmp_doprnt_integer (const struct doprnt_funs_t *funs,
retval = -1;
goto done;
}
+__GMP_INTERN_DEFINE (__gmp_doprnt_integer)
diff --git a/printf/fprintf.c b/printf/fprintf.c
index dba30b9..1148b34 100644
--- a/printf/fprintf.c
+++ b/printf/fprintf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -56,3 +45,4 @@ gmp_fprintf (va_alist)
va_end (ap);
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_fprintf)
diff --git a/printf/obprintf.c b/printf/obprintf.c
index 51ad703..cb58bf7 100644
--- a/printf/obprintf.c
+++ b/printf/obprintf.c
@@ -17,22 +17,9 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_OBSTACK_VPRINTF
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <obstack.h>
-#include <string.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
+#if HAVE_OBSTACK_VPRINTF
int
#if HAVE_STDARG
@@ -62,5 +49,6 @@ gmp_obstack_printf (va_alist)
va_end (ap);
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_obstack_printf)
#endif /* HAVE_OBSTACK_VPRINTF */
diff --git a/printf/obprntffuns.c b/printf/obprntffuns.c
index 092e6cc..d7c0db5 100644
--- a/printf/obprntffuns.c
+++ b/printf/obprntffuns.c
@@ -26,19 +26,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#if HAVE_OBSTACK_VPRINTF
-#define _GNU_SOURCE /* ask glibc <stdio.h> for obstack_vprintf */
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h> /* for obstack_vprintf */
-#include <string.h>
-#include <obstack.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -62,5 +49,6 @@ const struct doprnt_funs_t __gmp_obstack_printf_funs = {
(doprnt_memory_t) gmp_obstack_memory,
(doprnt_reps_t) gmp_obstack_reps
};
+__GMP_INTERN_DEFINE (__gmp_obstack_printf_funs);
#endif /* HAVE_OBSTACK_VPRINTF */
diff --git a/printf/obvprintf.c b/printf/obvprintf.c
index 4e3712f..c25d21c 100644
--- a/printf/obvprintf.c
+++ b/printf/obvprintf.c
@@ -21,16 +21,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#if HAVE_OBSTACK_VPRINTF
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <obstack.h>
-#include <string.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -42,5 +32,6 @@ gmp_obstack_vprintf (struct obstack *ob, const char *fmt, va_list ap)
return __gmp_doprnt (&__gmp_obstack_printf_funs, ob, fmt, ap);
}
+__GMP_PUBLIC_DEFINE (gmp_obstack_vprintf)
#endif /* HAVE_OBSTACK_VPRINTF */
diff --git a/printf/printf.c b/printf/printf.c
index bcb0acb..66e6c35 100644
--- a/printf/printf.c
+++ b/printf/printf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -54,3 +43,4 @@ gmp_printf (va_alist)
va_end (ap);
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_printf)
diff --git a/printf/printffuns.c b/printf/printffuns.c
index 89c9589..da3de1e 100644
--- a/printf/printffuns.c
+++ b/printf/printffuns.c
@@ -21,20 +21,9 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
+
/* SunOS 4 stdio.h doesn't provide a prototype for this */
#if ! HAVE_DECL_VFPRINTF
int vfprintf (FILE *, const char *, va_list);
@@ -74,3 +63,4 @@ const struct doprnt_funs_t __gmp_fprintf_funs = {
(doprnt_memory_t) gmp_fprintf_memory,
(doprnt_reps_t) gmp_fprintf_reps,
};
+__GMP_INTERN_DEFINE (__gmp_fprintf_funs)
diff --git a/printf/repl-vsnprintf.c b/printf/repl-vsnprintf.c
index 06809dc..a9604af 100644
--- a/printf/repl-vsnprintf.c
+++ b/printf/repl-vsnprintf.c
@@ -26,38 +26,6 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#if ! HAVE_VSNPRINTF /* only need this file if we don't have vsnprintf */
-
-#define _GNU_SOURCE /* for strnlen prototype */
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <ctype.h> /* for isdigit */
-#include <stddef.h> /* for ptrdiff_t */
-#include <string.h>
-#include <stdio.h> /* for NULL */
-#include <stdlib.h>
-
-#if HAVE_FLOAT_H
-#include <float.h> /* for DBL_MAX_10_EXP etc */
-#endif
-
-#if HAVE_INTTYPES_H
-# include <inttypes.h> /* for intmax_t */
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h> /* for quad_t */
-#endif
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -385,5 +353,6 @@ __gmp_replacement_vsnprintf (char *buf, size_t buf_size,
return len;
}
+__GMP_INTERN_DEFINE (__gmp_replacement_vsnprintf)
#endif /* ! HAVE_VSNPRINTF */
diff --git a/printf/snprintf.c b/printf/snprintf.c
index 88afc32..4e10afd 100644
--- a/printf/snprintf.c
+++ b/printf/snprintf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <string.h> /* for strlen */
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -62,3 +51,4 @@ gmp_snprintf (va_alist)
va_end (ap);
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_snprintf)
diff --git a/printf/snprntffuns.c b/printf/snprntffuns.c
index 340ee05..9b5bd55 100644
--- a/printf/snprntffuns.c
+++ b/printf/snprntffuns.c
@@ -21,18 +21,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -154,3 +142,4 @@ const struct doprnt_funs_t __gmp_snprintf_funs = {
(doprnt_reps_t) gmp_snprintf_reps,
(doprnt_final_t) gmp_snprintf_final
};
+__GMP_INTERN_DEFINE (__gmp_snprintf_funs)
diff --git a/printf/sprintf.c b/printf/sprintf.c
index 0a3294d..9ad19c0 100644
--- a/printf/sprintf.c
+++ b/printf/sprintf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <string.h> /* for strlen */
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -62,3 +51,4 @@ gmp_sprintf (va_alist)
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_sprintf)
diff --git a/printf/sprintffuns.c b/printf/sprintffuns.c
index 01fb3c9..5ba79a3 100644
--- a/printf/sprintffuns.c
+++ b/printf/sprintffuns.c
@@ -21,19 +21,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -89,3 +76,4 @@ const struct doprnt_funs_t __gmp_sprintf_funs = {
(doprnt_reps_t) gmp_sprintf_reps,
(doprnt_final_t) gmp_sprintf_final
};
+__GMP_INTERN_DEFINE (__gmp_sprintf_funs)
diff --git a/printf/vasprintf.c b/printf/vasprintf.c
index 4ed4c5d..7587754 100644
--- a/printf/vasprintf.c
+++ b/printf/vasprintf.c
@@ -17,19 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
#if ! HAVE_VSNPRINTF
@@ -97,7 +84,7 @@ gmp_asprintf_format (struct gmp_asprintf_t *d, const char *fmt,
return ret;
}
-const struct doprnt_funs_t __gmp_asprintf_funs = {
+static const struct doprnt_funs_t __gmp_asprintf_funs = {
(doprnt_format_t) gmp_asprintf_format,
(doprnt_memory_t) __gmp_asprintf_memory,
(doprnt_reps_t) __gmp_asprintf_reps,
@@ -111,3 +98,4 @@ gmp_vasprintf (char **result, const char *fmt, va_list ap)
GMP_ASPRINTF_T_INIT (d, result);
return __gmp_doprnt (&__gmp_asprintf_funs, &d, fmt, ap);
}
+__GMP_PUBLIC_DEFINE (gmp_vasprintf)
diff --git a/printf/vfprintf.c b/printf/vfprintf.c
index 8bed677..e1ba5c8 100644
--- a/printf/vfprintf.c
+++ b/printf/vfprintf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -36,3 +25,4 @@ gmp_vfprintf (FILE *fp, const char *fmt, va_list ap)
{
return __gmp_doprnt (&__gmp_fprintf_funs, fp, fmt, ap);
}
+__GMP_PUBLIC_DEFINE (gmp_vfprintf)
diff --git a/printf/vprintf.c b/printf/vprintf.c
index f8da0ef..c509995 100644
--- a/printf/vprintf.c
+++ b/printf/vprintf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <stdio.h>
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -36,3 +25,4 @@ gmp_vprintf (const char *fmt, va_list ap)
{
return __gmp_doprnt (&__gmp_fprintf_funs, stdout, fmt, ap);
}
+__GMP_PUBLIC_DEFINE (gmp_vprintf)
diff --git a/printf/vsnprintf.c b/printf/vsnprintf.c
index 565fdfd..c481501 100644
--- a/printf/vsnprintf.c
+++ b/printf/vsnprintf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <string.h> /* for strlen */
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -42,3 +31,4 @@ gmp_vsnprintf (char *buf, size_t size, const char *fmt, va_list ap)
d.size = size;
return __gmp_doprnt (&__gmp_snprintf_funs, &d, fmt, ap);
}
+__GMP_PUBLIC_DEFINE (gmp_vsnprintf)
diff --git a/printf/vsprintf.c b/printf/vsprintf.c
index b1a3045..22fdc38 100644
--- a/printf/vsprintf.c
+++ b/printf/vsprintf.c
@@ -17,17 +17,6 @@ License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-#include "config.h"
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include <string.h> /* for strlen */
-
-#include "gmp.h"
#include "gmp-impl.h"
@@ -45,3 +34,4 @@ gmp_vsprintf (char *buf, const char *fmt, va_list ap)
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_vsprintf)
--
1.8.1.2
More information about the gmp-devel
mailing list