unixpickle / alux

A lightweight C++ kernel designed to run a JavaScript or Dart VM
BSD 2-Clause "Simplified" License
22 stars 5 forks source link

Tip: use compiler attributes #5

Closed joskuijpers closed 10 years ago

joskuijpers commented 10 years ago

Hey!

I see you start having a lot of methods/functions that shall never return. There is an attribute for that: attribute((noreturn)). What it does is optimise, and also show warnings/errors when you have code after a call to a non returning function. But mostly the optimisation is cool.

Cheers

unixpickle commented 10 years ago

Great idea. I tried to use this in LearnOS but gave up when the compiler complained. This time, I found out I could use __builtin_unreachable() to hint to the compiler that my inline-assembly prevents returns.