From 17ad69885bde062ad131d435ecd90868a8188853 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Sat, 4 Mar 2006 03:58:55 +0000 Subject: [PATCH] Use libm, not fdlibm, on all/most platforms. bug 326842, patch from Josh Aas, r=brendan/shaver --- js/src/Makefile.in | 43 +-------------------------------- js/src/Makefile.ref | 59 +++------------------------------------------ js/src/jslibmath.h | 36 ++++++++------------------- 3 files changed, 14 insertions(+), 124 deletions(-) diff --git a/js/src/Makefile.in b/js/src/Makefile.in index fc2e52a42ce1..65fd17e83bff 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -153,8 +153,6 @@ ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH))) EXPORTS += jscpucfg.h endif -FDLIBM_LIBRARY = fdlibm/$(LIB_PREFIX)fdm.$(LIB_SUFFIX) -JSMATH_PRELINK = jsmathtemp.o JS_SAFE_ARENA = 1 DASH_R = -r @@ -163,10 +161,6 @@ include $(topsrcdir)/config/config.mk EXTRA_DSO_LDOPTS += $(NSPR_LIBS) -ifeq (,$(filter-out OS2 WINNT WINCE,$(OS_ARCH))) -SHARED_LIBRARY_LIBS += $(FDLIBM_LIBRARY) -endif - # When using gcc the assembly is inlined in the C-file (see jslock.c) ifeq ($(OS_ARCH),SunOS) ifneq ($(OS_TEST),i86pc) @@ -218,7 +212,7 @@ LDFLAGS += -OPT:NOICF endif endif -GARBAGE += $(JSMATH_PRELINK) jscpucfg.o jsautocfg.h jsautocfg.tmp jscpucfg +GARBAGE += jscpucfg.o jsautocfg.h jsautocfg.tmp jscpucfg ifneq (,$(CROSS_COMPILE)$(filter-out WINNT,$(OS_ARCH))) TARGETS += jscpucfg$(HOST_BIN_SUFFIX) @@ -297,13 +291,6 @@ LDFLAGS += -lposix4 -ldl -lnsl -lsocket endif endif -ifeq ($(OS_ARCH),QNX) -ifneq ($(OS_TARGET),NTO) -# Don't use wildcard here, because we only want this resolved at link time. -OBJS += fdlibm/*.o -endif -endif - ifeq ($(OS_ARCH),IRIX) ifndef GNU_CC _COMPILE_CFLAGS = $(patsubst -O%,-O1,$(COMPILE_CFLAGS)) @@ -314,31 +301,6 @@ jsapi.o jsarena.o jsarray.o jsatom.o jsemit.o jsfun.o jsinterp.o jsregexp.o jspa endif endif -# On OS/2 & win32 we are already linking against fdlibm, so don't bother -# creating jsmathtemp -ifeq (,$(filter OS2 WINNT OpenVMS,$(OS_ARCH))) -# special rule for jsmath.o since we want to incrementally link -# against fdlibm to pull in only what is needed -# Do this in a single step to avoid dependency problems -jsmath.o: jsmath.c $(FDLIBM_LIBRARY) Makefile.in - $(REPORT_BUILD) - @$(MAKE_DEPS_AUTO) - $(ELOG) $(CC) $(OUTOPTION)$(JSMATH_PRELINK) -c $(COMPILE_CFLAGS) $< -ifeq ($(OS_ARCH),QNX) -ifneq ($(OS_TARGET),NTO) - @cp $(JSMATH_PRELINK) $@ -else - $(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY) -endif -else - $(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY) -endif - @$(RM) -f $(JSMATH_PRELINK) -else -# Create dependency so we build fdlibm -jsmath.o: $(FDLIBM_LIBRARY) Makefile.in -endif - # An AIX Optimization bug causes PR_dtoa() & JS_dtoa to produce wrong result. # This suppresses optimization for this single compilation unit. ifeq ($(OS_ARCH),AIX) @@ -352,9 +314,6 @@ jsdtoa.o: jsdtoa.c Makefile.in $(CC) -o $@ -c $(filter-out $(MOZ_OPTIMIZE_FLAGS), $(COMPILE_CFLAGS)) $< endif -$(FDLIBM_LIBRARY): - $(MAKE) -C $(@D) $(@F) - jsopcode.h jsopcode.c: jsopcode.tbl ifeq (,$(CROSS_COMPILE)$(filter-out WINNT,$(OS_ARCH))) diff --git a/js/src/Makefile.ref b/js/src/Makefile.ref index 10b1b93eed87..50d37a1ebe5c 100644 --- a/js/src/Makefile.ref +++ b/js/src/Makefile.ref @@ -58,12 +58,6 @@ ifdef NARCISSUS DEFINES += -DNARCISSUS endif -ifdef USE_MSVC -OTHER_LIBS += fdlibm/$(OBJDIR)/fdlibm.lib -else -OTHER_LIBS += -Lfdlibm/$(OBJDIR) -lfdm -endif - # Look in OBJDIR to find jsautocfg.h and jsautokw.h INCLUDES += -I$(OBJDIR) @@ -253,24 +247,6 @@ JS_CFILES = \ prmjtime.c \ $(NULL) -PREDIRS += fdlibm - -ifdef USE_MSVC -FDLIBM_LIBRARY = fdlibm/$(OBJDIR)/fdlibm.lib -else -FDLIBM_LIBRARY = fdlibm/$(OBJDIR)/libfdm.a -endif -JSMATH_PRELINK = $(OBJDIR)/jsmathtemp.$(OBJ_SUFFIX) -# Flag for incremental linking -DASH_R = -r - -ifeq ($(OS_ARCH),QNX) -ifneq ($(OS_TARGET),NTO) -# Don't use wildcard here, because we only want this resolved at link time. -OBJS += fdlibm/*.$(OBJ_SUFFIX) -endif -endif - ifdef JS_LIVECONNECT DIRS += liveconnect endif @@ -348,10 +324,10 @@ endif # ifdef USE_MSVC -$(PROGRAM): $(PROG_OBJS) $(LIBRARY) $(FDLIBM_LIBRARY) +$(PROGRAM): $(PROG_OBJS) $(LIBRARY) link.exe -out:"$@" $(EXE_LINK_FLAGS) $^ else -$(PROGRAM): $(PROG_OBJS) $(LIBRARY) $(FDLIBM_LIBRARY) +$(PROGRAM): $(PROG_OBJS) $(LIBRARY) $(CC) -o $@ $(CFLAGS) $(PROG_OBJS) $(LIBRARY) $(LDFLAGS) $(OTHER_LIBS) \ $(PROG_LIBS) endif @@ -373,38 +349,9 @@ $(OBJDIR)/jscpucfg: $(OBJDIR)/jscpucfg.o # Add to TARGETS for clobber rule TARGETS += $(OBJDIR)/jsautocfg.h $(OBJDIR)/jscpucfg \ - $(OBJDIR)/jscpucfg.o $(OBJDIR)/jsmathtemp.o + $(OBJDIR)/jscpucfg.o endif -# special rule for jsmath.o since we want to incrementally link -# against fdlibm to pull in only what is needed -$(OBJDIR)/jsmath.o: jsmath.c jsmath.h jslibmath.h $(FDLIBM_LIBRARY) -ifneq (,$(filter OS2 WINNT,$(OS_ARCH))) - $(CC) -Fo$(JSMATH_PRELINK) -c $(CFLAGS) $< -else - $(CC) -o $(JSMATH_PRELINK) -c $(CFLAGS) $< -endif - -ifeq ($(OS_ARCH),QNX) -ifneq ($(OS_TARGET),NTO) - @cp $(JSMATH_PRELINK) $@ -else - $(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY) -endif -else -ifdef USE_MSVC - @echo Warning: to use $(LIBRARY) must also link against $(FDLIBM_LIBRARY) - @cp $(JSMATH_PRELINK) $@ -endif - $(LD) $(DASH_R) -o $@ $(JSMATH_PRELINK) $(FDLIBM_LIBRARY) -endif - -# Note: generated headers must be built before descending -# into fdlibm directory - -$(FDLIBM_LIBRARY) : - $(MAKE) -C fdlibm -f Makefile.ref $(@F) - # # Hardwire dependencies on jsopcode.tbl # diff --git a/js/src/jslibmath.h b/js/src/jslibmath.h index 6ee231c24ce7..a9baf6d07be2 100644 --- a/js/src/jslibmath.h +++ b/js/src/jslibmath.h @@ -53,38 +53,15 @@ * Define on which platforms to use fdlibm. Not used by default under * assumption that native math library works unless proved guilty. * Plus there can be problems with endian-ness and such in fdlibm itself. + * + * fdlibm compatibility notes: + * - fdlibm broken on OSF1/alpha */ #ifndef JS_USE_FDLIBM_MATH - -#if defined(_WIN32) && !defined(__MWERKS__) -#define JS_USE_FDLIBM_MATH 1 - -#elif defined(SUNOS4) -#define JS_USE_FDLIBM_MATH 1 - -#elif defined(IRIX) -#define JS_USE_FDLIBM_MATH 1 - -#elif defined(SOLARIS) -#define JS_USE_FDLIBM_MATH 1 - -#elif defined(HPUX) -#define JS_USE_FDLIBM_MATH 1 - -#elif defined(OSF1) -/* Want to use some fdlibm functions but fdlibm broken on OSF1/alpha. */ -#define JS_USE_FDLIBM_MATH 0 - -#elif defined(AIX) -#define JS_USE_FDLIBM_MATH 1 - -#else #define JS_USE_FDLIBM_MATH 0 #endif -#endif /* JS_USE_FDLIBM_MATH */ - #if !JS_USE_FDLIBM_MATH /* @@ -96,7 +73,14 @@ #define fd_atan atan #define fd_atan2 atan2 #define fd_ceil ceil +// the right copysign function is not always named the same thing +#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +#define fd_copysign __builtin_copysign +#elif (defined _WIN32 && !defined WINCE) +#define fd_copysign _copysign +#else #define fd_copysign copysign +#endif #define fd_cos cos #define fd_exp exp #define fd_fabs fabs