]> git.lyx.org Git - lyx.git/commitdiff
Mingw-w64 build fixes for long long
authorGeorg Baum <baum@lyx.org>
Thu, 5 May 2016 11:05:12 +0000 (13:05 +0200)
committerRichard Heck <rgheck@lyx.org>
Sun, 29 May 2016 21:55:43 +0000 (17:55 -0400)
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).

12 files changed:
configure.ac
development/cmake/ConfigureChecks.cmake
development/cmake/configCompiler.h.cmake
development/cmake/configCompiler.h.msvc
src/support/convert.cpp
src/support/convert.h
src/support/debug.cpp
src/support/debug.h
src/support/docstring.cpp
src/support/lstrings.cpp
src/support/lstrings.h
src/texstream.cpp

index 3f6b89c376fec34fe4b4ff902788316411cb50a5..6de63c9fd70e65cdc40388ec645395ef25148838 100644 (file)
@@ -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
 ])
 
index 6dc82a7d8788d75484792336cf3280da801de11d..825813b50186b11d6f8b223862311519004d2feb 100644 (file)
@@ -114,6 +114,13 @@ check_cxx_source_compiles(
        "
 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>
index 858cfc971144f5ff4baf38b32bcfd3b50d33c737..6eb627add763a558b94fbba7ec205ccc1285fe3f 100644 (file)
@@ -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
 #  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
index 334015b5e97573d1aafbb7aa618927baf42c952a..5ff2e9dcf3cf0e33051374885000146c09bcb02c 100644 (file)
 #  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
index 6b985f50baf26042d972fa8d4ea8f70127763ea1..58a56479a3abe377761d8a1afae8da3ace6ff322 100644 (file)
@@ -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)
 {
index e72fe61b5667363e846ee4bc0f5ee02e7b475949..fb069c98c312bf7a6a39da7740b414e5e11873c7 100644 (file)
@@ -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);
index 538b4877600f3cd5d5f6715ff4b97155a71542f7..bff9bf415a993a2cda8768a869f243884de52107 100644 (file)
@@ -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)
index 216538958d62c70af970541e927c9937c5351b7f..b98dfd0eab5fe988e75121907bd4045b04d75873 100644 (file)
@@ -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 &);
index f44259d349335623789c34d891bd4d6a72aa3f36..95c86b3665f2877052e543556e25d382fcaffcba 100644 (file)
@@ -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
index f4aba23c0a530d7c7e0aa4617b0950835776b875..6d5f86672fda133b10f060ecd346e18bee01b4e4 100644 (file)
@@ -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)
 {
index 269b5a656484f0b8de6f121dd1e3b22c054ff87c..ac310c59c43dcc598e6a6016c447e91a0bc274d2 100644 (file)
@@ -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);
index 3268dca7b23f954501ef4cfd2c99eefd87d25cd7..16f8dfbe68dee11acfa0a76fbf5e829d2f15ab6e 100644 (file)
@@ -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
 
 }