From 24be2773e9753b3868bff0e387b79a511b766e01 Mon Sep 17 00:00:00 2001 From: simonmar Date: Mon, 11 Nov 2002 11:18:39 +0000 Subject: [PATCH] [project @ 2002-11-11 11:18:39 by simonmar] Increase the size of many of the int variables used in hp2ps to 64 bits on a 32 bit machine, since they can easily overflow if the program runs for a few seconds. Fortunately there was a useful typedef to change - I couldn't be bothered figuring out exactly which variables to make wider, and the performance of hp2ps isn't really critical anyhow (this change makes it about 30% slower, but who cares). --- ghc/utils/hp2ps/AuxFile.c | 2 +- ghc/utils/hp2ps/Axes.c | 6 +++--- ghc/utils/hp2ps/Main.c | 5 +---- ghc/utils/hp2ps/Main.h | 12 +++++++++++- ghc/utils/hp2ps/Makefile | 4 ++-- ghc/utils/hp2ps/PsFile.c | 4 ++-- ghc/utils/hp2ps/Shade.c | 2 -- ghc/utils/hp2ps/Utilities.c | 6 +++--- ghc/utils/hp2ps/Utilities.h | 2 +- 9 files changed, 24 insertions(+), 19 deletions(-) diff --git a/ghc/utils/hp2ps/AuxFile.c b/ghc/utils/hp2ps/AuxFile.c index a6088eb..e5ce090 100644 --- a/ghc/utils/hp2ps/AuxFile.c +++ b/ghc/utils/hp2ps/AuxFile.c @@ -150,7 +150,7 @@ void PutAuxFile(auxfp) FILE* auxfp; { - intish i; + int i; fprintf(auxfp, "X_RANGE %.2f\n", xrange); fprintf(auxfp, "Y_RANGE %.2f\n", yrange); diff --git a/ghc/utils/hp2ps/Axes.c b/ghc/utils/hp2ps/Axes.c index ddd2bbf..0733edd 100644 --- a/ghc/utils/hp2ps/Axes.c +++ b/ghc/utils/hp2ps/Axes.c @@ -107,17 +107,17 @@ YAxisMark(y, num, unit) switch (unit) { case MEGABYTE : fprintf(psfp, "("); - CommaPrint(psfp, (int) (num / 1e6 + 0.5)); + CommaPrint(psfp, (intish) (num / 1e6 + 0.5)); fprintf(psfp, "M)\n"); break; case KILOBYTE : fprintf(psfp, "("); - CommaPrint(psfp, (int) (num / 1e3 + 0.5)); + CommaPrint(psfp, (intish) (num / 1e3 + 0.5)); fprintf(psfp, "k)\n"); break; case BYTE: fprintf(psfp, "("); - CommaPrint(psfp, (int) (num + 0.5)); + CommaPrint(psfp, (intish) (num + 0.5)); fprintf(psfp, ")\n"); break; } diff --git a/ghc/utils/hp2ps/Main.c b/ghc/utils/hp2ps/Main.c index 2e2c3cc..e1cfe63 100644 --- a/ghc/utils/hp2ps/Main.c +++ b/ghc/utils/hp2ps/Main.c @@ -1,5 +1,6 @@ #include #include +#include #include "Main.h" #include "Defines.h" #include "AuxFile.h" @@ -15,10 +16,6 @@ #include "Error.h" #include "Utilities.h" -#ifndef atof -double atof PROTO((char *)); -#endif - boolish pflag = 0; /* read auxiliary file */ boolish eflag = 0; /* scaled EPSF */ boolish dflag = 0; /* sort by standard deviation */ diff --git a/ghc/utils/hp2ps/Main.h b/ghc/utils/hp2ps/Main.h index b0d4bf4..efe520e 100644 --- a/ghc/utils/hp2ps/Main.h +++ b/ghc/utils/hp2ps/Main.h @@ -1,6 +1,8 @@ #ifndef MAIN_H #define MAIN_H +#include "config.h" + #ifdef __STDC__ #define PROTO(x) x #else @@ -27,9 +29,17 @@ void _ghcAssert PROTO((char *, unsigned int)); */ typedef double floatish; typedef double doublish; /* higher precision, if anything; little used */ -typedef long intish; typedef int boolish; +/* Use "long long" if we have it: the numbers in profiles can easily + * overflow 32 bits after a few seconds execution. + */ +#ifdef HAVE_LONG_LONG +typedef long long int intish; +#else +typedef long int intish; +#endif + extern intish nsamples; extern intish nmarks; extern intish nidents; diff --git a/ghc/utils/hp2ps/Makefile b/ghc/utils/hp2ps/Makefile index 878c51b..18cb05b 100644 --- a/ghc/utils/hp2ps/Makefile +++ b/ghc/utils/hp2ps/Makefile @@ -1,10 +1,10 @@ TOP=../.. include $(TOP)/mk/boilerplate.mk -C_SRCS = $(wildcard *.c) -H_SRCS = $(wildcard *.h) C_PROG = hp2ps +SRC_CC_OPTS += -I$(GHC_INCLUDE_DIR) -Wall + INSTALL_PROGS += $(C_PROG) LIBS = $(LIBM) diff --git a/ghc/utils/hp2ps/PsFile.c b/ghc/utils/hp2ps/PsFile.c index b2040f1..5286ad9 100644 --- a/ghc/utils/hp2ps/PsFile.c +++ b/ghc/utils/hp2ps/PsFile.c @@ -212,7 +212,7 @@ BigTitleText() fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT); fprintf(psfp, "%f %f moveto\n", x, y); fputc('(', psfp); - CommaPrint(psfp, (int) areabelow); + CommaPrint(psfp, (intish)areabelow); fprintf(psfp, " %s x %s)\n", valueunitstring, sampleunitstring); fprintf(psfp, "show\n"); @@ -248,7 +248,7 @@ TitleText() fprintf(psfp, "HE%d setfont\n", TITLE_TEXT_FONT); fputc('(', psfp); - CommaPrint(psfp, (int) areabelow); + CommaPrint(psfp, (intish) areabelow); fprintf(psfp, " %s x %s)\n", valueunitstring, sampleunitstring); fprintf(psfp, "dup stringwidth pop\n"); diff --git a/ghc/utils/hp2ps/Shade.c b/ghc/utils/hp2ps/Shade.c index f7e517b..e898027 100644 --- a/ghc/utils/hp2ps/Shade.c +++ b/ghc/utils/hp2ps/Shade.c @@ -97,8 +97,6 @@ ThinkOfAShade() { static int thisshade = -1; - floatish x; - thisshade++; return cflag ? c_shades[ thisshade % N_COLOUR_SHADES ] : diff --git a/ghc/utils/hp2ps/Utilities.c b/ghc/utils/hp2ps/Utilities.c index c6faca4..57d20b1 100644 --- a/ghc/utils/hp2ps/Utilities.c +++ b/ghc/utils/hp2ps/Utilities.c @@ -67,13 +67,13 @@ OpenFile(s, mode) void CommaPrint(fp,n) FILE* fp; - int n; + intish n; { if (n < ONETHOUSAND) { - fprintf(fp, "%d", n); + fprintf(fp, "%d", (int)n); } else { CommaPrint(fp, n / ONETHOUSAND); - fprintf(fp, ",%03d", n % ONETHOUSAND); + fprintf(fp, ",%03d", (int)n % ONETHOUSAND); } } diff --git a/ghc/utils/hp2ps/Utilities.h b/ghc/utils/hp2ps/Utilities.h index d6e9a17..bffc87d 100644 --- a/ghc/utils/hp2ps/Utilities.h +++ b/ghc/utils/hp2ps/Utilities.h @@ -4,7 +4,7 @@ char* Basename PROTO((char *)); void DropSuffix PROTO((char *, char *)); FILE* OpenFile PROTO((char *, char *)); -void CommaPrint PROTO((FILE *, int)); +void CommaPrint PROTO((FILE *, intish)); char *copystring PROTO((char *)); char *copystring2 PROTO((char *, char *)); void *xmalloc PROTO((int)); -- 1.7.10.4