Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcephfs: Improve portability by replacing loff_t type usage with off_t #6301

Merged
merged 1 commit into from Oct 20, 2015

Conversation

Projects
None yet
3 participants
@dx9
Copy link
Contributor

dx9 commented Oct 18, 2015

?

libcephfs: Improve portability by replacing loff_t type usage with of…
…f_t. 64-bit behavior on glibc is enforced with __USE_FILE_OFFSET64 compiler error.

Signed-off-by: John Coyle <dx9err@gmail.com>

@ghost ghost added cleanup cephfs labels Oct 19, 2015

@gregsfortytwo

This comment has been minimized.

Copy link
Member

gregsfortytwo commented Oct 19, 2015

@dx9, I'm confused. off_t is a 32-bit integer on 32-bit systems regardless of other system behaviors, isn't it? We need a 64-bit value on our interface functions.
(I'm not familiar with the __USE_FILE_OFFSET64 flag so maybe I'm missing something.)

@dx9

This comment has been minimized.

Copy link
Contributor Author

dx9 commented Oct 20, 2015

Hey @gregsfortytwo thanks for taking a look at this!

Here's the background info on the thinking behind this.

The suggestion is based on GNU libc File Position Primitives. The off_t and off64_t specs define:

Data Type: off_t
This is a signed integer type used to represent file sizes. In the GNU C Library, this type is no narrower than int.

If the source is compiled with _FILE_OFFSET_BITS == 64 this type is transparently replaced by off64_t.

Data Type: off64_t
This type is used similar to off_t. The difference is that even on 32 bit machines, where the off_t type would have 32 bits, off64_t has 64 bits and so is able to address files up to 2^63 bytes in length.

When compiling with _FILE_OFFSET_BITS == 64 this type is available under the name off_t.

In features.h __USE_FILE_OFFSET64 is defined as

#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
# define __USE_FILE_OFFSET64    1
#endif

Since __USE_FILE_OFFSET64 is already enforced, off_t should always be 64-bit on glibc platforms.

The compatibilty logic was aliasing off_t with loff_t. With loff_t dep removed, we can toss the compat code because it just assumed that FreeBSD and Apple are 64-bit. musl libc is also 64-bit. off64_t is not used in the header so we can toss it too.

?

gregsfortytwo added a commit that referenced this pull request Oct 20, 2015

Merge pull request #6301 from dx9/wip-12406-ditch-loff_t-for-off_t
libcephfs: Improve portability by replacing loff_t type usage with off_t

Reviewed-by: Greg Farnum <gfarnum@redhat.com>

@gregsfortytwo gregsfortytwo merged commit d763555 into ceph:master Oct 20, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.