summaryrefslogtreecommitdiff
path: root/src/basic/macro.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #2848 from keszybz/clang-warningsDaniel Mack2016-03-171-1/+5
|\ | | | | Clang warnings
| * basic/macros: clang 3.5 doesn't support alloc_sizeZbigniew Jędrzejewski-Szmek2016-03-151-1/+5
| | | | | | | | | | | | 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.
* | include sys/sysmacros.h in more placesMike Frysinger2016-03-141-0/+1
|/ | | | | | 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.
* Merge pull request #2702 from poettering/resolved-iterate-fixZbigniew Jędrzejewski-Szmek2016-02-291-0/+6
|\ | | | | resolved iteration fix
| * resolved: fix notification iteration logic when transactions are completedLennart Poettering2016-02-221-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | tree-wide: minor formatting inconsistency cleanupsVito Caputo2016-02-231-1/+1
|/
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* macro.h: provide a switch-case statement generator for IN_SETDaniel Mack2016-01-111-12/+41
| | | | | | | | | | | | 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
* util-lib: move CONF_DIRS_NULSTR definition to def.hLennart Poettering2015-11-031-15/+0
| | | | | | 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
* util-lib: split out globbing related calls into glob-util.[ch]Lennart Poettering2015-10-271-3/+0
|
* stat-util.h: move F_TYPE_EQUAL() macro definition to stat-util.hLennart Poettering2015-10-271-6/+0
|
* util-lib: split out printf() helpers to stdio-util.hLennart Poettering2015-10-271-45/+0
|
* macro.h: move definition of MODE_INVALID to parse-util.hLennart Poettering2015-10-271-2/+0
|
* macro: move DECIMAL_STR_WIDTH() into macro.hLennart Poettering2015-10-271-0/+9
| | | | So that it sets next to DECIMAL_STR_MAX(), where it belongs.
* socket-util: move CMSG_FOREACH() from macro.h to socket-util.hLennart Poettering2015-10-271-3/+0
|
* io-util.h: move iovec stuff from macro.h to io-util.hLennart Poettering2015-10-271-39/+2
|
* process-util: move PID related macros from macro.h to process-util.hLennart Poettering2015-10-271-3/+0
|
* user-util: move UID/GID related macros from macro.h to user-util.hLennart Poettering2015-10-271-10/+0
|
* util: drop UID_IS_INVALID() in favour of uid_is_valid()Lennart Poettering2015-09-221-12/+0
| | | | No need to keep both functions, settle on uid_is_valid() for everything.
* basic: nicer assert messagesMichal Schmidt2015-09-161-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* basic: make sure argument of ELEMENTSOF is an arrayMichal Schmidt2015-09-161-2/+5
| | | | Using ELEMENTSOF on a pointer will result in a compilation error.
* macro: introduce new PID_TO_PTR macros and make use of themLennart Poettering2015-09-041-0/+3
| | | | | | | 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.
* Merge pull request #537 from poettering/nss-mymachines-usernsDavid Herrmann2015-07-231-0/+13
|\ | | | | Hook up container userns with nss-mymachines
| * nss-mymachines: map userns users of containers to real user namesLennart Poettering2015-07-091-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | basic: more optimizable IN_SET macroMichal Schmidt2015-07-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | basic: better readable IN_SET macroMichal Schmidt2015-07-221-4/+4
|/ | | | | | | | | | | | | | 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
* sd-event: make errors on EPOLL_CTL_DEL pseudo-fatalDavid Herrmann2015-06-171-5/+6
| | | | | | | | | 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).
* build-sys: split internal basic/ library from shared/Kay Sievers2015-06-111-0/+473
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/