2
1

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

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