From 356d71a24d8dfc8ec7cfc2a2fb3fc2444ca2de12 Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Sun, 29 Dec 2013 12:54:48 -0800 Subject: [PATCH] inttypes: use portable types in public headers loff_t -> int64_t __u8 -> uint8_t Signed-off-by: Noah Watkins --- src/include/cephfs/libcephfs.h | 24 ++++++++++++------------ src/include/rados/librados.hpp | 4 ++-- src/libcephfs.cc | 24 ++++++++++++------------ src/test/libcephfs/test.cc | 10 +++++----- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index ded4e1e120a4b..1370021ef57cc 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -375,7 +375,7 @@ void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp * by ceph_telldir do not have a particular order (cannot be compared with * inequality). */ -loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); +int64_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); /** * Move the directory stream to a position specified by the given offset. @@ -386,7 +386,7 @@ loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp * a value returned by seekdir. Note that this value does not refer to the nth * entry in a directory, and can not be manipulated with plus or minus. */ -void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset); +void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, int64_t offset); /** * Create a directory. @@ -447,7 +447,7 @@ int ceph_link(struct ceph_mount_info *cmount, const char *existing, const char * * @param size the length of the buffer * @returns 0 on success or negative error code on failure */ -int ceph_readlink(struct ceph_mount_info *cmount, const char *path, char *buf, loff_t size); +int ceph_readlink(struct ceph_mount_info *cmount, const char *path, char *buf, int64_t size); /** * Creates a symbolic link. @@ -591,7 +591,7 @@ int ceph_utime(struct ceph_mount_info *cmount, const char *path, struct utimbuf * @param size the new size of the file. * @returns 0 on success or a negative error code on failure. */ -int ceph_truncate(struct ceph_mount_info *cmount, const char *path, loff_t size); +int ceph_truncate(struct ceph_mount_info *cmount, const char *path, int64_t size); /** * Make a block or character special file. @@ -660,7 +660,7 @@ int ceph_close(struct ceph_mount_info *cmount, int fd); * SEEK_END: the offset is set to the end of the file plus @ref offset bytes. * @returns 0 on success or a negative error code on failure. */ -loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, loff_t offset, int whence); +int64_t ceph_lseek(struct ceph_mount_info *cmount, int fd, int64_t offset, int whence); /** * Read data from the file. * @@ -672,7 +672,7 @@ loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, loff_t offset, int whe * function reads from the current offset of the file descriptor. * @returns the number of bytes read into buf, or a negative error code on failure. */ -int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, loff_t size, loff_t offset); +int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, int64_t size, int64_t offset); /** * Write data to a file. @@ -685,8 +685,8 @@ int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, loff_t size, lo * function writes to the current offset of the file descriptor. * @returns the number of bytes written, or a negative error code */ -int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, loff_t size, - loff_t offset); +int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, int64_t size, + int64_t offset); /** * Truncate a file to the given size. @@ -696,7 +696,7 @@ int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, loff_t s * @param size the new size of the file * @returns 0 on success or a negative error code on failure. */ -int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size); +int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, int64_t size); /** * Synchronize an open file to persistent media. @@ -725,7 +725,7 @@ int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly); * @return 0 on success or a negative error code on failure. */ int ceph_fallocate(struct ceph_mount_info *cmount, int fd, int mode, - loff_t offset, loff_t length); + int64_t offset, int64_t length); /** * Get the open file's statistics. @@ -1046,7 +1046,7 @@ int ceph_get_pool_replication(struct ceph_mount_info *cmount, int pool_id); * @returns the size of the addressed filled into the @ref addr parameter, or a negative * error code on failure. */ -int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd, loff_t offset, +int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd, int64_t offset, struct sockaddr_storage *addr, int naddr); /** @@ -1063,7 +1063,7 @@ int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd, loff_t * array is not large enough. */ int ceph_get_file_extent_osds(struct ceph_mount_info *cmount, int fh, - loff_t offset, loff_t *length, int *osds, int nosds); + int64_t offset, int64_t *length, int *osds, int nosds); /** * Get the fully qualified CRUSH location of an OSD. diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 2030fb15608d8..106c6f87ec5a0 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -848,10 +848,10 @@ namespace librados int pool_create(const char *name); int pool_create(const char *name, uint64_t auid); - int pool_create(const char *name, uint64_t auid, __u8 crush_rule); + int pool_create(const char *name, uint64_t auid, uint8_t crush_rule); int pool_create_async(const char *name, PoolAsyncCompletion *c); int pool_create_async(const char *name, uint64_t auid, PoolAsyncCompletion *c); - int pool_create_async(const char *name, uint64_t auid, __u8 crush_rule, PoolAsyncCompletion *c); + int pool_create_async(const char *name, uint64_t auid, uint8_t crush_rule, PoolAsyncCompletion *c); int pool_delete(const char *name); int pool_delete_async(const char *name, PoolAsyncCompletion *c); int64_t pool_lookup(const char *name); diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 86f9763478122..cc24a31a5fa13 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -419,14 +419,14 @@ extern "C" void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_r cmount->get_client()->rewinddir((dir_result_t*)dirp); } -extern "C" loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) +extern "C" int64_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) { if (!cmount->is_mounted()) return -ENOTCONN; return cmount->get_client()->telldir((dir_result_t*)dirp); } -extern "C" void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset) +extern "C" void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, int64_t offset) { if (!cmount->is_mounted()) return; @@ -480,7 +480,7 @@ extern "C" int ceph_rmdir(struct ceph_mount_info *cmount, const char *path) // symlinks extern "C" int ceph_readlink(struct ceph_mount_info *cmount, const char *path, - char *buf, loff_t size) + char *buf, int64_t size) { if (!cmount->is_mounted()) return -ENOTCONN; @@ -622,7 +622,7 @@ extern "C" int ceph_utime(struct ceph_mount_info *cmount, const char *path, } extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path, - loff_t size) + int64_t size) { if (!cmount->is_mounted()) return -ENOTCONN; @@ -662,8 +662,8 @@ extern "C" int ceph_close(struct ceph_mount_info *cmount, int fd) return cmount->get_client()->close(fd); } -extern "C" loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, - loff_t offset, int whence) +extern "C" int64_t ceph_lseek(struct ceph_mount_info *cmount, int fd, + int64_t offset, int whence) { if (!cmount->is_mounted()) return -ENOTCONN; @@ -671,7 +671,7 @@ extern "C" loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, } extern "C" int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, - loff_t size, loff_t offset) + int64_t size, int64_t offset) { if (!cmount->is_mounted()) return -ENOTCONN; @@ -679,14 +679,14 @@ extern "C" int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, } extern "C" int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, - loff_t size, loff_t offset) + int64_t size, int64_t offset) { if (!cmount->is_mounted()) return -ENOTCONN; return cmount->get_client()->write(fd, buf, size, offset); } -extern "C" int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size) +extern "C" int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, int64_t size) { if (!cmount->is_mounted()) return -ENOTCONN; @@ -701,7 +701,7 @@ extern "C" int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataon } extern "C" int ceph_fallocate(struct ceph_mount_info *cmount, int fd, int mode, - loff_t offset, loff_t length) + int64_t offset, int64_t length) { if (!cmount->is_mounted()) return -ENOTCONN; @@ -982,7 +982,7 @@ extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int } extern "C" int ceph_get_file_extent_osds(struct ceph_mount_info *cmount, int fh, - loff_t offset, loff_t *length, int *osds, int nosds) + int64_t offset, int64_t *length, int *osds, int nosds) { if (nosds < 0) return -EINVAL; @@ -1065,7 +1065,7 @@ extern "C" int ceph_get_osd_addr(struct ceph_mount_info *cmount, int osd, } extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fh, - loff_t offset, struct sockaddr_storage *addr, int naddr) + int64_t offset, struct sockaddr_storage *addr, int naddr) { vector address; unsigned i; diff --git a/src/test/libcephfs/test.cc b/src/test/libcephfs/test.cc index 597d049e2a446..a5fac4178e366 100644 --- a/src/test/libcephfs/test.cc +++ b/src/test/libcephfs/test.cc @@ -1021,24 +1021,24 @@ TEST(LibCephFS, GetExtentOsds) { int ret = ceph_get_file_extent_osds(cmount, fd, 0, NULL, NULL, 0); EXPECT_GT(ret, 0); - loff_t len; + int64_t len; int osds[ret]; /* full stripe extent */ EXPECT_EQ(ret, ceph_get_file_extent_osds(cmount, fd, 0, &len, osds, ret)); - EXPECT_EQ(len, (loff_t)stripe_unit); + EXPECT_EQ(len, (int64_t)stripe_unit); /* half stripe extent */ EXPECT_EQ(ret, ceph_get_file_extent_osds(cmount, fd, stripe_unit/2, &len, osds, ret)); - EXPECT_EQ(len, (loff_t)stripe_unit/2); + EXPECT_EQ(len, (int64_t)stripe_unit/2); /* 1.5 stripe unit offset -1 byte */ EXPECT_EQ(ret, ceph_get_file_extent_osds(cmount, fd, 3*stripe_unit/2-1, &len, osds, ret)); - EXPECT_EQ(len, (loff_t)stripe_unit/2+1); + EXPECT_EQ(len, (int64_t)stripe_unit/2+1); /* 1.5 stripe unit offset +1 byte */ EXPECT_EQ(ret, ceph_get_file_extent_osds(cmount, fd, 3*stripe_unit/2+1, &len, osds, ret)); - EXPECT_EQ(len, (loff_t)stripe_unit/2-1); + EXPECT_EQ(len, (int64_t)stripe_unit/2-1); /* only when more than 1 osd */ if (ret > 1) -- 2.39.5