News for hackers. Stuff that matters.
Re:Exploring GNU extensions in the Linux kernel by zhouzhouyi on Monday May 13, 2024 @03:55AM (#40340763)
I am fantastic on Linux kernel and on Clang compiler. This article teaches me what GNU extension characteristic will be when Linux kernel is accepting more modern C11 standard.

For example, Linux kernel use local labels, inline assembly and builtin functions heavily.

This article inspires me to persist studying in Linux kernel and Clang compiler.

Re:Exploring GNU extensions in the Linux kernel by jcalvinowens on Monday May 13, 2024 @12:42PM (#40345242)
Clang supports the extensions, you can build the Linux kernel with clang today:

  make -s LLVM=1
Re:Exploring GNU extensions in the Linux kernel by e63f67dd-065b on Monday May 13, 2024 @11:50PM (#40351468)
As sibling mentioned, you can build the kernel with clang today. `make CC=clang`, and for whatever reason I've found that it produces code that's significantly more pleasant to step through under a debugger than gcc.

If anybody has an explanation for this I'd love to hear it.

Re:Exploring GNU extensions in the Linux kernel by MaskRay on Tuesday May 14, 2024 @12:07AM (#40351516)
Interesting. Traditionally, Clang's -O1 and higher optimizations have been considered less debuggable than GCC's.

Sony developers have proposed changes to improve the debugging experience and some work has been done, e.g. https://discourse.llvm.org/t/rfc-redefine-og-o1-and-add-a-ne...

* change representation to help make -g not change codegen : https://discourse.llvm.org/t/rfc-debuginfo-proposed-changes-...

Re:Exploring GNU extensions in the Linux kernel by o11c on Tuesday May 14, 2024 @10:14PM (#40362386)
I don't kernel, but:

Empty structures are useful, but behave weirdly. Structures containing a zero-size `char` array are much more portable.

Although `__builtin_choose_expr` isn't available in C++, it's trivial to implement using templates. Actually a lot of these are a reminder that GNU C exists for people who refuse to use C++ for political reasons.

`__builtin_types_compatible_p` is mostly not needed now that C11 `_Generic` exists.

Re:Exploring GNU extensions in the Linux kernel by omoikane on Tuesday May 14, 2024 @10:55PM (#40362612)
I wonder what it would take to have the Elvis operator to be standardized in C and C++, since GCC and Clang have supported this extension for years.

https://en.wikipedia.org/wiki/Elvis_operator

Re:Exploring GNU extensions in the Linux kernel by pjmlp on Wednesday May 15, 2024 @03:11AM (#40363976)
Write a language improvement paper and fight for it at WG14 meetings, so that when voting comes to be, it is voted in.
Re:Exploring GNU extensions in the Linux kernel by AstroJetson on Wednesday May 15, 2024 @12:36PM (#40369168)
I've done a few bytecode interpreters but have mostly used the case of Operator type of driving loop. I was impressed by this

static void tbl[] = {&&do_ret, &&do_inc, &&do_dec};

#define NEXT goto tbl[*pc++]

NEXT;

for(;;) {

do_ret: return val;

do_inc: val++; NEXT;

do_dec: val--; NEXT;

}