|
|
Subscribe / Log in / New account

A pair of memory-allocation improvements in 5.13

A pair of memory-allocation improvements in 5.13

Posted May 10, 2021 19:55 UTC (Mon) by abatters (✭ supporter ✭, #6932)
In reply to: A pair of memory-allocation improvements in 5.13 by willy
Parent article: A pair of memory-allocation improvements in 5.13

Probably referring to this:

https://en.cppreference.com/w/c/language/identifier#Reser...

The following identifiers are reserved and may not be declared in a program (doing so invokes undefined behavior):

3) All identifiers that begin with an underscore followed by a capital letter or by another underscore (these reserved identifiers allow the library to use numerous behind-the-scenes non-external macros and functions)

---

The kernel has been violating this rule for a long time. It is more important in userspace though to avoid clashes with glibc internals. I recall there was once a programming guide years ago (by Rusty Russell IIRC) that suggested using the kernel's double-underscore convention in userspace, but it had to be updated once someone pointed out the above rule. If there has been a recent push to get the kernel to follow the rule, I am not aware of it.


to post comments

A pair of memory-allocation improvements in 5.13

Posted May 11, 2021 19:35 UTC (Tue) by jiiksteri (subscriber, #75247) [Link]

> The kernel has been violating this rule for a long time

IIRC the kernel interpretation has been that the underscore prefix is reserved _for the runtime implementation_ and compared to the average comfy userspace, the kernel _is_ the implementation rather than a hosted environment.

Plus as mentioned above, they should be mostly local helpers, and it's probably good to feel a bit dirty using an exported __symbol :)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds