# HG changeset patch # User Michael Goffioul # Date 1371523391 14400 # Node ID f8299bb6c8726a35d811841c31c7b64aaa5629b2 # Parent cbdf4575016d5b9d988b11992a8ea605869bb188 Initial support for native MSVC compilation. * add MSVC support files: compiler wrappers and support libraries * adapt libiconv to work with MSVC * adapt gettext to work with MSVC diff -r cbdf4575016d -r f8299bb6c872 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,14 @@ +^settings.mk +^usr/ +^log/ +^pkg/ +^installed-packages/ +^wip/ +^tmp-.*/ + +^autom4te.cache/ +^configure +^config.status +^config.log +^Makefile +^cmake-toolchain-file.stamp diff -r cbdf4575016d -r f8299bb6c872 Makefile.in --- a/Makefile.in Mon Jun 17 20:22:08 2013 -0400 +++ b/Makefile.in Mon Jun 17 22:43:11 2013 -0400 @@ -45,6 +45,9 @@ ## end of configuration variables. ifneq ($(MXE_NATIVE_BUILD),yes) + ifeq ($(MXE_SYSTEM),msvc) + $(error Cross-compiling to MSVC is not supported) + endif HOST_AND_BUILD_CONFIGURE_OPTIONS := \ --host='$(TARGET)' --build='$(BUILD_SYSTEM)' endif @@ -54,6 +57,9 @@ ifeq ($(MXE_SYSTEM),mingw) MXE_NATIVE_MINGW_BUILD := yes endif + ifeq ($(MXE_SYSTEM),msvc) + MXE_NATIVE_MINGW_BUILD := yes + endif endif # These can't be chosen arbitrarily. The way things are configured now, @@ -114,11 +120,15 @@ BUILD_TOOLS := $(ALL_BUILD_TOOLS) # Building flex for native mingw fails, so disable it. ifeq ($(MXE_NATIVE_MINGW_BUILD),yes) + REQUIREMENTS += flex BUILD_TOOLS := $(filter-out build-flex, $(BUILD_TOOLS)) endif ifeq ($(USE_SYSTEM_GCC),yes) BUILD_TOOLS := $(filter-out $(BUILD_COMPILER_TOOLS), $(BUILD_TOOLS)) endif +ifneq ($(MXE_SYSTEM),msvc) + BUILD_TOOLS := $(filter-out build-msvctools, $(BUILD_TOOLS)) +endif STAMP_DIR := $(PWD)/installed-packages MSYS_INFO_DIR := $(PWD)/msys-info @@ -137,24 +147,40 @@ CONFIGURE_CPPFLAGS := CPPFLAGS='-I$(HOST_PREFIX)/include' CONFIGURE_LDFLAGS := LDFLAGS='-L$(HOST_PREFIX)/lib' +CONFIGURE_POST_HOOK := true ifeq ($(MXE_NATIVE_BUILD),yes) MXE_TOOL_PREFIX := - MXE_AR := ar - MXE_RANLIB := ranlib - MXE_CC := gcc - MXE_CXX := g++ - MXE_F77 := gfortran - MXE_DLLTOOL := dlltool - MXE_NM := nm - MXE_STRIP := strip - ifeq ($(MXE_SYSTEM),mingw) + ifeq ($(MXE_SYSTEM),msvc) + MXE_AR := ar + MXE_RANLIB := ranlib + MXE_CC := clgcc + MXE_CXX := clg++ + MXE_F77 := gfortran-msvc + MXE_DLLTOOL := true + MXE_NM := nm + MXE_STRIP := true MXE_WINDRES := windres + MXE_PKG_CONFIG := pkg-config + MXE_QMAKE := qmake + HOST_AND_BUILD_CONFIGURE_OPTIONS := CC='$(MXE_CC)' CXX='$(MXE_CXX)' F77='$(MXE_F77)' DLLTOOL='$(MXE_DLLTOOL)' else - MXE_WINDRES := true + MXE_AR := ar + MXE_RANLIB := ranlib + MXE_CC := gcc + MXE_CXX := g++ + MXE_F77 := gfortran + MXE_DLLTOOL := dlltool + MXE_NM := nm + MXE_STRIP := strip + ifeq ($(MXE_SYSTEM),mingw) + MXE_WINDRES := windres + else + MXE_WINDRES := true + endif + MXE_PKG_CONFIG := pkg-config + MXE_QMAKE := qmake endif - MXE_PKG_CONFIG := pkg-config - MXE_QMAKE := qmake else MXE_TOOL_PREFIX := $(TARGET)- MXE_AR := '$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)ar' @@ -191,7 +217,7 @@ NOTEPAD_BASE_DIR := $(TOP_DIR)/notepad++ endif -else +else ifneq ($(MXE_SYSTEM),msvc) LD_LIBRARY_PATH := '$(HOST_LIBDIR)' export LD_LIBRARY_PATH MXE_CPPFLAGS := '-I$(HOST_INCDIR)' @@ -201,14 +227,31 @@ LN := ln LN_S := $(LN) -s LN_SF := $(LN_S) -f -ifeq ($(MXE_SYSTEM),mingw) - ifeq ($(MXE_NATIVE_BUILD),yes) +ifeq ($(MXE_NATIVE_BUILD),yes) + ifeq ($(MXE_SYSTEM),mingw) + LN := cp + LN_S := $(LN) + LN_SF := $(LN_S) + endif + ifeq ($(MXE_SYSTEM),msvc) LN := cp LN_S := $(LN) LN_SF := $(LN_S) endif endif +LIBRARY_PREFIX := +LIBRARY_SUFFIX := + +ifeq ($(MXE_SYSTEM),msvc) + CL_VERSION := $(shell cl -? 2>&1 | $(SED) -n -e 's/.*Compiler Version \([0-9]\+\).*/\1/p') + MSVC_VERSION := $(if $(filter 17,$(CL_VERSION)),110, \ + $(if $(filter 16,$(CL_VERSION)),100, \ + $(if $(filter 15,$(CL_VERSION)),90))) + LIBRARY_PREFIX := vc$(strip $(MSVC_VERSION))-lib + CONFIGURE_POST_HOOK := lt-postproc -p '$(LIBRARY_PREFIX)' -s '$(LIBRARY_SUFFIX)' +endif + OCTAVE_FORGE_BASE_URL := 'http://sourceforge.net/projects/octave/files/Octave Forge Packages/Individual Package Releases' OCTAVE_FORGE_PACKAGES := $(addprefix of-,miscellaneous struct optim specfun general signal communications image io statistics control) @@ -248,13 +291,13 @@ endif UNPACK_PKG_ARCHIVE = \ - $(call UNPACK_ARCHIVE,$(PKG_DIR)/$($(1)_FILE),$(1)) + $(if $(value $(1)_FILE),$(call UNPACK_ARCHIVE,$(PKG_DIR)/$($(1)_FILE)),true) PKG_CHECKSUM = \ openssl sha1 '$(PKG_DIR)/$($(1)_FILE)' 2>/dev/null | $(SED) -n 's,^.*\([0-9a-f]\{40\}\)$$,\1,p' CHECK_PKG_ARCHIVE = \ - [ '$($(1)_CHECKSUM)' == "`$$(call PKG_CHECKSUM,$(1))`" ] + [ -z "$($(1)_CHECKSUM)" -o '$($(1)_CHECKSUM)' == "`$$(call PKG_CHECKSUM,$(1))`" ] DOWNLOAD_PKG_ARCHIVE = \ mkdir -p '$(PKG_DIR)' && \ @@ -371,7 +414,9 @@ $(1): $(STAMP_DIR)/$(1) $(STAMP_DIR)/$(1): $(TOP_DIR)/src/$(1).mk \ $(wildcard $(TOP_DIR)/src/$(1)-*.patch) \ + $(wildcard $(TOP_DIR)/src/$(MXE_SYSTEM)-$(1)-*.patch) \ $(wildcard $(TOP_DIR)/src/$(1)-test*) \ + $(shell test -d $(TOPDIR)/src/$(1) && find $(TOPDIR)/src/$(1) -type f) \ $(addprefix $(STAMP_DIR)/,$($(1)_DEPS)) \ | check-requirements @[ -d '$(LOG_DIR)/$(TIMESTAMP)' ] || mkdir -p '$(LOG_DIR)/$(TIMESTAMP)' @@ -415,9 +460,12 @@ rm -rf '$(2)' mkdir -p '$(2)' cd '$(2)' && $(call UNPACK_PKG_ARCHIVE,$(1)) + test ! -d '$(TOP_DIR)/src/$(1)' || cp -a '$(TOP_DIR)/src/$(1)' '$(2)' cd '$(2)/$($(1)_SUBDIR)' $(foreach PKG_PATCH,$(sort $(wildcard $(TOP_DIR)/src/$(1)-*.patch)), (cd '$(2)/$($(1)_SUBDIR)' && $(PATCH) -p1 -u) < $(PKG_PATCH)) + $(foreach PKG_PATCH,$(sort $(wildcard $(TOP_DIR)/src/msvc-$(1)-*.patch)), + (cd '$(2)/$($(1)_SUBDIR)' && $(PATCH) -p1 -u) < $(PKG_PATCH)) $$(call $(1)_BUILD,$(2)/$($(1)_SUBDIR),$(TOP_DIR)/src/$(1)-test) (du -k -d 0 '$(2)' 2>/dev/null || du -k --max-depth 0 '$(2)') | $(SED) -n 's/^\(\S*\).*/du: \1 KiB/p' rm -rfv '$(2)' @@ -484,7 +532,7 @@ define build-cmake-toolchain-file # create the CMake toolchain file [ -d '$(dir $(CMAKE_TOOLCHAIN_FILE))' ] || mkdir -p '$(dir $(CMAKE_TOOLCHAIN_FILE))' - (if [ $(MXE_SYSTEM) = mingw ]; then \ + (if [ $(MXE_SYSTEM) = mingw -o $(MXE_SYSTEM) = msvc ]; then \ echo 'set(CMAKE_SYSTEM_NAME Windows)'; \ echo 'set(MSYS 1)'; \ fi; \ diff -r cbdf4575016d -r f8299bb6c872 index.html --- a/index.html Mon Jun 17 20:22:08 2013 -0400 +++ b/index.html Mon Jun 17 22:43:11 2013 -0400 @@ -1024,6 +1024,11 @@ libtool + msvctools + + + + pkg-config 0.28 pkg-config @@ -1220,7 +1225,7 @@ gettext - 0.18.1.1 + 0.18.2 gettext diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools.mk Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,27 @@ +# This file is part of MXE. +# See index.html for further information. + +PKG := build-msvctools +$(PKG)_IGNORE := +$(PKG)_CHECKSUM := a464ba0f26eef24c29bcd1e7489421117fb9ee35 +$(PKG)_FILE := gcc-$(build-gcc_VERSION).tar.bz2 +$(PKG)_URL := ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$(build-gcc_VERSION)/$($(PKG)_FILE) +$(PKG)_SUBDIR := build-msvctools +$(PKG)_DEPS := + +define $(PKG)_UPDATE + echo 1 +endef + +define $(PKG)_BUILD + make -C '$(1)' -j '$(JOBS)' \ + DESTDIR='$(HOST_PREFIX)' \ + GCCVERSION='$(build-gcc_VERSION)' \ + INSTALL='$(INSTALL)' \ + LIBRARY_PREFIX='$(LIBRARY_PREFIX)' \ + LIBRARY_SUFFIX='$(LIBRARY_SUFFIX)' \ + PATCH='$(PATCH)' \ + SED='$(SED)' \ + WGET='$(WGET)' \ + install +endef diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/Makefile Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,181 @@ +TARGETS = \ + ar-msvc \ + cc-msvc.exe \ + clgcc.exe \ + clg++.exe \ + dirent.h \ + dirent.lib \ + getopt.h \ + getopt.lib \ + inttypes.h \ + lt-postproc \ + ranlib-msvc \ + stdbool.h \ + unistd.h \ + compat/mingwcompat.lib \ + math/msvcmath.lib \ + gfortran-msvc.exe \ + gfortran-msvc.lib \ + gfortran-msvc-static.lib + +MSVCSTDINT := $(shell echo '\#include ' > t.c; cl -nologo -showIncludes -c t.c | $(SED) -n -e 's/^Note: including file: \(.*stdint\.h\)$$/\1/p'; rm -f t.c t.obj) +ifeq ($(MSVCSTDINT),) +TARGETS += stdint.h +endif + +.PHONY: all +all: $(TARGETS) + +cc-msvc.exe: cc-msvc.cc + cl -nologo -O2 -EHsc cc-msvc.cc + +clgcc.exe clg++.exe: cc-msvc.exe + cp -a $< $@ + +fixlibtool2: fixlibtool2.in + $(SED) \ + -e "s/@LIBRARY_PREFIX@/$(LIBRARY_PREFIX)/" \ + -e "s/@LIBRARY_SUFFIX@/$(LIBRARY_SUFFIX)/" $< > $@ + +stdint.h inttypes.h: + $(WGET) http://msinttypes.googlecode.com/svn/trunk/$@ + +dirent.h: + $(WGET) -O $@ 'http://sourceforge.net/p/mingw/mingw-org-wsl/ci/master/tree/include/dirent.h?format=raw' + $(SED) -i -e 's/FILENAME_MAX/260/g' \ + -e 's/__MINGW_NOTHROW//g' \ + -e 's,^.*_mingw\.h.*$$,/*&*/,' \ + -e 's/_A_VOLID/0x00/g' \ + $@ + +dirent.c: + $(WGET) -O $@ 'http://sourceforge.net/p/mingw/mingw-org-wsl/ci/master/tree/src/libcrt/tchar/dirent.c?format=raw' + +dirent.obj: dirent.c dirent.h + cl -nologo -O2 -MD -I. \ + -DFILENAME_MAX=260 \ + -Dinline=__inline \ + -D_TDIR=DIR \ + -D_tdirent=dirent \ + -D_topendir=opendir \ + -D_tclosedir=closedir \ + -D_treaddir=readdir \ + -D_trewinddir=rewinddir \ + -D_tseekdir=seekdir \ + -D_ttelldir=telldir \ + -c dirent.c -Fo$@ + +wdirent.obj: dirent.c dirent.h + cl -nologo -O2 -MD -I. \ + -D_UNICODE \ + -DFILENAME_MAX=260 \ + -Dinline=__inline \ + -D_osver=GetVersion\(\) \ + -D_TDIR=_WDIR \ + -D_tdirent=_wdirent \ + -D_topendir=_wopendir \ + -D_tclosedir=_wclosedir \ + -D_treaddir=_wreaddir \ + -D_trewinddir=_wrewinddir \ + -D_tseekdir=_wseekdir \ + -D_ttelldir=_wtelldir \ + -c dirent.c -Fo$@ + +dirent.lib: dirent.obj wdirent.obj + lib -out:$@ $^ + +getopt.h: + $(WGET) -O $@ 'http://sourceforge.net/p/mingw/mingw-org-wsl/ci/master/tree/include/getopt.h?format=raw' + $(SED) -i -e 's/__MINGW_NOTHROW//g' \ + -e 's,^.*_mingw\.h.*$$,/*&*/,' \ + getopt.h + +getopt.c: getopt.diff + $(WGET) -O $@ 'http://sourceforge.net/p/mingw/mingw-org-wsl/ci/master/tree/src/libcrt/misc/getopt.c?format=raw' + $(PATCH) -p0 < getopt.diff + +getopt.obj: getopt.c getopt.h + cl -nologo -O2 -MD -I. -c $< -Fo$@ + +getopt.lib: getopt.obj + lib -out:$@ $^ + +compat/mingwcompat.lib: + $(MAKE) -C compat + +math/msvcmath.lib: + $(MAKE) -C math SED='$(SED)' + +math/msvcmath.h: math/msvcmath.lib + +gfortran-msvc.exe: gfortran-msvc.cc + cl -nologo -O2 -EHsc gfortran-msvc.cc + +gfortran-msvc-gcc-patch.stamp: + (cd ../gcc-$(GCCVERSION)/ && patch -p1) < gcc.diff + (cd ../gcc-$(GCCVERSION)/ && \ + cp libgcc/config/i386/gthr-win32.h libgcc/gthr-default.h) + touch $@ + +gfortran-msvc-build: + mkdir $@ + +gfortran-msvc-build/.libs/libgfortran.a: gfortran-msvc-gcc-patch.stamp gfortran-msvc-build + cd gfortran-msvc-build && \ + ../../gcc-$(GCCVERSION)/libgfortran/configure \ + --disable-libquadmath-support \ + --disable-shared \ + --enable-static \ + --disable-multilib \ + CFLAGS="-O2 -mstackrealign -mincoming-stack-boundary=2" \ + FCFLAGS="-O3 -ff2c -mstackrealign -mincoming-stack-boundary=2" + $(MAKE) -C gfortran-msvc-build + +gfortran.lst: gfortran-msvc-build/.libs/libgfortran.a + ar x $< + ar t $< > $@ + +gfortran.def: gfortran.lst + (echo 'EXPORTS'; nm -C @$< | grep ' T _gfortran_' | cut -d' ' -f3) > $@ + +libgfortran-dllinit.o: libgfortran-dllinit.c cc-msvc.exe + cc-msvc -O2 -c $< -o $@ + +libgfortran-msvcinit.o: libgfortran-msvcinit.c cc-msvc.exe + cc-msvc -O2 -c $< -o $@ + +gfortran-msvc.lib: gfortran-msvc-build/.libs/libgfortran.a gfortran.def gfortran.lst \ + compat/mingwcompat.lib cc-msvc.exe libgfortran-dllinit.o + cc-msvc -shared -o $(LIBRARY_PREFIX)gfortran-msvc$(LIBRARY_SUFFIX).dll \ + libgfortran-dllinit.o @gfortran.lst -Wl,-def:gfortran.def -Wl,-implib:gfortran-msvc.lib \ + -Lcompat -Lmath -lmingwcompat -ladvapi32 + +gfortran-msvc-static.lib: gfortran-msvc-build/.libs/libgfortran.a gfortran.lst libgfortran-msvcinit.o + lib -out:$@ libgfortran-msvcinit.o @gfortran.lst + +.PHONY: install +install: all + $(INSTALL) -d $(DESTDIR)/bin + $(INSTALL) ar-msvc $(DESTDIR)/bin/ + $(INSTALL) cc-msvc.exe $(DESTDIR)/bin/ + $(INSTALL) clgcc.exe $(DESTDIR)/bin/ + $(INSTALL) clg++.exe $(DESTDIR)/bin/ + $(INSTALL) lt-postproc $(DESTDIR)/bin/ + $(INSTALL) gfortran-msvc.exe $(DESTDIR)/bin/ + $(INSTALL) ranlib-msvc $(DESTDIR)/bin/ + $(INSTALL) $(LIBRARY_PREFIX)gfortran-msvc$(LIBRARY_SUFFIX).dll $(DESTDIR)/bin/ + $(INSTALL) -d $(DESTDIR)/include + test -n "$(MSVCSTDINT)" || $(INSTALL) stdint.h $(DESTDIR)/include + $(INSTALL) inttypes.h $(DESTDIR)/include + $(INSTALL) unistd.h $(DESTDIR)/include + $(INSTALL) stdbool.h $(DESTDIR)/include + $(INSTALL) dirent.h $(DESTDIR)/include + $(INSTALL) getopt.h $(DESTDIR)/include + $(INSTALL) math/msvcmath.h $(DESTDIR)/include/math.h + $(INSTALL) -d $(DESTDIR)/lib + $(INSTALL) dirent.lib $(DESTDIR)/lib + $(INSTALL) getopt.lib $(DESTDIR)/lib + $(INSTALL) compat/mingwcompat.lib $(DESTDIR)/lib + $(INSTALL) math/msvcmath.lib $(DESTDIR)/lib + $(INSTALL) gfortran-msvc.lib $(DESTDIR)/lib + $(INSTALL) gfortran-msvc-static.lib $(DESTDIR)/lib diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/ar-msvc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/ar-msvc Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,124 @@ +#!/bin/sh + +# ar-msvc +# Wrapper around MS's lib.exe to make it act more like Unix ar. This +# software is largely inspired by cccl (http://cccl.sourceforge.net). +# +# Copyright (C) 2006 Michael Goffioul +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# + +usage() +{ + cat <. + * + * ========================================================================= + * + * Compile this file with "cl -EHs -O2 cc-msvc.cc" and install it into + * your PATH environment variable. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + +#ifdef _MSC_VER +#define popen _popen +#define pclose _pclose +#endif + +using namespace std; + +static string usage_msg = +"Usage: cc-msvc [OPTIONS]\n" +"\n" +"cc-msvc is a wrapper around Microsoft's cl.exe and link.exe. It translates\n" +"parameters that Unix cc's and ld's understand to parameters that cl and link\n" +"understand."; +static string version_msg = +"cc-msvc 0.1\n" +"\n" +"Copyright 2006 Michael Goffioul\n" +"This is free software; see the source for copying conditions. There is NO\n" +"waranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; + +inline bool starts_with(const string& s, const string& prefix) +{ + return (s.length() >= prefix.length() && s.find(prefix) == 0); +} + +inline bool ends_with(const string& s, const string& suffix) +{ + return (s.length() >= suffix.length() && s.rfind(suffix) == s.length()-suffix.length()); +} + +static list split(const string& s, char delim) +{ + list result; + size_t current = 0, pos, len = s.length (); + + while (current < len) + { + pos = s.find (delim, current); + if (pos == string::npos) + { + result.push_back (s.substr (current)); + break; + } + else + { + result.push_back (s.substr (current, pos - current)); + current = pos + 1; + } + } + + return result; +} + +static string get_line(FILE *fp) +{ + static vector buf(100); + int idx = 0; + char c; + + while (1) + { + c = (char)fgetc(fp); + if (c == '\n' || c == EOF) + break; + if (buf.size() <= idx) + buf.resize(buf.size() + 100); + buf[idx++] = c; + } + if (idx == 0) + return string(""); + else + return string(&buf[0], idx); +} + +static string process_depend(const string& s) +{ + string result; + string tmp(s); + + if (tmp.find(' ') != std::string::npos) + { + std::string sp; + int len; + + sp.resize(tmp.length()+1); + len = GetShortPathName(tmp.c_str(), &sp[0], tmp.length()+1); + sp.resize(len); + tmp = sp; + } + + for (int i=0; i': + case '(': + case ')': + case '|': + case '^': + case '@': + result.push_back('^'); + default: + result.push_back(value[i]); + break; + } + return ("\"" + name + "=" + result + "\""); + } + else + { + if (value.find_first_of("&<>()@^| ") != string::npos) + return ("\"" + name + "=" + value + "\""); + else + return (name + "=" + value); + } +} + +static string quote_quotes(const string& s) +{ + string result; + + if (s.find('"') != string::npos) + { + for (int i=0; i()@^| ") != string::npos) + result = "\"" + result + "\""; + +#if 0 + if (result.find_first_of("<>") != string::npos) + { + /* Could not find a better way to avoid the problem + * with those characters. */ + replace(result.begin(), result.end(), '<', '['); + replace(result.begin(), result.end(), '>', ']'); + } +#endif + + return result; +} + +static int do_system(const string& cmd) +{ + STARTUPINFO info; + PROCESS_INFORMATION proc; + DWORD result; + + ZeroMemory (&info, sizeof (info)); + info.cb = sizeof (info); + ZeroMemory (&proc, sizeof (proc)); + + if (CreateProcess (NULL, (char*)cmd.c_str (), NULL, NULL, TRUE, 0, NULL, NULL, + &info, &proc)) + { + WaitForSingleObject (proc.hProcess, INFINITE); + GetExitCodeProcess (proc.hProcess, &result); + CloseHandle (proc.hProcess); + CloseHandle (proc.hThread); + } + else + result = (DWORD)-1; + + return result; +} + +static bool read_stdin(const char *filename) +{ + char buf[1024]; + int n; + FILE *fout = fopen(filename, "wb"); + + if (fout == NULL) + { + cerr << filename << ": cannot open file for writing" << endl; + return false; + } + while ((n = fread(buf, 1, 1024, stdin)) > 0) + fwrite(buf, 1, n, fout); + fclose(fout); + return true; +} + +static void replace_option(string& s, const string& opt, const string& val = string()) +{ + if (starts_with(s, opt)) + s.erase(0, opt.length()).insert(0, val); + if (ends_with(s, opt)) + s.erase(s.length()-opt.length()).append(val); + + string look_str = (" " + opt + " "); + int n = opt.length(); + int pos; + + while ((pos = s.find(look_str)) != string::npos) + s.replace(pos+1, n, val); +} + +static void update_environment (void) +{ + char name_buffer[1024]; + DWORD len = GetModuleFileName (NULL, name_buffer, sizeof (name_buffer)); + + if (len == 0 && len >= sizeof (name_buffer)) + return; + + string root (name_buffer); + size_t pos = root.find_last_of ("\\/"); + + if (pos != string::npos) + root.resize (pos); + + if (root == "bin" + || ends_with (root, "\\bin") + || ends_with (root, "/bin")) + { + if (root.size () == 3) + root.clear (); + else + root.resize (root.size () - 4); + + string include_var = getenv ("INCLUDE"); + string lib_var = getenv ("LIB"); + + if (include_var.empty ()) + include_var = "INCLUDE=" + root + "\\include"; + else + include_var = "INCLUDE=" + root + "\\include;" + include_var; + + if (lib_var.empty ()) + lib_var = "LIB=" + root + "\\lib"; + else + lib_var = "LIB=" + root + "\\lib;" + lib_var; + + putenv (include_var.c_str ()); + putenv (lib_var.c_str ()); + } +} + +int main(int argc, char **argv) +{ + string clopt, linkopt, cllinkopt, sourcefile, objectfile, optarg, prog, exefile; + list Xlinkopt; + bool gotparam, dodepend, exeoutput, doshared, debug = false, read_from_stdin, gotXlinker; + bool mt_embed = true; + bool no_exceptions = false, default_libs = true, incremental_link = false; + bool cppmode = false; + + prog = "cl"; + clopt = "-nologo -MD -DWIN32 -D_WIN32 -D__WIN32__"; + linkopt = "-nologo"; + cllinkopt = ""; + sourcefile = ""; + objectfile = ""; + gotparam = false; + dodepend = false; + exeoutput = true; + exefile = ""; + doshared = false; + read_from_stdin = false; + gotXlinker = false; + + cppmode = (ends_with (argv[0], "c++-msvc.exe") + || ends_with (argv[0], "c++-msvc") + || ends_with (argv[0], "clg++.exe") + || ends_with (argv[0], "clg++")); + if (cppmode) + clopt += " -EHsc"; + + update_environment (); + + if (argc == 1) + { + cout << usage_msg << endl; + return 1; + } + + for (int i=1; i= '0' && arg[2] <= '9')) + { + clopt += " -Zi"; + linkopt += " -debug"; + } + else if (arg == "-d") + { + debug = true; + } + else if (arg == "-shared") + { + clopt += " -LD"; + linkopt += " -DLL"; + doshared = true; + } + else if (arg == "-mwindows") + { + linkopt += " -subsystem:windows"; + } + else if (arg == "-O2" || arg == "-MD") + { + // do not pass those to the linker + clopt += (" " + arg); + } + else if (starts_with(arg, "-I")) + { + string path = arg.substr(2); + clopt += " -I" + quote_path(path); + } + else if (arg == "-isystem") + { + // Convert -isystem arguments into regular -I flags + if (i < argc-1) + { + arg = argv[++i]; + // sysroot include prefix is not supported!! + if (arg.length () > 0 && arg[0] == '=') + { + cerr << "ERROR: isystem argument starting with '=' is not supported" << endl; + return 1; + } + clopt += " -I" + quote_path(arg); + } + else + { + cerr << "ERROR: isystem argument missing" << endl; + return 1; + } + } + else if (arg == "-isysroot" + || arg == "--sysroot") + { + // Ignore directory specifications (for the time being) + if (i < argc-1) + ++i; + else + { + cerr << "ERROR: missing argument for " << arg << endl; + return 1; + } + } + else if (starts_with(arg, "-L")) + { + string path = arg.substr(2); + linkopt += " -LIBPATH:" + quote_path(path); + cllinkopt += " -LIBPATH:" + quote_path(path); + } + else if (arg == "-link") + { + while (++i < argc) + { + arg = argv[i]; + cllinkopt += " " + arg; + linkopt += " " + arg; + } + } + else if (starts_with(arg, "-l")) + { + string libname = arg.substr(2) + ".lib"; + if (sourcefile.empty()) + clopt += " " + libname; + else + cllinkopt += " " + libname; + linkopt += " " + libname; + } + else if (starts_with(arg, "-Wl,")) + { + list flags = split (arg.substr (4), ','); + Xlinkopt.splice (Xlinkopt.end (), flags); + } + else if (arg == "-Xlinker") + { + gotXlinker = true; + } + else if (arg == "-Werror") + { + clopt += " -WX"; + } + else if (arg == "-Wall") + { + //clopt += " -Wall"; + } + else if (arg == "-fno-rtti") + { + clopt += " -GR-"; + } + else if (arg == "-fno-exceptions") + { + no_exceptions = true; + } + else if (arg == "-m386" || arg == "-m486" || arg == "-mpentium" || + arg == "-mpentiumpro" || arg == "-pedantic" || starts_with(arg, "-W") || + arg == "-fPIC" || arg == "-nostdlib") + { + // ignore + } + else if (arg == "-noembed") + { + mt_embed = false; + } + else if (arg == "-nodefaultlibs") + { + default_libs = false; + } + else if (arg == "-incremental-link") + { + incremental_link = true; + } + else if (arg == "-o") + { + if (i < argc-1) + { + arg = argv[++i]; + if (ends_with(arg, ".o") || ends_with(arg, ".obj")) + { + clopt += " -Fo" + quote_path(arg); + objectfile = arg; + } + else if (ends_with(arg, ".exe") || ends_with(arg, ".dll") || ends_with(arg, ".oct") + || ends_with(arg, ".mex")) + { + clopt += " -Fe" + quote_path(arg); + linkopt += " -out:" + quote_path(arg); + exefile = arg; + } + else + { + cerr << "WARNING: unrecognized output file type " << arg << ", assuming executable" << endl; + arg += ".exe"; + clopt += " -Fe" + quote_path(arg); + linkopt += " -out:" + quote_path(arg); + exefile = arg; + } + } + else + { + cerr << "ERROR: output file name missing" << endl; + return 1; + } + } + else if (ends_with(arg, ".cc") || ends_with(arg, ".cxx") || ends_with(arg, ".C")) + { + clopt += " -Tp" + quote_path(arg); + sourcefile = arg; + } + else if (ends_with(arg, ".o") || ends_with(arg, ".obj") || ends_with(arg, ".a") || + ends_with(arg, ".lib") || ends_with(arg, ".so")) + { + if (ends_with(arg, ".a")) + { + if (_access(arg.c_str(), 00) != 0) + { + string libarg; + int pos1 = arg.rfind('/'); + + if (pos1 != string::npos) + libarg = arg.substr(pos1+1); + else + libarg = arg; + if (starts_with(libarg, "lib")) + libarg = libarg.substr(3); + libarg = arg.substr(0, pos1+1) + libarg.substr(0, libarg.length()-1) + "lib"; + if (_access(libarg.c_str(), 00) == 0) + { + cerr << "WARNING: Converting " << arg << " into " << libarg << endl; + arg = libarg; + } + } + } + + if (sourcefile.empty()) + { + linkopt += " " + quote_path(arg); + prog = "link"; + } + else + { + cllinkopt += " " + quote_path(arg); + } + } + else if (ends_with(arg, ".c") || ends_with(arg, ".cpp")) + { + clopt += " " + quote_path(arg); + sourcefile = arg; + } + else if (ends_with(arg, ".dll")) + { + // trying to link against a DLL: convert to .lib file, keeping the same basename + string libarg = (" " + arg.substr(0, arg.length()-4) + ".lib"); + clopt += libarg; + linkopt += libarg; + } + else if (ends_with (arg, ".def")) + { + cllinkopt += " -DEF:" + arg; + linkopt += " -DEF:" + arg; + } + else if (arg == "-") + { + // read source file from stdin + read_from_stdin = true; + } + else + { + clopt += " " + quote_quotes(arg); + linkopt += " " + quote_quotes(arg); + if (!optarg.empty()) + { + clopt += "=" + quote_quotes(optarg); + linkopt += "=" + quote_quotes(optarg); + } + } + } + + for (list::const_iterator it = Xlinkopt.begin(); it != Xlinkopt.end(); ++it) + { + string arg = *it; + + if (arg == "--out-implib" + || starts_with (arg, "--out-implib=")) + { + string implib; + + if (arg == "--out-implib") + { + ++it; + if (it != Xlinkopt.end ()) + implib = *it; + else + { + cerr << "WARNING: missing import library name, ignored" << endl; + continue; + } + } + else + implib = arg.substr (13); + + cllinkopt += " -IMPLIB:" + implib; + linkopt += " -IMPLIB:" + implib; + } + else if (arg == "--enable-auto-import" + || arg == "--enable-auto-image-base") + { + // Ignore these. + } + else if (arg == "--output-def") + { + ++it; + if (it == Xlinkopt.end ()) + break; + } + else + { + cllinkopt += " " + arg; + linkopt += " " + arg; + } + } + + if (! incremental_link) + { + std::string arg ("-incremental:no"); + + cllinkopt += " " + arg; + linkopt += " " + arg; + } + + if (no_exceptions) + { + replace_option(clopt, "-EHsc"); + replace_option(clopt, "-EHcs"); + replace_option(clopt, "-EHs"); + replace_option(clopt, "-EHc"); + replace_option(clopt, "-EHa"); + replace_option(clopt, "-GX-"); + replace_option(clopt, "-GX"); + } + + if (dodepend && prog != "cl") + { + cerr << "ERROR: dependency generation only possible for source file" << endl; + return 1; + } + + if (read_from_stdin) + { + sourcefile = "cc-msvc-tmp.c"; + if (!read_stdin(sourcefile.c_str())) + { + unlink(sourcefile.c_str()); + return 1; + } + clopt += (" " + sourcefile); + } + + if (!exeoutput && !sourcefile.empty() && objectfile.empty()) + { + // use .o suffix by default + int pos = sourcefile.rfind('.'); + if (pos == string::npos) + objectfile = sourcefile + ".o"; + else + objectfile = sourcefile.substr(0, pos) + ".o"; + pos = objectfile.rfind('/'); + if (pos != string::npos) + objectfile = objectfile.substr(pos+1); + clopt += " -Fo" + objectfile; + } + + if (exeoutput && exefile.empty()) + { + if (doshared) + exefile = "a.dll"; + else + exefile = "a.exe"; + clopt += " -Fe" + exefile; + linkopt += " -out:" + exefile; + } + + if (exeoutput && default_libs) + { + cllinkopt += " dirent.lib msvcmath.lib shell32.lib advapi32.lib user32.lib kernel32.lib"; + linkopt += " dirent.lib msvcmath.lib shell32.lib advapi32.lib user32.lib kernel32.lib"; + } + + string opts; + if (prog == "cl") + { + opts = clopt; + if (!cllinkopt.empty()) + opts += " -link " + cllinkopt; + } + else + opts = linkopt; + + if (dodepend) + { + FILE *fd; + string cmd = prog + " " + opts, line; + list depend_list; + + if (objectfile.empty()) + { + cerr << "ERROR: object file name missing and cannot be determined" << endl; + return 1; + } + cout << objectfile << ":"; + + fd = popen(cmd.c_str(), "r"); + if (fd == NULL) + { + cerr << "ERROR: cannot execute " << cmd << endl; + return 1; + } + while (!feof(fd)) + { + line = get_line(fd); + if (starts_with(line, "#line")) + { + int pos1 = line.find('"'), pos2 = line.find('"', pos1+1); + depend_list.push_back(process_depend(line.substr(pos1+1, pos2-pos1-1))); + } + } + pclose(fd); + + depend_list.sort(); + depend_list.unique(); + for (list::const_iterator it=depend_list.begin(); it!=depend_list.end(); ++it) + cout << " \\" << endl << " " << *it; + cout << endl; + return 0; + } + else + { + string cmd = prog + " " + opts; + int cmdresult; + + if (debug) + cout << cmd << endl; + if ((cmdresult=do_system(cmd)) == 0 && exeoutput) + { + // auto-embed the manifest, if any + if (exefile.empty()) + { + if (!sourcefile.empty()) + { + if (doshared) + exefile = sourcefile + ".dll"; + else + exefile = sourcefile + ".exe"; + } + else + { + cerr << "ERROR: cannot determine the output executable file" << endl; + return 1; + } + } + + if (_access((exefile + ".manifest").c_str(), 00) == 0) + { + // Do not auto-embed for conftest.exe (temporary executable generated + // by configure scripts): this avoids wrong test results when an AV + // software is scanning the executable while mt.exe tries to update it + // (results in "mt.exe:general error c101008d:..." + // + // This should be harmless for common situations (can only be a problem + // if the target application uses conftest.exe as executable name; but + // I don't know any). + + if (mt_embed && exefile != "conftest.exe") + { + cmd = "mt -nologo -outputresource:" + exefile + + (doshared ? ";2" : ";1") + " -manifest " + exefile + ".manifest"; + + if (debug) + cout << cmd << endl; + + cmdresult = do_system(cmd); + + if (cmdresult == 0) + _unlink((exefile + ".manifest").c_str()); + } + } + } + + if (read_from_stdin) + unlink(sourcefile.c_str()); + + return cmdresult; + } +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/Makefile Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,39 @@ +GCCHEADERS = +GCCSOURCES = gettimeofday.c usleep.c complex/cabsf.c complex/ccos.c complex/ccosf.c complex/cexp.c complex/cexpf.c complex/clog.c complex/clogf.c complex/csin.c complex/csinf.c complex/csqrt.c complex/csqrtf.c +ASMSOURCES = +MSCSOURCES = mingwcompat.c + +OBJECTS = $(notdir $(GCCSOURCES:.c=.o)) $(ASMSOURCES:.S=.o) $(MSCSOURCES:.c=.obj) mingwcompat_gcc.o + +GCCFLAGS = -mstackrealign -mincoming-stack-boundary=2 + +all: mingwcompat.lib + +$(GCCSOURCES) $(GCCHEADERS) $(ASMSOURCES): + @echo "DOWNLOAD $@" + @wget -q -O $(notdir $@) 'http://cygwin.com/cgi-bin/cvsweb.cgi/~checkout~/src/winsup/mingw/mingwex/$@?&cvsroot=src' + +%.o: %.c + @echo "GCC $<" + @gcc $(CFLAGS) $(GCCFLAGS) -O2 -c -o $@ $< + +%.obj: %.c + @echo "MSC $<" + @cl -nologo -MD -O2 -Fo$@ -c $< + +%.o : %.S + @echo "AS $<" + @as $(ASFLAGS) -o $@ $< + +mingwcompat.lib: $(GCCHEADERS) $(OBJECTS) + @echo "LIB $@" + @lib -nologo -out:$@ $(OBJECTS) + +clean: + -rm -f $(OBJECTS) + -rm -f mingwcompat.lib + +files-clean: clean + -rm $(GCCHEADERS) $(GCCSOURCES) $(ASMSOURCES) + +sources: $(GCCSOURCES) $(ASMSOURCES) diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/cabsf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/cabsf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,7 @@ +#include +#include + +float cabsf (float complex Z) +{ + return (float) _hypot ( __real__ Z, __imag__ Z); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/ccos.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/ccos.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,20 @@ +/* + ccos.c + Contributed by Danny Smith + 2003-10-20 +*/ + +#include +#include + +/* ccos (x + I * y) = cos (x) * cosh (y) + + I * (sin (x) * sinh (y)) */ + + +double complex ccos (double complex Z) +{ + double complex Res; + __real__ Res = cos (__real__ Z) * cosh ( __imag__ Z); + __imag__ Res = -sin (__real__ Z) * sinh ( __imag__ Z); + return Res; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/ccosf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/ccosf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,20 @@ +/* + ccosf.c + Contributed by Danny Smith + 2003-12-24 +*/ + +#include +#include + +/* ccos (x + I * y) = cos (x) * cosh (y) + + I * (sin (x) * sinh (y)) */ + + +float complex ccosf (float complex Z) +{ + float complex Res; + __real__ Res = cosf (__real__ Z) * coshf ( __imag__ Z); + __imag__ Res = -sinf (__real__ Z) * sinhf ( __imag__ Z); + return Res; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/cexp.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/cexp.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + cexp.c + Contributed by Danny Smith + 2003-10-20 +*/ + +#include +#include + +/* cexp (x + I * y) = exp (x) * cos (y) + I * exp (x) * sin (y) */ + +double complex cexp (double complex Z) +{ + double complex Res; + long double rho = exp (__real__ Z); + __real__ Res = rho * cos(__imag__ Z); + __imag__ Res = rho * sin(__imag__ Z); + return Res; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/cexpf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/cexpf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + cexpf.c + Contributed by Danny Smith + 2004-12-24 +*/ + +#include +#include + +/* cexp (x + I * y) = exp (x) * cos (y) + I * exp (x) * sin (y) */ + +float complex cexpf (float complex Z) +{ + float complex Res; + double rho = exp (__real__ Z); + __real__ Res = rho * cosf(__imag__ Z); + __imag__ Res = rho * sinf(__imag__ Z); + return Res; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/clog.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/clog.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + clog.c + Contributed by Danny Smith + 2003-10-20 +*/ + +/* clog (x + I * y) = log (hypot (x, y)) + I * atan2 (y, x) */ + +#include +#include + +double complex clog (double complex Z) +{ + double complex Res; + __real__ Res = log (_hypot (__real__ Z, __imag__ Z)); + __imag__ Res = carg (Z); + return Res; +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/clogf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/clogf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + clogf.c + Contributed by Danny Smith + 2004-12-24 +*/ + +/* clog (x + I * y) = log (hypot (x, y)) + I * atan2 (y, x) */ + +#include +#include + +float complex clogf (float complex Z) +{ + float complex Res; + __real__ Res = logf (_hypot (__real__ Z, __imag__ Z)); + __imag__ Res = cargf (Z); + return Res; +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/csin.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/csin.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,21 @@ +/* csin.c */ + +/* + Contributed by Danny Smith + 2003-10-20 +*/ + +#include +#include + +/* csin (x + I * y) = sin (x) * cosh (y) + + I * (cos (x) * sinh (y)) */ + +double complex csin (double complex Z) +{ + double complex Res; + __real__ Res = sin (__real__ Z) * cosh ( __imag__ Z); + __imag__ Res = cos (__real__ Z) * sinh ( __imag__ Z); + return Res; +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/csinf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/csinf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,21 @@ +/* csinf.c */ + +/* + Contributed by Danny Smith + 2004-12-24 +*/ + +#include +#include + +/* csin (x + I * y) = sin (x) * cosh (y) + + I * (cos (x) * sinh (y)) */ + +float complex csinf (float complex Z) +{ + float complex Res; + __real__ Res = sinf (__real__ Z) * coshf ( __imag__ Z); + __imag__ Res = cosf (__real__ Z) * sinhf ( __imag__ Z); + return Res; +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/csqrt.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/csqrt.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,56 @@ +/* + csqrt.c + Contributed by Danny Smith + 2003-10-20 +*/ + +#include +#include + +double complex csqrt (double complex Z) +{ + double complex Res; + double t; + double x = __real__ Z; + double y = __imag__ Z; + + if (y == 0.0) + { + if (x < 0.0) + { + __real__ Res = 0.0; + __imag__ Res = sqrt (-x); + } + else + { + __real__ Res = sqrt (x); + __imag__ Res = 0.0; + } + } + + else if (x == 0.0) + { + t = sqrt(0.5 * fabs (y)); + __real__ Res = t; + __imag__ Res = y > 0 ? t : -t; + } + + else + { + t = sqrt (2.0 * (_hypot (x, y) + fabs (x))); + double u = t / 2.0; + if ( x > 0.0) + { + __real__ Res = u; + __imag__ Res = y / t; + } + else + { + __real__ Res = fabs ( y / t); + __imag__ Res = y < 0.0 ? -u : u; + } + } + + return Res; +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/csqrtf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/csqrtf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,49 @@ +#include +#include + +float complex csqrtf (float complex Z) +{ + float complex Res; + float r; + float x = __real__ Z; + float y = __imag__ Z; + + if (y == 0.0f) + { + if (x < 0.0f) + { + __real__ Res = 0.0f; + __imag__ Res = sqrtf (-x); + } + else + { + __real__ Res = sqrtf (x); + __imag__ Res = 0.0f; + } + } + + else if (x == 0.0f) + { + r = sqrtf(0.5f * fabsf (y)); + __real__ Res = r; + __imag__ Res = y > 0 ? r : -r; + } + + else + { + float t = sqrtf (2 * (_hypot (__real__ Z, __imag__ Z) + fabsf (x))); + float u = t / 2.0f; + if ( x > 0.0f) + { + __real__ Res = u; + __imag__ Res = y / t; + } + else + { + __real__ Res = fabsf (y / t); + __imag__ Res = y < 0 ? -u : u; + } + } + + return Res; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/gettimeofday.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/gettimeofday.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,49 @@ +/* + * gettimeofday + * Implementation according to: + * The Open Group Base Specifications Issue 6 + * IEEE Std 1003.1, 2004 Edition + */ + +/* + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Contributed by: + * Danny Smith + */ + +#include +#define WIN32_LEAN_AND_MEAN +#include + +/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ +#define _W32_FT_OFFSET (116444736000000000ULL) + + +int __cdecl gettimeofday(struct timeval *__restrict__ tp, + void *__restrict__ tzp __attribute__((unused))) + { + union { + unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ + FILETIME ft; + } _now; + + if(tp) + { + GetSystemTimeAsFileTime (&_now.ft); + tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); + tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); + } + /* Always return 0 as per Open Group Base Specifications Issue 6. + Do not set errno on error. */ + return 0; +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/mingwcompat.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/mingwcompat.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,118 @@ +#ifdef _WIN64 +#error "this file is not ported to Win64 yet" +#endif + +#define __STDC__ 1 + +#include +#include +#include + +int __mingw_vfprintf (FILE *stream, const char *fmt, va_list argptr) +{ + return vfprintf (stream, fmt, argptr); +} + +int __mingw_vprintf (const char *fmt, va_list argptr) +{ + return vprintf (fmt, argptr); +} + +int __mingw_vsprintf (char *buf, const char *fmt, va_list argptr) +{ + return vsprintf (buf, fmt, argptr); +} + +int snprintf (char *buffer, size_t count, const char *fmt, ...) +{ + va_list av; + int result; + + va_start (av, fmt); + result = vsnprintf (buffer, count, fmt, av); + va_end (av); + + return result; +} + +int __mingw_snprintf (char *buffer, size_t count, const char *fmt, ...) +{ + va_list av; + int result; + + va_start (av, fmt); + result = vsnprintf (buffer, count, fmt, av); + va_end (av); + + return result; +} + +long long int strtoll (const char *nptr, char **endptr, int base) +{ + return _strtoi64 (nptr, endptr, base); +} + +__int64 __divdi3 (__int64 num, __int64 den) +{ + return (num / den); +} + +__int64 __moddi3 (__int64 num, __int64 den) +{ + return (num % den); +} + +unsigned __int64 __udivdi3 (unsigned __int64 num, unsigned __int64 den) +{ + return (num / den); +} + +unsigned __int64 __umoddi3 (unsigned __int64 num, unsigned __int64 den) +{ + return (num % den); +} + +void __main (void) +{ + /* In GCC, this function calls _do_global_ctors. + */ +} + +__declspec(naked) +void __chkstk_ms (void) +{ + __asm { + push ecx + push eax + cmp eax,1000h + lea ecx,dword ptr [esp+12] + jb label_2 + + label_1: + sub ecx,1000h + or dword ptr [ecx],0h + sub eax,1000h + cmp eax,1000h + ja label_1 + + label_2: + sub ecx,eax + or dword ptr [ecx],0h + + pop eax + pop ecx + ret + } +} + +int _CRT_MT = 1; + +double __strtod (const char *nptr, char **endptr) +{ + return strtod (nptr, endptr); +} + +float __strtof (const char *nptr, char **endptr) +{ + return strtod (nptr, endptr); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/mingwcompat_gcc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/mingwcompat_gcc.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,85 @@ +#ifdef __MINGW64__ +#error "this file is not ported to MinGW-64 yet" +#endif + +/* + * Code mainly copied from libgcc2.c. + */ + +typedef float SFtype __attribute__ ((mode (SF))); +typedef float DFtype __attribute__ ((mode (DF))); +typedef float XFtype __attribute__ ((mode (XF))); +typedef float TFtype __attribute__ ((mode (TF))); + +#define W_TYPE_SIZE 32 +#define UDWtype unsigned long long +#define UWtype unsigned long +#define Wtype_MAXp1_F 0x1p32f + +#define __fixunsdfDI __fixunsdfdi +#define __fixunsxfDI __fixunsxfdi + +UDWtype +__fixunsdfDI (DFtype a) +{ + /* Get high part of result. The division here will just moves the radix + point and will not cause any rounding. Then the conversion to integral + type chops result as desired. */ + const UWtype hi = a / Wtype_MAXp1_F; + + /* Get low part of result. Convert `hi' to floating type and scale it back, + then subtract this from the number being converted. This leaves the low + part. Convert that to integral type. */ + const UWtype lo = a - (DFtype) hi * Wtype_MAXp1_F; + + /* Assemble result from the two parts. */ + return ((UDWtype) hi << W_TYPE_SIZE) | lo; +} + +UDWtype +__fixunsxfDI (XFtype a) +{ + if (a < 0) + return 0; + + /* Compute high word of result, as a flonum. */ + const XFtype b = (a / Wtype_MAXp1_F); + /* Convert that to fixed (but not to DWtype!), + and shift it into the high word. */ + UDWtype v = (UWtype) b; + v <<= W_TYPE_SIZE; + /* Remove high part from the XFtype, leaving the low part as flonum. */ + a -= (XFtype)v; + /* Convert that to fixed (but not to DWtype!) and add it in. + Sometimes A comes out negative. This is significant, since + A has more bits than a long int does. */ + if (a < 0) + v -= (UWtype) (- a); + else + v += (UWtype) a; + return v; +} + +#define POWIF_IMPL(NAME, TYPE) \ +TYPE \ +NAME (TYPE x, int m) \ +{ \ + unsigned int n = m < 0 ? -m : m; \ + TYPE y = n % 2 ? x : 1; \ + while (n >>= 1) \ + { \ + x = x * x; \ + if (n % 2) \ + y = y * x; \ + } \ + return m < 0 ? 1/y : y; \ +} + +POWIF_IMPL(__powisf2, SFtype) +POWIF_IMPL(__powidf2, DFtype) +POWIF_IMPL(__powixf2, XFtype) + +long double __strtold (const char *nptr, char **endptr) +{ + return strtod (nptr, endptr); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/compat/usleep.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/compat/usleep.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,40 @@ +/* + * usleep + * Implementation according to: + * The Open Group Base Specifications Issue 6 + * IEEE Std 1003.1, 2004 Edition + */ + +/* + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAIMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * Contributed by: + * Ramiro Polla + */ + +#include +#include + +#define WIN32_LEAN_AND_MEAN +#include + +int __cdecl usleep(useconds_t useconds) +{ + if(useconds == 0) + return 0; + + if(useconds >= 1000000) + return EINVAL; + + Sleep((useconds + 999) / 1000); + + return 0; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/fixlibtool2.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/fixlibtool2.in Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,53 @@ +#!/bin/sh + +libtool_file="$1" +if test -z "$libtool_file"; then + echo "usage: $0 " + exit -1 +fi + +library_prefix="$2" +library_suffix="$3" + +if test -z "$library_prefix"; then + library_prefix="@LIBRARY_PREFIX@" +fi +if test -z "$library_suffix"; then + library_suffix="@LIBRARY_SUFFIX@" +fi + +libtool_dir=`dirname $libtool_file` + +sed -e 's/^wl=.*$/wl="-Wl,"/' \ + -e 's/^fast_install=.*$/fast_install=no/' \ + -e 's/^file_list_spec=.*$/file_list_spec="@"/' \ + -e 's/^fix_srcfile_path=.*$/fix_srcfile_path=""/' \ + -e 's/^old_archive_from_new_cmds=.*$/old_archive_from_new_cmds=""/' \ + -e 's/^deplibs_check_method=.*$/deplibs_check_method="pass_all"/' \ + -e 's/^shlibpath_overrides_runpath=.*$/shlibpath_overrides_runpath=yes/' \ + -e 's/^library_names_spec=.*$/library_names_spec="\\`echo \\${libname} | \\$SED -e '\''s\/^lib\/\/'\''\\`.lib"/' \ + -e 's/^soname_spec=.*$/soname_spec="'${library_prefix}'\\${libname}\\`echo \\${release} | \\$SED -e '\''s\/[.]\/-\/g'\''\\`\\${versuffix}'${library_suffix}'\\${shared_ext}"/' \ + -e '/^postinstall_cmds=\(""\)\?$/ { i\ +postinstall_cmds="base_file=\\\\\\`basename \\\\\\${file}\\\\\\`~\ + dlpath=\\\\\\`\\$SHELL 2>&1 -c '\''. \\$dir/'\''\\\\\\${base_file}'\''i; echo \\\\\\$dlname'\''\\\\\\`~\ + dldir=\\$destdir/\\\\\\`dirname \\\\\\$dlpath\\\\\\`~\ + test -d \\\\\\$dldir || mkdir -p \\\\\\$dldir~\ + \\$install_prog \\$dir/\\$dlname \\\\\\$dldir/\\$dlname~\ + chmod a+x \\\\\\$dldir/\\$dlname~\ + if test -n '\''\\$stripme'\'' && test -n '\''\\$striplib'\''; then\ + eval '\''\\$striplib \\\\\\$dldir/\\$dlname'\'' || exit \\\\\\$?;\ + fi" + ;d; }' \ + -e '/^postuninstall_cmds=\(""\)\?$/ { i\ +postuninstall_cmds="dldll=\\\\\\`\\$SHELL 2>&1 -c '\''. \\$file; echo \\\\\\$dlname'\''\\\\\\`~\ + dlpath=\\$dir/\\\\\\$dldll~\ + \\$RM \\\\\\$dlpath" + ;d; }' \ + -e 's,-link -dll,-shared,g' \ + -e 's,^archive_cmds=.*$,archive_cmds="\\$CC -shared -o \\$output_objdir/\\$soname_spec \\$libobjs \\$compiler_flags \\\\\\`\\$ECHO \\\\\\"X\\$deplibs\\\\\\" | \\$Xsed -e '\''s/ -lc\\$//'\''\\\\\\` -Xlinker --out-implib -Xlinker \\$lib ~linknames=",' \ + -e 's,^ECHO=.*,ECHO="echo",' \ + -e '/#.*BEGIN LIBTOOL TAG CONFIG: CXX/,/#.*END LIBTOOL TAG CONFIG: CXX/! {s,^archive_expsym_cmds=.*$,archive_expsym_cmds="if ! \\$EGREP -q \\\\\\"^\\\\s*\\\\\\\\s*\\$\\\\\\" \\$export_symbols; then echo EXPORTS > \\$\{export_symbols\}T; cat \\$export_symbols >> \\$\{export_symbols\}T; \\$MV \\$\{export_symbols\}T \\$export_symbols; fi~\\$CC -shared -o \\$output_objdir/\\$soname_spec \\$libobjs \\$compiler_flags \\\\\\`\\$ECHO \\\\\\"X\\$deplibs\\\\\\" | \\$Xsed -e '\''s/ -lc\\$//'\''\\\\\\` \\$\{wl\}-def:\\$export_symbols -Xlinker --out-implib -Xlinker \\$lib ~linknames=",;}' \ + -e 's/^sys_lib_search_path_spec=.*$/fix_srcfile_path=""/' \ + -e 's/^sys_lib_dlsearch_path_spec=.*$/fix_srcfile_path=""/' \ + "$libtool_file" > "$libtool_dir/ttt" && + mv "$libtool_dir/ttt" "$libtool_file" diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/gcc.diff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/gcc.diff Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,115 @@ +diff -ur gcc-4.7.0-orig/libgfortran/intrinsics/c99_functions.c gcc-4.7.0-new/libgfortran/intrinsics/c99_functions.c +--- gcc-4.7.0-orig/libgfortran/intrinsics/c99_functions.c 2011-11-08 10:31:04 +0000 ++++ gcc-4.7.0-new/libgfortran/intrinsics/c99_functions.c 2012-07-06 17:29:18 +0100 +@@ -1026,6 +1026,7 @@ + } + #endif + ++#if 0 + #if !defined(HAVE_CLOG10L) && defined(HAVE_LOG10L) && defined(HAVE_CABSL) && defined(HAVE_CARGL) + #define HAVE_CLOG10L 1 + long double complex clog10l (long double complex z); +@@ -1039,6 +1040,7 @@ + return v; + } + #endif ++#endif + + + /* pow(base, power) = cexp (power * clog (base)) */ +diff -ur gcc-4.7.0-orig/libgfortran/mk-kinds-h.sh gcc-4.7.0-new/libgfortran/mk-kinds-h.sh +--- gcc-4.7.0-orig/libgfortran/mk-kinds-h.sh 2010-11-16 21:23:19 +0000 ++++ gcc-4.7.0-new/libgfortran/mk-kinds-h.sh 2012-07-06 17:29:18 +0100 +@@ -6,7 +6,7 @@ + + # Possible types must be listed in ascending order + possible_integer_kinds="1 2 4 8 16" +-possible_real_kinds="4 8 10 16" ++possible_real_kinds="4 8" + + + largest="" +diff -ur gcc-4.7.0-orig/libgfortran/mk-srk-inc.sh gcc-4.7.0-new/libgfortran/mk-srk-inc.sh +--- gcc-4.7.0-orig/libgfortran/mk-srk-inc.sh 2010-06-25 20:40:37 +0100 ++++ gcc-4.7.0-new/libgfortran/mk-srk-inc.sh 2012-07-06 17:29:18 +0100 +@@ -2,7 +2,7 @@ + + compile="$1" + kinds="" +-possible_kinds="4 8 10 16" ++possible_kinds="4 8" + c=0 + + for k in $possible_kinds; do +diff -ur gcc-4.7.0-orig/libgfortran/runtime/backtrace.c gcc-4.7.0-new/libgfortran/runtime/backtrace.c +--- gcc-4.7.0-orig/libgfortran/runtime/backtrace.c 2012-01-12 10:30:45 +0000 ++++ gcc-4.7.0-new/libgfortran/runtime/backtrace.c 2012-07-06 19:24:45 +0100 +@@ -109,6 +109,7 @@ + } + bt_state; + ++#if 0 + static _Unwind_Reason_Code + trace_function (struct _Unwind_Context *context, void *state_ptr) + { +@@ -185,6 +186,7 @@ + + return _URC_NO_REASON; + } ++#endif + + + /* Display the backtrace. */ +@@ -192,6 +194,7 @@ + void + show_backtrace (void) + { ++#if 0 + bt_state state; + state.frame_number = 0; + state.error = 0; +@@ -276,4 +279,5 @@ + /* Fallback to the simple backtrace without addr2line. */ + state.direct_output = 1; + _Unwind_Backtrace (trace_function, &state); ++#endif + } +diff -ur gcc-4.7.0-orig/libgfortran/runtime/main.c gcc-4.7.0-new/libgfortran/runtime/main.c +--- gcc-4.7.0-orig/libgfortran/runtime/main.c 2012-01-12 09:58:34 +0000 ++++ gcc-4.7.0-new/libgfortran/runtime/main.c 2012-07-06 23:25:20 +0100 +@@ -154,13 +154,14 @@ + } + + +-char *addr2line_path; ++char *addr2line_path = NULL; + + /* Find addr2line and store the path. */ + + void + find_addr2line (void) + { ++#if 0 + #ifdef HAVE_ACCESS + #define A2L_LEN 10 + char *path = getenv ("PATH"); +@@ -187,6 +188,9 @@ + } + } + #endif ++#else ++ addr2line_path = NULL; ++#endif + } + + +@@ -255,3 +259,9 @@ + + free (addr2line_path); + } ++ ++void __msvc_free_exe_path (void) ++{ ++ if (please_free_exe_path_when_done) ++ free ((char *) exe_path); ++} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/getopt.diff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/getopt.diff Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,46 @@ +--- getopt.c 2010-01-14 21:38:46 +0000 ++++ getopt-new.c 2010-01-14 21:37:14 +0000 +@@ -47,6 +47,10 @@ + # define PROGNAME *argv + #endif + ++#ifdef _MSC_VER ++# define __inline__ __inline ++#endif ++ + /* Initialise the public variables. */ + + int optind = 1; /* index for first non-option arg */ +@@ -463,7 +467,7 @@ + /* + * we use `this_arg' to store these temporarily. + */ +- CHAR *this_arg[optspan]; ++ CHAR **this_arg = (CHAR**) malloc (sizeof(CHAR*) * optspan); + /* + * we cannot manipulate `argv' directly, since the `getopt' + * API prototypes it as `read-only'; this cast to `arglist' +@@ -493,6 +497,8 @@ + /* adjust `optbase', to account for the relocated option. + */ + optbase += optspan; ++ ++ free(this_arg); + } + + else +@@ -578,9 +584,12 @@ + * specified for the `getopt_long' APIs. + */ + va_list refptr; ++ struct option *longopts; ++ int *optindex; ++ + va_start( refptr, optstring ); +- struct option *longopts = va_arg( refptr, struct option * ); +- int *optindex = va_arg( refptr, int * ); ++ longopts = va_arg( refptr, struct option * ); ++ optindex = va_arg( refptr, int * ); + va_end( refptr ); + + /* ensuring that `optarg' does not inherit any junk, from parsing diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/gfortran-msvc.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/gfortran-msvc.cc Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,253 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + +using namespace std; + +bool verbose = false; + +inline bool starts_with(const string& s, const string& prefix) +{ + return (s.length() >= prefix.length() && s.find(prefix) == 0); +} + +inline bool ends_with(const string& s, const string& suffix) +{ + return (s.length() >= suffix.length() && s.rfind(suffix) == s.length()-suffix.length()); +} + +string quote(const string& s) +{ + if (s.find(' ') != string::npos) + return "\"" + s + "\""; + else + return s; +} + +int do_system(const string& cmd) +{ + if (verbose) + cerr << "Running: " << cmd << endl; + + STARTUPINFO info; + PROCESS_INFORMATION proc; + DWORD result; + + ZeroMemory (&info, sizeof (info)); + info.cb = sizeof (info); + ZeroMemory (&proc, sizeof (proc)); + + if (CreateProcess (NULL, (char*)cmd.c_str (), NULL, NULL, TRUE, 0, NULL, NULL, + &info, &proc)) + { + WaitForSingleObject (proc.hProcess, INFINITE); + GetExitCodeProcess (proc.hProcess, &result); + CloseHandle (proc.hProcess); + CloseHandle (proc.hThread); + } + else + result = (DWORD)-1; + + if (verbose) + cerr << "Result: " << (int)result << endl; + + return result; +} + +int do_system(const list& args) +{ + string cmd; + + for (list::const_iterator it = args.begin(); it != args.end(); ++it) + { + if (!cmd.empty()) + cmd += " "; + cmd += quote(*it); + } + return do_system(cmd); +} + +string get_env_var(const char *name, const char *defval) +{ + char *result = getenv(name); + if (!result || result[0] == '\0') + return string(defval); + return string(result); +} + +inline bool is_source_file (const string& s) +{ + static char* f_ext_list[] = { ".f", ".F", ".f90", ".F90", ".f77", ".F77", 0 }; + + for (int i = 0; f_ext_list[i]; i++) + if (ends_with (s, f_ext_list[i])) + return true; + + return false; +} + +inline string get_object_name (const string& s) +{ + int pos = s.rfind ('.'); + + return s.substr (0, pos) + ".o"; +} + +string get_line(FILE *fp) +{ + static vector buf(100); + int idx = 0; + char c; + + while (1) + { + c = (char)fgetc(fp); + if (c == '\n' || c == EOF) + break; + if (buf.size() <= idx) + buf.resize(buf.size() + 100); + buf[idx++] = c; + } + if (idx == 0) + return string(""); + else + return string(&buf[0], idx); +} + +string de_cygwin_path(const string& s) +{ + string result = s; + + if (starts_with(s, "/cygdrive/")) + { + string cmd = "cygpath -m \"" + s + "\""; + FILE* pout = _popen(cmd.c_str(), "r"); + + if (pout != NULL) + { + result = get_line(pout); + _pclose(pout); + } + } + + return result; +} + +int main (int argc, char **argv) +{ + list args, compiler_opts; + string compiler, gfortran_exe = "gfortran"; + bool do_link = true, has_files = false; + list< pair > source_files; + + for (int i = 1; i < argc; i++) + { + string arg (argv[i]); + + args.push_back (arg); + + if (arg == "-c") + do_link = false; + else if (arg == "-v") + { + verbose = true; + args.pop_back (); + } + else if (starts_with (arg, "--gfortran-exe=")) + { + gfortran_exe = arg.substr (15); + } + else if (! starts_with (arg, "-")) + { + has_files = true; + if (is_source_file (arg)) + { + arg = de_cygwin_path (arg); + source_files.push_back (pair (arg, args.size () - 1)); + } + } + else if (starts_with (arg, "-D") + || starts_with (arg, "-U") + || starts_with (arg, "-O") + || starts_with (arg, "-f") + || starts_with (arg, "-m")) + compiler_opts.push_back (arg); + } + + if (has_files) + { + if (do_link) + { + if (! source_files.empty ()) + { + // Because the compiler and the linker are different, we need + // to compile the source files separately. + + for (list< pair >::const_iterator it = source_files.begin (); + it != source_files.end (); ++it) + { + list cargs (compiler_opts); + string obj_name = get_object_name (it->first); + + cargs.push_front ("-c"); + cargs.push_front ("-ff2c"); + cargs.push_front ("-mstackrealign"); + cargs.push_front ("-mincoming-stack-boundary=2"); + if (verbose) + cargs.push_front ("-v"); + cargs.push_front (gfortran_exe); + cargs.push_back (it->first); + cargs.push_back ("-o"); + cargs.push_back (obj_name); + + int res = do_system (cargs); + + if (res == 0) + { + list::iterator lit = args.begin (); + + for (int i = it->second; i > 0; i--, lit++) + /* nothing */; + *lit = obj_name; + } + else + return res; + } + } + + compiler = "cc-msvc"; + if (verbose) + args.push_front ("-d"); + args.push_back ("-lgfortran-msvc"); + args.push_back ("-lmingwcompat"); + args.push_back ("-lmsvcrt"); + //args.push_back ("-lmsvcrt"); + } + else + { + args.push_front ("-ff2c"); + args.push_front ("-mstackrealign"); + args.push_front ("-mincoming-stack-boundary=2"); + if (verbose) + args.push_front ("-v"); + } + } + + if (compiler.empty ()) + compiler = gfortran_exe; + + args.push_front (compiler); + + int retval = do_system (args); + + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/libgfortran-dllinit.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/libgfortran-dllinit.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,47 @@ +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + +extern void _gfortrani_init_variables (void); +extern void _gfortrani_init_units (void); +extern void _gfortrani_close_units (void); +extern void _gfortrani_set_fpu (void); +extern void _gfortrani_init_compile_options (void); +extern void _gfortran_random_seed_i4 (void *a, void *b, void *c); +extern int _gfortrani_big_endian; + +extern void __msvc_free_exe_path (void); + +static void __cdecl __msvc_init (void) +{ + _gfortrani_big_endian = 0; + _gfortrani_init_variables (); + _gfortrani_init_units (); + _gfortrani_set_fpu (); + _gfortrani_init_compile_options (); + _gfortran_random_seed_i4 (NULL, NULL, NULL); +} + +static void __cdecl __msvc_cleanup (void) +{ + _gfortrani_close_units (); + __msvc_free_exe_path (); +} + +BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwreason, LPVOID lpvReserved) +{ + switch (fdwreason) + { + case DLL_PROCESS_ATTACH: + __msvc_init (); + break; + case DLL_PROCESS_DETACH: + __msvc_cleanup (); + break; + default: + break; + } + + return TRUE; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/libgfortran-msvcinit.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/libgfortran-msvcinit.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,40 @@ +#include +#include + +extern void _gfortrani_init_variables (void); +extern void _gfortrani_init_units (void); +extern void _gfortrani_close_units (void); +extern void _gfortrani_set_fpu (void); +extern void _gfortrani_init_compile_options (void); +extern void _gfortran_random_seed_i4 (void *a, void *b, void *c); +extern int _gfortrani_big_endian; + +extern void __msvc_free_exe_path (void); + +#pragma section(".CRT$XCU", read) +static void __cdecl __msvc_init (void); +static void __cdecl __msvc_cleanup (void); +__declspec(allocate(".CRT$XCU")) void (__cdecl *__msvc_init_) (void) = __msvc_init; + +static void __cdecl __msvc_init (void) +{ + _gfortrani_big_endian = 0; + _gfortrani_init_variables (); + _gfortrani_init_units (); + _gfortrani_set_fpu (); + _gfortrani_init_compile_options (); + _gfortran_random_seed_i4 (NULL, NULL, NULL); + + atexit (__msvc_cleanup); +} + +static void __cdecl __msvc_cleanup (void) +{ + _gfortrani_close_units (); + __msvc_free_exe_path (); +} + +void __msvc_stupid_function_name_for_static_linking (void) +{ + return; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/lt-postproc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/lt-postproc Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,27 @@ +#!/bin/bash + +prefix= +suffix= + +while getopts ":p:s:" opt; do + case $opt in + s) suffix="$OPTARG" ;; + p) prefix="$OPTARG" ;; + esac +done +shift $((OPTIND-1)) + +if [ "$1" = "" ]; then + libtool_files=`find . -name libtool` +else + libtool_files="$@" +fi + +for ltfile in $libtool_files; do + sed -i \ + -e "s/^soname_spec=\"\\(.*\\)\\\${shared_ext}\"/soname_spec=\"$prefix\\1$suffix\\\${shared_ext}\"/" \ + -e "s/\.dll\.lib/\.lib/" \ + -e "s/^\(deplibs_check_method\)=.*/\1=\"pass_all\"/" \ + -e "s/-link\\>//" \ + $ltfile +done diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/Makefile Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,74 @@ +MSVCMATH := $(shell echo '\#include ' > t.c; cl -nologo -showIncludes -c t.c | $(SED) -n -e 's/^Note: including file: \(.*math\.h\)$$/\1/p'; rm -f t.c t.obj) +MSVCMATH := $(subst \,\\,$(MSVCMATH)) + +GCCHEADERS = cephes_mconf.h fastmath.h +GCCSOURCES = acosh.c acoshf.c asinh.c asinhf.c atanh.c atanhf.c cbrt.c cbrtf.c expm1.c expm1f.c fpclassify.c fpclassifyf.c isnan.c isnanf.c llrint.c llrintf.c logb.c logbf.c lrint.c lrintf.c modff.c nextafterf.c rint.c rintf.c trunc.c truncf.c +ASMSOURCES = exp2.S exp2f.S fma.S fmaf.S ilogb.S ilogbf.S log1p.S log1pf.S log2.S log2f.S nearbyint.S nearbyintf.S remainder.S remainderf.S scalbn.S scalbnf.S +MSCSOURCES = finite.c finitef.c funx.c isinf.c isinff.c nan.c nextafter.c + +OBJECTS = $(GCCSOURCES:.c=.o) round.o roundf.o lround.o lroundf.o $(ASMSOURCES:.S=.o) $(MSCSOURCES:.c=.obj) +DOWNLOADSOURCES = $(GCCSOURCES) $(GCCHEADERS) $(ASMSOURCES) round_internal.h round_generic.c lround_generic.c + +all: msvcmath.lib msvcmath.h + +check: testmath.dll + +$(DOWNLOADSOURCES): + @echo "DOWNLOAD $@" + @wget -q -O $@ 'http://cygwin.com/cgi-bin/cvsweb.cgi/~checkout~/src/winsup/mingw/mingwex/math/$@?&cvsroot=src' + +round.o: CFLAGS += -DFUNCTION=round +roundf.o: CFLAGS += -DFUNCTION=roundf +lround.o: CFLAGS += -DFUNCTION=lround +lroundf.o: CFLAGS += -DFUNCTION=lroundf + +GCCFLAGS = -mstackrealign -mincoming-stack-boundary=2 + +round.o roundf.o: round_generic.c round_internal.h + @echo "GCC $(@:.o=).c" + @gcc $(CFLAGS) $(GCCFLAGS) -O2 -c -o $@ $< + +lround.o lroundf.o: lround_generic.c round_internal.h + @echo "GCC $(@:.o=).c" + @gcc $(CFLAGS) $(GCCFLAGS) -O2 -c -o $@ $< + +%.o: %.c + @echo "GCC $<" + @gcc $(CFLAGS) $(GCCFLAGS) -O2 -c -o $@ $< + +%.obj: %.c + @echo "MSC $<" + @cl -nologo -MD -O2 -Fo$@ -c $< + +%.o : %.S + @echo "AS $<" + @as $(ASFLAGS) -o $@ $< + +msvcmath.lib: $(GCCHEADERS) $(OBJECTS) + @echo "LIB $@" + @lib -nologo -out:$@ $(OBJECTS) + +testmath.dll: $(GCCHEADERS) $(OBJECTS) math.def + @echo "DLL $@" + @cl -nologo -LD -Fe$@ $(OBJECTS) math.def msvcrt.lib + +msvcmath.h: math.h.in + @echo "HEADER $@" + -@if sed -e 's,@MSVCMATH@,$(MSVCMATH),' $< > $@-t; then \ + mv $@-t $@; \ + fi + @rm -f $@-t + +clean: + -rm -f $(OBJECTS) + -rm -f msvcmath.lib msvcmath.h + -rm -f testmath.dll testmath.lib testmath.exp + +files-clean: clean + -rm $(GCCHEADERS) $(GCCSOURCES) $(ASMSOURCES) + +files: $(DOWNLOADSOURCES) + +# Additional dependencies + +funx.obj: msvcmath.h diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/acosh.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/acosh.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,26 @@ +#include +#include +#include "fastmath.h" + +/* acosh(x) = log (x + sqrt(x * x - 1)) */ +double acosh (double x) +{ + if (isnan (x)) + return x; + + if (x < 1.0) + { + errno = EDOM; + return nan(""); + } + + if (x > 0x1p32) + /* Avoid overflow (and unnecessary calculation when + sqrt (x * x - 1) == x). GCC optimizes by replacing + the long double M_LN2 const with a fldln2 insn. */ + return __fast_log (x) + 6.9314718055994530941723E-1L; + + /* Since x >= 1, the arg to log will always be greater than + the fyl2xp1 limit (approx 0.29) so just use logl. */ + return __fast_log (x + __fast_sqrt((x + 1.0) * (x - 1.0))); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/acoshf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/acoshf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,25 @@ +#include +#include +#include "fastmath.h" + +/* acosh(x) = log (x + sqrt(x * x - 1)) */ +float acoshf (float x) +{ + if (isnan (x)) + return x; + if (x < 1.0f) + { + errno = EDOM; + return nan(""); + } + + if (x > 0x1p32f) + /* Avoid overflow (and unnecessary calculation when + sqrt (x * x - 1) == x). GCC optimizes by replacing + the long double M_LN2 const with a fldln2 insn. */ + return __fast_log (x) + 6.9314718055994530941723E-1L; + + /* Since x >= 1, the arg to log will always be greater than + the fyl2xp1 limit (approx 0.29) so just use logl. */ + return __fast_log (x + __fast_sqrt((x + 1.0) * (x - 1.0))); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/asinh.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/asinh.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,28 @@ +#include +#include +#include "fastmath.h" + + /* asinh(x) = copysign(log(fabs(x) + sqrt(x * x + 1.0)), x) */ +double asinh(double x) +{ + double z; + if (!isfinite (x)) + return x; + z = fabs (x); + + /* Avoid setting FPU underflow exception flag in x * x. */ +#if 0 + if ( z < 0x1p-32) + return x; +#endif + + /* Use log1p to avoid cancellation with small x. Put + x * x in denom, so overflow is harmless. + asinh(x) = log1p (x + sqrt (x * x + 1.0) - 1.0) + = log1p (x + x * x / (sqrt (x * x + 1.0) + 1.0)) */ + + z = __fast_log1p (z + z * z / (__fast_sqrt (z * z + 1.0) + 1.0)); + + return ( x > 0.0 ? z : -z); +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/asinhf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/asinhf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,28 @@ +#include +#include +#include "fastmath.h" + + /* asinh(x) = copysign(log(fabs(x) + sqrt(x * x + 1.0)), x) */ +float asinhf(float x) +{ + float z; + if (!isfinite (x)) + return x; + z = fabsf (x); + + /* Avoid setting FPU underflow exception flag in x * x. */ +#if 0 + if ( z < 0x1p-32) + return x; +#endif + + + /* Use log1p to avoid cancellation with small x. Put + x * x in denom, so overflow is harmless. + asinh(x) = log1p (x + sqrt (x * x + 1.0) - 1.0) + = log1p (x + x * x / (sqrt (x * x + 1.0) + 1.0)) */ + + z = __fast_log1p (z + z * z / (__fast_sqrt (z * z + 1.0) + 1.0)); + + return ( x > 0.0 ? z : -z); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/atanh.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/atanh.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,31 @@ +#include +#include +#include "fastmath.h" + +/* atanh (x) = 0.5 * log ((1.0 + x)/(1.0 - x)) */ + +double atanh(double x) +{ + double z; + if isnan (x) + return x; + z = fabs (x); + if (z == 1.0) + { + errno = ERANGE; + return (x > 0 ? INFINITY : -INFINITY); + } + if (z > 1.0) + { + errno = EDOM; + return nan(""); + } + /* Rearrange formula to avoid precision loss for small x. + + atanh(x) = 0.5 * log ((1.0 + x)/(1.0 - x)) + = 0.5 * log1p ((1.0 + x)/(1.0 - x) - 1.0) + = 0.5 * log1p ((1.0 + x - 1.0 + x) /(1.0 - x)) + = 0.5 * log1p ((2.0 * x ) / (1.0 - x)) */ + z = 0.5 * __fast_log1p ((z + z) / (1.0 - z)); + return x >= 0 ? z : -z; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/atanhf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/atanhf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,30 @@ +#include +#include +#include "fastmath.h" + +/* atanh (x) = 0.5 * log ((1.0 + x)/(1.0 - x)) */ +float atanhf (float x) +{ + float z; + if isnan (x) + return x; + z = fabsf (x); + if (z == 1.0) + { + errno = ERANGE; + return (x > 0 ? INFINITY : -INFINITY); + } + if ( z > 1.0) + { + errno = EDOM; + return nanf(""); + } + /* Rearrange formula to avoid precision loss for small x. + + atanh(x) = 0.5 * log ((1.0 + x)/(1.0 - x)) + = 0.5 * log1p ((1.0 + x)/(1.0 - x) - 1.0) + = 0.5 * log1p ((1.0 + x - 1.0 + x) /(1.0 - x)) + = 0.5 * log1p ((2.0 * x ) / (1.0 - x)) */ + z = 0.5 * __fast_log1p ((z + z) / (1.0 - z)); + return x >= 0 ? z : -z; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/cbrt.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/cbrt.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,162 @@ +/* cbrt.c + * + * Cube root + * + * + * + * SYNOPSIS: + * + * double x, y, cbrt(); + * + * y = cbrt( x ); + * + * + * + * DESCRIPTION: + * + * Returns the cube root of the argument, which may be negative. + * + * Range reduction involves determining the power of 2 of + * the argument. A polynomial of degree 2 applied to the + * mantissa, and multiplication by the cube root of 1, 2, or 4 + * approximates the root to within about 0.1%. Then Newton's + * iteration is used three times to converge to an accurate + * result. + * + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * DEC -10,10 200000 1.8e-17 6.2e-18 + * IEEE 0,1e308 30000 1.5e-16 5.0e-17 + * + */ + /* cbrt.c */ + +/* +Cephes Math Library Release 2.2: January, 1991 +Copyright 1984, 1991 by Stephen L. Moshier +Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +*/ + +/* + Modified for mingwex.a + 2002-07-01 Danny Smith + */ +#ifdef __MINGW32__ +#include +#include "cephes_mconf.h" +#else +#include "mconf.h" +#endif + + +static const double CBRT2 = 1.2599210498948731647672; +static const double CBRT4 = 1.5874010519681994747517; +static const double CBRT2I = 0.79370052598409973737585; +static const double CBRT4I = 0.62996052494743658238361; + +#ifndef __MINGW32__ +#ifdef ANSIPROT +extern double frexp ( double, int * ); +extern double ldexp ( double, int ); +extern int isnan ( double ); +extern int isfinite ( double ); +#else +double frexp(), ldexp(); +int isnan(), isfinite(); +#endif +#endif + +double cbrt(x) +double x; +{ +int e, rem, sign; +double z; + +#ifdef __MINGW32__ +if (!isfinite (x) || x == 0 ) + return x; +#else + +#ifdef NANS +if( isnan(x) ) + return x; +#endif +#ifdef INFINITIES +if( !isfinite(x) ) + return x; +#endif +if( x == 0 ) + return( x ); + +#endif /* __MINGW32__ */ + +if( x > 0 ) + sign = 1; +else + { + sign = -1; + x = -x; + } + +z = x; +/* extract power of 2, leaving + * mantissa between 0.5 and 1 + */ +x = frexp( x, &e ); + +/* Approximate cube root of number between .5 and 1, + * peak relative error = 9.2e-6 + */ +x = (((-1.3466110473359520655053e-1 * x + + 5.4664601366395524503440e-1) * x + - 9.5438224771509446525043e-1) * x + + 1.1399983354717293273738e0 ) * x + + 4.0238979564544752126924e-1; + +/* exponent divided by 3 */ +if( e >= 0 ) + { + rem = e; + e /= 3; + rem -= 3*e; + if( rem == 1 ) + x *= CBRT2; + else if( rem == 2 ) + x *= CBRT4; + } + + +/* argument less than 1 */ + +else + { + e = -e; + rem = e; + e /= 3; + rem -= 3*e; + if( rem == 1 ) + x *= CBRT2I; + else if( rem == 2 ) + x *= CBRT4I; + e = -e; + } + +/* multiply by power of 2 */ +x = ldexp( x, e ); + +/* Newton iteration */ +x -= ( x - (z/(x*x)) )*0.33333333333333333333; +#ifdef DEC +x -= ( x - (z/(x*x)) )/3.0; +#else +x -= ( x - (z/(x*x)) )*0.33333333333333333333; +#endif + +if( sign < 0 ) + x = -x; +return(x); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/cbrtf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/cbrtf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,147 @@ +/* cbrtf.c + * + * Cube root + * + * + * + * SYNOPSIS: + * + * float x, y, cbrtf(); + * + * y = cbrtf( x ); + * + * + * + * DESCRIPTION: + * + * Returns the cube root of the argument, which may be negative. + * + * Range reduction involves determining the power of 2 of + * the argument. A polynomial of degree 2 applied to the + * mantissa, and multiplication by the cube root of 1, 2, or 4 + * approximates the root to within about 0.1%. Then Newton's + * iteration is used to converge to an accurate result. + * + * + * + * ACCURACY: + * + * Relative error: + * arithmetic domain # trials peak rms + * IEEE 0,1e38 100000 7.6e-8 2.7e-8 + * + */ + /* cbrt.c */ + +/* +Cephes Math Library Release 2.2: June, 1992 +Copyright 1984, 1987, 1988, 1992 by Stephen L. Moshier +Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +*/ + +/* + Modified for mingwex.a + 2002-07-01 Danny Smith + */ +#ifdef __MINGW32__ +#include +#include "cephes_mconf.h" +#else +#include "mconf.h" +#endif + +static const float CBRT2 = 1.25992104989487316477; +static const float CBRT4 = 1.58740105196819947475; + +#ifndef __MINGW32__ +#ifdef ANSIC +float frexpf(float, int *), ldexpf(float, int); + +float cbrtf( float xx ) +#else +float frexpf(), ldexpf(); + +float cbrtf(xx) +double xx; +#endif +{ +int e, rem, sign; +float x, z; + +x = xx; + +#else /* __MINGW32__ */ +float cbrtf (float x) +{ +int e, rem, sign; +float z; +#endif /* __MINGW32__ */ + +#ifdef __MINGW32__ +if (!isfinite (x) || x == 0.0F ) + return x; +#else +if( x == 0 ) + return( 0.0 ); +#endif +if( x > 0 ) + sign = 1; +else + { + sign = -1; + x = -x; + } + +z = x; +/* extract power of 2, leaving + * mantissa between 0.5 and 1 + */ +x = frexpf( x, &e ); + +/* Approximate cube root of number between .5 and 1, + * peak relative error = 9.2e-6 + */ +x = (((-0.13466110473359520655053 * x + + 0.54664601366395524503440 ) * x + - 0.95438224771509446525043 ) * x + + 1.1399983354717293273738 ) * x + + 0.40238979564544752126924; + +/* exponent divided by 3 */ +if( e >= 0 ) + { + rem = e; + e /= 3; + rem -= 3*e; + if( rem == 1 ) + x *= CBRT2; + else if( rem == 2 ) + x *= CBRT4; + } + + +/* argument less than 1 */ + +else + { + e = -e; + rem = e; + e /= 3; + rem -= 3*e; + if( rem == 1 ) + x /= CBRT2; + else if( rem == 2 ) + x /= CBRT4; + e = -e; + } + +/* multiply by power of 2 */ +x = ldexpf( x, e ); + +/* Newton iteration */ +x -= ( x - (z/(x*x)) ) * 0.333333333333; + +if( sign < 0 ) + x = -x; +return(x); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/cephes_mconf.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/cephes_mconf.h Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,402 @@ +#include +#include + + +#define IBMPC 1 +#define ANSIPROT 1 +#define MINUSZERO 1 +#define INFINITIES 1 +#define NANS 1 +#define DENORMAL 1 +#define VOLATILE +#define mtherr(fname, code) +#define XPD 0 + +typedef union uLD { const unsigned short sh[6]; long double ld; } uLD; +typedef union uD { const unsigned short sh[4]; double d; } uD; + +#define _CEPHES_USE_ERRNO + +#ifdef _CEPHES_USE_ERRNO +#define _SET_ERRNO(x) errno = (x) +#else +#define _SET_ERRNO(x) +#endif + +/* constants used by cephes functions */ + +/* double */ +#define MAXNUM 1.7976931348623158E308 +#define MAXLOG 7.09782712893383996843E2 +#define MINLOG -7.08396418532264106224E2 +#define LOGE2 6.93147180559945309417E-1 +#define LOG2E 1.44269504088896340736 +#define PI 3.14159265358979323846 +#define PIO2 1.57079632679489661923 +#define PIO4 7.85398163397448309616E-1 + +#define NEGZERO (-0.0) +#undef NAN +#undef INFINITY +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)) +#define INFINITY __builtin_huge_val() +#define NAN __builtin_nan("") +#else +extern double __INF; +#define INFINITY (__INF) +extern double __QNAN; +#define NAN (__QNAN) +#endif + +/*long double*/ +#define MAXNUML 1.189731495357231765021263853E4932L +#define MAXLOGL 1.1356523406294143949492E4L +#define MINLOGL -1.13994985314888605586758E4L +#define LOGE2L 6.9314718055994530941723E-1L +#define LOG2EL 1.4426950408889634073599E0L +#define PIL 3.1415926535897932384626L +#define PIO2L 1.5707963267948966192313L +#define PIO4L 7.8539816339744830961566E-1L + +#define isfinitel isfinite +#define isinfl isinf +#define isnanl isnan +#define signbitl signbit + +#define NEGZEROL (-0.0L) + +#undef NANL +#undef INFINITYL +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)) +#define INFINITYL __builtin_huge_vall() +#define NANL __builtin_nanl("") +#else +extern long double __INFL; +#define INFINITYL (__INFL) +extern long double __QNANL; +#define NANL (__QNANL) +#endif + +/* float */ + +#define MAXNUMF 3.4028234663852885981170418348451692544e38F +#define MAXLOGF 88.72283905206835F +#define MINLOGF -103.278929903431851103F /* log(2^-149) */ +#define LOG2EF 1.44269504088896341F +#define LOGE2F 0.693147180559945309F +#define PIF 3.141592653589793238F +#define PIO2F 1.5707963267948966192F +#define PIO4F 0.7853981633974483096F + +#define isfinitef isfinite +#define isinff isinf +#define isnanf isnan +#define signbitf signbit + +#define NEGZEROF (-0.0F) + +#undef NANF +#undef INFINITYF +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 2)) +#define INFINITYF __builtin_huge_valf() +#define NANF __builtin_nanf("") +#else +extern float __INFF; +#define INFINITYF (__INFF) +extern float __QNANF; +#define NANF (__QNANF) +#endif + + +/* double */ + +/* +Cephes Math Library Release 2.2: July, 1992 +Copyright 1984, 1987, 1988, 1992 by Stephen L. Moshier +Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +*/ + + +/* polevl.c + * p1evl.c + * + * Evaluate polynomial + * + * + * + * SYNOPSIS: + * + * int N; + * double x, y, coef[N+1], polevl[]; + * + * y = polevl( x, coef, N ); + * + * + * + * DESCRIPTION: + * + * Evaluates polynomial of degree N: + * + * 2 N + * y = C + C x + C x +...+ C x + * 0 1 2 N + * + * Coefficients are stored in reverse order: + * + * coef[0] = C , ..., coef[N] = C . + * N 0 + * + * The function p1evl() assumes that coef[N] = 1.0 and is + * omitted from the array. Its calling arguments are + * otherwise the same as polevl(). + * + * + * SPEED: + * + * In the interest of speed, there are no checks for out + * of bounds arithmetic. This routine is used by most of + * the functions in the library. Depending on available + * equipment features, the user may wish to rewrite the + * program in microcode or assembly language. + * + */ + +/* Polynomial evaluator: + * P[0] x^n + P[1] x^(n-1) + ... + P[n] + */ +static __inline__ double polevl( x, p, n ) +double x; +const uD *p; +int n; +{ +register double y; + +y = p->d; +p++; +do + { + y = y * x + p->d; + p++; + } +while( --n ); +return(y); +} + + + +/* Polynomial evaluator: + * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n] + */ +static __inline__ double p1evl( x, p, n ) +double x; +const uD *p; +int n; +{ +register double y; + +n -= 1; +y = x + p->d; +p++; +do + { + y = y * x + p->d; + p++; + } +while( --n ); +return( y ); +} + + +/* long double */ +/* +Cephes Math Library Release 2.2: July, 1992 +Copyright 1984, 1987, 1988, 1992 by Stephen L. Moshier +Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +*/ + + +/* polevll.c + * p1evll.c + * + * Evaluate polynomial + * + * + * + * SYNOPSIS: + * + * int N; + * long double x, y, coef[N+1], polevl[]; + * + * y = polevll( x, coef, N ); + * + * + * + * DESCRIPTION: + * + * Evaluates polynomial of degree N: + * + * 2 N + * y = C + C x + C x +...+ C x + * 0 1 2 N + * + * Coefficients are stored in reverse order: + * + * coef[0] = C , ..., coef[N] = C . + * N 0 + * + * The function p1evll() assumes that coef[N] = 1.0 and is + * omitted from the array. Its calling arguments are + * otherwise the same as polevll(). + * + * + * SPEED: + * + * In the interest of speed, there are no checks for out + * of bounds arithmetic. This routine is used by most of + * the functions in the library. Depending on available + * equipment features, the user may wish to rewrite the + * program in microcode or assembly language. + * + */ + +/* Polynomial evaluator: + * P[0] x^n + P[1] x^(n-1) + ... + P[n] + */ +static __inline__ long double polevll( x, p, n ) +long double x; +const uLD *p; +int n; +{ +register long double y; + +y = p->ld; +p++; +do + { + y = y * x + p->ld; + p++; + } +while( --n ); +return(y); +} + + + +/* Polynomial evaluator: + * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n] + */ +static __inline__ long double p1evll( x, p, n ) +long double x; +const uLD *p; +int n; +{ +register long double y; + +n -= 1; +y = x + p->ld; +p++; +do + { + y = y * x + p->ld; + p++; + } +while( --n ); +return( y ); +} + +/* Float version */ + +/* polevlf.c + * p1evlf.c + * + * Evaluate polynomial + * + * + * + * SYNOPSIS: + * + * int N; + * float x, y, coef[N+1], polevlf[]; + * + * y = polevlf( x, coef, N ); + * + * + * + * DESCRIPTION: + * + * Evaluates polynomial of degree N: + * + * 2 N + * y = C + C x + C x +...+ C x + * 0 1 2 N + * + * Coefficients are stored in reverse order: + * + * coef[0] = C , ..., coef[N] = C . + * N 0 + * + * The function p1evl() assumes that coef[N] = 1.0 and is + * omitted from the array. Its calling arguments are + * otherwise the same as polevl(). + * + * + * SPEED: + * + * In the interest of speed, there are no checks for out + * of bounds arithmetic. This routine is used by most of + * the functions in the library. Depending on available + * equipment features, the user may wish to rewrite the + * program in microcode or assembly language. + * + */ + +/* +Cephes Math Library Release 2.1: December, 1988 +Copyright 1984, 1987, 1988 by Stephen L. Moshier +Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +*/ + +static __inline__ float polevlf(float x, const float* coef, int N ) +{ +float ans; +float *p; +int i; + +p = (float*)coef; +ans = *p++; + +/* +for( i=0; i. + * Adapted for exp2 by Ulrich Drepper . + * Public domain. + */ + + .file "exp2.S" + .text + .align 4 +.globl _exp2 + .def _exp2; .scl 2; .type 32; .endef +_exp2: + fldl 4(%esp) +/* I added the following ugly construct because exp(+-Inf) resulted + in NaN. The ugliness results from the bright minds at Intel. + For the i686 the code can be written better. + -- drepper@cygnus.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + fld %st + frndint /* int(x) */ + fsubr %st,%st(1) /* fract(x) */ + fxch + f2xm1 /* 2^(fract(x)) - 1 */ + fld1 + faddp /* 2^(fract(x)) */ + fscale /* e^x */ + fstp %st(1) + ret + +1: testl $0x200, %eax /* Test sign. */ + jz 2f /* If positive, jump. */ + fstp %st + fldz /* Set result to 0. */ +2: ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/exp2f.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/exp2f.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,39 @@ +/* + * Written by J.T. Conklin . + * Adapted for exp2 by Ulrich Drepper . + * Public domain. + */ + + .file "exp2f.S" + .text + .align 4 +.globl _exp2f + .def _exp2f; .scl 2; .type 32; .endef +_exp2f: + flds 4(%esp) +/* I added the following ugly construct because exp(+-Inf) resulted + in NaN. The ugliness results from the bright minds at Intel. + For the i686 the code can be written better. + -- drepper@cygnus.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + fld %st + frndint /* int(x) */ + fsubr %st,%st(1) /* fract(x) */ + fxch + f2xm1 /* 2^(fract(x)) - 1 */ + fld1 + faddp /* 2^(fract(x)) */ + fscale /* e^x */ + fstp %st(1) + ret + +1: testl $0x200, %eax /* Test sign. */ + jz 2f /* If positive, jump. */ + fstp %st + fldz /* Set result to 0. */ +2: ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/expm1.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/expm1.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,28 @@ +/* + * Written 2005 by Gregory W. Chicares . + * Adapted to double by Danny Smith . + * Public domain. + * + * F2XM1's input is constrained to (-1, +1), so the domain of + * 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain, + * delegating to exp() handles C99 7.12.6.3/2 range errors. + * + * Constants from moshier.net, file cephes/ldouble/constl.c, + * are used instead of M_LN2 and M_LOG2E, which would not be + * visible with 'gcc std=c99'. The use of these extended precision + * constants also allows gcc to replace them with x87 opcodes. + */ + +#include /* expl() */ +#include "cephes_mconf.h" +double expm1 (double x) +{ + if (fabs(x) < LOGE2L) + { + x *= LOG2EL; + __asm__("f2xm1" : "=t" (x) : "0" (x)); + return x; + } + else + return exp(x) - 1.0; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/expm1f.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/expm1f.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,29 @@ +/* + * Written 2005 by Gregory W. Chicares . + * Adapted to float by Danny Smith . + * Public domain. + * + * F2XM1's input is constrained to (-1, +1), so the domain of + * 'x * LOG2EL' is (-LOGE2L, +LOGE2L). Outside that domain, + * delegating to exp() handles C99 7.12.6.3/2 range errors. + * + * Constants from moshier.net, file cephes/ldouble/constl.c, + * are used instead of M_LN2 and M_LOG2E, which would not be + * visible with 'gcc std=c99'. The use of these extended precision + * constants also allows gcc to replace them with x87 opcodes. + */ + +#include /* expl() */ +#include "cephes_mconf.h" + +float expm1f (float x) +{ + if (fabsf(x) < LOGE2L) + { + x *= LOG2EL; + __asm__("f2xm1" : "=t" (x) : "0" (x)); + return x; + } + else + return expf(x) - 1.0F; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/fastmath.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/fastmath.h Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,115 @@ +#ifndef _MINGWEX_FASTMATH_H_ +#define _MINGWEX_FASTMATH_H_ + +/* Fast math inlines + No range or domain checks. No setting of errno. No tweaks to + protect precision near range limits. */ + +/* For now this is an internal header with just the functions that + are currently used in building libmingwex.a math components */ + +/* FIXME: We really should get rid of the code duplication using euther + C++ templates or tgmath-type macros. */ + +static __inline__ double __fast_sqrt (double x) +{ + double res; + asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x)); + return res; +} + +static __inline__ long double __fast_sqrtl (long double x) +{ + long double res; + asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x)); + return res; +} + +static __inline__ float __fast_sqrtf (float x) +{ + float res; + asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x)); + return res; +} + + +static __inline__ double __fast_log (double x) +{ + double res; + asm __volatile__ + ("fldln2\n\t" + "fxch\n\t" + "fyl2x" + : "=t" (res) : "0" (x) : "st(1)"); + return res; +} + +static __inline__ long double __fast_logl (long double x) +{ + long double res; + asm __volatile__ + ("fldln2\n\t" + "fxch\n\t" + "fyl2x" + : "=t" (res) : "0" (x) : "st(1)"); + return res; +} + + +static __inline__ float __fast_logf (float x) +{ + float res; + asm __volatile__ + ("fldln2\n\t" + "fxch\n\t" + "fyl2x" + : "=t" (res) : "0" (x) : "st(1)"); + return res; +} + +static __inline__ double __fast_log1p (double x) +{ + double res; + /* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */ + if (fabs (x) >= 1.0 - 0.5 * 1.41421356237309504880) + res = __fast_log (1.0 + x); + else + asm __volatile__ + ("fldln2\n\t" + "fxch\n\t" + "fyl2xp1" + : "=t" (res) : "0" (x) : "st(1)"); + return res; +} + +static __inline__ long double __fast_log1pl (long double x) +{ + long double res; + /* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */ + if (fabsl (x) >= 1.0L - 0.5L * 1.41421356237309504880L) + res = __fast_logl (1.0L + x); + else + asm __volatile__ + ("fldln2\n\t" + "fxch\n\t" + "fyl2xp1" + : "=t" (res) : "0" (x) : "st(1)"); + return res; +} + +static __inline__ float __fast_log1pf (float x) +{ + float res; + /* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */ + if (fabsf (x) >= 1.0 - 0.5 * 1.41421356237309504880) + res = __fast_logf (1.0 + x); + else + asm __volatile__ + ("fldln2\n\t" + "fxch\n\t" + "fyl2xp1" + : "=t" (res) : "0" (x) : "st(1)"); + return res; +} + +#endif diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/finite.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/finite.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,7 @@ +#define __STDC__ 1 + +#include +#include + +int finite (double x) +{ return _finite (x); } diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/finitef.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/finitef.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,7 @@ +#define __STDC__ 1 + +#include +#include + +int finitef (float x) +{ return _finite (x); } diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/fma.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/fma.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,12 @@ + .file "fma.S" + .text + .align 2 + .p2align 4,,15 +.globl _fma + .def _fma; .scl 2; .type 32; .endef +_fma: + fldl 4(%esp) + fmull 12(%esp) + fldl 20(%esp) + faddp + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/fmaf.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/fmaf.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,12 @@ + .file "fmaf.S" + .text + .align 2 + .p2align 4,,15 +.globl _fmaf + .def _fmaf; .scl 2; .type 32; .endef +_fmaf: + flds 4(%esp) + fmuls 8(%esp) + flds 12(%esp) + faddp + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/fpclassify.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/fpclassify.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,20 @@ +#include + +/* 'fxam' sets FPU flags C3,C2,C0 'fstsw' stores: + FP_NAN 001 0x0100 + FP_NORMAL 010 0x0400 + FP_INFINITE 011 0x0500 + FP_ZERO 100 0x4000 + FP_SUBNORMAL 110 0x4400 + +and sets C1 flag (signbit) if neg */ + +int __fpclassify (double _x){ + unsigned short sw; + __asm__ ( + "fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (_x) + ); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/fpclassifyf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/fpclassifyf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,10 @@ +#include +int __fpclassifyf (float _x){ + unsigned short sw; + __asm__ ( + "fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (_x) + ); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/funx.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/funx.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,110 @@ +/* + * This file is part of msvcmath library. + * Author: Michael Goffioul. + */ +#include "msvcmath.h" + +#define FUNC_IMPL_1(FUNC, RETTYPE, TYPE, SUFFIX) \ +RETTYPE FUNC ## SUFFIX (TYPE x) { return (RETTYPE) FUNC (x); } +#define FUNC_IMPL_2(FUNC, TYPE, SUFFIX) FUNC_IMPL_1(FUNC, TYPE, TYPE, SUFFIX) +#define FUNC_IMPL_F(FUNC) FUNC_IMPL_2(FUNC, float, f) +#define FUNC_IMPL_L(FUNC) FUNC_IMPL_2(FUNC, long double, l) + +#define FUNC_IMPL2_2(FUNC, TYPE, TYPE1, TYPE2, SUFFIX) \ +TYPE FUNC ## SUFFIX (TYPE1 x, TYPE2 y) \ + { return (TYPE) FUNC (x, y); } +#define FUNC_IMPL2_1(FUNC, TYPE, SUFFIX) \ + FUNC_IMPL2_2(FUNC, TYPE, TYPE, TYPE, SUFFIX) +#define FUNC_IMPL2_F(FUNC) FUNC_IMPL2_1(FUNC, float, f) +#define FUNC_IMPL2_L(FUNC) FUNC_IMPL2_1(FUNC, long double, l) + +FUNC_IMPL2_2(frexp, float, float, int*, f) + +#ifndef _M_IA64 + +FUNC_IMPL2_2(ldexp, float, float, int, f) +FUNC_IMPL_F(fabs) + +# ifndef _M_AMD64 + +FUNC_IMPL_F(acos) +FUNC_IMPL_F(asin) +FUNC_IMPL_F(atan) +FUNC_IMPL_F(ceil) +FUNC_IMPL_F(cos) +FUNC_IMPL_F(cosh) +FUNC_IMPL_F(exp) +FUNC_IMPL_F(floor) +FUNC_IMPL_F(log) +FUNC_IMPL_F(log10) +FUNC_IMPL_F(sin) +FUNC_IMPL_F(sinh) +FUNC_IMPL_F(sqrt) +FUNC_IMPL_F(tan) +FUNC_IMPL_F(tanh) + +FUNC_IMPL2_F(atan2) +FUNC_IMPL2_F(fmod) +FUNC_IMPL2_F(pow) + +# endif /* ! _M_AMD64 */ + +#endif /* ! _M_IA64 */ + +FUNC_IMPL_L(acos) +FUNC_IMPL_L(asin) +FUNC_IMPL_L(atan) +FUNC_IMPL_L(ceil) +FUNC_IMPL_L(cos) +FUNC_IMPL_L(cosh) +FUNC_IMPL_L(exp) +FUNC_IMPL_L(floor) +FUNC_IMPL_L(log) +FUNC_IMPL_L(log10) +FUNC_IMPL_L(sin) +FUNC_IMPL_L(sinh) +FUNC_IMPL_L(sqrt) +FUNC_IMPL_L(tan) +FUNC_IMPL_L(tanh) + +FUNC_IMPL2_L(atan2) +FUNC_IMPL2_L(fmod) +FUNC_IMPL2_L(pow) + +FUNC_IMPL2_2(ldexp, long double, long double, int, l) +FUNC_IMPL2_2(frexp, long double, long double, int*, l) + +FUNC_IMPL_L(cbrt) +FUNC_IMPL_L(exp2) +FUNC_IMPL_L(expm1) +FUNC_IMPL_L(fabs) +FUNC_IMPL_1(finite, int, long double, l) +FUNC_IMPL_1(ilogb, int, long double, l) +FUNC_IMPL_1(isinf, int, long double, l) +FUNC_IMPL_1(isnan, int, long double, l) +FUNC_IMPL_L(log1p) +FUNC_IMPL_L(log2) +FUNC_IMPL_L(logb) +FUNC_IMPL_1(llrint, long long int, long double, l) +FUNC_IMPL_1(lrint, long int, long double, l) +FUNC_IMPL_1(lround, long int, long double, l) +FUNC_IMPL_L(nearbyint) +FUNC_IMPL2_L(nextafter) +FUNC_IMPL2_L(remainder) +FUNC_IMPL_L(rint) +FUNC_IMPL_L(round) +FUNC_IMPL2_2(scalbn, long double, long double, int, l) +FUNC_IMPL_L(trunc) + +long double fmal (long double x, long double y, long double z) +{ return (long double) fma (x, y, z); } + +long double modfl (long double x, long double *iptr) +{ + double d, ret; + + ret = modf (x, &d); + *iptr = d; + + return (long double) ret; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/ilogb.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/ilogb.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,37 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + + + .file "ilogb.S" + .text + .align 4 +.globl _ilogb + .def _ilogb; .scl 2; .type 32; .endef +_ilogb: + + fldl 4(%esp) +/* I added the following ugly construct because ilogb(+-Inf) is + required to return INT_MAX in ISO C99. + -- jakub@redhat.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + + fxtract + pushl %eax + fstp %st + + fistpl (%esp) + fwait + popl %eax + + ret + +1: fstp %st + movl $0x7fffffff, %eax + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/ilogbf.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/ilogbf.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,35 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + + .file "ilogbf.S" + .text + .align 4 +.globl _ilogbf + .def _ilogbf; .scl 2; .type 32; .endef +_ilogbf: + flds 4(%esp) +/* I added the following ugly construct because ilogb(+-Inf) is + required to return INT_MAX in ISO C99. + -- jakub@redhat.com. */ + fxam /* Is NaN or +-Inf? */ + fstsw %ax + movb $0x45, %dh + andb %ah, %dh + cmpb $0x05, %dh + je 1f /* Is +-Inf, jump. */ + + fxtract + pushl %eax + fstp %st + + fistpl (%esp) + fwait + popl %eax + + ret + +1: fstp %st + movl $0x7fffffff, %eax + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/isinf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/isinf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,12 @@ +#define __STDC__ 1 + +#include +#include + +int isinf (double x) +{ + int c = (_fpclass (x) & (_FPCLASS_PINF | _FPCLASS_NINF)); + + return (c == _FPCLASS_PINF ? 1 + : c == _FPCLASS_NINF ? -1 : 0); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/isinff.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/isinff.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,12 @@ +#define __STDC__ 1 + +#include +#include + +int isinff (float x) +{ + int c = (_fpclass (x) & (_FPCLASS_PINF | _FPCLASS_NINF)); + + return (c == _FPCLASS_PINF ? 1 + : c == _FPCLASS_NINF ? -1 : 0); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/isnan.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/isnan.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,14 @@ +#include + +int +__isnan (double _x) +{ + unsigned short _sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (_sw) : "t" (_x)); + return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} + +#undef isnan +int __attribute__ ((alias ("__isnan"))) isnan (double); diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/isnanf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/isnanf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,12 @@ +#include +int +__isnanf (float _x) +{ + unsigned short _sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (_sw) : "t" (_x) ); + return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} + +int __attribute__ ((alias ("__isnanf"))) isnanf (float); diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/llrint.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/llrint.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,10 @@ +#include + +long long llrint (double x) +{ + long long retval; + __asm__ __volatile__ \ + ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \ + return retval; +} + diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/llrintf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/llrintf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,9 @@ +#include + +long long llrintf (float x) +{ + long long retval; + __asm__ __volatile__ \ + ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); \ + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/log1p.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/log1p.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,47 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * Removed header file dependency for use in libmingwex.a by + * Danny Smith + */ + + .file "log1p.S" + .text + .align 4 + /* The fyl2xp1 can only be used for values in + -1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2 + 0.29 is a safe value. + */ +limit: .double 0.29 +one: .double 1.0 +/* + * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29, + * otherwise fyl2x with the needed extra computation. + */ +.globl _log1p; + .def _log1p; .scl 2; .type 32; .endef +_log1p: + fldln2 + fldl 4(%esp) + fxam + fnstsw + fld %st + sahf + jc 3f /* in case x is NaN or ħInf */ + +4: fabs + fcompl limit + fnstsw + sahf + jc 2f + faddl one + fyl2x + ret + +2: fyl2xp1 + ret + +3: jp 4b /* in case x is ħInf */ + fstp %st(1) + fstp %st(1) + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/log1pf.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/log1pf.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,47 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * Removed header file dependency for use in libmingwex.a by + * Danny Smith + */ + + .file "log1pf.S" + .text + .align 4 + /* The fyl2xp1 can only be used for values in + -1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2 + 0.29 is a safe value. + */ +limit: .float 0.29 +one: .float 1.0 +/* + * Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29, + * otherwise fyl2x with the needed extra computation. + */ +.globl _log1pf; + .def _log1pf; .scl 2; .type 32; .endef +_log1pf: + fldln2 + flds 4(%esp) + fxam + fnstsw + fld %st + sahf + jc 3f /* in case x is NaN or ħInf */ + +4: fabs + fcomps limit + fnstsw + sahf + jc 2f + fadds one + fyl2x + ret + +2: fyl2xp1 + ret + +3: jp 4b /* in case x is ħInf */ + fstp %st(1) + fstp %st(1) + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/log2.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/log2.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,51 @@ +/* + * Written by J.T. Conklin . + * Adapted for use as log2 by Ulrich Drepper . + * Public domain. + * + * Changed to use fyl2xp1 for values near 1, . + * + * Removed header file dependency for use in libmingwex.a by + * Danny Smith + */ + + .file "log2.S" + .text + .align 4 +one: .double 1.0 + /* It is not important that this constant is precise. It is only + a value which is known to be on the safe side for using the + fyl2xp1 instruction. */ +limit: .double 0.29 + + .text + .align 4 +.globl _log2 + .def _log2; .scl 2; .type 32; .endef +_log2: + fldl one + fldl 4(%esp) /* x : 1 */ + fxam + fnstsw + fld %st /* x : x : 1 */ + sahf + jc 3f /* in case x is NaN or ħInf */ +4: fsub %st(2), %st /* x-1 : x : 1 */ + fld %st /* x-1 : x-1 : x : 1 */ + fabs /* |x-1| : x-1 : x : 1 */ + fcompl limit /* x-1 : x : 1 */ + fnstsw /* x-1 : x : 1 */ + andb $0x45, %ah + jz 2f + fstp %st(1) /* x-1 : 1 */ + fyl2xp1 /* log(x) */ + ret + +2: fstp %st(0) /* x : 1 */ + fyl2x /* log(x) */ + ret + +3: jp 4b /* in case x is ħInf */ + fstp %st(1) + fstp %st(1) + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/log2f.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/log2f.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,51 @@ +/* + * Written by J.T. Conklin . + * Adapted for use as log2 by Ulrich Drepper . + * Public domain. + * + * Changed to use fyl2xp1 for values near 1, . + * + * Removed header file dependency for use in libmingwex.a by + * Danny Smith + */ + + .file "log2f.S" + .text + .align 4 +one: .double 1.0 + /* It is not important that this constant is precise. It is only + a value which is known to be on the safe side for using the + fyl2xp1 instruction. */ +limit: .double 0.29 + + .text + .align 4 +.globl _log2f + .def _log2f; .scl 2; .type 32; .endef +_log2f: + fldl one + flds 4(%esp) /* x : 1 */ + fxam + fnstsw + fld %st /* x : x : 1 */ + sahf + jc 3f /* in case x is NaN or ħInf */ +4: fsub %st(2), %st /* x-1 : x : 1 */ + fld %st /* x-1 : x-1 : x : 1 */ + fabs /* |x-1| : x-1 : x : 1 */ + fcompl limit /* x-1 : x : 1 */ + fnstsw /* x-1 : x : 1 */ + andb $0x45, %ah + jz 2f + fstp %st(1) /* x-1 : 1 */ + fyl2xp1 /* log(x) */ + ret + +2: fstp %st(0) /* x : 1 */ + fyl2x /* log(x) */ + ret + +3: jp 4b /* in case x is ħInf */ + fstp %st(1) + fstp %st(1) + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/logb.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/logb.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +double +logb (double x) +{ + double res; + asm ("fxtract\n\t" + "fstp %%st" : "=t" (res) : "0" (x)); + return res; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/logbf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/logbf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +float +logbf (float x) +{ + float res; + asm ("fxtract\n\t" + "fstp %%st" : "=t" (res) : "0" (x)); + return res; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/lrint.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/lrint.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,9 @@ +#include + +long lrint (double x) +{ + long retval; + __asm__ __volatile__ \ + ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \ + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/lrintf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/lrintf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,9 @@ +#include + +long lrintf (float x) +{ + long retval; + __asm__ __volatile__ \ + ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); \ + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/lround_generic.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/lround_generic.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,64 @@ +/* + * lround_generic.c + * + * $Id: lround_generic.c,v 1.1 2008/06/03 18:42:21 keithmarshall Exp $ + * + * Provides a generic implementation for the `lround()', `lroundf()', + * `lroundl()', `llround()', `llroundf()' and `llroundl()' functions; + * compile with `-D FUNCTION=name', with `name' set to each of these + * six in turn, to create separate object files for each of the six + * functions. + * + * Written by Keith Marshall + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#ifndef FUNCTION +/* + * Normally specified with `-D FUNCTION=name', on the command line. + * Valid FUNCTION names are `lround', `lroundf', `lroundl', `llround' + * `llroundf' and `llroundl'; specifying anything else will most likely + * cause a compilation error. If user did not specify an appropriate + * FUNCTION name, default to `lround'. + */ +#define FUNCTION lround +#endif + +#include "round_internal.h" + +#include +#include + +/* Generic implementation. + * The user is required to specify the FUNCTION name; + * the RETURN_TYPE and INPUT_TYPE macros resolve to appropriate + * type declarations, to match the selected FUNCTION prototype, + * while RETURN_MAX and RETURN_MIN map to the correspondingly + * appropriate limits.h manifest values, to establish the + * valid range for the RETURN_TYPE. + */ +RETURN_TYPE FUNCTION( INPUT_TYPE x ) +{ + if( !isfinite( x ) || !isfinite( x = round_internal( x ) ) + || (x > MAX_RETURN_VALUE) || (x < MIN_RETURN_VALUE) ) + /* + * Undefined behaviour... + * POSIX requires us to report a domain error; ANSI C99 says we + * _may_ report a range error, and previous MinGW implementation + * set `errno = ERANGE' here; we change that, conforming to the + * stricter requiremment of the POSIX standard. + */ + errno = EDOM; + + return (RETURN_TYPE)(x); +} + +/* $RCSfile: lround_generic.c,v $$Revision: 1.1 $: end of file */ diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/math.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/math.def Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,114 @@ +EXPORTS + acosf + acosh + acoshf + acosl + asinf + asinh + asinhf + asinl + atan2f + atan2l + atanf + atanh + atanhf + atanl + cbrt + cbrtf + cbrtl + ceilf + ceill + cosf + coshf + coshl + cosl + exp2 + exp2f + exp2l + expf + expl + expm1 + expm1f + expm1l + fabsf + fabsl + finite + finitef + finitel + floorf + floorl + fma + fmaf + fmal + fmodf + fmodl + frexpf + frexpl + ilogb + ilogbf + ilogbl + isinf + isinff + isinfl + isnan + isnanf + isnanl + ldexpf + ldexpl + llrint + llrintf + llrintl + log1p + log1pf + log1pl + log2 + log2f + log2l + logb + logbf + logbl + logf + logl + log10f + log10l + lrint + lrintf + lrintl + lround + lroundf + lroundl + modff + modfl + nan + nanf + nanl + nearbyint + nearbyintf + nearbyintl + powf + powl + remainder + remainderf + remainderl + rint + rintf + rintl + round + roundf + roundl + scalbn + scalbnf + scalbnl + sinf + sinhf + sinhl + sinl + sqrtf + sqrtl + tanf + tanhf + tanhl + tanl + trunc + truncf + truncl diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/math.h.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/math.h.in Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,323 @@ +/* + * This file is part of msvcmath library. + * Author: Michael Goffioul + */ +#ifndef __MSVCMATHLIB_H__ +#define __MSVCMATHLIB_H__ + +#ifndef _MSC_VER +# error "this header can only be used with Visual C++ compiler" +#endif + +/* Make sure math constants are defined */ +#ifndef _USE_MATH_DEFINES +# define _USE_MATH_DEFINES +#endif + +/* + * Original math.h rom VC++ defines float and long double variants + * of math functions as inline in C++. This conflicts with C version + * defined below. + */ +#ifdef __cplusplus +# define frexpf __msvc_frexpf +# ifndef _M_IA64 +# define fabsf __msvc_fabsf +# define ldexpf __msvc_ldexpf +# ifndef _M_AMD64 +# define acosf __msvc_acosf +# define asinf __msvc_asinf +# define atanf __msvc_atanf +# define atan2f __msvc_atan2f +# define ceilf __msvc_ceilf +# define cosf __msvc_cosf +# define coshf __msvc_coshf +# define expf __msvc_expf +# define floorf __msvc_floorf +# define fmodf __msvc_fmodf +# define logf __msvc_logf +# define log10f __msvc_log10f +# define modff __msvc_modff +# define powf __msvc_powf +# define sinf __msvc_sinf +# define sinhf __msvc_sinhf +# define sqrtf __msvc_sqrtf +# define tanf __msvc_tanf +# define tanhf __msvc_tanhf +# endif +# endif +# define acosl __msvc_acosl +# define asinl __msvc_asinl +# define atanl __msvc_atanl +# define atan2l __msvc_atan2l +# define ceill __msvc_ceill +# define cosl __msvc_cosl +# define coshl __msvc_coshl +# define expl __msvc_expl +# define fabsl __msvc_fabsl +# define floorl __msvc_floorl +# define fmodl __msvc_fmodl +# define frexpl __msvc_frexpl +# define ldexpl __msvc_ldexpl +# define logl __msvc_logl +# define log10l __msvc_log10l +# define modfl __msvc_modfl +# define powl __msvc_powl +# define sinl __msvc_sinl +# define sinhl __msvc_sinhl +# define sqrtl __msvc_sqrtl +# define tanl __msvc_tanl +# define tanhl __msvc_tanhl +#endif + +/* Include VC++ original math.h */ +#include <@MSVCMATH@> + +/* Undo override of inlined version in C++ */ +#ifdef __cplusplus +# undef frexpf +# ifndef _M_IA64 +# undef fabsf +# undef ldexpf +# ifndef _M_AMD64 +# undef acosf +# undef asinf +# undef atanf +# undef atan2f +# undef ceilf +# undef cosf +# undef coshf +# undef expf +# undef floorf +# undef fmodf +# undef logf +# undef log10f +# undef modff +# undef powf +# undef sinf +# undef sinhf +# undef sqrtf +# undef tanf +# undef tanhf +# endif +# endif +# undef acosl +# undef asinl +# undef atanl +# undef atan2l +# undef ceill +# undef cosl +# undef coshl +# undef expl +# undef fabsl +# undef floorl +# undef fmodl +# undef frexpl +# undef ldexpl +# undef logl +# undef log10l +# undef modfl +# undef powl +# undef sinl +# undef sinhl +# undef sqrtl +# undef tanl +# undef tanhl +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* Override definitions in VC++ math.h */ +#undef frexpf +extern float frexpf (float x, int* y); +#ifndef _M_IA64 +# undef fabsf +# undef ldexpf +extern float fabsf (float x); +extern float ldexpf (float x, int y); +# ifndef _M_AMD64 +# undef acosf +# undef asinf +# undef atanf +# undef atan2f +# undef ceilf +# undef cosf +# undef coshf +# undef expf +# undef floorf +# undef fmodf +# undef logf +# undef log10f +# undef modff +# undef powf +# undef sinf +# undef sinhf +# undef sqrtf +# undef tanf +# undef tanhf +extern float acosf (float x); +extern float asinf (float x); +extern float atanf (float x); +extern float atan2f (float y, float x); +extern float ceilf (float x); +extern float cosf (float x); +extern float coshf (float x); +extern float expf (float x); +extern float floorf (float x); +extern float fmodf (float x, float y); +extern float logf (float x); +extern float log10f (float x); +extern float modff (float x, float* y); +extern float powf (float x, float y); +extern float sinf (float x); +extern float sinhf (float x); +extern float sqrtf (float x); +extern float tanf (float x); +extern float tanhf (float x); +# endif /* ! _M_AMD64 */ +#endif /* ! _M_IA64 */ + +#undef acosl +#undef asinl +#undef atanl +#undef atan2l +#undef ceill +#undef cosl +#undef coshl +#undef expl +#undef fabsl +#undef floorl +#undef fmodl +#undef frexpl +#undef ldexpl +#undef logl +#undef log10l +#undef modfl +#undef powl +#undef sinl +#undef sinhl +#undef sqrtl +#undef tanl +#undef tanhl +extern long double acosl (long double x); +extern long double asinl (long double x); +extern long double atanl (long double x); +extern long double atan2l (long double y, long double x); +extern long double ceill (long double x); +extern long double cosl (long double x); +extern long double coshl (long double x); +extern long double expl (long double x); +extern long double fabsl (long double x); +extern long double floorl (long double x); +extern long double fmodl (long double x, long double y); +extern long double frexpl (long double x, int* y); +extern long double ldexpl (long double x, int y); +extern long double logl (long double x); +extern long double log10l (long double x); +extern long double modfl (long double x, long double* y); +extern long double powl (long double x, long double y); +extern long double sinl (long double x); +extern long double sinhl (long double x); +extern long double sqrtl (long double x); +extern long double tanl (long double x); +extern long double tanhl (long double x); + +/* Inverse hyperbolic functions */ +extern double acosh (double x); +extern double asinh (double x); +extern double atanh (double x); +extern float acoshf (float x); +extern float asinhf (float x); +extern float atanhf (float x); +extern long double acoshl (long double x); +extern long double asinhl (long double x); +extern long double atanhl (long double x); + +/* Cubic root functions */ +extern double cbrt (double x); +extern float cbrtf (float x); +extern long double cbrtl (long double x); + +/* Logarithmic functions */ +extern double exp2 (double x); +extern double expm1 (double x); +extern int ilogb (double x); +extern double log1p (double x); +extern double log2 (double x); +extern double logb (double x); +extern float exp2f (float x); +extern float expm1f (float x); +extern int ilogbf (float x); +extern float log1pf (float x); +extern float log2f (float x); +extern float logbf (float x); +extern long double exp2l (long double x); +extern long double expm1l (long double x); +extern int ilogbl (long double x); +extern long double log1pl (long double x); +extern long double log2l (long double x); +extern long double logbl (long double x); + +/* Rounding functions */ +extern long int lrint (double x); +extern long long int llrint (double x); +extern long int lround (double x); +extern double nearbyint (double x); +extern double rint (double x); +extern double round (double x); +extern double trunc (double x); +extern long int lrintf (float x); +extern long long int llrintf (float x); +extern long int lroundf (float x); +extern float nearbyintf (float x); +extern float rintf (float x); +extern float roundf (float x); +extern float truncf (float x); +extern long int lrintl (long double x); +extern long long int llrintl (long double x); +extern long int lroundl (long double x); +extern long double nearbyintl (long double x); +extern long double rintl (long double x); +extern long double roundl (long double x); +extern long double truncl (long double x); + +/* Other functions */ +extern double fma (double x, double y, double z); +extern float fmaf (float x, float y, float z); +extern long double fmal (long double x, long double y, long double z); + +extern int finite(double x); +extern int finitef(float x); +extern int finitel(long double x); + +extern int isinf(double x); +extern int isinff(float x); +extern int isinfl(long double x); + +extern int isnan(double x); +extern int isnanf(float x); +extern int isnanl(long double x); + +extern double nan (const char* tagp); +extern float nanf (const char* tagp); +extern long double nanl (const char* tagp); + +extern double nextafter (double x, double y); +extern float nextafterf (float x, float y); +extern long double nextafterl (long double x, long double y); + +extern double remainder(double x, double y); +extern float remainderf(float x, float y); +extern long double remainderl(long double x, long double y); + +extern double scalbn(double x, int exp); +extern float scalbnf(float x, int exp); +extern long double scalbnl(long double x, int exp); + +#ifdef __cplusplus +} +#endif + +#endif diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/modff.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/modff.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,22 @@ +#include +#include +#include +#define FE_ROUNDING_MASK \ + (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO) + +float +modff (float value, float* iptr) +{ + float int_part; + unsigned short saved_cw; + unsigned short tmp_cw; + /* truncate */ + asm ("fnstcw %0;" : "=m" (saved_cw)); /* save control word */ + tmp_cw = (saved_cw & ~FE_ROUNDING_MASK) | FE_TOWARDZERO; + asm ("fldcw %0;" : : "m" (tmp_cw)); + asm ("frndint;" : "=t" (int_part) : "0" (value)); /* round */ + asm ("fldcw %0;" : : "m" (saved_cw)); /* restore saved cw */ + if (iptr) + *iptr = int_part; + return (isinf (value) ? 0.0F : value - int_part); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/nan.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/nan.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,15 @@ +#include +#include + +static __inline double __fast_nan (const char* tagp) +{ return _Nan._Double; } + +static __inline double __fast_nanf (const char* tagp) +{ return _FNan._Float; } + +static __inline long double __fast_nanl (const char* tagp) +{ return _LNan._Long_double; } + +double nan (const char* tagp) { return __fast_nan (tagp); } +float nanf (const char* tagp) { return __fast_nanf (tagp); } +long double nanl (const char* tagp) { return __fast_nanl (tagp); } diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/nearbyint.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/nearbyint.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,30 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * + * Adapted for use as nearbyint by Ulrich Drepper . + * + * Removed header file dependency for use in libmingwex.a by + * Danny Smith + */ + + .file "nearbyint.S" + .text + .align 4 +.globl _nearbyint + .def _nearbyint; .scl 2; .type 32; .endef +_nearbyint: + fldl 4(%esp) + pushl %eax + pushl %ecx + fnstcw (%esp) + movl (%esp), %eax + orl $0x20, %eax + movl %eax, 4(%esp) + fldcw 4(%esp) + frndint + fclex + fldcw (%esp) + popl %ecx + popl %eax + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/nearbyintf.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/nearbyintf.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,29 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * Adapted for use as nearbyint by Ulrich Drepper . + * + * Removed header file dependency for use in libmingwex.a by + * Danny Smith + */ + + .file "nearbyintf.S" + .text + .align 4 +.globl _nearbyintf + .def _nearbyintf; .scl 2; .type 32; .endef +_nearbyintf: + flds 4(%esp) + pushl %eax + pushl %ecx + fnstcw (%esp) + movl (%esp), %eax + orl $0x20, %eax + movl %eax, 4(%esp) + fldcw 4(%esp) + frndint + fclex + fldcw (%esp) + popl %ecx + popl %eax + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/nextafter.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/nextafter.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,8 @@ +#define __STDC__ 1 + +#include + +double nextafter (double x, double y) +{ + return _nextafter (x, y); +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/nextafterf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/nextafterf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,27 @@ +#include + +float +nextafterf (float x, float y) +{ + union + { + float f; + unsigned int i; + } u; + if (isnan (y) || isnan (x)) + return x + y; + if (x == y ) + /* nextafter (0.0, -O.0) should return -0.0. */ + return y; + u.f = x; + if (x == 0.0F) + { + u.i = 1; + return y > 0.0F ? u.f : -u.f; + } + if (((x > 0.0F) ^ (y > x)) == 0) + u.i++; + else + u.i--; + return u.f; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/remainder.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/remainder.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + + .file "remainder.S" + .text + .align 4 +.globl _remainder + .def _remainder; .scl 2; .type 32; .endef +_remainder: + fldl 12(%esp) + fldl 4(%esp) +1: fprem1 + fstsw %ax + sahf + jp 1b + fstp %st(1) + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/remainderf.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/remainderf.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + + .file "remainderf.S" + .text + .align 4 +.globl _remainder + .def _remainderf; .scl 2; .type 32; .endef +_remainderf: + flds 8(%esp) + flds 4(%esp) +1: fprem1 + fstsw %ax + sahf + jp 1b + fstp %st(1) + ret diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/rint.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/rint.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,6 @@ +#include +double rint (double x){ + double retval; + __asm__ ("frndint;" : "=t" (retval) : "0" (x)); + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/rintf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/rintf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,7 @@ +#include + +float rintf (float x){ + float retval; + __asm__ ("frndint;": "=t" (retval) : "0" (x)); + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/round_generic.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/round_generic.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,51 @@ +/* + * round_generic.c + * + * $Id: round_generic.c,v 1.1 2008/06/03 18:42:21 keithmarshall Exp $ + * + * Provides a generic implementation for the `round()', `roundf()' + * and `roundl()' functions; compile with `-D FUNCTION=name', with + * `name' set to each of these three in turn, to create separate + * object files for each of the three functions. + * + * Written by Keith Marshall + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#ifndef FUNCTION +/* + * Normally specified with `-D FUNCTION=name', on the command line. + * Valid FUNCTION names are `round', `roundf' and `roundl'; specifying + * anything else will most likely cause a compilation error. If user + * did not specify any FUNCTION name, default to `round'. + */ +#define FUNCTION round +#endif + +#include "round_internal.h" + +/* Generic implementation. + * The user is required to specify the FUNCTION name; + * the RETURN_TYPE and INPUT_TYPE macros resolve to appropriate + * type declarations, to match the selected FUNCTION prototype. + */ +RETURN_TYPE FUNCTION( INPUT_TYPE x ) +{ + /* Round to nearest integer, away from zero for half-way. + * + * We split it with the `round_internal()' function in + * a private header file, so that it may be shared by this, + * `lround()' and `llround()' implementations. + */ + return isfinite( x ) ? round_internal( x ) : x; +} + +/* $RCSfile: round_generic.c,v $$Revision: 1.1 $: end of file */ diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/round_internal.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/round_internal.h Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,155 @@ +#ifndef _ROUND_INTERNAL_H +/* + * round_internal.h + * + * $Id: round_internal.h,v 1.1 2008/06/03 18:42:21 keithmarshall Exp $ + * + * Provides a generic implementation of the numerical rounding + * algorithm, which is shared by all functions in the `round()', + * `lround()' and `llround()' families. + * + * Written by Keith Marshall + * + * This is free software. You may redistribute and/or modify it as you + * see fit, without restriction of copyright. + * + * This software is provided "as is", in the hope that it may be useful, + * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of + * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no + * time will the author accept any form of liability for any damages, + * however caused, resulting from the use of this software. + * + */ +#define _ROUND_INTERNAL_H + +#include +#include + +#define TYPE_PASTE( NAME, TYPE ) NAME##TYPE + +#define INPUT_TYPE INPUT_TYPEDEF( FUNCTION ) +#define INPUT_TYPEDEF( FUNCTION ) TYPE_PASTE( FUNCTION, _input_type ) +/* + * The types for the formal parameter, to each of the derived functions. + */ +#define round_input_type double +#define roundf_input_type float +#define roundl_input_type long double + +#define lround_input_type double +#define lroundf_input_type float +#define lroundl_input_type long double + +#define llround_input_type double +#define llroundf_input_type float +#define llroundl_input_type long double + +#define RETURN_TYPE RETURN_TYPEDEF( FUNCTION ) +#define RETURN_TYPEDEF( FUNCTION ) TYPE_PASTE( FUNCTION, _return_type ) +/* + * The types for the return value, from each of the derived functions. + */ +#define round_return_type double +#define roundf_return_type float +#define roundl_return_type long double + +#define lround_return_type long +#define lroundf_return_type long +#define lroundl_return_type long + +#define llround_return_type long long +#define llroundf_return_type long long +#define llroundl_return_type long long + +#define MAX_RETURN_VALUE RETURN_MAX( FUNCTION ) +#define RETURN_MAX( FUNCTION ) TYPE_PASTE( FUNCTION, _return_max ) +/* + * The maximum values which may be returned by each of the derived functions + * in the `lround' or the `llround' families. + */ +#define lround_return_max LONG_MAX +#define lroundf_return_max LONG_MAX +#define lroundl_return_max LONG_MAX + +#define llround_return_max LLONG_MAX +#define llroundf_return_max LLONG_MAX +#define llroundl_return_max LLONG_MAX + +#define MIN_RETURN_VALUE RETURN_MIN( FUNCTION ) +#define RETURN_MIN( FUNCTION ) TYPE_PASTE( FUNCTION, _return_min ) +/* + * The minimum values which may be returned by each of the derived functions + * in the `lround' or the `llround' families. + */ +#define lround_return_min LONG_MIN +#define lroundf_return_min LONG_MIN +#define lroundl_return_min LONG_MIN + +#define llround_return_min LLONG_MIN +#define llroundf_return_min LLONG_MIN +#define llroundl_return_min LLONG_MIN + +#define REF_VALUE( VALUE ) REF_TYPE( FUNCTION, VALUE ) +#define REF_TYPE( FUNC, VAL ) TYPE_PASTE( FUNC, _ref )( VAL ) +/* + * Macros for expressing constant values of the appropriate data type, + * for use in each of the derived functions. + */ +#define round_ref( VALUE ) VALUE +#define lround_ref( VALUE ) VALUE +#define llround_ref( VALUE ) VALUE + +#define roundl_ref( VALUE ) TYPE_PASTE( VALUE, L ) +#define lroundl_ref( VALUE ) TYPE_PASTE( VALUE, L ) +#define llroundl_ref( VALUE ) TYPE_PASTE( VALUE, L ) + +#define roundf_ref( VALUE ) TYPE_PASTE( VALUE, F ) +#define lroundf_ref( VALUE ) TYPE_PASTE( VALUE, F ) +#define llroundf_ref( VALUE ) TYPE_PASTE( VALUE, F ) + +static __inline__ +INPUT_TYPE __attribute__(( always_inline )) round_internal( INPUT_TYPE x ) +#define ROUND_MODES ( FE_TONEAREST | FE_UPWARD | FE_DOWNWARD | FE_TOWARDZERO ) +{ + /* Generic helper function, for rounding of the input parameter value to + * the nearest integer value. + */ + INPUT_TYPE z; + unsigned short saved_CW, tmp_required_CW; + + /* Rounding method suggested by Danny Smith + * + * Save the FPU control word state, set rounding mode TONEAREST, round the + * input value, then restore the original FPU control word state. + */ + __asm__( "fnstcw %0;" : "=m"( saved_CW )); + tmp_required_CW = ( saved_CW & ~ROUND_MODES ) | FE_TONEAREST; + __asm__( "fldcw %0;" :: "m"( tmp_required_CW )); + __asm__( "frndint;" : "=t"( z ) : "0"( x )); + __asm__( "fldcw %0;" :: "m"( saved_CW )); + + /* We now have a possible rounded value; unfortunately the FPU uses the + * `round-to-even' rule for exact mid-way cases, where both C99 and POSIX + * require us to always round away from zero, so we need to adjust those + * mid-way cases which the FPU rounded in the wrong direction. + * + * Correction method suggested by Greg Chicares + */ + return x < REF_VALUE( 0.0 ) + ? /* + * For negative input values, an incorrectly rounded value will be + * exactly 0.5 greater than the original value; when we find such an + * exact rounding offset, we must subtract an additional 1.0 from the + * rounded result, otherwise we return the rounded result unchanged. + */ + z - x == REF_VALUE( 0.5 ) ? z - REF_VALUE( 1.0 ) : z + + : /* For positive input values, an incorrectly rounded value will be + * exactly 0.5 less than the original value; when we find such an exact + * rounding offset, we must add an additional 1.0 to the rounded result, + * otherwise we return the rounded result unchanged. + */ + x - z == REF_VALUE( 0.5 ) ? z + REF_VALUE( 1.0 ) : z; +} + +#endif /* !defined _ROUND_INTERNAL_H: $RCSfile: round_internal.h,v $: end of file */ diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/scalbn.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/scalbn.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + + .file "scalbn.S" + .text + .align 4 +.globl _scalbn + .def _scalbn; .scl 2; .type 32; .endef +_scalbn: + fildl 12(%esp) + fldl 4(%esp) + fscale + fstp %st(1) + ret + +.globl _scalbln + .set _scalbln,_scalbn diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/scalbnf.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/scalbnf.S Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + + .file "scalbnf.S" + .text + .align 4 +.globl _scalbnf + .def _scalbnf; .scl 2; .type 32; .endef +_scalbnf: + fildl 8(%esp) + flds 4(%esp) + fscale + fstp %st(1) + ret + +.globl _scalblnf + .set _scalblnf,_scalbnf diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/trunc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/trunc.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,16 @@ +#include +#include + +double +trunc (double _x){ + double retval; + unsigned short saved_cw; + unsigned short tmp_cw; + __asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */ + tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) + | FE_TOWARDZERO; + __asm__ ("fldcw %0;" : : "m" (tmp_cw)); + __asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ + __asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/math/truncf.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/math/truncf.c Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,17 @@ +#include +#include + +float +truncf (float _x) +{ + float retval; + unsigned short saved_cw; + unsigned short tmp_cw; + __asm__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */ + tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) + | FE_TOWARDZERO; + __asm__ ("fldcw %0;" : : "m" (tmp_cw)); + __asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ + __asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ + return retval; +} diff -r cbdf4575016d -r f8299bb6c872 src/build-msvctools/ranlib-msvc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/build-msvctools/ranlib-msvc Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,27 @@ +#!/bin/sh + +# ranlib-msvc +# Dummy software to make configure scripts happy +# +# Copyright (C) 2006 Michael Goffioul +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# + +cat < +#include +#include + +#ifndef PATH_MAX +# define PATH_MAX 260 +#endif + +#endif diff -r cbdf4575016d -r f8299bb6c872 src/gettext.mk --- a/src/gettext.mk Mon Jun 17 20:22:08 2013 -0400 +++ b/src/gettext.mk Mon Jun 17 22:43:11 2013 -0400 @@ -3,7 +3,7 @@ PKG := gettext $(PKG)_IGNORE := -$(PKG)_CHECKSUM := 5009deb02f67fc3c59c8ce6b82408d1d35d4e38f +$(PKG)_CHECKSUM := 47685e20abf9df6e5fede9efd04442943a96818b $(PKG)_SUBDIR := gettext-$($(PKG)_VERSION) $(PKG)_FILE := gettext-$($(PKG)_VERSION).tar.gz $(PKG)_URL := ftp://ftp.gnu.org/pub/gnu/gettext/$($(PKG)_FILE) @@ -24,6 +24,6 @@ --enable-threads=win32 \ --without-libexpat-prefix \ --without-libxml2-prefix \ - CONFIG_SHELL=$(SHELL) + CONFIG_SHELL=$(SHELL) && $(CONFIGURE_POST_HOOK) $(MAKE) -C '$(1)/gettext-runtime/intl' -j '$(JOBS)' install endef diff -r cbdf4575016d -r f8299bb6c872 src/libiconv.mk --- a/src/libiconv.mk Mon Jun 17 20:22:08 2013 -0400 +++ b/src/libiconv.mk Mon Jun 17 22:43:11 2013 -0400 @@ -22,10 +22,8 @@ $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \ --prefix='$(HOST_PREFIX)' \ $(ENABLE_SHARED_OR_STATIC) \ + CC='$(MXE_CC)' \ CPPFLAGS='$(MXE_CPPFLAGS)' \ - --disable-nls - $(MAKE) -C '$(1)/libcharset' -j '$(JOBS)' install - $(MAKE) -C '$(1)/lib' -j '$(JOBS)' install - $(INSTALL) -d '$(HOST_INCDIR)' - $(INSTALL) -m644 '$(1)/include/iconv.h.inst' '$(HOST_INCDIR)/iconv.h' + --disable-nls && $(CONFIGURE_POST_HOOK) + $(MAKE) -C '$(1)' -j '$(JOBS)' install endef diff -r cbdf4575016d -r f8299bb6c872 src/msvc-gettext-1.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/msvc-gettext-1.patch Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,17 @@ +diff -ur gettext-0.18.2-orig/gettext-runtime/intl/export.h gettext-0.18.2/gettext-runtime/intl/export.h +--- gettext-0.18.2-orig/gettext-runtime/intl/export.h 2012-12-04 01:28:58 -0500 ++++ gettext-0.18.2/gettext-runtime/intl/export.h 2013-06-15 22:18:02 -0400 +@@ -2,5 +2,13 @@ + #if @HAVE_VISIBILITY@ && BUILDING_LIBINTL + #define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default"))) + #else ++#ifdef _MSC_VER ++#ifdef BUILDING_LIBINTL ++#define LIBINTL_DLL_EXPORTED __declspec(dllexport) ++#else ++#define LIBINTL_DLL_EXPORTED __declspec(dllimport) ++#endif ++#else + #define LIBINTL_DLL_EXPORTED + #endif ++#endif diff -r cbdf4575016d -r f8299bb6c872 src/msvc-libiconv-1.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/msvc-libiconv-1.patch Mon Jun 17 22:43:11 2013 -0400 @@ -0,0 +1,184 @@ +diff -ur libiconv-1.14-orig/configure libiconv-1.14-new/configure +--- libiconv-1.14-orig/configure 2011-08-07 13:49:02 -0400 ++++ libiconv-1.14-new/configure 2013-06-14 15:31:17 -0400 +@@ -17212,8 +17212,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_errno_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/errno.h#{ +- s#.*"\(.*/errno.h\)".*#\1# ++ sed -n '\#[\\/]errno.h#{ ++ s#.*"\(.*[\\/]errno.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -18378,8 +18378,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdint_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/stdint.h#{ +- s#.*"\(.*/stdint.h\)".*#\1# ++ sed -n '\#[\\/]stdint.h#{ ++ s#.*"\(.*[\\/]stdint.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -19223,8 +19223,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_string_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/string.h#{ +- s#.*"\(.*/string.h\)".*#\1# ++ sed -n '\#[\\/]string.h#{ ++ s#.*"\(.*[\\/]string.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -19481,8 +19481,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_time_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/time.h#{ +- s#.*"\(.*/time.h\)".*#\1# ++ sed -n '\#[\\/]time.h#{ ++ s#.*"\(.*[\\/]time.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -19948,8 +19948,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_fcntl_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/fcntl.h#{ +- s#.*"\(.*/fcntl.h\)".*#\1# ++ sed -n '\#[\\/]fcntl.h#{ ++ s#.*"\(.*[\\/]fcntl.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -20418,8 +20418,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_signal_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/signal.h#{ +- s#.*"\(.*/signal.h\)".*#\1# ++ sed -n '\#[\\/]signal.h#{ ++ s#.*"\(.*[\\/]signal.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -20837,8 +20837,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stddef_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/stddef.h#{ +- s#.*"\(.*/stddef.h\)".*#\1# ++ sed -n '\#[\\/]stddef.h#{ ++ s#.*"\(.*[\\/]stddef.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -20896,8 +20896,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdio_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/stdio.h#{ +- s#.*"\(.*/stdio.h\)".*#\1# ++ sed -n '\#[\\/]stdio.h#{ ++ s#.*"\(.*[\\/]stdio.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -21033,8 +21033,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_stdlib_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/stdlib.h#{ +- s#.*"\(.*/stdlib.h\)".*#\1# ++ sed -n '\#[\\/]stdlib.h#{ ++ s#.*"\(.*[\\/]stdlib.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -21270,8 +21270,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_sys_stat_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/sys/stat.h#{ +- s#.*"\(.*/sys/stat.h\)".*#\1# ++ sed -n '\#[\\/]sys[\\/]stat.h#{ ++ s#.*"\(.*[\\/]sys[\\/]stat.h\)".*#\1# + s#^/[^/]#//&# + p + q +@@ -21392,8 +21392,8 @@ + *) gl_absname_cpp="$ac_cpp" ;; + esac + gl_cv_next_unistd_h='"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 | +- sed -n '\#/unistd.h#{ +- s#.*"\(.*/unistd.h\)".*#\1# ++ sed -n '\#[\\/]unistd.h#{ ++ s#.*"\(.*[\\/]unistd.h\)".*#\1# + s#^/[^/]#//&# + p + q +diff -ur libiconv-1.14-orig/include/iconv.h.build.in libiconv-1.14-new/include/iconv.h.build.in +--- libiconv-1.14-orig/include/iconv.h.build.in 2011-08-07 13:49:04 -0400 ++++ libiconv-1.14-new/include/iconv.h.build.in 2013-06-14 15:36:17 -0400 +@@ -26,9 +26,17 @@ + #if @HAVE_VISIBILITY@ && BUILDING_LIBICONV + #define LIBICONV_DLL_EXPORTED __attribute__((__visibility__("default"))) + #else ++#ifdef _MSC_VER ++#ifdef BUILDING_LIBICONV ++#define LIBICONV_DLL_EXPORTED __declspec (dllexport) ++#else ++#define LIBICONV_DLL_EXPORTED __declspec (dllimport) ++#endif ++#else + #define LIBICONV_DLL_EXPORTED + #endif +-extern LIBICONV_DLL_EXPORTED @DLL_VARIABLE@ int _libiconv_version; /* Likewise */ ++#endif ++extern LIBICONV_DLL_EXPORTED int _libiconv_version; /* Likewise */ + + /* We would like to #include any system header file which could define + iconv_t, 1. in order to eliminate the risk that the user gets compilation +diff -ur libiconv-1.14-orig/lib/Makefile.in libiconv-1.14-new/lib/Makefile.in +--- libiconv-1.14-orig/lib/Makefile.in 2011-08-07 13:48:03 -0400 ++++ libiconv-1.14-new/lib/Makefile.in 2013-06-14 15:39:20 -0400 +@@ -60,8 +60,8 @@ + SOURCES = $(srcdir)/iconv.c $(srcdir)/../libcharset/lib/localcharset.c $(srcdir)/relocatable.c + + OBJECTS = iconv.lo localcharset.lo relocatable.lo $(OBJECTS_EXP_@WOE32DLL@) $(OBJECTS_RES_@WOE32@) +-OBJECTS_EXP_yes = iconv-exports.lo +-OBJECTS_EXP_no = ++#OBJECTS_EXP_yes = iconv-exports.lo ++#OBJECTS_EXP_no = + OBJECTS_RES_yes = libiconv.res.lo + OBJECTS_RES_no = + +diff -ur libiconv-1.14-orig/srclib/stat.c libiconv-1.14-new/srclib/stat.c +--- libiconv-1.14-orig/srclib/stat.c 2011-08-07 09:42:06 -0400 ++++ libiconv-1.14-new/srclib/stat.c 2013-06-14 17:35:49 -0400 +@@ -35,6 +35,7 @@ + + #include + #include ++#include + #include + #include + #include "dosname.h" +diff -ur libiconv-1.14-orig/srclib/sys_stat.in.h libiconv-1.14-new/srclib/sys_stat.in.h +--- libiconv-1.14-orig/srclib/sys_stat.in.h 2011-08-07 09:42:06 -0400 ++++ libiconv-1.14-new/srclib/sys_stat.in.h 2013-06-14 17:33:10 -0400 +@@ -38,6 +38,9 @@ + + /* Get nlink_t. */ + #include ++#ifdef _MSC_VER ++typedef unsigned short mode_t; ++#endif + + /* Get struct timespec. */ + #include