]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/macro.h
macro.h: provide a switch-case statement generator for IN_SET 2294/head
authorDaniel Mack <daniel@zonque.org>
Sun, 10 Jan 2016 17:11:22 +0000 (18:11 +0100)
committerDaniel Mack <daniel@zonque.org>
Mon, 11 Jan 2016 11:02:36 +0000 (12:02 +0100)
commitd5b26d50fca744d1b19eb8c125b047c18c61ad94
tree54a510fc8e7098178eb474cd2d8ac1be38e549e2
parent201f0c916d8f65ad2595a651b1371fcd39a4cf55
macro.h: provide a switch-case statement generator for IN_SET

Rather than walking a list of valid values one-by-one, generate a
switch-case statement for the IN_SET() macro. This allows the compiler to
further optimize its code output, possibly by generating jump tables.
This effectively decreases the binary size slightly.

The implementation is based on macro overloading depending on the number of
arguments. h/t to the following post:

  https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
src/basic/macro.h