News for hackers. Stuff that matters.
Re:Asm-declaration – Embed assembly language code within a C... by mbel on Friday July 26, 2019 @08:43AM (#20534317)
Old, well-known feature of one of the most popular languages. I must be missing something, because I have no idea how this became a hacker "news" :)
Re:Asm-declaration – Embed assembly language code within a C... by mikeash on Friday July 26, 2019 @10:37AM (#20535098)
Hacker News Guidelines

What to Submit

On-Topic: Anything that good hackers would find interesting. That includes more than hacking and startups. If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity.

Re:Asm-declaration – Embed assembly language code within a C... by asveikau on Friday July 26, 2019 @10:59AM (#20535268)
It's not technically a feature of the language, as it is not standardized and is compiler-specific.

But thing you are talking about indeed recurs here. The way I typically guess is that new generations of programmers are coming up all the time and may be unfamiliar with some old stuff. Or, maybe even some experienced people who never happened to touch c or c++ [there are more of those as time goes on].

Re:Asm-declaration – Embed assembly language code within a C... by AdmiralAsshat on Friday July 26, 2019 @12:16PM (#20535902)
I'm scratching my head, too. I could've sworn the Linux kernel itself had a few chunks of hand-written assembly for better performance in key spots.

EDIT: I see several, just from doing a simple search against 'movq'

https://github.com/torvalds/linux/search?q=movq&unscoped_q=m...

I am not a kernel programmer, though, so I can't say whether it's being used in any capacity on modern, x64 systems or whether it's a compatibility mode for low-powered embedded architectures. Maybe someone more knowledgeable can chime in.

Re:Asm-declaration – Embed assembly language code within a C... by asveikau on Friday July 26, 2019 @03:03PM (#20537444)
In the case of the kernel it's not just a performance thing. There are a lot of things that are totally irrelevant to the high level notion of the C execution model that are therefore not exposed, and certainly not in the C standard.

Things like: Hm, I need to swap my stack register and page table with this other process.

Or writing interrupt handlers.

Atomic operations and memory barriers used to be one of those things, but compiler extensions and new language standards have been catching up on some of that... Though to be honest a kernel will want enough control that it will likely still go outside the standard or extra compiler support for these anyway.