summaryrefslogtreecommitdiff
path: root/src/basic/macro.h
AgeCommit message (Collapse)Author
2016-06-10networkd: add support to configure VLAN on bridge portsTobias Jungel
2016-03-17Merge pull request #2848 from keszybz/clang-warningsDaniel Mack
Clang warnings
2016-03-15basic/macros: clang 3.5 doesn't support alloc_sizeZbigniew Jędrzejewski-Szmek
The attribute was removed in commit c047507 in the clang repository as it was never properly implemented anyway. Avoid using the attribute with clang because it generates a ton of annoying warnings.
2016-03-14include sys/sysmacros.h in more placesMike Frysinger
Since glibc is moving away from implicitly including sys/sysmacros.h all the time via sys/types.h, include the header directly in more places. This seems to cover most makedev/major/minor usage.
2016-02-29Merge pull request #2702 from poettering/resolved-iterate-fixZbigniew Jędrzejewski-Szmek
resolved iteration fix
2016-02-23tree-wide: minor formatting inconsistency cleanupsVito Caputo
2016-02-22resolved: fix notification iteration logic when transactions are completedLennart Poettering
When a transaction is complete, and we notify its owners, make sure we deal correctly with the requesters removing themselves from the list of owners while we continue iterating. This was previously already dealt with with transactions that require other transactions for DNSSEC purposes, fix this for other possibly transaction owners too now. Since iterating through "Set" objects is not safe regarding removal of entries from it, rework the logic to use two Sets, and move each entry we notified from one set to the other set before we dispatch the notification. This move operation requires no additional memory, and enables us to ensure that we don't notify any object twice. Fixes: #2676
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-01-11macro.h: provide a switch-case statement generator for IN_SETDaniel Mack
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
2015-11-03util-lib: move CONF_DIRS_NULSTR definition to def.hLennart Poettering
After all, this is not some compiler or C magic, but something very specific to how systemd works, hence let's move it into def.h, and out of macro.h
2015-10-27util-lib: split out globbing related calls into glob-util.[ch]Lennart Poettering
2015-10-27stat-util.h: move F_TYPE_EQUAL() macro definition to stat-util.hLennart Poettering
2015-10-27util-lib: split out printf() helpers to stdio-util.hLennart Poettering
2015-10-27macro.h: move definition of MODE_INVALID to parse-util.hLennart Poettering
2015-10-27macro: move DECIMAL_STR_WIDTH() into macro.hLennart Poettering
So that it sets next to DECIMAL_STR_MAX(), where it belongs.
2015-10-27socket-util: move CMSG_FOREACH() from macro.h to socket-util.hLennart Poettering
2015-10-27io-util.h: move iovec stuff from macro.h to io-util.hLennart Poettering
2015-10-27process-util: move PID related macros from macro.h to process-util.hLennart Poettering
2015-10-27user-util: move UID/GID related macros from macro.h to user-util.hLennart Poettering
2015-09-22util: drop UID_IS_INVALID() in favour of uid_is_valid()Lennart Poettering
No need to keep both functions, settle on uid_is_valid() for everything.
2015-09-16basic: nicer assert messagesMichal Schmidt
Make sure the assert expression is not macro-expanded before stringification. This makes several assertion failure messages more readable. As an example: assert(streq("foo", "bar")); I'd rather see this: Assertion 'streq("foo", "bar")' failed at foo.c:5, function main(). Aborting. ...than this, though awesome, incomprehensible truncated mess: Assertion '(__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (( "foo")) && __builtin_constant_p (("bar")) && (__s1_len = strlen (("foo")), __s2_ len = strlen (("bar")), (!((size_t)(const void *)((("foo")) + 1) - (size_t)(cons t void *)(("foo")) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((("bar") ) + 1) - (size_t)(const void *)(("bar")) == 1) || __s2_len >= 4)) ? __builtin_st rcmp (("foo"), ("bar")) : (__builtin_constant_p (("foo")) && ((size_t)(const voi d *)((("foo")) + 1) - (size_t)(const void *)(("foo")) == 1) && (__s1_len = strle n (("foo")), __s1_len < 4) ? (__builtin_constant_p (("bar")) && ((size_t)(const void *)((("bar")) + 1) - (size_t)(const void *)(("bar")) == 1) ? __builtin_strcm p (("foo"), ("bar")) : (__extension__ ({ const unsigned char *__s2 = (const unsi gned char *) (const char *) (("bar")); int __result = (((const unsigned char *) (const char *) (("foo")))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __ result = (((const unsigned char *) (const char *) (("foo")))[1] - __s2[1]); if ( __s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const cha r *) (("foo")))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = ((( const unsigned char *) (const char *) (("foo")))[3] - __s2[3]); } } __result; }) )) : (__builtin_constant_p (("bar")) && ((size_t)(const void *)((("bar")) + 1) - (size_t)(const void *)(("bar")) == 1) && (__s2_len = strlen (("bar")), __s2_len < 4) ? (__builtin_constant_p (("foo")) && ((size_t)(const void *)((("foo")) + 1 ) - (size_t)(const void *)(("foo")) == 1) ? __builtin_strcmp (("foo"), ("bar")) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (cons t char *) (("foo")); int __result = (((const unsigned char *) (const char *) ((" bar")))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (("bar")))[1] - __s2[1]); if (__s2_len > 1 && __ result == 0) { __result = (((const unsigned char *) (const char *) (("bar")))[2] - __s2[2]); if (__s2_len > 2 && __result == 0)
2015-09-16basic: make sure argument of ELEMENTSOF is an arrayMichal Schmidt
Using ELEMENTSOF on a pointer will result in a compilation error.
2015-09-04macro: introduce new PID_TO_PTR macros and make use of themLennart Poettering
This adds a new PID_TO_PTR() macro, plus PTR_TO_PID() and makes use of it wherever we maintain processes in a hash table. Previously we sometimes used LONG_TO_PTR() and other times ULONG_TO_PTR() for that, hence let's make this more explicit and clean up things.
2015-07-23Merge pull request #537 from poettering/nss-mymachines-usernsDavid Herrmann
Hook up container userns with nss-mymachines
2015-07-22basic: more optimizable IN_SET macroMichal Schmidt
Making the array static allows gcc -O2 to generate smaller code: "size systemd" before: text data bss dec hex filename 1377286 128608 2632 1508526 1704ae systemd After: text data bss dec hex filename 1374326 128572 2664 1505562 16f91a systemd (IN_SET still results in worse generated code than using "x == FOO || x == BAR || ...". I don't think we'll be able to match that with the C preprocessor.) This change limits the use of IN_SET to sets with constant elements. All present callers use constants. The compiler would report an "initializer element is not constant" error otherwise.
2015-07-22basic: better readable IN_SET macroMichal Schmidt
Putting the set elements in an array variable and using ELEMENTSOF makes it clearer what's going on. Incidentally, it also makes gcc -O2 generate slightly smaller code: "size systemd", before: text data bss dec hex filename 1378318 128608 2632 1509558 1708b6 systemd After: text data bss dec hex filename 1377286 128608 2632 1508526 1704ae systemd
2015-07-09nss-mymachines: map userns users of containers to real user namesLennart Poettering
Given a container "foo", that maps user id $UID to container user, using user namespaces, this NSS module extenstion will now map the $UID to a name "vu-foo-$TUID" for the translated UID $UID. Similar, userns groups are mapped to "vg-foo-$TGID" for translated GIDs of $GID. This simple change should make userns users more discoverable. Also, given that many tools like "adduser" check NSS before allocating a UID, should lower the chance of UID range conflicts between tools.
2015-06-17sd-event: make errors on EPOLL_CTL_DEL pseudo-fatalDavid Herrmann
If we call EPOLL_CTL_DEL, we *REALLY* expect the file-descriptor to be present in that given epoll-set. We actually track such state via our s->io.registered flag, so it better be true. Make sure if that's not true, we treat it similar to assert_return() (ie., print a loud warning).
2015-06-11build-sys: split internal basic/ library from shared/Kay Sievers
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/