-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Sync ext/hash installed headers #13210
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks correct
@devnexen just one question here. Do you think this might conflict somewhere with possible system xxhash.h file? There is for example Because we can even write the include here |
ah good point. What can be done to counteract possible conflict is to set this, for example
|
@devnexen the xxhash.h is included with the XXH_INLINE_ALL: #define XXH_INLINE_ALL 1
#include "xxhash.h" Isn't then XXH_NAMESPACE undefined in the xxhash.h file (meaning it wouldn't take effect)? Or would this work ok? #define XXH_NAMESPACE PHP_NAMESPACE
#define XXH_INLINE_ALL 1
#include "xxhash.h" |
it should work like this, it s just a "safety net" in case a theoretical case when XXH_NAMESPACE is defined by a php extension for example. |
Ah, I understand now. Ok... |
This syncs ext/hash headers installation on *nix and Windows: - php_hash_joaat.h and php_hash_fnv.h added also on Windows installation - xxhash/xxhash.h added on both installations as it is included in php_hash_xxhash.h - Include path for xxhash.h changed to relative so the php_hash_xxhash.h can be included outside of php-src - Redundant include flags removed - Fix xxhash namespace in case it was set elsewhere
eae7e0c
to
4f8ea22
Compare
@devnexen Do you know maybe about the include order of system include directories and local php-src ones set to the compiler? Is there any chance that the include order is changed somehow in some case? For example, if the system's xxhash.h would be included from some system location prior to ext/hash? That shouldn't happen, right? Or can happen? |
xxhash is so customisable, some include an untouched version, some use one with couple of fixes/improvements backported from git commits (what we do here) that there is no "system" version of it ; that would be quite a conundrum. Each project include their own. In the field, a code can have xxhash then including a dependency having its own xxhash. |
Sorry for bumping the topic again, 😄 but I'm still trying to figure out how the XXH_NAMESPACE should work in PHP case. Because anything used with XXH_INLINE defined is the same from the compiler point of view... #define XXH_INLINE_ALL 1
#include "xxhash/xxhash.h"
#include "some/other/xxhash.h" is the same as: #undef XXH_NAMESPACE
#define XXH_NAMESPACE PHP_NAMESPACE
#define XXH_INLINE_ALL 1
#include "xxhash/xxhash.h"
#include "some/other/xxhash.h" And #include "some/other/xxhash.h"
#define XXH_INLINE_ALL 1
#include "xxhash/xxhash.h" is the same as: #include "some/other/xxhash.h"
#undef XXH_NAMESPACE
#define XXH_NAMESPACE PHP_NAMESPACE
#define XXH_INLINE_ALL 1
#include "xxhash/xxhash.h" Even: #define XXH_NAMESPACE EXT_NAMESPACE
#include "some/other/xxhash.h"
#define XXH_INLINE_ALL 1
#include "xxhash/xxhash.h" is the same as: #define XXH_NAMESPACE EXT_NAMESPACE
#include "some/other/xxhash.h"
#undef XXH_NAMESPACE
#define XXH_NAMESPACE PHP_NAMESPACE
#define XXH_INLINE_ALL 1
#include "xxhash/xxhash.h" I think it's not possible to properly cover the case when some other xxhash.h is used in the extension without knowing the exact case how it is used. If extension has perhaps included some xxhash.h the result will be different no matter what. I think it's such an edge case that we don't need to bother with this. So maybe we simply don't change the XXH_NAMESPACE and that's it? |
Fair point, you can always commit as is we can always adjust later on in case. |
This syncs ext/hash headers installation on *nix and Windows:
This looks ok or have I misses something perhaps?