Closed Bug 422407 Opened 18 years ago Closed 3 years ago

Compile error on Solaris 8 - uses floorf and ceilf which are not available

Categories

(Core :: XPCOM, defect)

Sun
Solaris
defect

Tracking

()

RESOLVED INACTIVE

People

(Reporter: stevee, Unassigned)

Details

(Whiteboard: reviewed)

User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.8.1.12) Gecko/20080211 Firefox/2.0.0.12 Build Identifier: Firefox 3 beta 4 The file xpcom/ds/nsMathUtils.h uses floorf and ceilf which are not available on Solaris 8. This results in several compile errors, one of which is: gmake[5]: Entering directory `/icad/12/mozilla/build/mozilla/uriloader/base' nsDocLoader.cpp c++ -o nsDocLoader.o -c -DMOZILLA_INTERNAL_API -D_IMPL_NS_COM -DEXPORT_XPT_API -DEXPORT_XPTC_API -D_IMPL_NS_COM_OBSOLETE -D_IMPL_NS_GFX -D_IMPL_NS_WIDGET -DIMPL_XREAPI -DIMPL_NS_NET -DIMPL_THEBES -DZLIB_INTERNAL -DOSTYPE=\"SunOS5\" -DOSARCH=SunOS -I. -I. -I../../dist/include/xpcom -I../../dist/include/string -I../../dist/include/necko -I../../dist/include/dom -I../../dist/include/exthandler -I../../dist/include/js -I../../dist/include/docshell -I../../dist/include/gfx -I../../dist/include/thebes -I../../dist/include/layout -I../../dist/include/content -I../../dist/include/widget -I../../dist/include/caps -I../../dist/include/intl -I../../dist/include/xpconnect -I../../dist/include/mimetype -I../../dist/include/locale -I../../dist/include -I../../dist/include/uriloader -I../../dist/include/nspr -I../../dist/sdk/include -I/usr/openwin/include -fPIC -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -O2 -Wno-unknown-pragmas -mcpu=ultrasparc -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -I/gorbag/exta/cad/externals/SOLARIS/include -I/usr/openwin/include -fno-rtti -fno-exceptions -Wno-long-long -pedantic -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -O2 -fomit-frame-pointer -fno-exceptions -Wno-unknown-pragmas -mcpu=ultrasparc -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -I/gorbag/exta/cad/externals/SOLARIS/include -fno-strict-aliasing -fshort-wchar -pthreads -DNDEBUG -DTRIMMED -O -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -O2 -Wno-unknown-pragmas -mcpu=ultrasparc -I/gorbag/exta/cad/externals/SOLARIS/gnome2/include/glib-2.0 -I/gorbag/exta/cad/externals/SOLARIS/include -I/usr/openwin/include -DMOZILLA_CLIENT -include ../../mozilla-config.h -Wp,-MD,.deps/nsDocLoader.pp nsDocLoader.cpp In file included from ../../dist/include/gfx/nsCoord.h:42, from ../../dist/include/layout/nsIPresShell.h:58, from nsDocLoader.cpp:58: ../../dist/include/xpcom/nsMathUtils.h: In function `float NS_roundf(float)': ../../dist/include/xpcom/nsMathUtils.h:54: error: `floorf' was not declared in this scope ../../dist/include/xpcom/nsMathUtils.h:54: error: `ceilf' was not declared in this scope ../../dist/include/xpcom/nsMathUtils.h: In function `float NS_ceilf(float)': ../../dist/include/xpcom/nsMathUtils.h:74: error: `ceilf' was not declared in this scope ../../dist/include/xpcom/nsMathUtils.h: In function `float NS_floorf(float)': ../../dist/include/xpcom/nsMathUtils.h:86: error: `floorf' was not declared in this scope Reproducible: Always Steps to Reproduce: 1. Build with a .mozconfig containing: . $topsrcdir/browser/config/mozconfig ac_add_options --disable-debug ac_add_options --enable-optimize ac_add_options --disable-tests ac_add_options --enable-official-branding ac_add_options --enable-svg ac_add_options --enable-xft
Did you use another compiler as in Bug 422401 (gcc 3.4.6) or did you solve Bug 422401?
This was using gcc 3.4.6. I added ran gmake with -i to see what other problems occurred.
Confirmed on Solaris 8. libm on Sol8 does not contain floorf() or ceilf(), so the fix is to use float() and ceil() and static_cast<float> their outputs to strap the value range to that of a float. diff -Naur mozilla-old/xpcom/ds/nsMathUtils.h mozilla-updated/xpcom/ds/nsMathUtils.h --- mozilla-old/xpcom/ds/nsMathUtils.h 2007-02-28 12:57:13.000000000 -0800 +++ mozilla-updated/xpcom/ds/nsMathUtils.h 2008-03-19 08:27:04.206253000 -0700 @@ -39,8 +39,12 @@ #define nsMathUtils_h__ #include "nscore.h" -#include <math.h> -#include <float.h> +#include <cmath> +#include <cfloat> + +using std::floor; +using std::ceil; + /* * round @@ -51,7 +55,7 @@ } inline NS_HIDDEN_(float) NS_roundf(float x) { - return x >= 0.0f ? floorf(x + 0.5f) : ceilf(x - 0.5f); + return x >= 0.0f ? static_cast<float>(floor(x + 0.5f)) : static_cast<float>(ceil(x - 0.5f)); } inline NS_HIDDEN_(PRInt32) NS_lround(double x) { @@ -71,7 +75,7 @@ } inline NS_HIDDEN_(float) NS_ceilf(float x) { - return ceilf(x); + return static_cast<float>(ceil(x)); } /* @@ -83,7 +87,7 @@ } inline NS_HIDDEN_(float) NS_floorf(float x) { - return floorf(x); + return static_cast<float>(floor(x)); } #endif
So you want to use a slower function everywhere else just to satisfy Solaris 8?
Whiteboard: reviewed
I can also verify this as I ran into it today compiling Firefox 3.0 stable on Solaris 8 with GCC 4.2.2. Any fix yet?
Just curious: what's the difference between NS_round()+friends vs posix round()+friends ?
Severity: normal → S3
Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.