qt5base-0007-detect-posix_fallocate-at-configure-time.patch 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. From 46e632e2555b6b8abe6b8d8ad7d255e27c128e25 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= <fatih.asici@gmail.com>
  3. Date: Mon, 11 Nov 2013 17:04:46 +0200
  4. Subject: [PATCH] Detect posix_fallocate at configure time
  5. Testing feature macros is not enough for uclibc. Fixes build of the built-in
  6. sqlite3 with uclibc <= 0.9.33.2. Later versions will have posix_fallocate().
  7. Change-Id: I918a52777ac63624635802221effc6b86fa2269c
  8. Signed-off-by: Fatih Aşıcı <fatih.asici@gmail.com>
  9. Reported-Upstream: https://codereview.qt-project.org/70935
  10. ---
  11. .../unix/posix_fallocate/posix_fallocate.cpp | 53 ++++++++++++++++++++++
  12. .../unix/posix_fallocate/posix_fallocate.pro | 2 +
  13. configure | 14 ++++++
  14. src/3rdparty/sqlite.pri | 1 +
  15. src/3rdparty/sqlite/sqlite3.c | 7 ---
  16. 5 files changed, 70 insertions(+), 7 deletions(-)
  17. create mode 100644 config.tests/unix/posix_fallocate/posix_fallocate.cpp
  18. create mode 100644 config.tests/unix/posix_fallocate/posix_fallocate.pro
  19. diff --git a/config.tests/unix/posix_fallocate/posix_fallocate.cpp b/config.tests/unix/posix_fallocate/posix_fallocate.cpp
  20. new file mode 100644
  21. index 0000000..5acd45a
  22. --- /dev/null
  23. +++ b/config.tests/unix/posix_fallocate/posix_fallocate.cpp
  24. @@ -0,0 +1,53 @@
  25. +/****************************************************************************
  26. +**
  27. +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
  28. +** Contact: http://www.qt-project.org/legal
  29. +**
  30. +** This file is part of the config.tests of the Qt Toolkit.
  31. +**
  32. +** $QT_BEGIN_LICENSE:LGPL$
  33. +** Commercial License Usage
  34. +** Licensees holding valid commercial Qt licenses may use this file in
  35. +** accordance with the commercial license agreement provided with the
  36. +** Software or, alternatively, in accordance with the terms contained in
  37. +** a written agreement between you and Digia. For licensing terms and
  38. +** conditions see http://qt.digia.com/licensing. For further information
  39. +** use the contact form at http://qt.digia.com/contact-us.
  40. +**
  41. +** GNU Lesser General Public License Usage
  42. +** Alternatively, this file may be used under the terms of the GNU Lesser
  43. +** General Public License version 2.1 as published by the Free Software
  44. +** Foundation and appearing in the file LICENSE.LGPL included in the
  45. +** packaging of this file. Please review the following information to
  46. +** ensure the GNU Lesser General Public License version 2.1 requirements
  47. +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  48. +**
  49. +** In addition, as a special exception, Digia gives you certain additional
  50. +** rights. These rights are described in the Digia Qt LGPL Exception
  51. +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  52. +**
  53. +** GNU General Public License Usage
  54. +** Alternatively, this file may be used under the terms of the GNU
  55. +** General Public License version 3.0 as published by the Free Software
  56. +** Foundation and appearing in the file LICENSE.GPL included in the
  57. +** packaging of this file. Please review the following information to
  58. +** ensure the GNU General Public License version 3.0 requirements will be
  59. +** met: http://www.gnu.org/copyleft/gpl.html.
  60. +**
  61. +**
  62. +** $QT_END_LICENSE$
  63. +**
  64. +****************************************************************************/
  65. +
  66. +#include <fcntl.h>
  67. +
  68. +int main(int, char **)
  69. +{
  70. +#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
  71. + return ::posix_fallocate(0, 0, 0);
  72. +#else
  73. +# error posix_fallocate not available
  74. + // MIPSpro doesn't understand #error, so force a compiler error
  75. + force_compiler_error = true;
  76. +#endif
  77. +}
  78. diff --git a/config.tests/unix/posix_fallocate/posix_fallocate.pro b/config.tests/unix/posix_fallocate/posix_fallocate.pro
  79. new file mode 100644
  80. index 0000000..f01b15f
  81. --- /dev/null
  82. +++ b/config.tests/unix/posix_fallocate/posix_fallocate.pro
  83. @@ -0,0 +1,2 @@
  84. +SOURCES = posix_fallocate.cpp
  85. +CONFIG -= qt dylib
  86. diff --git a/configure b/configure
  87. index 81e2a93..b67ed89 100755
  88. --- a/configure
  89. +++ b/configure
  90. @@ -968,6 +968,7 @@ CFG_MIPS_DSP=auto
  91. CFG_MIPS_DSPR2=auto
  92. CFG_CLOCK_GETTIME=auto
  93. CFG_CLOCK_MONOTONIC=auto
  94. +CFG_POSIX_FALLOCATE=auto
  95. CFG_MREMAP=auto
  96. CFG_GETADDRINFO=auto
  97. CFG_IPV6IFNAME=auto
  98. @@ -5653,6 +5654,15 @@ elif [ "$CFG_CLOCK_GETTIME" = "no" ]; then
  99. CFG_CLOCK_MONOTONIC=no
  100. fi
  101. +# detect posix_fallocate
  102. +if [ "$CFG_POSIX_FALLOCATE" = "auto" ]; then
  103. + if compileTest unix/posix_fallocate "posix_fallocate"; then
  104. + CFG_POSIX_FALLOCATE=yes
  105. + else
  106. + CFG_POSIX_FALLOCATE=no
  107. + fi
  108. +fi
  109. +
  110. # detect mremap
  111. if [ "$CFG_MREMAP" = "auto" ]; then
  112. if compileTest unix/mremap "mremap"; then
  113. @@ -5970,6 +5980,9 @@ fi
  114. if [ "$CFG_CLOCK_MONOTONIC" = "yes" ]; then
  115. QT_CONFIG="$QT_CONFIG clock-monotonic"
  116. fi
  117. +if [ "$CFG_POSIX_FALLOCATE" = "yes" ]; then
  118. + QT_CONFIG="$QT_CONFIG posix_fallocate"
  119. +fi
  120. if [ "$CFG_MREMAP" = "yes" ]; then
  121. QT_CONFIG="$QT_CONFIG mremap"
  122. fi
  123. @@ -6449,6 +6462,7 @@ QMakeVar set sql-plugins "$SQL_PLUGINS"
  124. [ "$CFG_GLIB" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GLIB"
  125. [ "$CFG_QGTKSTYLE" != "yes" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_STYLE_GTK"
  126. [ "$CFG_CLOCK_MONOTONIC" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_CLOCK_MONOTONIC"
  127. +[ "$CFG_POSIX_FALLOCATE" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_POSIX_FALLOCATE"
  128. [ "$CFG_MREMAP" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_MREMAP"
  129. [ "$CFG_GETADDRINFO" = "no" ]&& QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GETADDRINFO"
  130. [ "$CFG_IPV6IFNAME" = "no" ] && QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_IPV6IFNAME"
  131. diff --git a/src/3rdparty/sqlite.pri b/src/3rdparty/sqlite.pri
  132. index 58d4ddd..072502c 100644
  133. --- a/src/3rdparty/sqlite.pri
  134. +++ b/src/3rdparty/sqlite.pri
  135. @@ -1,5 +1,6 @@
  136. CONFIG(release, debug|release):DEFINES *= NDEBUG
  137. DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE SQLITE_ENABLE_FTS3 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_RTREE
  138. !contains(CONFIG, largefile):DEFINES += SQLITE_DISABLE_LFS
  139. +contains(QT_CONFIG, posix_fallocate):DEFINES += HAVE_POSIX_FALLOCATE=1
  140. INCLUDEPATH += $$PWD/sqlite
  141. SOURCES += $$PWD/sqlite/sqlite3.c
  142. diff --git a/src/3rdparty/sqlite/sqlite3.c b/src/3rdparty/sqlite/sqlite3.c
  143. index 03fa649..1ae9be2 100644
  144. --- a/src/3rdparty/sqlite/sqlite3.c
  145. +++ b/src/3rdparty/sqlite/sqlite3.c
  146. @@ -22935,13 +22935,6 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
  147. */
  148. #if SQLITE_OS_UNIX /* This file is used on unix only */
  149. -/* Use posix_fallocate() if it is available
  150. -*/
  151. -#if !defined(HAVE_POSIX_FALLOCATE) \
  152. - && (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L)
  153. -# define HAVE_POSIX_FALLOCATE 1
  154. -#endif
  155. -
  156. /*
  157. ** There are various methods for file locking used for concurrency
  158. ** control:
  159. --
  160. 1.8.4.rc3