[Vm-dev] FloatMathPlugin: patch for squeak 4.19.2 fdlibm.h header

stes@PANDORA.BE stes at telenet.be
Sun Dec 6 10:28:33 UTC 2020


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


Because I'm having some annoying compiler warnings when compiling
the subversion classical VM squeak 4.19.2, I'm checking the FloatMathPlugin.

First of all the problem is the following, about 70 errors like this:

"./platforms/Cross/plugins/FloatMathPlugin/fdlibm/fdlibm.h", line 19: warning: m
acro redefined: __LITTLE_ENDIAN

The Makefile for building the FloatMathPlugin sets 

./i86/FloatMathPlugin/CMakeFiles/FloatMathPlugin.dir/flags.make:C_DEFINES = -DNO
_ISNAN=1 -DSQUEAK_BUILTIN_PLUGIN=1 -D__LITTLE_ENDIAN=1

The flag -D__LITTLE_ENDIAN=1 comes from cmake 's config.cmake:

In platforms/unix/plugins/FloatMathPlugin/config.cmake you can see

>   PLUGIN_DEFINITIONS (-D__LITTLE_ENDIAN=1)

Now at the same time the fdlibm.h header file redefines the __LITTLE_ENDIAN:

#if defined(i386) || defined(i486) || \
        defined(intel) || defined(x86) || defined(i86pc) || \
        defined(__alpha) || defined(__osf__)
#define __LITTLE_ENDIAN
#endif

So this causes lots of harmless but annoying,

"./platforms/Cross/plugins/FloatMathPlugin/fdlibm/fdlibm.h", line 19: warning: m
acro redefined: __LITTLE_ENDIAN

I'd like to get rid of those warnings by fixing the fdlibm.h.

If I compare platforms/Cross/plugins/FloatMathPlugin/fdlibm/fdlibm.h
in the subversion sources (for Squeak 4.19.2),
and in the opensmalltalk git sources (for Squeak Cog 5.0 ),
then I notice major differences.

In both cases the head of the fdlibm.h file is the same:

/* @(#)fdlibm.h 1.5 04/04/22 */
/*
 * ====================================================
 * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * is preserved.
 * ====================================================
 */

However if I "diff" the fdlibm.h from OpenSmalltalk and the one that
is in Subversion, they seem very different.

For example the OpenSmalltalk fdlibh.h has

#ifdef __cplusplus

while that is not present in the subversion 4.19.2 sources for the fdlibm.h.

As an experiment I copied the one from OpenSmalltalk to the VM 4.19.2:

bash-4.4$ cp $HOME/src/opensmalltalk/platforms/Cross/third-party/fdlibm/fdlibm.h
 $HOME/src/squeak4vm/platforms/Cross/plugins/FloatMathPlugin/fdlibm/fdlibm.h

If you run then

	svn diff

you gets lots of differences between the fdlibm.h from OpenSmalltalk,
and the one that is in subversion.

However the OpenSmalltalk fdlibm.h is NOT compiling in the classical VM 4.19.2.

I can fix the compiler warnings by the following small patch:

bash-4.4$ svn diff fdlibm.h 
Index: fdlibm.h
===================================================================
- --- fdlibm.h	(revision 3790)
+++ fdlibm.h	(working copy)
@@ -16,8 +16,10 @@
 #if defined(i386) || defined(i486) || \
 	defined(intel) || defined(x86) || defined(i86pc) || \
 	defined(__alpha) || defined(__osf__)
+#ifndef __LITTLE_ENDIAN
 #define __LITTLE_ENDIAN
 #endif
+#endif

With the above patch I get a clean build for the FloatMathPlugin.

It results in a clean build for both 64bit and 32bit.

Which is important as the CMAKE comment indicates the cmake flag is set,
precisely for the 64bit case
(the 64bit case was not dealt with by the SunOS 2004 header file).

So what happened I think is that the cmake settings was done for 64bit,
and it started to cause a lot of redefined macro warnings in the 32bit case.

Would it please be possible to commit the above small patch to the 
subversion sources ?

This would suppress the compiler warnings.

Thanks !
David Stes

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJfzLGjAAoJEAwpOKXMq1MaYu8H/0qGt9eBZdgBADEg8tptKnSb
5mCSxSMybnSG1rRolnp9UG+8jRd8f0gwjlUuv2UvylV6bZekbGXicNFvTG/nxF6L
htP65CVftVbdwwmt+wPa9juSBhsAFy7qcYF7YZeUJ4jLq7z8fFLI3Zid1Wco3Vb9
cyPUcKMTZ+xgPQ/b9DpHlScPX0NoZQranKQe3Xa5vnczewyxcigBRQ/wtevg8gl1
ormfE218TzCjvdRPjfxCvkybtmsbzLhMdlq7Ymih71xD+4VvrFZd4rNn8YAQddPe
ScJxyw4nUXO8lLnG2DZeW15xSpGtyAujL4SlY6XLvu2E88WQI6PRYLrSimemXjU=
=0zl1
-----END PGP SIGNATURE-----


More information about the Vm-dev mailing list