Summary: | dev-db/sqlite - Use pread(), pread64(), pwrite(), pwrite64() | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Thomas Deutschmann (RETIRED) <whissi> |
Component: | Current packages | Assignee: | Arfrever Frehtes Taifersar Arahesis <arfrever.fta> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | proxy-maint |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Thomas Deutschmann (RETIRED)
2015-05-10 15:04:26 UTC
Mhh... > we are currently building dev-db/sqlite with support for pread. should be obviously > we are currently building dev-db/sqlite *without* support for pread. :> With glibc, on 64-bit architectures, pread() and pread64() probably behave identically: $ gcc -E -P - <<< "#include <unistd.h>" |& grep -E "typedef .* __off" typedef long int __off_t; typedef long int __off64_t; $ gcc -E -P -m32 - <<< "#include <unistd.h>" |& grep -E "typedef .* __off" __extension__ typedef long int __off_t; __extension__ typedef __quad_t __off64_t; $ gcc -E -P -m32 - <<< "#include <unistd.h>" |& grep -E "typedef .* __quad_t" __extension__ typedef long long int __quad_t; $ gcc -o test -x c - <<< $'#include <stdio.h>\nint main(){printf("sizeof(__off_t) = %zd\\nsizeof(__off64_t) = %zd\\n", sizeof(__off_t), sizeof(__off64_t));}' $ ./test sizeof(__off_t) = 8 sizeof(__off64_t) = 8 $ gcc -m32 -o test -x c - <<< $'#include <stdio.h>\nint main(){printf("sizeof(__off_t) = %zd\\nsizeof(__off64_t) = %zd\\n", sizeof(__off_t), sizeof(__off64_t));}' $ ./test sizeof(__off_t) = 4 sizeof(__off64_t) = 8 With _FILE_OFFSET_BITS=64, pread() is redirection to pread64(): $ gcc -E -P - <<< "#include <unistd.h>" | grep -EA1 "(pread|pwrite)" extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset) ; extern ssize_t pwrite (int __fd, const void *__buf, size_t __n, __off_t __offset) ; $ gcc -E -P -D_LARGEFILE64_SOURCE - <<< "#include <unistd.h>" | grep -EA1 "(pread|pwrite)" extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset) ; extern ssize_t pwrite (int __fd, const void *__buf, size_t __n, __off_t __offset) ; extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) ; extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n, __off64_t __offset) ; $ gcc -E -P -D_FILE_OFFSET_BITS=64 - <<< "#include <unistd.h>" | grep -E "(pread|pwrite)" extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pread64") ; extern ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pwrite64") ; $ gcc -E -P -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 - <<< "#include <unistd.h>" | grep -EA1 "(pread|pwrite)" extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pread64") ; extern ssize_t pwrite (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset) __asm__ ("" "pwrite64") ; extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) ; extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n, __off64_t __offset) ; $ gcc -S -D_FILE_OFFSET_BITS=64 -o - -x c - <<< $'#include <unistd.h>\nint main(){pread(0,0,0,0);pwrite(0,0,0,0);}' | grep -E "(pread|pwrite)" call pread64 call pwrite64 $ gcc -S -m32 -D_FILE_OFFSET_BITS=64 -o - -x c - <<< $'#include <unistd.h>\nint main(){pread(0,0,0,0);pwrite(0,0,0,0);}' | grep -E "(pread|pwrite)" call pread64 call pwrite64 src/sqliteInt.h of SQLite 3.8.10.1: #ifndef SQLITE_DISABLE_LFS # define _LARGE_FILE 1 # ifndef _FILE_OFFSET_BITS # define _FILE_OFFSET_BITS 64 # endif # define _LARGEFILE_SOURCE 1 #endif After building of SQLite on 64-bit architecture with -DUSE_PREAD and without -DUSE_PREAD64: $ readelf -s .libs/libsqlite3.so | grep -E "(pread|pwrite)" 60: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pread64@GLIBC_2.2.5 (3) 75: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pwrite64@GLIBC_2.2.5 (3) 1619: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pread64@@GLIBC_2.2.5 1651: 0000000000000000 0 FUNC GLOBAL DEFAULT UND pwrite64@@GLIBC_2.2.5 pread64() and pwrite64() are declared when _LARGEFILE64_SOURCE is defined. src/sqliteInt.h of SQLite 3.8.10.1: #if defined(__GNUC__) && !defined(_GNU_SOURCE) # define _GNU_SOURCE #endif features.h of glibc 2.20: #ifdef _GNU_SOURCE ... # undef _LARGEFILE64_SOURCE # define _LARGEFILE64_SOURCE 1 ... #endif So using of pread64() and pwrite64() with glibc and compiler not defining __GNUC__ might require using -D_LARGEFILE64_SOURCE (potentially using append-lfs-flags() from flag-o-matic.eclass). Fixed in dev-db/sqlite-3.8.10.1. |