m68k: math-emu: Miscellaneous esthetical improvements
Geert Uytterhoeven
maintainercover m68k: math-emu: Miscellaneous esthetical improvements
Hi all,
This patch series contains miscellaneous esthetical improvements for the Linux/m68k floating point emulator. They have no functional impact. The main objective is to get rid of the compiler warnings when building with W=1.
I plan to queue this in the m68k tree rather sooner than later.
Thanks for your comments!
Geert Uytterhoeven (6):
m68k: math-emu: Fix incorrect file reference in fp_log.c
m68k: math-emu: Sanitize include guards
m68k: math-emu: Make multi_arith.h self-contained
m68k: math-emu: Replace external declarations by header inclusion
m68k: math-emu: Reformat function and variable headers
m68k: math-emu: Add missing prototypes
arch/m68k/math-emu/fp_arith.c | 49 ++++++++++------------------- arch/m68k/math-emu/fp_arith.h | 49 +++++++++++------------------ arch/m68k/math-emu/fp_log.c | 46 ++++++++++----------------- arch/m68k/math-emu/fp_log.h | 44 ++++++++++++++++++++++++++ arch/m68k/math-emu/fp_trig.c | 54 +++++++++++--------------------- arch/m68k/math-emu/fp_trig.h | 25 +++++++++++++-- arch/m68k/math-emu/multi_arith.h | 8 +++-- 7 files changed, 142 insertions(+), 133 deletions(-) create mode 100644 arch/m68k/math-emu/fp_log.h
Signature · 12 lines
2.34.1
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus TorvaldsGeert Uytterhoeven
maintainerPATCH 1/6 m68k: math-emu: Fix incorrect file reference in fp_log.c
The file comment header refers to the wrong file.
--- arch/m68k/math-emu/fp_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/math-emu/fp_log.c +1 -1
@@ -1,6 +1,6 @@/* -fp_trig.c: floating-point math routines for the Linux-m68k +fp_log.c: floating-point math routines for the Linux-m68k floating point emulator. Copyright (c) 1998-1999 David Huggins-Daines / Roman Zippel.
Signature · 1 line
2.34.1
Geert Uytterhoeven
maintainerPATCH 2/6 m68k: math-emu: Sanitize include guards
In reply to Geert UytterhoevenSome include guards start with an underscore, others don't. Some comments do not match the actual include guard.
Make them uniform, adhering to the "FP_<FOO>_H" format.
--- arch/m68k/math-emu/fp_arith.h | 6 +++--- arch/m68k/math-emu/fp_trig.h | 6 +++--- arch/m68k/math-emu/multi_arith.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
arch/m68k/math-emu/fp_arith.h +3 -3
@@ -12,8 +12,8 @@*/ -#ifndef FP_ARITH_H -#define FP_ARITH_H +#ifndef _FP_ARITH_H +#define _FP_ARITH_H/* easy ones */ struct fp_ext *
@@ -47,4 +47,4 @@ fp_fintrz(struct fp_ext *dest, struct fp_ext *src);struct fp_ext *fp_fscale (struct fp_ext *dest,struct fp_ext *src); -#endif /* FP_ARITH__H */ +#endif /* _FP_ARITH_H */
arch/m68k/math-emu/fp_trig.h +3 -3
@@ -15,8 +15,8 @@*/ -#ifndef FP_TRIG_H -#define FP_TRIG_H +#ifndef _FP_TRIG_H +#define _FP_TRIG_H#include "fp_emu.h"
@@ -29,4 +29,4 @@they return a status code, which should end up in %d0, if all goes well. */ -#endif /* FP_TRIG__H */ +#endif /* _FP_TRIG_H */
arch/m68k/math-emu/multi_arith.h +3 -3
@@ -15,8 +15,8 @@implement the subset of integer arithmetic that we need in order to multiply, divide, and normalize 128-bit unsigned mantissae. */ -#ifndef MULTI_ARITH_H -#define MULTI_ARITH_H +#ifndef _MULTI_ARITH_H +#define _MULTI_ARITH_Hstatic inline void fp_denormalize (struct fp_ext *reg,unsigned int cnt) {
@@ -285,4 +285,4 @@ static inline void fp_putmant128(struct fp_ext *dest, union fp_mant128 *src, } } -#endif /* MULTI_ARITH_H */ +#endif /* _MULTI_ARITH_H */
Signature · 1 line
2.34.1
Geert Uytterhoeven
maintainerPATCH 3/6 m68k: math-emu: Make multi_arith.h self-contained
In reply to Geert UytterhoevenAdd the missing #include "fp_emu.h".
--- arch/m68k/math-emu/multi_arith.h | 2 ++ 1 file changed, 2 insertions(+)
arch/m68k/math-emu/multi_arith.h +2 -0
@@ -18,6 +18,8 @@#ifndef _MULTI_ARITH_H#define _MULTI_ARITH_H +#include "fp_emu.h" +static inline void fp_denormalize (struct fp_ext *reg,unsigned int cnt) { reg->exp += cnt;
Signature · 1 line
2.34.1
Geert Uytterhoeven
maintainerPATCH 4/6 m68k: math-emu: Replace external declarations by header inclusion
In reply to Geert UytterhoevenReplace the (incorrect) external declarations by an inclusion of the appropriate header file.
Semantically, the "src" parameters of the various fp_*() functions are constant. However, they cannot actually be const as most of these functions perform a normalization step first. As the fp_one constant passed to fp_add() is already normalized, it is safe to cast away its constness when making the function call.
--- arch/m68k/math-emu/fp_log.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/m68k/math-emu/fp_log.c +3 -4
@@ -15,6 +15,7 @@*/ +#include "fp_arith.h" #include "fp_emu.h" static const struct fp_ext fp_one =
@@ -22,9 +23,6 @@ static const struct fp_ext fp_one = .exp = 0x3fff, }; -extern struct fp_ext *fp_fadd (struct fp_ext *dest,const struct fp_ext *src); -extern struct fp_ext *fp_fdiv (struct fp_ext *dest,const struct fp_ext *src); -struct fp_ext *fp_fsqrt (struct fp_ext *dest,struct fp_ext *src) {
@@ -70,7 +68,8 @@ fp_fsqrt(struct fp_ext *dest, struct fp_ext *src)* sqrt(x) = 1 + 1/2*(x-1) * = 1/2*(1+x) */ -fp_fadd (dest, &fp_one); +/* It is safe to cast away the constness, as fp_one is normalized */ +fp_fadd (dest, (struct fp_ext *)&fp_one); dest->exp--;/* * 1/2 */ /*
Signature · 1 line
2.34.1
Geert Uytterhoeven
maintainerPATCH 5/6 m68k: math-emu: Reformat function and variable headers
In reply to Geert UytterhoevenMake the code shorter and easier to read.
--- arch/m68k/math-emu/fp_arith.c | 49 +++++++++++-------------------- arch/m68k/math-emu/fp_arith.h | 39 +++++++++---------------- arch/m68k/math-emu/fp_log.c | 36 ++++++++--------------- arch/m68k/math-emu/fp_trig.c | 54 ++++++++++++----------------------- 4 files changed, 60 insertions(+), 118 deletions(-)
arch/m68k/math-emu/fp_arith.c +17 -32
@@ -28,8 +28,7 @@ const struct fp_ext fp_Inf =/* let's start with the easy ones */ -struct fp_ext * -fp_fabs (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fabs (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fabs\n" );
@@ -40,8 +39,7 @@ fp_fabs(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fneg (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fneg (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fneg\n" );
@@ -57,8 +55,7 @@ fp_fneg(struct fp_ext *dest, struct fp_ext *src)/* fp_fadd: Implements the kernel of the FADD, FSADD, FDADD, FSUB, FDSUB, and FCMP instructions. */ -struct fp_ext * -fp_fadd (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fadd (struct fp_ext *dest,struct fp_ext *src) {int diff;
@@ -117,8 +114,7 @@ fp_fadd(struct fp_ext *dest, struct fp_ext *src)Remember that the arguments are in assembler-syntax order! */ -struct fp_ext * -fp_fsub (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fsub (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fsub " );
@@ -127,8 +123,7 @@ fp_fsub(struct fp_ext *dest, struct fp_ext *src) } -struct fp_ext * -fp_fcmp (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fcmp (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fcmp " );
@@ -137,8 +132,7 @@ fp_fcmp(struct fp_ext *dest, struct fp_ext *src)return fp_fadd (&FPDATA ->temp[1 ], src); } -struct fp_ext * -fp_ftst (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_ftst (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"ftst\n" );
@@ -147,8 +141,7 @@ fp_ftst(struct fp_ext *dest, struct fp_ext *src)return src; } -struct fp_ext * -fp_fmul (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fmul (struct fp_ext *dest,struct fp_ext *src) {union fp_mant128 temp;int exp;
@@ -225,8 +218,7 @@ fp_fmul(struct fp_ext *dest, struct fp_ext *src)Note that the order of the operands is counter-intuitive: instead of src / dest, the result is actually dest / src. */ -struct fp_ext * -fp_fdiv (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fdiv (struct fp_ext *dest,struct fp_ext *src) {union fp_mant128 temp;int exp;
@@ -306,8 +298,7 @@ fp_fdiv(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fsglmul (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fsglmul (struct fp_ext *dest,struct fp_ext *src) {int exp;
@@ -363,8 +354,7 @@ fp_fsglmul(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fsgldiv (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fsgldiv (struct fp_ext *dest,struct fp_ext *src) {int exp;unsigned long quot, rem;
@@ -573,8 +563,8 @@ static void fp_roundint(struct fp_ext *dest, int mode)(which are exactly the same, except for the rounding used on the intermediate value) */ -static struct fp_ext * -modrem_kernel (struct fp_ext *dest,struct fp_ext *src,int mode) +static struct fp_ext *modrem_kernel (struct fp_ext *dest,struct fp_ext *src, +int mode) {struct fp_ext tmp;
@@ -607,8 +597,7 @@ modrem_kernel(struct fp_ext *dest, struct fp_ext *src, int mode)fmod(src,dest) = (dest - (src * floor(dest / src))) */ -struct fp_ext * -fp_fmod (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fmod (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fmod\n" );return modrem_kernel (dest, src,FPCR_ROUND_RZ );
@@ -619,15 +608,13 @@ fp_fmod(struct fp_ext *dest, struct fp_ext *src)frem(src,dest) = (dest - (src * round(dest / src))) */ -struct fp_ext * -fp_frem (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_frem (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"frem\n" );return modrem_kernel (dest, src,FPCR_ROUND_RN ); } -struct fp_ext * -fp_fint (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fint (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fint\n" );
@@ -638,8 +625,7 @@ fp_fint(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fintrz (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fintrz (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fintrz\n" );
@@ -650,8 +636,7 @@ fp_fintrz(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fscale (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fscale (struct fp_ext *dest,struct fp_ext *src) {int scale, oldround;
arch/m68k/math-emu/fp_arith.h +13 -26
@@ -16,35 +16,22 @@#define _FP_ARITH_H/* easy ones */ -struct fp_ext * -fp_fabs (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fneg (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fabs (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fneg (struct fp_ext *dest,struct fp_ext *src);/* straightforward arithmetic */ -struct fp_ext * -fp_fadd (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fsub (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fcmp (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_ftst (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fmul (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fdiv (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fadd (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsub (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fcmp (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_ftst (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fmul (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fdiv (struct fp_ext *dest,struct fp_ext *src);/* ones that do rounding and integer conversions */ -struct fp_ext * -fp_fmod (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_frem (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fint (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fintrz (struct fp_ext *dest,struct fp_ext *src); -struct fp_ext * -fp_fscale (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fmod (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_frem (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fint (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fintrz (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fscale (struct fp_ext *dest,struct fp_ext *src);#endif /* _FP_ARITH_H */
arch/m68k/math-emu/fp_log.c +12 -24
@@ -18,13 +18,11 @@#include "fp_arith.h" #include "fp_emu.h" -static const struct fp_ext fp_one = -{ +static const struct fp_ext fp_one = { .exp =0x3fff , }; -struct fp_ext * -fp_fsqrt (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fsqrt (struct fp_ext *dest,struct fp_ext *src) {struct fp_ext tmp, src2;int i, exp;
@@ -97,8 +95,7 @@ fp_fsqrt(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fetoxm1 (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fetoxm1 (struct fp_ext *dest,struct fp_ext *src) {uprint ("fetoxm1\n" );
@@ -107,8 +104,7 @@ fp_fetoxm1(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fetox (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fetox (struct fp_ext *dest,struct fp_ext *src) {uprint ("fetox\n" );
@@ -117,8 +113,7 @@ fp_fetox(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_ftwotox (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_ftwotox (struct fp_ext *dest,struct fp_ext *src) {uprint ("ftwotox\n" );
@@ -127,8 +122,7 @@ fp_ftwotox(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_ftentox (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_ftentox (struct fp_ext *dest,struct fp_ext *src) {uprint ("ftentox\n" );
@@ -137,8 +131,7 @@ fp_ftentox(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_flogn (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_flogn (struct fp_ext *dest,struct fp_ext *src) {uprint ("flogn\n" );
@@ -147,8 +140,7 @@ fp_flogn(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_flognp1 (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_flognp1 (struct fp_ext *dest,struct fp_ext *src) {uprint ("flognp1\n" );
@@ -157,8 +149,7 @@ fp_flognp1(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_flog10 (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_flog10 (struct fp_ext *dest,struct fp_ext *src) {uprint ("flog10\n" );
@@ -167,8 +158,7 @@ fp_flog10(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_flog2 (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_flog2 (struct fp_ext *dest,struct fp_ext *src) {uprint ("flog2\n" );
@@ -177,8 +167,7 @@ fp_flog2(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fgetexp (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fgetexp (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fgetexp\n" );
@@ -198,8 +187,7 @@ fp_fgetexp(struct fp_ext *dest, struct fp_ext *src)return dest; } -struct fp_ext * -fp_fgetman (struct fp_ext *dest,struct fp_ext *src) +struct fp_ext *fp_fgetman (struct fp_ext *dest,struct fp_ext *src) {dprint (PINSTR ,"fgetman\n" );
arch/m68k/math-emu/fp_trig.c +18 -36
162 lines not on this page · raw message
Signature · 1 line
2.34.1
Geert Uytterhoeven
maintainerPATCH 6/6 m68k: math-emu: Add missing prototypes
In reply to Geert UytterhoevenWhen building with W=1:
arch/m68k/math-emu/fp_arith.c:301:16: warning: no previous prototype for ‘fp_fsglmul’ [-Wmissing-prototypes]
301 | struct fp_ext *fp_fsglmul(struct fp_ext *dest, struct fp_ext *src)
| ^~~~~~~~~~
arch/m68k/math-emu/fp_arith.c:357:16: warning: no previous prototype for ‘fp_fsgldiv’ [-Wmissing-prototypes]
357 | struct fp_ext *fp_fsgldiv(struct fp_ext *dest, struct fp_ext *src)
| ^~~~~~~~~~
CC arch/m68k/math-emu/fp_log.o
...
Fix this by adding the missing prototypes to header files.
--- arch/m68k/math-emu/fp_arith.h | 2 ++ arch/m68k/math-emu/fp_log.c | 1 + arch/m68k/math-emu/fp_log.h | 44 +++++++++++++++++++++++++++++++++++ arch/m68k/math-emu/fp_trig.h | 19 +++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 arch/m68k/math-emu/fp_log.h
arch/m68k/math-emu/fp_arith.h +2 -0
@@ -26,6 +26,8 @@ struct fp_ext *fp_fcmp(struct fp_ext *dest, struct fp_ext *src);struct fp_ext *fp_ftst (struct fp_ext *dest,struct fp_ext *src);struct fp_ext *fp_fmul (struct fp_ext *dest,struct fp_ext *src);struct fp_ext *fp_fdiv (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsglmul (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsgldiv (struct fp_ext *dest,struct fp_ext *src);/* ones that do rounding and integer conversions */ struct fp_ext *fp_fmod (struct fp_ext *dest,struct fp_ext *src);
arch/m68k/math-emu/fp_log.c +1 -0
@@ -17,6 +17,7 @@#include "fp_arith.h" #include "fp_emu.h" +#include "fp_log.h" static const struct fp_ext fp_one = { .exp =0x3fff ,
arch/m68k/math-emu/fp_log.h new file +44 -0
44 lines not on this page · raw message
arch/m68k/math-emu/fp_trig.h +19 -0
@@ -29,4 +29,23 @@they return a status code, which should end up in %d0, if all goes well. */ +struct fp_ext *fp_fsin (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fcos (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_ftan (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fasin (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_facos (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fatan (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsinh (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fcosh (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_ftanh (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fatanh (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos0 (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos1 (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos2 (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos3 (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos4 (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos5 (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos6 (struct fp_ext *dest,struct fp_ext *src); +struct fp_ext *fp_fsincos7 (struct fp_ext *dest,struct fp_ext *src); +#endif /* _FP_TRIG_H */
Signature · 1 line
2.34.1