Use posix_fadvise(2) only if it's available.
This commit is contained in:
parent
5dab658d09
commit
b75cd05c37
72
configure
vendored
72
configure
vendored
@ -4,12 +4,6 @@
|
|||||||
VERSION=0.19
|
VERSION=0.19
|
||||||
|
|
||||||
# Ensure that we do not inherit these from env
|
# Ensure that we do not inherit these from env
|
||||||
STRLCPY=
|
|
||||||
STRLCAT=
|
|
||||||
VASPRINTF=
|
|
||||||
HUMANIZE_NUMBER=
|
|
||||||
LIBFETCH=
|
|
||||||
PROPLIB=
|
|
||||||
OS=
|
OS=
|
||||||
BUILD=
|
BUILD=
|
||||||
HOST=
|
HOST=
|
||||||
@ -330,21 +324,38 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC _$func.c -o _$func 2>/dev/null; then
|
if $XCC _$func.c -o _$func 2>/dev/null; then
|
||||||
VASPRINTF=yes
|
echo yes.
|
||||||
echo "CPPFLAGS += -DHAVE_VASPRINTF" >> $CONFIG_MK
|
echo "CPPFLAGS += -DHAVE_VASPRINTF" >> $CONFIG_MK
|
||||||
else
|
else
|
||||||
VASPRINTF=no
|
echo no.
|
||||||
echo "COMPAT_SRCS+= compat/vasprintf.o" >>$CONFIG_MK
|
echo "COMPAT_SRCS+= compat/vasprintf.o" >>$CONFIG_MK
|
||||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||||
fi
|
fi
|
||||||
echo "$VASPRINTF."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
|
|
||||||
|
# Check for posix_fadvise(2)
|
||||||
|
func=posix_fadvise
|
||||||
|
printf "Checking for $func() ... "
|
||||||
|
cat <<EOF >_$func.c
|
||||||
|
#include <fcntl.h>
|
||||||
|
int main(void) {
|
||||||
|
posix_fadvise(0, 0, 0, POSIX_FADV_NORMAL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
if $XCC _$func.c -o _$func 2>/dev/null; then
|
||||||
|
echo "yes."
|
||||||
|
echo "CPPFLAGS += -DHAVE_POSIX_FADVISE" >>$CONFIG_MK
|
||||||
|
else
|
||||||
|
echo "no."
|
||||||
|
fi
|
||||||
|
rm -f _$func _$func.c
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for strcasestr().
|
# Check for strcasestr().
|
||||||
#
|
#
|
||||||
func=strcasestr
|
func=strcasestr
|
||||||
printf "Checking for $func() ..."
|
printf "Checking for $func() ... "
|
||||||
cat <<EOF >_$func.c
|
cat <<EOF >_$func.c
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -356,14 +367,13 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC _$func.c -o _$func 2>/dev/null; then
|
if $XCC _$func.c -o _$func 2>/dev/null; then
|
||||||
STRCASESTR=yes
|
echo yes.
|
||||||
echo "CPPFLAGS += -DHAVE_STRCASESTR" >>$CONFIG_MK
|
echo "CPPFLAGS += -DHAVE_STRCASESTR" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
STRCASESTR=no
|
echo no.
|
||||||
echo "COMPAT_SRCS += compat/strcasestr.o" >>$CONFIG_MK
|
echo "COMPAT_SRCS += compat/strcasestr.o" >>$CONFIG_MK
|
||||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||||
fi
|
fi
|
||||||
echo "$STRCASESTR."
|
|
||||||
rm -f _$func _$func.c
|
rm -f _$func _$func.c
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -381,14 +391,13 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC _$func.c -o _$func 2>/dev/null; then
|
if $XCC _$func.c -o _$func 2>/dev/null; then
|
||||||
STRLCPY=yes
|
echo yes.
|
||||||
echo "CPPFLAGS += -DHAVE_STRLCPY" >> $CONFIG_MK
|
echo "CPPFLAGS += -DHAVE_STRLCPY" >> $CONFIG_MK
|
||||||
else
|
else
|
||||||
STRLCPY=no
|
echo no.
|
||||||
echo "COMPAT_SRCS += compat/strlcpy.o" >>$CONFIG_MK
|
echo "COMPAT_SRCS += compat/strlcpy.o" >>$CONFIG_MK
|
||||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||||
fi
|
fi
|
||||||
echo "$STRLCPY."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -405,14 +414,13 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC _$func.c -o _$func 2>/dev/null; then
|
if $XCC _$func.c -o _$func 2>/dev/null; then
|
||||||
STRLCAT=yes
|
echo yes.
|
||||||
echo "CPPFLAGS += -DHAVE_STRLCAT" >>$CONFIG_MK
|
echo "CPPFLAGS += -DHAVE_STRLCAT" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
STRLCAT=no
|
echo no.
|
||||||
echo "COMPAT_SRCS += compat/strlcat.o" >>$CONFIG_MK
|
echo "COMPAT_SRCS += compat/strlcat.o" >>$CONFIG_MK
|
||||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||||
fi
|
fi
|
||||||
echo "$STRLCAT."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -429,14 +437,13 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC -lutil _$func.c -o _$func 2>/dev/null; then
|
if $XCC -lutil _$func.c -o _$func 2>/dev/null; then
|
||||||
HUMANIZE_NUMBER=yes
|
echo yes.
|
||||||
echo "CPPFLAGS+= -DHAVE_HUMANIZE_NUMBER" >>$CONFIG_MK
|
echo "CPPFLAGS+= -DHAVE_HUMANIZE_NUMBER" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
HUMANIZE_NUMBER=no
|
echo no.
|
||||||
echo "COMPAT_SRCS+= compat/humanize_number.o" >>$CONFIG_MK
|
echo "COMPAT_SRCS+= compat/humanize_number.o" >>$CONFIG_MK
|
||||||
echo "#include \"compat.h\"" >>$CONFIG_H
|
echo "#include \"compat.h\"" >>$CONFIG_H
|
||||||
fi
|
fi
|
||||||
echo "$HUMANIZE_NUMBER."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -452,13 +459,12 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC _$func.c -o _$func 2>/dev/null; then
|
if $XCC _$func.c -o _$func 2>/dev/null; then
|
||||||
RBTREE=yes
|
echo yes.
|
||||||
echo "CPPFLAGS += -DHAVE_RBTREE" >>$CONFIG_MK
|
echo "CPPFLAGS += -DHAVE_RBTREE" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
RBTREE=no
|
echo no.
|
||||||
echo "LIBPROP_OBJS += portableproplib/rb.o" >>$CONFIG_MK
|
echo "LIBPROP_OBJS += portableproplib/rb.o" >>$CONFIG_MK
|
||||||
fi
|
fi
|
||||||
echo "$RBTREE."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -474,16 +480,15 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC -lfetch _$func.c -o _$func 2>/dev/null; then
|
if $XCC -lfetch _$func.c -o _$func 2>/dev/null; then
|
||||||
LIBFETCH=yes
|
echo yes.
|
||||||
echo "USE_EXTERNAL_LIBFETCH = 1" >>$CONFIG_MK
|
echo "USE_EXTERNAL_LIBFETCH = 1" >>$CONFIG_MK
|
||||||
echo "LDFLAGS += -lfetch" >>$CONFIG_MK
|
echo "LDFLAGS += -lfetch" >>$CONFIG_MK
|
||||||
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a -lfetch" >>$CONFIG_MK
|
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a -lfetch" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
LIBFETCH=no
|
echo no.
|
||||||
echo "CPPFLAGS += -I\$(TOPDIR)/lib/fetch" >>$CONFIG_MK
|
echo "CPPFLAGS += -I\$(TOPDIR)/lib/fetch" >>$CONFIG_MK
|
||||||
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a" >>$CONFIG_MK
|
echo "STATIC_LIBS = \$(TOPDIR)/lib/libxbps.a" >>$CONFIG_MK
|
||||||
fi
|
fi
|
||||||
echo "$LIBFETCH."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -500,17 +505,16 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC -lprop _$func.c -o _$func 2>/dev/null; then
|
if $XCC -lprop _$func.c -o _$func 2>/dev/null; then
|
||||||
PROPLIB=yes
|
echo yes.
|
||||||
echo "USE_EXTERNAL_PROPLIB = 1" >>$CONFIG_MK
|
echo "USE_EXTERNAL_PROPLIB = 1" >>$CONFIG_MK
|
||||||
echo "LDFLAGS += -lz -lpthread -lprop" >>$CONFIG_MK
|
echo "LDFLAGS += -lz -lpthread -lprop" >>$CONFIG_MK
|
||||||
echo "STATIC_LIBS += -lprop -lz -lpthread" >>$CONFIG_MK
|
echo "STATIC_LIBS += -lprop -lz -lpthread" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
PROPLIB=no
|
echo no.
|
||||||
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib" >>$CONFIG_MK
|
echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib" >>$CONFIG_MK
|
||||||
echo "LDFLAGS += -lpthread" >>$CONFIG_MK
|
echo "LDFLAGS += -lpthread" >>$CONFIG_MK
|
||||||
echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK
|
echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK
|
||||||
fi
|
fi
|
||||||
echo "$PROPLIB."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -555,13 +559,12 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC -lz _$func.c -o _$func 2>/dev/null; then
|
if $XCC -lz _$func.c -o _$func 2>/dev/null; then
|
||||||
ZLIB=yes
|
echo yes.
|
||||||
echo "LDFLAGS += -lz" >>$CONFIG_MK
|
echo "LDFLAGS += -lz" >>$CONFIG_MK
|
||||||
echo "STATIC_LIBS += -lz" >>$CONFIG_MK
|
echo "STATIC_LIBS += -lz" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
ZLIB=no
|
ZLIB=no
|
||||||
fi
|
fi
|
||||||
echo "$ZLIB."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
if [ "$ZLIB" = "no" ]; then
|
if [ "$ZLIB" = "no" ]; then
|
||||||
echo "Failed to link with your system's zlib, can't continue..."
|
echo "Failed to link with your system's zlib, can't continue..."
|
||||||
@ -665,12 +668,11 @@ int main(void) {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
if $XCC -lcrypto _$func.c -o _$func 2>/dev/null; then
|
if $XCC -lcrypto _$func.c -o _$func 2>/dev/null; then
|
||||||
CRYPTO_SHA256=yes
|
echo yes.
|
||||||
echo "LDFLAGS += -lcrypto" >>$CONFIG_MK
|
echo "LDFLAGS += -lcrypto" >>$CONFIG_MK
|
||||||
else
|
else
|
||||||
CRYPTO_SHA256=no
|
CRYPTO_SHA256=no
|
||||||
fi
|
fi
|
||||||
echo "$ZLIB."
|
|
||||||
rm -f _$func.c _$func
|
rm -f _$func.c _$func
|
||||||
if [ "$CRYPTO_SHA256" = "no" ]; then
|
if [ "$CRYPTO_SHA256" = "no" ]; then
|
||||||
echo "Failed to link with your system's OpenSSL library, can't continue..."
|
echo "Failed to link with your system's OpenSSL library, can't continue..."
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -581,6 +585,7 @@ int HIDDEN
|
|||||||
xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||||
{
|
{
|
||||||
struct archive *ar = NULL;
|
struct archive *ar = NULL;
|
||||||
|
struct stat pkg_stat;
|
||||||
const char *pkgname, *version, *pkgver;
|
const char *pkgname, *version, *pkgver;
|
||||||
char *bpkg;
|
char *bpkg;
|
||||||
int pkg_fd, rv = 0;
|
int pkg_fd, rv = 0;
|
||||||
@ -627,8 +632,11 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
|||||||
}
|
}
|
||||||
archive_read_open_fd(ar, pkg_fd, ARCHIVE_READ_BLOCKSIZE);
|
archive_read_open_fd(ar, pkg_fd, ARCHIVE_READ_BLOCKSIZE);
|
||||||
free(bpkg);
|
free(bpkg);
|
||||||
posix_fadvise(pkg_fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
|
||||||
|
|
||||||
|
#ifdef HAVE_POSIX_FADVISE
|
||||||
|
fstat(pkg_fd, &pkg_stat);
|
||||||
|
posix_fadvise(pkg_fd, 0, pkg_stat.st_size, POSIX_FADV_SEQUENTIAL);
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Extract archive files.
|
* Extract archive files.
|
||||||
*/
|
*/
|
||||||
@ -639,8 +647,9 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
|||||||
pkgver, strerror(rv));
|
pkgver, strerror(rv));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
posix_fadvise(pkg_fd, 0, 0, POSIX_FADV_DONTNEED);
|
#ifdef HAVE_POSIX_FADVISE
|
||||||
|
posix_fadvise(pkg_fd, 0, pkg_stat.st_size, POSIX_FADV_DONTNEED);
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Set package state to unpacked.
|
* Set package state to unpacked.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user