QFileSystemEngine/Unix: remove futimes related code

- futimes isn't a standard system call[1]:
«
This system call is nonstandard.  It was implemented from a specification
that was proposed for POSIX.1, but that specification was replaced by the
one for utimensat(2).

A similar system call exists on Solaris.
»
[1] https://man7.org/linux/man-pages/man2/futimesat.2.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html

- futimens is a standard system call[2], it's available on:
 - Linux: https://man7.org/linux/man-pages/man2/futimesat.2.html
 - FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=futimens&sektion=2&n=1
 - OpenBSD: https://man.openbsd.org/futimens.2
 - QNX: https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/f/futimens.html

So, remove futimes related code.

Change-Id: I58ac466f08161a88219e3a32eab98d168f065140
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Ahmad Samir 2022-10-31 22:57:24 +02:00
parent ef935f6e37
commit cb9d76169a
3 changed files with 0 additions and 83 deletions

View File

@ -229,22 +229,6 @@ futimens(-1, 0);
/* END TEST: */
return 0;
}
"# FIXME: qmake: ["# Block futimens() on Apple platforms unless it's available on ALL", '# deployment targets. This simplifies the logic at the call site', "# dramatically, as it isn't strictly needed compared to futimes().", 'darwin: QMAKE_CXXFLAGS += -Werror=unguarded-availability -Werror=unguarded-availability-new', 'CONFIG += warn_on']
)
# futimes
qt_config_compile_test(futimes
LABEL "futimes()"
CODE
"#include <sys/time.h>
int main(void)
{
/* BEGIN TEST: */
futimes(-1, 0);
/* END TEST: */
return 0;
}
")
# getauxval
@ -578,10 +562,6 @@ qt_feature("futimens" PRIVATE
LABEL "futimens()"
CONDITION NOT WIN32 AND TEST_futimens
)
qt_feature("futimes" PRIVATE
LABEL "futimes()"
CONDITION NOT WIN32 AND NOT QT_FEATURE_futimens AND TEST_futimes
)
qt_feature("getauxval" PRIVATE
LABEL "getauxval()"
CONDITION LINUX AND TEST_getauxval

View File

@ -63,7 +63,6 @@
#define QT_FEATURE_jalalicalendar -1
#define QT_FEATURE_journald -1
#define QT_FEATURE_futimens -1
#define QT_FEATURE_futimes -1
#define QT_FEATURE_future -1
#define QT_FEATURE_itemmodel -1
#define QT_FEATURE_library -1

View File

@ -159,41 +159,6 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
namespace {
namespace GetFileTimes {
#if !QT_CONFIG(futimens) && (QT_CONFIG(futimes))
template <typename T>
static inline typename std::enable_if_t<(&T::st_atim, &T::st_mtim, true)> get(const T *p, struct timeval *access, struct timeval *modification)
{
access->tv_sec = p->st_atim.tv_sec;
access->tv_usec = p->st_atim.tv_nsec / 1000;
modification->tv_sec = p->st_mtim.tv_sec;
modification->tv_usec = p->st_mtim.tv_nsec / 1000;
}
template <typename T>
static inline typename std::enable_if_t<(&T::st_atimespec, &T::st_mtimespec, true)> get(const T *p, struct timeval *access, struct timeval *modification)
{
access->tv_sec = p->st_atimespec.tv_sec;
access->tv_usec = p->st_atimespec.tv_nsec / 1000;
modification->tv_sec = p->st_mtimespec.tv_sec;
modification->tv_usec = p->st_mtimespec.tv_nsec / 1000;
}
# ifndef st_atimensec
// if "st_atimensec" is defined, this would expand to invalid C++
template <typename T>
static inline typename std::enable_if_t<(&T::st_atimensec, &T::st_mtimensec, true)> get(const T *p, struct timeval *access, struct timeval *modification)
{
access->tv_sec = p->st_atime;
access->tv_usec = p->st_atimensec / 1000;
modification->tv_sec = p->st_mtime;
modification->tv_usec = p->st_mtimensec / 1000;
}
# endif
#endif
qint64 timespecToMSecs(const timespec &spec)
{
return (qint64(spec.tv_sec) * 1000) + (spec.tv_nsec / 1000000);
@ -1567,33 +1532,6 @@ bool QFileSystemEngine::setFileTime(int fd, const QDateTime &newDate, QAbstractF
return false;
}
return true;
#elif QT_CONFIG(futimes)
struct timeval tv[2];
QT_STATBUF st;
if (QT_FSTAT(fd, &st) == -1) {
error = QSystemError(errno, QSystemError::StandardLibraryError);
return false;
}
GetFileTimes::get(&st, &tv[0], &tv[1]);
const qint64 msecs = newDate.toMSecsSinceEpoch();
if (time == QAbstractFileEngine::AccessTime) {
tv[0].tv_sec = msecs / 1000;
tv[0].tv_usec = (msecs % 1000) * 1000;
} else if (time == QAbstractFileEngine::ModificationTime) {
tv[1].tv_sec = msecs / 1000;
tv[1].tv_usec = (msecs % 1000) * 1000;
}
if (futimes(fd, tv) == -1) {
error = QSystemError(errno, QSystemError::StandardLibraryError);
return false;
}
return true;
#else
Q_UNUSED(fd);