Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Fix builds for 32 bit architecture#15

Merged
chingor13 merged 8 commits intomasterfrom
32bit
Aug 15, 2017
Merged

Fix builds for 32 bit architecture#15
chingor13 merged 8 commits intomasterfrom
32bit

Conversation

@chingor13
Copy link
Copy Markdown
Member

@chingor13 chingor13 commented Aug 15, 2017

Fixes #13 (unsigned int issue)
Fixes #14 (segfaults with zend_parse_parameters)

zend_parse_parameters is not setting optional zval pointers to NULL.
Instead, we need to default the pointer to NULL so we can check for it
and set a default value.
php_mt_rand() returns 32 bits of randomness even for 64 bit integers.
In the 64 bit case, a 0 is always right shifted into the 32nd bit.
In the 32 bit case, a right shift is dependent on the compiler
implementation. Generally, negative numbers will remain negative to make
bitshift arthmatic work.
@chingor13 chingor13 changed the title [WIP] Fix builds for 32 bit architecture Fix builds for 32 bit architecture Aug 15, 2017
@chingor13 chingor13 requested a review from tmatsuo August 15, 2017 21:37
Comment thread ext/opencensus_trace.c
}
#endif
span->span_id = (php_mt_rand() >> 1);
span->span_id = ((uint32_t) php_mt_rand()) >> 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So does it pass the test on 32bit? Worth adding some comments?

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.

It should pass on 32-bit versions of PHP we now test against PHP 7.0 and 7.1 on a 32-bit debian build.
Also added comment about why this is in here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks. It might be a dumb question.

The return value of php_mt_rand is uint32_t (https://github.com/php/php-src/blob/869fccea24ac829de8ebf9947f6515f03b7d1fe1/ext/standard/mt_rand.c#L163) and I still don't understand why it works.

@chingor13 chingor13 merged commit db6c507 into master Aug 15, 2017
@chingor13 chingor13 deleted the 32bit branch August 15, 2017 22:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants