Nonworking scalarization patch

Eric S. Raymond esr at thyrsus.com
Wed Jan 4 13:10:17 UTC 2017


Hal Murray <hmurray at megapathdsl.net>:
> 
> l_fp is used 2 places.  One is scattered throughout the code.  That's the 
> stuff you are trying to clean up.
> 
> The other is on the wire.
> 
> The wire is big endian.  Intel is little endian.  On Intel, you need to do an 
> 8 byte swap rather than 2 4 byte swaps.
> 
> I have working code, but I'll let you clean things up and push since the patch you sent doesn't apply to HEAD.
> 
> I made a separate type for the on-wire forms.  It's only used in 4 places in the packet and 2 for htonl_fp and ntohl_fp.  The idea is to let the compiler help check things.
> 
> typedef struct {
>         uint32_t        l_ui;
>         uint32_t        l_uf;
> } l_fp_w;
> 
> static inline l_fp_w htonl_fp(l_fp lfp) {
>     l_fp_w lfpw;
>     lfpw.l_ui = htonl(lfpuint(lfp));
>     lfpw.l_uf = htonl(lfpfrac(lfp));
>     return lfpw;
> }
> 
> static inline l_fp ntohl_fp(l_fp_w lfpw) {
>     return lfpinit(ntohl(lfpw.l_ui), ntohl(lfpw.l_uf));
> }
> 
> I think that will work on a big endian system without any extra ifdefs.  It could be simplified with a few ifdefs.

Would you please send me a diff from HEAD to your working version?
That will give me a place to start cleaning up from.
-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>


More information about the devel mailing list