Something like __builtin_expect for enums?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

in GCC we can use __builtin_expect() to give the compiler a branch prediction information for expressions. Is it possible to use an attribute for enums to say that enum value A is more likely than B, e.g.

enum e {
	__attribute__((likely)) A,
	B,
	C
};

This is useful for status codes that are encoded in an enum, e.g.

enum status = func();
if (status != ERROR_STATUS) {
  blablub();
}

I found  nothing in the manual.  Maybe this is a useful enhancement for the GCC?

--
Sebastian Huber, embedded brains GmbH

Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone   : +49 89 18 90 80 79-6
Fax     : +49 89 18 90 80 79-9
E-Mail  : sebastian.huber@xxxxxxxxxxxxxxxxxx
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux