Skip to content

Commit c5f1ecc

Browse files
committed
Use off_t instead of off64_t for musl compatibility.
1 parent 3f4561f commit c5f1ecc

18 files changed

+37
-40
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ configure_file(
7272
${CMAKE_BINARY_DIR}/extra_version_string.h
7373
)
7474

75-
set(FLAGS_COMMON "-D__USE_LARGEFILE64 -pthread")
75+
set(FLAGS_COMMON "-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -pthread")
7676
set(supports32bit true)
7777
set(x86ish false)
7878
set(has_syscallbuf false)

src/AddressSpace.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ static void add_range(set<MemoryRange>& ranges, const MemoryRange& range) {
815815

816816
KernelMapping AddressSpace::map(Task* t, remote_ptr<void> addr,
817817
size_t num_bytes, int prot, int flags,
818-
off64_t offset_bytes, const string& fsname,
818+
off_t offset_bytes, const string& fsname,
819819
dev_t device, ino_t inode,
820820
unique_ptr<struct stat> mapped_file_stat,
821821
const KernelMapping* recorded_map,
@@ -1633,7 +1633,7 @@ static bool is_adjacent_mapping(const KernelMapping& mleft,
16331633
return false;
16341634
}
16351635
if (mleft.is_real_device() &&
1636-
mleft.file_offset_bytes() + off64_t(mleft.size()) !=
1636+
mleft.file_offset_bytes() + off_t(mleft.size()) !=
16371637
mright.file_offset_bytes()) {
16381638
return false;
16391639
}

src/AddressSpace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class KernelMapping : public MemoryRange {
6363
KernelMapping() : device_(0), inode_(0), prot_(0), flags_(0), offset(0) {}
6464
KernelMapping(remote_ptr<void> start, remote_ptr<void> end,
6565
const std::string& fsname, dev_t device, ino_t inode, int prot,
66-
int flags, off64_t offset = 0)
66+
int flags, off_t offset = 0)
6767
: MemoryRange(start, end),
6868
fsname_(fsname),
6969
device_(device),
@@ -441,7 +441,7 @@ class AddressSpace : public HasTaskSet {
441441
*/
442442
KernelMapping map(
443443
Task* t, remote_ptr<void> addr, size_t num_bytes, int prot, int flags,
444-
off64_t offset_bytes, const std::string& fsname,
444+
off_t offset_bytes, const std::string& fsname,
445445
dev_t device = KernelMapping::NO_DEVICE,
446446
ino_t inode = KernelMapping::NO_INODE,
447447
std::unique_ptr<struct stat> mapped_file_stat = nullptr,

src/AutoRemoteSyscalls.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ void AutoRemoteSyscalls::finish_direct_mmap(
917917
int prot, int flags,
918918
const string& backing_file_name,
919919
int backing_file_open_flags,
920-
off64_t backing_offset_bytes,
920+
off_t backing_offset_bytes,
921921
struct stat& real_file, string& real_file_name) {
922922
int fd;
923923

src/AutoRemoteSyscalls.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class AutoRemoteSyscalls {
278278
int prot, int flags,
279279
const std::string& backing_file_name,
280280
int backing_file_open_flags,
281-
off64_t backing_offset_bytes,
281+
off_t backing_offset_bytes,
282282
struct stat& real_file, std::string& real_file_name);
283283

284284
// Calling this with allow_death false is DEPRECATED.

src/CompressedReader.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
22

3-
#define _LARGEFILE64_SOURCE
4-
53
#include "CompressedReader.h"
64

75
#include <brotli/decode.h>

src/CompressedWriter.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* -*- Mode: C++; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
22

3-
#define _LARGEFILE64_SOURCE
4-
53
#include "CompressedWriter.h"
64

75
#include <brotli/encode.h>

src/kernel_abi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,8 @@ struct BaseArch : public wordsize,
13571357
};
13581358
RR_VERIFY_TYPE_EXPLICIT(struct ::statfs, statfs_t);
13591359

1360-
struct statfs64_t {
1360+
/* Don't align for the 64-bit values on 32-bit x86 */
1361+
struct __attribute__((packed)) statfs64_t {
13611362
__statfs_word f_type;
13621363
__statfs_word f_bsize;
13631364
uint64_t f_blocks;

src/record_syscall.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6019,8 +6019,8 @@ static void process_execve(RecordTask* t, TaskSyscallState& syscall_state) {
60196019
TraceWriter::EXEC_MAPPING) ==
60206020
TraceWriter::RECORD_IN_TRACE) {
60216021
if (st.st_size > 0) {
6022-
off64_t end = (off64_t)st.st_size - km.file_offset_bytes();
6023-
t->record_remote(km.start(), min(end, (off64_t)km.size()));
6022+
off_t end = (off_t)st.st_size - km.file_offset_bytes();
6023+
t->record_remote(km.start(), min(end, (off_t)km.size()));
60246024
} else {
60256025
// st_size is not valid. Some device files are mmappable but have zero
60266026
// size. We also take this path if there's no file at all (vdso etc).
@@ -6122,7 +6122,7 @@ static vector<WriteHole> find_holes(RecordTask* t, int desc, uint64_t offset, ui
61226122
uint64_t file_start = offset;
61236123
uint64_t file_end = offset + size;
61246124
while (offset < file_end) {
6125-
off64_t r = lseek(fd, offset, SEEK_HOLE);
6125+
off_t r = lseek(fd, offset, SEEK_HOLE);
61266126
if (r < 0) {
61276127
// SEEK_HOLE not supported?
61286128
return ret;
@@ -6198,7 +6198,7 @@ static void check_outside_mappings(const KernelMapping& tracee_km, const RecordS
61986198
}
61996199

62006200
static void process_mmap(RecordTask* t, size_t length, int prot, int flags,
6201-
int fd, off64_t offset) {
6201+
int fd, off_t offset) {
62026202
if (t->regs().syscall_failed()) {
62036203
// We purely emulate failed mmaps.
62046204
return;
@@ -6266,8 +6266,8 @@ static void process_mmap(RecordTask* t, size_t length, int prot, int flags,
62666266
TraceWriter::SYSCALL_MAPPING,
62676267
!monitor_this_fd) ==
62686268
TraceWriter::RECORD_IN_TRACE) {
6269-
off64_t end = (off64_t)st.st_size - km.file_offset_bytes();
6270-
off64_t nbytes = min(end, (off64_t)km.size());
6269+
off_t end = (off_t)st.st_size - km.file_offset_bytes();
6270+
off_t nbytes = min(end, (off_t)km.size());
62716271
vector<WriteHole> holes = find_holes(t, fd, km.file_offset_bytes(), (uint64_t)nbytes);
62726272
ssize_t nread = t->record_remote_fallible(addr, nbytes, holes);
62736273
if (!adjusted_size && nread != nbytes) {
@@ -6376,10 +6376,10 @@ static void process_mremap(RecordTask* t, remote_ptr<void> old_addr,
63766376
if (t->trace_writer().write_mapped_region(t, km, st, km.fsname(),
63776377
vector<TraceRemoteFd>()) ==
63786378
TraceWriter::RECORD_IN_TRACE) {
6379-
off64_t end = max<off64_t>(st.st_size - km.file_offset_bytes(), 0);
6379+
off_t end = max<off_t>(st.st_size - km.file_offset_bytes(), 0);
63806380
// Allow failure; the underlying file may have true zero size, in which
63816381
// case this may try to record unmapped memory.
6382-
t->record_remote_fallible(km.start(), min(end, (off64_t)km.size()));
6382+
t->record_remote_fallible(km.start(), min(end, (off_t)km.size()));
63836383
}
63846384

63856385
// If the original mapping was monitored, we'll continue monitoring it

src/replay_syscall.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ static void write_mapped_data(ReplayTask* t,
598598

599599
static void finish_private_mmap(ReplayTask* t, AutoRemoteSyscalls& remote,
600600
remote_ptr<void> rec_addr, size_t length,
601-
int prot, int flags, off64_t offset_bytes,
601+
int prot, int flags, off_t offset_bytes,
602602
const KernelMapping& km,
603603
TraceReader::MappedData& data) {
604604
LOG(debug) << " finishing private mmap of " << km.fsname();
@@ -622,7 +622,7 @@ static void finish_private_mmap(ReplayTask* t, AutoRemoteSyscalls& remote,
622622
static void finish_shared_mmap(ReplayTask* t, AutoRemoteSyscalls& remote,
623623
remote_ptr<void> rec_addr, size_t length,
624624
int prot, int flags, const vector<TraceRemoteFd>& fds,
625-
off64_t offset_bytes,
625+
off_t offset_bytes,
626626
const KernelMapping& km,
627627
TraceReader::MappedData& data) {
628628
// Ensure there's a virtual file for the file that was mapped
@@ -680,7 +680,7 @@ static void finish_shared_mmap(ReplayTask* t, AutoRemoteSyscalls& remote,
680680

681681
static void process_mmap(ReplayTask* t, const TraceFrame& trace_frame,
682682
size_t length, int prot, int flags, int fd,
683-
off64_t offset_bytes, ReplayTraceStep* step) {
683+
off_t offset_bytes, ReplayTraceStep* step) {
684684
step->action = TSTEP_RETIRE;
685685

686686
{

0 commit comments

Comments
 (0)