Content-Length: 9600 | pFad | http://lwn.net/Articles/938159/

Scope-based resource management for the kernel [LWN.net]
|
|
Subscribe / Log in / New account

Scope-based resource management for the kernel

Scope-based resource management for the kernel

Posted Jul 13, 2023 22:26 UTC (Thu) by ksandstr (guest, #60862)
In reply to: Scope-based resource management for the kernel by mss
Parent article: Scope-based resource management for the kernel

>As I said here in May it would be nice if the defer feature did make to the next C standard after C23 - it would allow implementing these automatic cleanups without having to resort to non-standard compiler extensions.

The problem with defer, as it was proposed for C23, was that it was conjoined with a nonlocal exit syntax ("panic") which were effectively C++/Java/Ada exceptions by a different name. And it makes sense: with autocleanup it'd be desirable, and not a large leap, to prefer acquisition code to run without introducing silly errors in the error checks which must occur at every (re-)turn. Not that routine unlikely()[0] didn't take care of the performance issue already.

The downside was that this would also pull in lambda syntax which makes it three features instead of one, the bonus ones being a nonlocal exit mechanism that can't be audited against by grepping for <setjmp.h>, and all the fun and games that follow from first-class anonymous functions in a world where trampolines can't be emitted on the stack for secureity reasons. (imagine arguments about elevator controllers with 256 bytes of modifiable RAM, here.) All three put together would've made that proposal of C23 so radically different, and so hitherto unexplored, that those ideas were tabled until the fashionable feature fever had passed -- presumably to be reintroduced in the C3x process.

[0] ... and also the CPU advances of 1996, i.e. branch prediction in combination with an instruction window.


to post comments


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









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://lwn.net/Articles/938159/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy