Achim Gratz writes: > Eric S. Raymond writes: >> Fortunately, we have good regression tests for those macros. So if you want >> to submit a simplification MR, feel free. > > Here's that patch. Tests are still clean of course. I have not removed > the distinction between signed and unsigned where it makes no difference > to the result.
Please disregard, I was having trouble with the 2.x version of magit… here's the correct patch that was being tested.
>From d1aa8b72f44e9ae3464f2ecc28250354c9299c06 Mon Sep 17 00:00:00 2001 From: Achim Gratz <strom...@stromeko.de> Date: Sat, 25 Feb 2017 12:48:48 +0100 Subject: [PATCH] Simplify l_fp access macros since the code is assuming POSIX/C99 * include/ntp_fp.h: Remove magic constants and rely on C99 cast semantics instead. --- include/ntp_fp.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/include/ntp_fp.h b/include/ntp_fp.h index 2f15124..2ab8cb8 100644 --- a/include/ntp_fp.h +++ b/include/ntp_fp.h @@ -30,17 +30,16 @@ * */ typedef uint64_t l_fp; -#define LOW32 0x00000000ffffffffUL -#define HIGH32 0xffffffff00000000UL -#define BUMP 0x0000000100000000UL -#define lfpfrac(n) ((uint32_t)((n) & LOW32)) -#define setlfpfrac(n, v) (n) = (((n) & HIGH32) | ((v) & LOW32)) -#define lfpsint(n) (int32_t)(((n) & HIGH32) >> 32) -#define setlfpsint(n, v) (n) = (int64_t)((((int64_t)(v)) << 32) | ((n) & LOW32)) -#define bumplfpsint(n, i) (n) += (i)*BUMP -#define lfpuint(n) (uint32_t)(((n) & HIGH32) >> 32) -#define setlfpuint(n, v) (n) = (uint64_t)((((uint64_t)(v)) << 32) | ((n) & LOW32)) -#define bumplfpuint(n, i) (n) += (i)*BUMP +#define lfpfrac(n) ((uint32_t)(n)) +#define lfptosint(n) (( int64_t)((uint64_t)(n) << 32)) +#define lfptouint(n) ((uint64_t)((uint64_t)(n) << 32)) +#define lfpsint(n) (( int32_t)((n) >> 32)) +#define lfpuint(n) ((uint32_t)((n) >> 32)) +#define bumplfpsint(n, i) ((n) += lfptosint(i)) +#define bumplfpuint(n, i) ((n) += lfptouint(i)) +#define setlfpfrac(n, v) ((n) = (lfptouint(lfpuint(n)) | lfpfrac(v))) +#define setlfpsint(n, v) ((n) = (lfptosint(v) | lfpfrac(n))) +#define setlfpuint(n, v) ((n) = (lfptouint(v) | lfpfrac(n))) static inline l_fp lfpinit(int32_t hi, uint32_t lo) { -- 2.1.4
Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Samples for the Waldorf Blofeld: http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra
_______________________________________________ devel mailing list devel@ntpsec.org http://lists.ntpsec.org/mailman/listinfo/devel