From: Noah Watkins Date: Fri, 6 Dec 2013 19:09:51 +0000 (-0800) Subject: buffer: use int64_t instead of loff_t X-Git-Tag: v0.75~64^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F916%2Fhead;p=ceph.git buffer: use int64_t instead of loff_t Because portability. Signed-off-by: Noah Watkins --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 69e4c85b1b27..be74879e71eb 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -525,10 +525,10 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE #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); @@ -733,9 +733,9 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE 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 -- @@ -1629,8 +1629,8 @@ int buffer::list::write_fd_zero_copy(int fd) const /* 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) diff --git a/src/include/buffer.h b/src/include/buffer.h index 2d2e8e467fa9..e1366463795f 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -157,7 +157,7 @@ public: 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. @@ -216,7 +216,7 @@ public: } 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(); diff --git a/src/test/bufferlist.cc b/src/test/bufferlist.cc index 85af76486f54..3809ba15da12 100644 --- a/src/test/bufferlist.cc +++ b/src/test/bufferlist.cc @@ -240,7 +240,7 @@ TEST_F(TestRawPipe, c_str_source_short) { } 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); @@ -249,7 +249,7 @@ TEST_F(TestRawPipe, c_str_explicit_zero_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); @@ -258,7 +258,7 @@ TEST_F(TestRawPipe, c_str_explicit_positive_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); @@ -266,7 +266,7 @@ TEST_F(TestRawPipe, c_str_explicit_positive_empty_result) { } 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()); @@ -274,7 +274,7 @@ TEST_F(TestRawPipe, c_str_source_short_explicit_offset) { } 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());