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

Use fixed width types #1258

Merged
merged 6 commits into from
Dec 22, 2024
Merged

Use fixed width types #1258

merged 6 commits into from
Dec 22, 2024

Conversation

sbooth
Copy link
Contributor

@sbooth sbooth commented Dec 8, 2024

Most 64-bit Linux systems and macOS use LP64 with 64-bit long and pointers. Windows is slightly different and uses LLP64.

This means that on LP64 systems long and long long are the same size.

As usual cppreference.com has a good page on Fundamental Types.

The current definition of the byteSwap functions use unsigned short, unsigned int and unsigned long long for 16-, 32-, and 64-bit uints.

The definitions I've seen for the various builtin bswap functions are defined using fixed with types. For example gcc has the folllwing:

Built-in Function: uint16_t __builtin_bswap16 (uint16_t x)
Returns x with the order of the bytes reversed; for example, 0xaabb becomes 0xbbaa. Byte here always means exactly 8 bits.

Built-in Function: uint32_t __builtin_bswap32 (uint32_t x)
Similar to __builtin_bswap16, except the argument and return types are 32-bit.

Built-in Function: uint64_t __builtin_bswap64 (uint64_t x)
Similar to __builtin_bswap32, except the argument and return types are 64-bit.

And macOS uses something similar for the OSSwap functions.

I think it would be great if TagLib followed suit.

@sbooth sbooth marked this pull request as draft December 8, 2024 17:46
@sbooth sbooth marked this pull request as ready for review December 9, 2024 18:31
@sbooth sbooth requested a review from ufleisch December 9, 2024 18:36
@ufleisch
Copy link
Contributor

Just rebased, looks good to me.

@sbooth sbooth merged commit c1c60eb into taglib:master Dec 22, 2024
3 checks passed
@sbooth sbooth deleted the stdint branch December 22, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants