Skip to content

Fix pointer size detection - #5562

Merged
GMNGeoffrey merged 4 commits into
iree-org:mainfrom
GMNGeoffrey:ptr-size
Apr 22, 2021
Merged

GMNGeoffrey merged 4 commits into
iree-org:mainfrom
GMNGeoffrey:ptr-size

Conversation

@GMNGeoffrey

@GMNGeoffrey GMNGeoffrey commented Apr 22, 2021 •

Copy link
Copy Markdown
Member

This wasn't working on our internal 32-bit arm architecture for some
reason. Unlike many methods one can find on the internet, the one used
here doesn't require listing every possible architecture. It has the
disadvantage (like the one used previously) that it requires uintptr_t,
which is not technically required by the standard and it requires that
uintptr_t be the size of a void pointer, which is also not
technically required. Both these properties are checked at compile time
though, so if we ever have to deal with some weird architecture where
that isn't true, I guess we can find some other way.

@google-cla google-cla Bot added the cla: yes label Apr 22, 2021
@GMNGeoffrey
GMNGeoffrey requested a review from benvanik April 22, 2021 01:45
Comment thread iree/base/target_platform.h Outdated
#define IREE_PTR_SIZE_64
#define IREE_PTR_SIZE 8
// See https://stackoverflow.com/q/51616057
_Static_assert(sizeof(void*) == sizeof(uintptr_t),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just use static_assert here instead of the funky casing

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh whew. I was wondering what the hell that was :-D This is what I get for copy-pasting from stack overflow

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I can't:

../iree/base/target_platform.h:108:15: error: expected parameter declarator
static_assert(sizeof(void*) == sizeof(uintptr_t),

https://source.cloud.google.com/results/invocations/e710f9e5-183d-4a0b-87d1-d945fd84f8bb/log

@GMNGeoffrey
GMNGeoffrey merged commit 96890e5 into iree-org:main Apr 22, 2021
@GMNGeoffrey
GMNGeoffrey deleted the ptr-size branch April 22, 2021 16:41
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