-
Notifications
You must be signed in to change notification settings - Fork 117
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
[libc] exit,abort,longjmp are noreturn #1771
Conversation
Hello Chuck, Well, you beat me to it on this one :) I've been meaning to make some changes like this, but didn't think it'd actually save a whole block on the distribution media, nice! I'll commit this now, but think we could probably put the Thank you! |
I debated where to put this, even what to call it. This was first standardized in the C99 spec, so this follows that lead. And modern compilers ship this header, although the syntax has changed.
The worst thing is including what should be a compiler header in the libc includes. Maybe I don't need to supply this header at all; shouldn't the ia16 gcc include this header? It seems to... but I will have to do a super-clean build to be sure. The rest of the PR might be sufficient and standards-compliant, but we should drop the actual libc/include/stdnoreturn.h if possible. |
This area of C is a mess. There are 3 options:
The ia16 cross compiler does include the header. Even so, I now think it would be best to sprinkle the |
Thanks for the research, I wasn't aware this (and likely many others) are C99. However, I like your implementation of
Are you referring to this PR's stdnoreturn.h, or something else? Of course you've seen that ELKS libc sys/types.h also includes the kernel types.h as well as arch/types.h... so all sorts of kernel stuff gets dragged in to libc. I'm not sure its terrible that a compiler header gets included, iff it is done in only once place such that it would be easy to change. The issue of where to put compiler-specific keyword-based enhancements should probably be thought out a bit more, but since this is the first new keyword, and first new header file, I'm OK with committing it now and possibly changing it when more keywords are added. |
Yes. That much, at least, should be deleted. |
Wow. Defined, then deprecated? What a mess.
Actually, I don't like the mess that adding underbar-prefixed keywords in actual source provides. I view this as the least best option (!)
This also allows using
ELKS can't be built with another compiler without lots of work. In summary, I think we're getting close to going overboard on this. I actually prefer this first submission as-is, and would not like it to be updated to |
It builds fine after dropping the redundant |
For an idea of how a great C library deals with most of this kind of stuff, see Cosmopolitan's c.inc which defines lots of convenience macros and deals with all the compiler inanities in almost a single file.
Having said all this, the aims and goals of Cosmopolitan are far greater than ELKS; I'm not sure we need to go to the same trouble. |
Well, OK. But now haven't we made compilation (even outside of linking, just for analyzation, etc) dependent on a header file that we don't define? I actually had made a big effort to reduce this quite a bit, for complexities sake. IIRC, ELKS is only dependent on external limits.h, stddef.h and stdint.h. (And now stdnoreturn.h). |
Okay, I understand your desire now, but the list seems larger than that. :-/
|
Thanks for the research lol!! And I thought for sure I'd killed Your list is interesting. Perhaps we should think about this a bit more. BTW, when I ended up having to add limits.h into libc for reasons I can't remember it turned into a "real pain" actually getting it to work, as my limits.h "replacement" was required for some reason and so was the original! It took forever, and finally, you can see, that libc/include/limits.h ended up having to do a Here's libc limits.h:
Its a mess - we have libc limits.h, kernel limits.h, and gcc limits.h :( |
Hello @ccoffing,
It got a little late last night... I now understand what you meant by the above comment - that of creating a header file with the same name as one that is supposed to be already supplied by the compiler. I agree if the header name is an actual standard, given the example of what has happened with limits.h (described above) where the compiler header was needed, along with the "replacement". When I'm still not sure exactly when/where Thank you! |
@ghaerr I thought about this just a bit more. Summarizing the points...
Based on that, the answer seems simple -- revert this change, and put |
I'm pretty much in agreement with your summary. But I still very much like the idea of having convenience macros - they don't have to use a special header file per se, and they can provide a simple way to hide the actual compiler extensions from the source. IMO, this is better than sprinkling compiler-specific extensions in the source, for a variety of reasons. And what do you know - turns out I already implemented
I now remember doing that for some experimentation (and obviously without research like you did for proper, existing, or deprecated standards).
I ended up committing your work yesterday because, while there is still some debate, your research showed that There is already some user land stack trace code (in elkscmd/debug/) that has been partly moved to libc (which uses [EDIT: After looking at Cosmopolitan libc, whose author I have great respect for, I notice that "standard" keywords have been avoided, instead using, for instance Instead of adding multiple standard or non-standard header files for some keywords or convenience macros, why not just place them in a single lower-level header file (think hierarchy includes here, instead of explicit includes everywhere), like possibly include/arch/cdefs.h. Then, in include/linuxmt/types.h do this:
Our libc sys/types.h already includes features.h which includes sys/cdefs.h, and also includes the kernel types.h using While not "standard", this would allow all ELKS to use a common convenience macro for any/all compiler-specific extensions, with very little changes to existing libc or kernel header files. What do you think? |
Okay, that seems good. I should have checked what was already in the tree! Ha. I do like the thought of having it in a core header, and not having to include extra headers every time. And it can be protected to not conflict in case the compiler's version was manually included first. Is this a change you're going to make? |
Yes @ccoffing I'll make the change, thanks for your research and comments! |
If the compiler supports
noreturn
annotations, it can occasionally allow the optimizer to be more effective.I checked a full build with and without this change, and didn't see any new warnings. It does save one block when building everything on the 2.88M floppy.