aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2022-12-17 10:33:01 -0800
committernickjsanders <nick.j.sanders@gmail.com>2022-12-19 10:40:46 -0800
commitef57014bedc0b1ffa61bacf26ed463d8b66f6194 (patch)
treeb2164dd473344df683b0644f6f0904dbd21099c5
parenta0e893e706be9c2958be3d84836422844ebf20b7 (diff)
downloadstressapptest-ef57014bedc0b1ffa61bacf26ed463d8b66f6194.tar.gz
Replace lfs64 functions and defines
AC_SYS_LARGEFILE is already in use in configure.ac which detects enabling lfs64 functions as needed, it will define _FILE_OFFSET_BITS=64 which should make lseek same as lseek64 since off_t is 64bit on most of current 32bit linux platforms Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--src/os.cc18
-rw-r--r--src/worker.cc6
2 files changed, 9 insertions, 15 deletions
diff --git a/src/os.cc b/src/os.cc
index 1928e0a..faa6068 100644
--- a/src/os.cc
+++ b/src/os.cc
@@ -142,7 +142,7 @@ int OsLayer::AddressMode() {
uint64 OsLayer::VirtualToPhysical(void *vaddr) {
uint64 frame, paddr, pfnmask, pagemask;
int pagesize = sysconf(_SC_PAGESIZE);
- off64_t off = ((uintptr_t)vaddr) / pagesize * 8;
+ off_t off = ((uintptr_t)vaddr) / pagesize * 8;
int fd = open(kPagemapPath, O_RDONLY);
/*
@@ -154,7 +154,7 @@ uint64 OsLayer::VirtualToPhysical(void *vaddr) {
if (fd < 0)
return 0;
- if (lseek64(fd, off, SEEK_SET) != off || read(fd, &frame, 8) != 8) {
+ if (lseek(fd, off, SEEK_SET) != off || read(fd, &frame, 8) != 8) {
int err = errno;
string errtxt = ErrorString(err);
logprintf(0, "Process Error: failed to access %s with errno %d (%s)\n",
@@ -607,9 +607,9 @@ bool OsLayer::AllocateTestMem(int64 length, uint64 paddr_base) {
dynamic_mapped_shmem_ = true;
} else {
// Do a full mapping here otherwise.
- shmaddr = mmap64(NULL, length, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_NORESERVE | MAP_LOCKED | MAP_POPULATE,
- shm_object, 0);
+ shmaddr = mmap(NULL, length, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_NORESERVE | MAP_LOCKED | MAP_POPULATE,
+ shm_object, 0);
if (shmaddr == reinterpret_cast<void*>(-1)) {
int err = errno;
string errtxt = ErrorString(err);
@@ -704,18 +704,12 @@ void *OsLayer::PrepareTestMem(uint64 offset, uint64 length) {
if (dynamic_mapped_shmem_) {
// TODO(nsanders): Check if we can support MAP_NONBLOCK,
// and evaluate performance hit from not using it.
-#ifdef HAVE_MMAP64
- void * mapping = mmap64(NULL, length, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_NORESERVE | MAP_LOCKED | MAP_POPULATE,
- shmid_, offset);
-#else
void * mapping = mmap(NULL, length, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_NORESERVE | MAP_LOCKED | MAP_POPULATE,
shmid_, offset);
-#endif
if (mapping == MAP_FAILED) {
string errtxt = ErrorString(errno);
- logprintf(0, "Process Error: PrepareTestMem mmap64(%llx, %llx) failed. "
+ logprintf(0, "Process Error: PrepareTestMem mmap(%llx, %llx) failed. "
"error: %s.\n",
offset, length, errtxt.c_str());
sat_assert(0);
diff --git a/src/worker.cc b/src/worker.cc
index 745a816..41e93a0 100644
--- a/src/worker.cc
+++ b/src/worker.cc
@@ -1705,7 +1705,7 @@ bool FileThread::WritePages(int fd) {
int strict = sat_->strict();
// Start fresh at beginning of file for each batch of pages.
- lseek64(fd, 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
for (int i = 0; i < sat_->disk_pages(); i++) {
struct page_entry src;
if (!GetValidPage(&src))
@@ -1943,7 +1943,7 @@ bool FileThread::ReadPages(int fd) {
bool result = true;
// Read our data back out of the file, into it's new location.
- lseek64(fd, 0, SEEK_SET);
+ lseek(fd, 0, SEEK_SET);
for (int i = 0; i < sat_->disk_pages(); i++) {
struct page_entry dst;
if (!GetEmptyPage(&dst))
@@ -3153,7 +3153,7 @@ bool DiskThread::ValidateBlockOnDisk(int fd, BlockData *block) {
// Read block from disk and time the read. If it takes longer than the
// threshold, complain.
- if (lseek64(fd, address * kSectorSize, SEEK_SET) == -1) {
+ if (lseek(fd, address * kSectorSize, SEEK_SET) == -1) {
logprintf(0, "Process Error: Unable to seek to sector %lld in "
"DiskThread::ValidateSectorsOnDisk on disk %s "
"(thread %d).\n", address, device_name_.c_str(), thread_num_);