TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

C++ in the Linux Kernel

112 点作者 davikrr超过 3 年前

13 条评论

jcelerier超过 3 年前
&gt; You see the problem. My C++ code expected the calling convention that pushed arguments on the stack,<p>that would be very weird on Linux. The x86_64 linux ABI mandates that the first arguments go on registers afaik (I&#x27;m assuming x86_64 here since the post mentions linux distros which are overwhelmingly x64). What compiler would default to a pure stack-based calling convention ? Certainly not GCC or clang, no ?<p>&gt; and the kernel expected my code to pass arguments in the registers.<p>so, how is that a problem with C++ and not the compiler defaults ?<p>&gt; I found the real gold mine of C++ kernel module development knowledge in OSDev.org. They have an entire article on C++ issues. That includes avoiding templates<p>bullshit it is then. <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=A_saS93Clgk" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=A_saS93Clgk</a><p>if templates are good (sometimes better even) on AVR microcontrollers with memory in kilobytes, there&#x27;s no reason to not use them in a kernel meant to run on large embedded.<p>Also what&#x27;s that rant about strings for ? In the end there is zero substance to this article, only very strange rants.
评论 #29468975 未加载
评论 #29469282 未加载
评论 #29468977 未加载
评论 #29469525 未加载
zauguin超过 3 年前
&gt; I found the real gold mine of C++ kernel module development knowledge in OSDev.org. They have an entire article on C++ issues. That includes avoiding templates<p>No, it doesn&#x27;t?!? The linked article mentions templates two times (+ 2 mentions of the standard template library), once saying that templates can be used without further setup and the other times recommending that some template based data structures should be implemented. That&#x27;s pretty far from &quot;avoiding templates&quot;.
monocasa超过 3 年前
Lol, part of me likes the effort taken just because, but the kernel devs _really_ do not want C++. One hint: &quot;struct class&quot;<p><a href="https:&#x2F;&#x2F;elixir.bootlin.com&#x2F;linux&#x2F;latest&#x2F;source&#x2F;include&#x2F;linux&#x2F;device&#x2F;class.h#L54" rel="nofollow">https:&#x2F;&#x2F;elixir.bootlin.com&#x2F;linux&#x2F;latest&#x2F;source&#x2F;include&#x2F;linux...</a>
评论 #29470036 未加载
评论 #29471473 未加载
评论 #29469401 未加载
评论 #29469274 未加载
rajeevk超过 3 年前
In the past, I wrote a unix like kernel from scratch in C++. I have summarized what I had to do to get C++ code run on bare metal in this article <a href="https:&#x2F;&#x2F;www.avabodh.com&#x2F;cxxin&#x2F;nostdlib.html" rel="nofollow">https:&#x2F;&#x2F;www.avabodh.com&#x2F;cxxin&#x2F;nostdlib.html</a>
评论 #29470152 未加载
nly超过 3 年前
These are all standard C and C++ interop problems also found in userland and typically go away if the C project at hand is cooperative.
creamytaco超过 3 年前
There&#x27;s one problem with rants such as these, it&#x27;s too easy for someone to be exposed as clueless and broadcast his lack of knowledge and assumption-heavy development process to the world. How is that as an advertisement for one&#x27;s employer?
rramadass超过 3 年前
Valueless Article. Please stop posting these sort of articles which have no information content.<p>The article is merely a rant because the author doesn&#x27;t have much of an idea of how C++ actually works. Merely knowing the syntax doesn&#x27;t make one a &quot;C++ programmer&quot; and this is even more true when you are messing around in the Kernel. The article contains no specifics only general statements making me think this was put up to just be a &quot;hit piece&quot;.
评论 #29473740 未加载
jlkjaoifnwlekfj超过 3 年前
&gt; A first-year computer science student can tell you that the arguments get pushed onto the stack. In other words, a call to this 3GL function results in the following assembly pseudo code<p>Are people this ignorant when it comes to C&#x2F;C++ or any systems language? ABI &amp; calling conventions were introduced early in my C &amp; C++ textbooks (age 13 btw, not even close to college years).
评论 #29469165 未加载
评论 #29472171 未加载
评论 #29469346 未加载
kwertyoowiyop超过 3 年前
The article has maybe three paragraphs of actual information.
uyt超过 3 年前
&gt; Kernel developers obsess about speed and performance. The Linux kernel is built using -mregparm=3, which is sometimes called fastcall.<p>I&#x27;ve never messed with calling convention for the sake of performance before so I found this bit interesting. I found more info about it at: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;X86_calling_conventions#Borland_register" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;X86_calling_conventions#Borlan...</a><p>Does anyone have benchmarks? Assuming I don&#x27;t care about ABI stability, what&#x27;s the fastest calling convention?
评论 #29470655 未加载
jayp1418超过 3 年前
There should be Ada in Linux kernel
评论 #29468902 未加载
gtqytqyqyq超过 3 年前
a complete waste of time
评论 #29475008 未加载
qqumut超过 3 年前
I guess Rust is far better choise for that.
评论 #29470525 未加载
评论 #29469267 未加载