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).
This commit is contained in:
Georg Baum 2016-05-05 13:05:12 +02:00 committed by Richard Heck
parent e07a01a3c3
commit d5f2bad461
12 changed files with 107 additions and 2 deletions

View 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
])

View 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>

View 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
@ -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

View File

@ -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

View 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)
{

View 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);

View 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)

View 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 &);

View 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

View 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)
{

View 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);

View 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
}