]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: tests: virmockstathelpers: replace check for _FILE_OFFSET_BITS
authorPavel Hrdina <phrdina@redhat.com>
Fri, 24 Jul 2020 12:02:39 +0000 (14:02 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 3 Aug 2020 07:26:36 +0000 (09:26 +0200)
Meson always defines _FILE_OFFSET_BITS=64 which effectively makes
mocking of non 64-bit stat functions dead code.

On linux it was not an issue because we use the 64-bit versions but
on FreeBSD there are not 64-bit versions, there is only stat & lstat.

We cannot simply drop the check as that would resolve to compilation
error on 64-bit linux:

{standard input}: Assembler messages:
{standard input}:11468: Error: symbol `__xstat64' is already defined
{standard input}:11679: Error: symbol `__xstat64.cold' is already defined
{standard input}:12034: Error: symbol `__lxstat64' is already defined
{standard input}:12245: Error: symbol `__lxstat64.cold' is already defined

So we have to replace the _FILE_OFFSET_BITS with a check if the
corresponding 64-bit version of the stat function exists.

Replicate the meson behavior by always defining _FILE_OFFSET_BITS
instead of using AC_SYS_LARGEFILE otherwise this change would break
our tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
configure.ac
tests/virmockstathelpers.c

index 7acf3f2fe70b52bb456d008acfcdb740c064b5a0..796abdbb347451ec5da8da72e4cef93d018f55f8 100644 (file)
@@ -148,7 +148,7 @@ fi
 
 
 dnl get 64-int interfaces on 32-bit platforms
-AC_SYS_LARGEFILE
+CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64"
 
 AC_TYPE_UID_T
 
index ba26e7bd4554ed96b7fd7b9421daca9d2f804c1e..2c3715ae0cc8b01010b6b66048da27e7e0f64a4e 100644 (file)
  *
  * On 32-bit hosts they refer to the 32-bit & 64-bit ABIs respectively.
  *
- * Libvirt uses _FILE_OFFSET_BITS=64 on 32-bit hosts, which causes the
- * C library to transparently rewrite stat() calls to be stat64() calls.
- * Libvirt will never see the 32-bit ABI from the traditional stat()
- * call. We cannot assume this rewriting is done using a macro. It might
- * be, but on GLibC it is done with a magic __asm__ statement to apply
- * the rewrite at link time instead of at preprocessing.
+ * With meson libvirt will have _FILE_OFFSET_BITS=64 always defined.
+ * On 32-bit hosts it causes the C library to transparently rewrite
+ * stat() calls to be stat64() calls. Libvirt will never see the 32-bit
+ * ABI from the traditional stat() call. We cannot assume this rewriting
+ * is done using a macro. It might be, but on GLibC it is done with a
+ * magic __asm__ statement to apply the rewrite at link time instead of
+ * at preprocessing.
  *
  * In GLibC there may be two additional functions exposed by the headers,
  * __xstat() and __xstat64(). When these exist, stat() and stat64() are
  * With all this in mind the list of functions we have to mock will depend
  * on several factors
  *
- *  - If _FILE_OFFSET_BITS is set, then we are on a 32-bit host, and we
- *    only need to mock stat64 and __xstat64. The other stat / __xstat
- *    functions exist, but we'll never call them so they can be ignored
- *    for mocking.
- *
- *  - If _FILE_OFFSET_BITS is not set, then we are on a 64-bit host and
- *    we should mock stat, stat64, __xstat & __xstat64. Either may be
- *    called by app code.
+ *  - If the stat or __xstat but there is no 64-bit version.
  *
  *  - If __xstat & __xstat64 exist, then stat & stat64 will not exist
  *    as symbols in the library, so the latter should not be mocked.
 
 
 
-#if defined(HAVE_STAT) && !defined(HAVE___XSTAT) && !defined(_FILE_OFFSET_BITS)
+#if defined(HAVE_STAT) && !defined(HAVE___XSTAT) && !defined(HAVE_STAT64)
 # define MOCK_STAT
 #endif
 #if defined(HAVE_STAT64) && !defined(HAVE___XSTAT64)
 # define MOCK_STAT64
 #endif
-#if defined(HAVE___XSTAT) && !defined(_FILE_OFFSET_BITS)
+#if defined(HAVE___XSTAT) && !defined(HAVE___XSTAT64)
 # define MOCK___XSTAT
 #endif
 #if defined(HAVE___XSTAT64)
 # define MOCK___XSTAT64
 #endif
-#if defined(HAVE_LSTAT) && !defined(HAVE___LXSTAT) && !defined(_FILE_OFFSET_BITS)
+#if defined(HAVE_LSTAT) && !defined(HAVE___LXSTAT) && !defined(HAVE_LSTAT64)
 # define MOCK_LSTAT
 #endif
 #if defined(HAVE_LSTAT64) && !defined(HAVE___LXSTAT64)
 # define MOCK_LSTAT64
 #endif
-#if defined(HAVE___LXSTAT) && !defined(_FILE_OFFSET_BITS)
+#if defined(HAVE___LXSTAT) && !defined(HAVE___LXSTAT64)
 # define MOCK___LXSTAT
 #endif
 #if defined(HAVE___LXSTAT64)