From 6a735f19f2ff582da96d4ad19eaf428c8dd03868 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 11 Oct 2017 21:13:50 +0100 Subject: [PATCH] ieee80.c: Fix -Wmissing-prototypes warnings (create an ieee80.h header file). --- README.md | 4 +-- src/libespeak-ng/ieee80.c | 7 +---- src/libespeak-ng/ieee80.h | 62 +++++++++++++++++++++++++++++++++++++++ src/libespeak-ng/spect.c | 5 ++-- 4 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 src/libespeak-ng/ieee80.h diff --git a/README.md b/README.md index dac80c21..d5935ffd 100644 --- a/README.md +++ b/README.md @@ -391,8 +391,8 @@ The `ieee80.c` implementation is taken directly from [ToFromIEEE.c.txt](http://www.realitypixels.com/turk/opensource/ToFromIEEE.c.txt) which has been made available for use in Open Source applications per the [license statement](COPYING.IEEE) on http://www.realitypixels.com/turk/opensource/. -The only modification made to the code is to comment out the `TEST_FP` define -to make it useable in the eSpeak NG library. +The only modifications made to the code is to comment out the `TEST_FP` define +to make it useable in the eSpeak NG library, and to fix compiler warnings. The `getopt.c` compatibility implementation for getopt support on Windows is taken from the NetBSD `getopt_long` implementation, which is licensed under a diff --git a/src/libespeak-ng/ieee80.c b/src/libespeak-ng/ieee80.c index c3653d15..43c10191 100644 --- a/src/libespeak-ng/ieee80.c +++ b/src/libespeak-ng/ieee80.c @@ -49,15 +49,10 @@ #include #include +#include "ieee80.h" typedef float Single; -#ifndef applec - typedef double defdouble; -#else applec - typedef long double defdouble; -#endif applec - #ifndef THINK_C typedef double Double; #else THINK_C diff --git a/src/libespeak-ng/ieee80.h b/src/libespeak-ng/ieee80.h new file mode 100644 index 00000000..04ca67f4 --- /dev/null +++ b/src/libespeak-ng/ieee80.h @@ -0,0 +1,62 @@ +/* Copyright (C) 1989-1991 Apple Computer, Inc. + * + * All rights reserved. + * + * Warranty Information + * Even though Apple has reviewed this software, Apple makes no warranty + * or representation, either express or implied, with respect to this + * software, its quality, accuracy, merchantability, or fitness for a + * particular purpose. As a result, this software is provided "as is," + * and you, its user, are assuming the entire risk as to its quality + * and accuracy. + * + * This code may be used and freely distributed as long as it includes + * this copyright notice and the above warranty information. + * + * Machine-independent I/O routines for IEEE floating-point numbers. + * + * NaN's and infinities are converted to HUGE_VAL or HUGE, which + * happens to be infinity on IEEE machines. Unfortunately, it is + * impossible to preserve NaN's in a machine-independent way. + * Infinities are, however, preserved on IEEE machines. + * + * These routines have been tested on the following machines: + * Apple Macintosh, MPW 3.1 C compiler + * Apple Macintosh, THINK C compiler + * Silicon Graphics IRIS, MIPS compiler + * Cray X/MP and Y/MP + * Digital Equipment VAX + * Sequent Balance (Multiprocesor 386) + * NeXT + * + * + * Implemented by Malcolm Slaney and Ken Turkowski. + * + * Malcolm Slaney contributions during 1988-1990 include big- and little- + * endian file I/O, conversion to and from Motorola's extended 80-bit + * floating-point format, and conversions to and from IEEE single- + * precision floating-point format. + * + * In 1991, Ken Turkowski implemented the conversions to and from + * IEEE double-precision format, added more precision to the extended + * conversions, and accommodated conversions involving +/- infinity, + * NaN's, and denormalized numbers. + */ +#ifndef IEEE_H +#define IEEE_H + +#ifndef applec + typedef double defdouble; +#else applec + typedef long double defdouble; +#endif applec + +defdouble ConvertFromIeeeSingle( char *bytes); +defdouble ConvertFromIeeeDouble( char *bytes); +defdouble ConvertFromIeeeExtended(char *bytes); + +void ConvertToIeeeSingle( defdouble num, char *bytes); +void ConvertToIeeeDouble( defdouble num, char *bytes); +void ConvertToIeeeExtended(defdouble num, char *bytes); + +#endif diff --git a/src/libespeak-ng/spect.c b/src/libespeak-ng/spect.c index 7bb0bb94..e468dfd6 100644 --- a/src/libespeak-ng/spect.c +++ b/src/libespeak-ng/spect.c @@ -35,8 +35,7 @@ #include "voice.h" #include "synthesize.h" #include "spect.h" - -extern double ConvertFromIeeeExtended(unsigned char *bytes); +#include "ieee80.h" extern unsigned char pk_shape1[]; extern int pk_select; @@ -56,7 +55,7 @@ static double read_double(FILE *stream) { unsigned char bytes[10]; fread(bytes, sizeof(char), 10, stream); - return ConvertFromIeeeExtended(bytes); + return ConvertFromIeeeExtended((char *)bytes); } float polint(float xa[], float ya[], int n, float x)