commit 06a43e860f7a9e7e21f3d320aa2b2aed69635d38
Author: Georg Baum <[email protected]>
Date: Thu May 5 13:05:12 2016 +0200
Mingw-w64 build fixes for long long
On mingw-w64, long long (64bit wide) is larger than long (32bit wide).
Therefore we need some more specializations for string, docstring,
otextstream and << overloaded ostream functions. The configuration code
is by me, the source code changes by Shankar Giri Venkita Giri (bug 10053).
diff --git a/configure.ac b/configure.ac
index 3f6b89c..6de63c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,6 +130,13 @@ LYX_CHECK_CALLSTACK_PRINTING
# Needed for our char_type
AC_CHECK_SIZEOF(wchar_t)
+# Needed for Mingw-w64
+AC_TYPE_LONG_LONG_INT
+if test "$ac_cv_type_long_long_int" = yes; then
+ AC_CHECK_SIZEOF(long)
+ AC_CHECK_SIZEOF(long long)
+fi
+
### We need iconv for unicode support (Qt4 frontend requires it too)
AM_ICONV
if test "$am_cv_func_iconv" = no; then
@@ -324,6 +331,12 @@ char * strerror(int n);
# define USE_WCHAR_T
#endif
+#ifdef HAVE_LONG_LONG_INT
+#if SIZEOF_LONG_LONG > SIZEOF_LONG
+#define LYX_USE_LONG_LONG
+#endif
+#endif
+
#endif
])
diff --git a/development/cmake/ConfigureChecks.cmake
b/development/cmake/ConfigureChecks.cmake
index 6dc82a7..825813b 100644
--- a/development/cmake/ConfigureChecks.cmake
+++ b/development/cmake/ConfigureChecks.cmake
@@ -116,6 +116,13 @@ SIZEOF_WCHAR_T_IS_4)
check_cxx_source_compiles(
"
+ int i[ ( sizeof(long long)>sizeof(long) ? 1 : -1 ) ];
+ int main(){return 0;}
+ "
+SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG)
+
+check_cxx_source_compiles(
+ "
#include <execinfo.h>
#include <cxxabi.h>
int main() {
diff --git a/development/cmake/configCompiler.h.cmake
b/development/cmake/configCompiler.h.cmake
index 858cfc9..6eb627a 100644
--- a/development/cmake/configCompiler.h.cmake
+++ b/development/cmake/configCompiler.h.cmake
@@ -42,6 +42,7 @@
#cmakedefine HAVE_MAGIC_H 1
#cmakedefine SIZEOF_WCHAR_T_IS_2 1
#cmakedefine SIZEOF_WCHAR_T_IS_4 1
+#cmakedefine SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG 1
#ifdef SIZEOF_WCHAR_T_IS_2
# define SIZEOF_WCHAR_T 2
@@ -51,6 +52,12 @@
# endif
#endif
+#ifdef HAVE_LONG_LONG
+#ifdef SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG
+#define LYX_USE_LONG_LONG
+#endif
+#endif
+
#cmakedefine GETTEXT_FOUND 1
#cmakedefine HAVE_ALLOCA 1
diff --git a/development/cmake/configCompiler.h.msvc
b/development/cmake/configCompiler.h.msvc
index 334015b..5ff2e9d 100644
--- a/development/cmake/configCompiler.h.msvc
+++ b/development/cmake/configCompiler.h.msvc
@@ -152,6 +152,12 @@
# define USE_WCHAR_T
#endif
+#ifdef HAVE_LONG_LONG
+#ifdef SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG
+#define LYX_USE_LONG_LONG
+#endif
+#endif
+
#if defined(MAKE_INTL_LIB) && defined(_MSC_VER)
#define __attribute__(x)
#define inline
diff --git a/src/support/convert.cpp b/src/support/convert.cpp
index 6b985f5..58a5647 100644
--- a/src/support/convert.cpp
+++ b/src/support/convert.cpp
@@ -90,6 +90,22 @@ docstring convert<docstring>(unsigned long ul)
}
+#ifdef LYX_USE_LONG_LONG
+template<>
+string convert<string>(unsigned long long ull)
+{
+ return lexical_cast<string>(ull);
+}
+
+
+template<>
+docstring convert<docstring>(unsigned long long ull)
+{
+ return from_ascii(lexical_cast<string>(ull));
+}
+#endif
+
+
template<>
string convert<string>(long l)
{
@@ -104,6 +120,22 @@ docstring convert<docstring>(long l)
}
+#ifdef LYX_USE_LONG_LONG
+template<>
+string convert<string>(long long ll)
+{
+ return lexical_cast<string>(ll);
+}
+
+
+template<>
+docstring convert<docstring>(long long ll)
+{
+ return from_ascii(lexical_cast<string>(ll));
+}
+#endif
+
+
template<>
string convert<string>(float f)
{
diff --git a/src/support/convert.h b/src/support/convert.h
index e72fe61..fb069c9 100644
--- a/src/support/convert.h
+++ b/src/support/convert.h
@@ -33,8 +33,16 @@ template<> std::string convert<std::string>(unsigned int ui);
template<> docstring convert<docstring>(unsigned int ui);
template<> std::string convert<std::string>(unsigned long ul);
template<> docstring convert<docstring>(unsigned long ul);
+#ifdef LYX_USE_LONG_LONG
+template<> std::string convert<std::string>(unsigned long long ull);
+template<> docstring convert<docstring>(unsigned long long ull);
+#endif
template<> std::string convert<std::string>(long l);
template<> docstring convert<docstring>(long l);
+#ifdef LYX_USE_LONG_LONG
+template<> std::string convert<std::string>(long long ll);
+template<> docstring convert<docstring>(long long ll);
+#endif
template<> std::string convert<std::string>(float f);
template<> std::string convert<std::string>(double d);
template<> int convert<int>(std::string const & s);
diff --git a/src/support/debug.cpp b/src/support/debug.cpp
index 538b487..bff9bf4 100644
--- a/src/support/debug.cpp
+++ b/src/support/debug.cpp
@@ -243,6 +243,12 @@ LyXErr & operator<<(LyXErr & l, long t)
{ return toStream(l, t); }
LyXErr & operator<<(LyXErr & l, unsigned long t)
{ return toStream(l, t); }
+#ifdef LYX_USE_LONG_LONG
+LyXErr & operator<<(LyXErr & l, long long t)
+{ return toStream(l, t); }
+LyXErr & operator<<(LyXErr & l, unsigned long long t)
+{ return toStream(l, t); }
+#endif
LyXErr & operator<<(LyXErr & l, double t)
{ return toStream(l, t); }
LyXErr & operator<<(LyXErr & l, string const & t)
diff --git a/src/support/debug.h b/src/support/debug.h
index 2165389..b98dfd0 100644
--- a/src/support/debug.h
+++ b/src/support/debug.h
@@ -202,6 +202,10 @@ LyXErr & operator<<(LyXErr &, int);
LyXErr & operator<<(LyXErr &, unsigned int);
LyXErr & operator<<(LyXErr &, long);
LyXErr & operator<<(LyXErr &, unsigned long);
+#ifdef LYX_USE_LONG_LONG
+LyXErr & operator<<(LyXErr &, long long);
+LyXErr & operator<<(LyXErr &, unsigned long long);
+#endif
LyXErr & operator<<(LyXErr &, double);
LyXErr & operator<<(LyXErr &, std::string const &);
LyXErr & operator<<(LyXErr &, docstring const &);
diff --git a/src/support/docstring.cpp b/src/support/docstring.cpp
index f44259d..95c86b3 100644
--- a/src/support/docstring.cpp
+++ b/src/support/docstring.cpp
@@ -514,7 +514,7 @@ protected:
return do_put_helper(oit, b, fill, v);
}
-#ifdef _GLIBCXX_USE_LONG_LONG
+#ifdef LYX_USE_LONG_LONG
iter_type
do_put(iter_type oit, ios_base & b, char_type fill, long long v) const
{
@@ -675,7 +675,7 @@ protected:
return do_get_integer(iit, eit, b, err, v);
}
-#ifdef _GLIBCXX_USE_LONG_LONG
+#ifdef LYX_USE_LONG_LONG
iter_type
do_get(iter_type iit, iter_type eit, ios_base & b,
ios_base::iostate & err, long long & v) const
diff --git a/src/support/lstrings.cpp b/src/support/lstrings.cpp
index f4aba23..6d5f866 100644
--- a/src/support/lstrings.cpp
+++ b/src/support/lstrings.cpp
@@ -1437,6 +1437,17 @@ docstring bformat(docstring const & fmt, long arg1)
}
+#ifdef LYX_USE_LONG_LONG
+template<>
+docstring bformat(docstring const & fmt, long long arg1)
+{
+ LATTEST(contains(fmt, from_ascii("%1$d")));
+ docstring const str = subst(fmt, from_ascii("%1$d"),
convert<docstring>(arg1));
+ return subst(str, from_ascii("%%"), from_ascii("%"));
+}
+#endif
+
+
template<>
docstring bformat(docstring const & fmt, unsigned int arg1)
{
diff --git a/src/support/lstrings.h b/src/support/lstrings.h
index 269b5a6..ac310c5 100644
--- a/src/support/lstrings.h
+++ b/src/support/lstrings.h
@@ -357,6 +357,9 @@ docstring bformat(docstring const & fmt, Arg1, Arg2, Arg3,
Arg4);
template<> docstring bformat(docstring const & fmt, int arg1);
template<> docstring bformat(docstring const & fmt, long arg1);
+#ifdef LYX_USE_LONG_LONG
+template<> docstring bformat(docstring const & fmt, long long arg1);
+#endif
template<> docstring bformat(docstring const & fmt, unsigned int arg1);
template<> docstring bformat(docstring const & fmt, docstring arg1);
template<> docstring bformat(docstring const & fmt, char * arg1);
diff --git a/src/texstream.cpp b/src/texstream.cpp
index 3268dca..16f8dfb 100644
--- a/src/texstream.cpp
+++ b/src/texstream.cpp
@@ -215,6 +215,11 @@ template otexrowstream & operator<< <unsigned
int>(otexrowstream &,
template otexrowstream & operator<< <unsigned long>(otexrowstream &,
unsigned long);
+#ifdef LYX_USE_LONG_LONG
+template otexrowstream & operator<< <unsigned long long>(otexrowstream &,
+ unsigned long long);
+#endif
+
template <typename Type>
otexstream & operator<<(otexstream & ots, Type value)
@@ -230,5 +235,8 @@ template otexstream & operator<< <double>(otexstream &,
double);
template otexstream & operator<< <int>(otexstream &, int);
template otexstream & operator<< <unsigned int>(otexstream &, unsigned int);
template otexstream & operator<< <unsigned long>(otexstream &, unsigned long);
+#ifdef LYX_USE_LONG_LONG
+template otexstream & operator<< <unsigned long long>(otexstream &, unsigned
long long);
+#endif
}