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

naming consistency for kernel object initializer macros #24645

Closed
pabigot opened this issue Apr 23, 2020 · 4 comments · Fixed by #24684
Closed

naming consistency for kernel object initializer macros #24645

pabigot opened this issue Apr 23, 2020 · 4 comments · Fixed by #24684
Assignees

Comments

@pabigot
Copy link
Collaborator

pabigot commented Apr 23, 2020

What is the policy for naming the initializer value macro for objects defined in kernel.h?

I see the following being used:

Object KObj Recommended Deprecated
FIFO no Z_* K_*
FUTEX_DATA* yes Z_*
LIFO no _K_* K_*
MBOX no _K_* K_*
MEM_SLAB yes _K_* K_*
MSGQ yes _K_* K_*
MUTEX yes _K_* K_*
PIPE yes _K_* K_*
POLL_EVENT no K_*
POLL_SIGNAL yes K_*
QUEUE yes _K_* K_*
SEM yes Z_* K_*
STACK yes _K_* K_*
TIMER yes Z_* K_*
WORK no Z_* K_*

[*] FUTEX_DATA is the initialized object, FUTEX is the kernel object.

The selection between Z_*, _K_*, and K_* has no pattern I can immediately discern. This makes it difficult to figure out how to initialize a kernel object at compile-time (must go to the header and see which spelling is used for the type).

@andrewboie
Copy link
Contributor

andrewboie commented Apr 23, 2020

K_ is public.
Z_ is not.
_K_ needs to be changed to Z_, whoever did the naming conversion a couple years ago to rename variables with prefixed underscores to Z_ didn't finish the job.

@pabigot
Copy link
Collaborator Author

pabigot commented Apr 23, 2020

@andrewboie Thanks. I thought it might be that, but was surprised that I can't statically initialize semaphores and timers without using a non-public API.

@nashif
Copy link
Member

nashif commented Apr 23, 2020

but was surprised that I can't statically initialize semaphores and timers without using a non-public API.

You should be using K_SEM_DEFINE for that?

@pabigot
Copy link
Collaborator Author

pabigot commented Apr 23, 2020

You should be using K_SEM_DEFINE for that?

Thanks for the clue; I see what happened. This all started because I wanted to statically define a k_delayed_work instance, but there is no K_DELAYED_WORK_DEFINE() or K_DELAYED_WORK_INITIALIZER, so I have to do it with:

static k_delayed_work work = {
    .work = Z_WORK_INITIALIZER(work_handler),
};

Also I'd planned to have a semaphore inside another structure, for which the *_DEFINE() macros don't work.

Probably there should be an issue to finish the conversion of _K_* to Z_*, and backfill any missing *_DEFINE() macros, but that's not this one. Questions answered; thanks.

@pabigot pabigot closed this as completed Apr 23, 2020
nashif added a commit to nashif/zephyr that referenced this issue Apr 24, 2020
Rename internal macros to use Z_ prefix instead of _K..

Those macros were missed when we did the global renaming activities.

Fixes zephyrproject-rtos#24645

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
carlescufi pushed a commit that referenced this issue Apr 24, 2020
Rename internal macros to use Z_ prefix instead of _K..

Those macros were missed when we did the global renaming activities.

Fixes #24645

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
sandeepbrcm pushed a commit to Broadcom/zephyr that referenced this issue Apr 30, 2020
Rename internal macros to use Z_ prefix instead of _K..

Those macros were missed when we did the global renaming activities.

Fixes zephyrproject-rtos#24645

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
hakehuang pushed a commit to hakehuang/zephyr that referenced this issue Jun 20, 2020
Rename internal macros to use Z_ prefix instead of _K..

Those macros were missed when we did the global renaming activities.

Fixes zephyrproject-rtos#24645

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants