zend_compiler, ...: use uint8_t instead of zend_uchar#10621
Merged
Merged
zend_compiler, ...: use uint8_t instead of zend_uchar#10621
uint8_t instead of zend_uchar#10621Conversation
TimWolla
reviewed
Feb 19, 2023
nikic
suggested changes
Feb 19, 2023
nikic
left a comment
Member
There was a problem hiding this comment.
To be safe on theoretical architectures which don't have uint8_t, this commit uses uint_least8_t instead, which is guaranteed to be supported.
We already make extensive use of uint8_t, you can assume it exists.
Especially your changes to the zval structure are outright incorrect if the type doesn't an 8 bit size.
Contributor
Author
Okay for me, it's just that @derickr felt it was important to point out to me that these types are optional. If that's not important at all for the rest of you, I can ignore his comment out it from now on. |
be3b1f6 to
1fc953a
Compare
Contributor
Author
|
Changed to |
mvorisek
reviewed
Feb 19, 2023
mvorisek
reviewed
Feb 19, 2023
Contributor
There was a problem hiding this comment.
Suggested change
| uint8_t type; /* packed zend_stream_type */ | |
| uint8_t type; /* packed zend_stream_type */ |
mvorisek
reviewed
Feb 19, 2023
1fc953a to
1b907cf
Compare
MaxKellermann
added a commit
to CM4all/php-src
that referenced
this pull request
Feb 20, 2023
PHP 8 switched to C99, but did not documented that anywhere. After @derickr rejected a pull request on timelib (derickr/timelib#141 (comment)) because my suggested change removed compile-time checks for fixed-width integer types, pointing out that they are optional in the C99 standard, @nikic disagreed with using `uint_least8_t` instead (which is guaranteed to be available), stating that "We already make extensive use of uint8_t, you can assume it exists" (php#10621 (review)). In order to avoid such confusion in the future, let's document this architecture requirement.
Girgias
pushed a commit
that referenced
this pull request
Feb 20, 2023
…0631) PHP 8 switched to C99, but did not documented that anywhere. After @derickr rejected a pull request on timelib (derickr/timelib#141 (comment)) because my suggested change removed compile-time checks for fixed-width integer types, pointing out that they are optional in the C99 standard, @nikic disagreed with using `uint_least8_t` instead (which is guaranteed to be available), stating that "We already make extensive use of uint8_t, you can assume it exists" (#10621 (review)). In order to avoid such confusion in the future, let's document this architecture requirement.
`zend_uchar` suggests that the value is an ASCII character, but here, it's about very small integers. This is misleading, so let's use a C99 integer instead. On all architectures currently supported by PHP, `zend_uchar` and `uint8_t` are identical. This change is only about code readability.
1b907cf to
0bfc9fb
Compare
Contributor
Author
|
Rebased & fixed conflict. |
Merged
uint_least8_t instead of zend_ucharuint8_t instead of zend_uchar
MaxKellermann
added a commit
to CM4all/php-src
that referenced
this pull request
Mar 7, 2023
`zend_uchar` suggests that the value is an ASCII character, but here, it's about very small integers. This is misleading, so let's use a C99 integer instead. On all architectures currently supported by PHP, `zend_uchar` and `uint8_t` are identical. This change is only about code readability.
MaxKellermann
added a commit
to CM4all/php-src
that referenced
this pull request
Jul 7, 2025
`zend_uchar` suggests that the value is an ASCII character, but here, it's about very small integers. This is misleading, so let's use a C99 integer instead. On all architectures currently supported by PHP, `zend_uchar` and `uint8_t` are identical. This change is only about code readability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
zend_ucharsuggests that the value is an ASCII character, but here, it's about very small integers. This is misleading, so let's use a C99 integer instead.On all architectures currently supported by PHP,
zend_ucharanduint_tare identical. This change is only about code readability.(See #10597 (comment) for a discussion; @mvorisek)