Because portability.
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
#endif
}
- buffer::raw* buffer::create_zero_copy(unsigned len, int fd, loff_t *offset) {
+ buffer::raw* buffer::create_zero_copy(unsigned len, int fd, int64_t *offset) {
#ifdef CEPH_HAVE_SPLICE
buffer::raw_pipe* buf = new raw_pipe(len);
- int r = buf->set_source(fd, offset);
+ int r = buf->set_source(fd, (loff_t*)offset);
if (r < 0) {
delete buf;
throw error_code(r);
return _raw->can_zero_copy();
}
- int buffer::ptr::zero_copy_to_fd(int fd, loff_t *offset) const
+ int buffer::ptr::zero_copy_to_fd(int fd, int64_t *offset) const
{
- return _raw->zero_copy_to_fd(fd, offset);
+ return _raw->zero_copy_to_fd(fd, (loff_t*)offset);
}
// -- buffer::list::iterator --
/* pass offset to each call to avoid races updating the fd seek
* position, since the I/O may be non-blocking
*/
- loff_t offset = ::lseek(fd, 0, SEEK_CUR);
- loff_t *off_p = &offset;
+ int64_t offset = ::lseek(fd, 0, SEEK_CUR);
+ int64_t *off_p = &offset;
if (offset < 0 && offset != ESPIPE)
return (int) offset;
if (offset == ESPIPE)
static raw* claim_malloc(unsigned len, char *buf);
static raw* create_static(unsigned len, char *buf);
static raw* create_page_aligned(unsigned len);
- static raw* create_zero_copy(unsigned len, int fd, loff_t *offset);
+ static raw* create_zero_copy(unsigned len, int fd, int64_t *offset);
/*
* a buffer pointer. references (a subsequence of) a raw buffer.
}
bool can_zero_copy() const;
- int zero_copy_to_fd(int fd, loff_t *offset) const;
+ int zero_copy_to_fd(int fd, int64_t *offset) const;
unsigned wasted();
}
TEST_F(TestRawPipe, c_str_explicit_zero_offset) {
- loff_t offset = 0;
+ int64_t offset = 0;
::lseek(fd, 1, SEEK_SET);
bufferptr ptr = bufferptr(buffer::create_zero_copy(len, fd, &offset));
EXPECT_EQ(len, offset);
}
TEST_F(TestRawPipe, c_str_explicit_positive_offset) {
- loff_t offset = 1;
+ int64_t offset = 1;
bufferptr ptr = bufferptr(buffer::create_zero_copy(len - offset, fd,
&offset));
EXPECT_EQ(len, offset);
}
TEST_F(TestRawPipe, c_str_explicit_positive_empty_result) {
- loff_t offset = len;
+ int64_t offset = len;
bufferptr ptr = bufferptr(buffer::create_zero_copy(len - offset, fd,
&offset));
EXPECT_EQ(len, offset);
}
TEST_F(TestRawPipe, c_str_source_short_explicit_offset) {
- loff_t offset = 1;
+ int64_t offset = 1;
bufferptr ptr = bufferptr(buffer::create_zero_copy(len, fd, &offset));
EXPECT_EQ(len, offset);
EXPECT_EQ(len - 1, ptr.length());
}
TEST_F(TestRawPipe, c_str_dest_short_explicit_offset) {
- loff_t offset = 1;
+ int64_t offset = 1;
bufferptr ptr = bufferptr(buffer::create_zero_copy(2, fd, &offset));
EXPECT_EQ(3, offset);
EXPECT_EQ(2u, ptr.length());