Earlier quoted context omitted.
> No. The C/C++ ABI is quite uniform across architectures. The first 1..N (N is ISA dependant) parameters that can fit into a CPU register are passed via registers. Here is the "System V i386 ABI" mentioned above: https://refspecs.linuxfoundation.org/elf/abi386-4.pdf (from https://refspecs.linuxfoundation.org/ ). It clearly passes all arguments on the stack, and none on registers ("Function Calling Sequence" starting…
You are not incorrect, and I shall ruminate on why I had thought that the SysV ABI on i386 used %rax ÷ %rex as input function parameters without having to resort to the use -mpregparm. Thanks for the correction.
C++ in the Linux Kernel
81–90 of 102 posts
Re: C++ in the Linux Kernel
#82Earlier quoted context omitted.
What bothers me about that is that, because C doesn't have namespaces, it's already a terrible name for a struct. What if you want another "class" of thing? Call it device_class ffs
You're dismissing the fact that the keyword collision really well might be intentional, the worst of it is that `/sys/class` siblings `bus` and `driver`, if their internal linux rep is actually in the `class.h` siblings, are called `struct bus_type` and `struct device_driver`
https://lwn.net/ml/linux-api/20180905165436.GA25206@kroah.co...
And that's for a userspace header.
Re: C++ in the Linux Kernel
#83Earlier quoted context omitted.
The whole issue with Linux and C++ is political, there are other OSes that don't suffer from such issues and gladly accept templates. https://developer.apple.com/documentation/driverkit https://docs.microsoft.com/en-us/cpp/build/reference/kernel-... https://fuchsia.dev/fuchsia-src/development/languages/c-cpp/... https://genodians.org/nfeske/2019-01-22-conscious-c++
I understand that for C++ programmers "That's possible" versus "That's a good idea" is a distinction without a difference, however for the rest of us the fact you can use templates as much as you like in, say, Windows drivers, does not magically mean it's a good idea to write complex templated code in Windows drivers. The constraints in /kernel like forbidding exceptions are because otherwise they (Microsoft) need to…
Re: C++ in the Linux Kernel
#84Re: C++ in the Linux Kernel
#85Earlier quoted context omitted.
Here is another example, running C++ straight on car firmware free of Linux politics via AUTOSAR certification standard. https://www.parasoft.com/blog/breaking-down-the-autosar-c14-... But what do they state specifically? Ah, right. > "The document allows in particular the usage of dynamic memory, exceptions, templates, inheritance and virtual functions." https://www.autosar.org/fileadmin/user_upload/standards/adap..…
It definitely feels like we're talking past each other. I keep telling you why people think it's a bad idea, and you keep showing that you're allowed to do it anyway. We know. That's the difference between impossible and a bad idea.
Re: C++ in the Linux Kernel
#86Earlier quoted context omitted.
Here is another example, running C++ straight on car firmware free of Linux politics via AUTOSAR certification standard. https://www.parasoft.com/blog/breaking-down-the-autosar-c14-... But what do they state specifically? Ah, right. > "The document allows in particular the usage of dynamic memory, exceptions, templates, inheritance and virtual functions." https://www.autosar.org/fileadmin/user_upload/standards/adap..…
It definitely feels like we're talking past each other. I keep telling you why people think it's a bad idea, and you keep showing that you're allowed to do it anyway. We know. That's the difference between impossible and a bad idea.
Re: C++ in the Linux Kernel
#87Earlier quoted context omitted.
So it is fine on a 64KB system, but unmanageable on a platform that gets all the different kinds of boilerplate to run cloud workloads, got it
C++ or even C isn't exactly "fine" on any 8-bit system though. It's nice for a little demo, it can even be tolerable for some real-world projects when mixed with large amounts of inline assembly, but those 8-bit ISAs have been designed mainly for manual assembly coding, not high level compiled languages like C.
Re: C++ in the Linux Kernel
#88Earlier quoted context omitted.
So it is fine on a 64KB system, but unmanageable on a platform that gets all the different kinds of boilerplate to run cloud workloads, got it
C++ or even C isn't exactly "fine" on any 8-bit system though. It's nice for a little demo, it can even be tolerable for some real-world projects when mixed with large amounts of inline assembly, but those 8-bit ISAs have been designed mainly for manual assembly coding, not high level compiled languages like C.
C++ adds type-safety on top of that for no cost. It's great when your compiler tells you that there is no operator =|(PORTD, PINA). Did you mean |=(PORTD,PIND) or =|(PORTA,PINA).
Re: C++ in the Linux Kernel
#89Valueless Article. Please stop posting these sort of articles which have no information content. The article is merely a rant because the author doesn't have much of an idea of how C++ actually works. Merely knowing the syntax doesn't make one a "C++ programmer" 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…
> Merely knowing the syntax doesn't make one a "C++ programmer"
Does knowing all the possible abstract layers (uh, it's an ocean) make one a C ++ programmer then?
> this is even more true when you are messing around in the Kernel
It's his right to mess around Kernel and learn things.
Re: C++ in the Linux Kernel
#90Earlier quoted context omitted.
C++ or even C isn't exactly "fine" on any 8-bit system though. It's nice for a little demo, it can even be tolerable for some real-world projects when mixed with large amounts of inline assembly, but those 8-bit ISAs have been designed mainly for manual assembly coding, not high level compiled languages like C.
C translates directly to ASM in many cases. It just makes managing offsets and other stuff easier. C++ adds type-safety on top of that for no cost. It's great when your compiler tells you that there is no operator =|(PORTD, PINA). Did you mean |=(PORTD,PIND) or =|(PORTA,PINA).