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

Move to using C99 int types and deprecating zephyr int types #25679

Merged
merged 7 commits into from
Jun 8, 2020

Conversation

galak
Copy link
Collaborator

@galak galak commented May 27, 2020

No description provided.

@zephyrbot

This comment has been minimized.

@galak galak linked an issue May 28, 2020 that may be closed by this pull request
@ceolin
Copy link
Member

ceolin commented May 28, 2020

I'm totally in favor of using standard stdint types .

include/sys/util.h Outdated Show resolved Hide resolved
@sjg20
Copy link
Collaborator

sjg20 commented May 28, 2020

These are longer and harder to type. Could we do what linux does instead?

u64, u32, u16, u8 for unsigned

@galak
Copy link
Collaborator Author

galak commented May 28, 2020

These are longer and harder to type. Could we do what linux does instead?

u64, u32, u16, u8 for unsigned

The issue is that a lot of code integrated w/zephyr utilizes C99 and those types have leaked into Zephyr. If we plan on getting 2 different types, we'd just leave the zephyr types as is.

@galak galak force-pushed the c99 branch 2 times, most recently from d83049d to 3110f62 Compare May 30, 2020 20:23
@galak
Copy link
Collaborator Author

galak commented Jun 1, 2020

The sanitycheck failure is timeout of a test that passes when run by itself.

@galak galak added the TSC Topics that need TSC discussion label Jun 2, 2020
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

Move to using PRIu64/PRId64 instead of %llu/%lld since on native_posix_64 the uint64_t/int64_t type is defined in terms of 'long int' and not 'long long int'.

Dropping the keyword "LP64" in the commit message and documentation would add a lot of relevant background information with very few extra characters. Something like: "Unlike Zephyr, native_posix_64 follows the LP64 model that blabla..."

https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
https://www.google.com/search?q=__LP64__

These are longer and harder to type.

https://twitter.com/study_web_dev/status/764811712394620928

(Not counting all the time spent trying to understand Zephyr types - and I barely did)

Could we do what linux does instead?

The Linux kernel doesn't look like it will ever care about POSIX-looking code.

galak added 6 commits June 6, 2020 07:30
On 64-bit arch's like AARCH64, x86_64, or riscv-64 the way {u}int64_t
will differ from how its defined on 32-bit arch's.  Do the same trick we
do for {u}int32_t for {u}int64_t so that the type is the same regardless
of what we are building for.

This keeps things like %lld working the same regardless of 32-bit or
64-bit arch.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Pull in various module updates for C99 type change

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
	git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Move to using PRIu64/PRId64 instead of %llu/%lld since on
native_posix_64 the uint64_t/int64_t type is defined in terms of 'long
int' and not 'long long int'.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
As the int types defined in include/zephyr/types.h are typdef's we
utilize a Kconfig option (LEGACY_ZEPHYR_INT_TYPES) to enable/disable
the support for them.  By default to LEGACY_ZEPHYR_INT_TYPES not
being enabled and add an explicit test to ensure the types continue to
function until removed in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Now that we are standardizing C99 integer types we can revert the commit
that warned about C99 type usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

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

I can't believe we're doing this again. But OK, quick spot checks show that the scripting did the right thing. Please rip the bandaid off and merge this quickly so we can get past the resulting rebase hell.

@nashif
Copy link
Member

nashif commented Jun 6, 2020

I am not fond of calling old types legacy, legacy means that you want to maintain those for a lengthy period of time where deprecated is more strict and follows deprecation policies.

Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

Please add an entry in the API Changes section of the 2.4 release notes in this PR

help
Allows use of the deprecated Zephyr integer typedefs defined in
Zephyr 2.3 and previous versions.

Copy link
Member

Choose a reason for hiding this comment

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

@galak could you please mention the types by name here?

@carlescufi
Copy link
Member

I am not fond of calling old types legacy, legacy means that you want to maintain those for a lengthy period of time where deprecated is more strict and follows deprecation policies.

It's what we do when we deprecate via Kconfig option. At least it's what we've done so far (timeouts and DT, which will both go away in 2 releases), so for consistency I think we should keep the same naming scheme.

It's mentioned here: https://docs.zephyrproject.org/latest/development_process/api_lifecycle.html#deprecated

@nashif
Copy link
Member

nashif commented Jun 6, 2020

t's what we do when we deprecate via Kconfig option. At least it's what we've done so far (timeouts and DT, which will both go away in 2 releases), so for consistency I think we should keep the same naming scheme.

It's mentioned here: https://docs.zephyrproject.org/latest/development_process/api_lifecycle.html#deprecated

well, just because we have what I think is a mistake, does not mean we have to continue with that mistake, and all of this happened just recently...

https://www.linkedin.com/pulse/deprecated-vs-legacy-ayoub-moustaid/

the way I see it:

  • deprecated: is something that you should not use and will be removed at some point following the deprecation policy. (2 releases)
  • legacy: won't be removed for backwards compatibility or other reasons.

Are we going to keep those types more than 2 releases?

@carlescufi
Copy link
Member

Are we going to keep those types more than 2 releases?

No, I don't think so. So in that case I suggest we change the doc, because right now (mostly because of the timeout and DT Kconfig options using LEGACY even though they'll be removed after 2 releases) it recommends using LEGACY and not DEPRECATED in the Kconfig option name.
I'm not against changing policy, I just want us to be consistent.

Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

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

Is samples/tests: Convert use of %ll{u,d} to PRI{u,d}64 intended to be comprehensive? git grep '%ll' tests/ finds a few more cases.

@galak
Copy link
Collaborator Author

galak commented Jun 8, 2020

Is samples/tests: Convert use of %ll{u,d} to PRI{u,d}64 intended to be comprehensive? git grep '%ll' tests/ finds a few more cases.

Only the samples/tests that get built on native_posix_64 were touched.

@galak
Copy link
Collaborator Author

galak commented Jun 8, 2020

@carlescufi I suggest we merge this and deal with any Kconfig/relnote fixes a follow up PRs.

@galak
Copy link
Collaborator Author

galak commented Jun 8, 2020

Add top line note about C99 integer types being the default

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
@galak galak merged commit a2d4292 into zephyrproject-rtos:master Jun 8, 2020
@galak galak deleted the c99 branch June 8, 2020 13:26
@galak
Copy link
Collaborator Author

galak commented Jun 8, 2020

@carlescufi & @nashif opened up PR #26047 to continue the legacy/deprecated naming discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TSC Topics that need TSC discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move to C99 integer types and deprecate zephyr specific types