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

endian.h not found on macOS #15

Closed
EricFromCanada opened this issue Jul 8, 2021 · 5 comments
Closed

endian.h not found on macOS #15

EricFromCanada opened this issue Jul 8, 2021 · 5 comments

Comments

@EricFromCanada
Copy link

The reference to <endian.h> in passwdqc_filter.h needs to be <machine/endian.h> for it to compile on macOS.

@solardiz
Copy link
Member

solardiz commented Jul 9, 2021

Thank you, @EricFromCanada! Does <machine/endian.h> define __BYTE_ORDER, __BIG_ENDIAN, and __LITTLE_ENDIAN? If not, then including it is of no use.

Since this is just an optimization anyhow, I'm tempted to treat macOS the same as MSVC there, like this:

-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__APPLE__)
 #include <endian.h>
 #endif

Does this work?

@EricFromCanada
Copy link
Author

machine/endian.h includes i386/endian.h which defines BYTE_ORDER, BIG_ENDIAN and LITTLE_ENDIAN via sys/_endian.h, but it also looks like those aren't necessarily needed since you can assume little endian on macOS for Intel and ARM.

@solardiz
Copy link
Member

defines BYTE_ORDER, BIG_ENDIAN and LITTLE_ENDIAN

However, these are not the "underscored" versions that passwdqc_filter.h currently uses.

via sys/_endian.h

Not, it defines those directly. That other file only defines the conversions.

you can assume little endian on macOS for Intel and ARM.

But not on PowerPC.

Overall, I'm tempted not to over-complicate this, and use the simpler patch I suggested above. The optimization would then continue to work for Linux and *BSDs. I guess large files would most commonly be processed with pwqfilter on Linux.

@solardiz
Copy link
Member

I'm tempted to treat macOS the same as MSVC there, like this:

-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(__APPLE__)
 #include <endian.h>
 #endif

Does this work?

@EricFromCanada Can you please test this specific change? Thanks!

@EricFromCanada
Copy link
Author

Yes, that seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants