macro.h revision bac3c8eefe23a820caac930d41629cebafbfc7b2
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen#pragma once
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen/***
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen This file is part of systemd.
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen Copyright 2010 Lennart Poettering
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen systemd is free software; you can redistribute it and/or modify it
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen under the terms of the GNU Lesser General Public License as published by
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen the Free Software Foundation; either version 2.1 of the License, or
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (at your option) any later version.
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen systemd is distributed in the hope that it will be useful, but
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen Lesser General Public License for more details.
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen You should have received a copy of the GNU Lesser General Public License
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen***/
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen#include <assert.h>
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen#include <sys/param.h>
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include <sys/types.h>
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering#include <sys/uio.h>
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen#include <inttypes.h>
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poettering#define _printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#define _sentinel_ __attribute__ ((sentinel))
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#define _noreturn_ __attribute__((noreturn))
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#define _unused_ __attribute__ ((unused))
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen#define _destructor_ __attribute__ ((destructor))
586ac6f711e2eccceb12421df22fca4f117226c4Lennart Poettering#define _pure_ __attribute__ ((pure))
586ac6f711e2eccceb12421df22fca4f117226c4Lennart Poettering#define _const_ __attribute__ ((const))
4dc355680460fdc8e0d590d8572dff1b6a257d88Tom Gundersen#define _deprecated_ __attribute__ ((deprecated))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _packed_ __attribute__ ((packed))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _malloc_ __attribute__ ((malloc))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _weak_ __attribute__ ((weak))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _likely_(x) (__builtin_expect(!!(x),1))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _unlikely_(x) (__builtin_expect(!!(x),0))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _public_ __attribute__ ((visibility("default")))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _hidden_ __attribute__ ((visibility("hidden")))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _weakref_(x) __attribute__((weakref(#x)))
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define _introspect_(x) __attribute__((section("introspect." x)))
2dead8129f7b6fe644e17e1dc1739bebacfe1364Tom Gundersen#define _alignas_(x) __attribute__((aligned(__alignof(x))))
2dead8129f7b6fe644e17e1dc1739bebacfe1364Tom Gundersen
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define XSTRINGIFY(x) #x
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define STRINGIFY(x) XSTRINGIFY(x)
99634696183dfabae20104e58157c69029a11594Tom Gundersen
99634696183dfabae20104e58157c69029a11594Tom Gundersen/* Rounds up */
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define ALIGN(l) ALIGN_TO((l), sizeof(void*))
99634696183dfabae20104e58157c69029a11594Tom Gundersenstatic inline size_t ALIGN_TO(size_t l, size_t ali) {
99634696183dfabae20104e58157c69029a11594Tom Gundersen return ((l + ali - 1) & ~(ali - 1));
99634696183dfabae20104e58157c69029a11594Tom Gundersen}
99634696183dfabae20104e58157c69029a11594Tom Gundersen
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
99634696183dfabae20104e58157c69029a11594Tom Gundersen
99634696183dfabae20104e58157c69029a11594Tom Gundersen/*
99634696183dfabae20104e58157c69029a11594Tom Gundersen * container_of - cast a member of a structure out to the containing structure
99634696183dfabae20104e58157c69029a11594Tom Gundersen * @ptr: the pointer to the member.
99634696183dfabae20104e58157c69029a11594Tom Gundersen * @type: the type of the container struct this is embedded in.
99634696183dfabae20104e58157c69029a11594Tom Gundersen * @member: the name of the member within the struct.
99634696183dfabae20104e58157c69029a11594Tom Gundersen *
99634696183dfabae20104e58157c69029a11594Tom Gundersen */
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define container_of(ptr, type, member) ({ \
99634696183dfabae20104e58157c69029a11594Tom Gundersen const typeof( ((type *)0)->member ) *__mptr = (ptr); \
99634696183dfabae20104e58157c69029a11594Tom Gundersen (type *)( (char *)__mptr - offsetof(type,member) );})
99634696183dfabae20104e58157c69029a11594Tom Gundersen
99634696183dfabae20104e58157c69029a11594Tom Gundersen#ifndef MAX
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define MAX(a,b) \
99634696183dfabae20104e58157c69029a11594Tom Gundersen __extension__ ({ \
99634696183dfabae20104e58157c69029a11594Tom Gundersen typeof(a) _a = (a); \
99634696183dfabae20104e58157c69029a11594Tom Gundersen typeof(b) _b = (b); \
99634696183dfabae20104e58157c69029a11594Tom Gundersen _a > _b ? _a : _b; \
99634696183dfabae20104e58157c69029a11594Tom Gundersen })
99634696183dfabae20104e58157c69029a11594Tom Gundersen#endif
99634696183dfabae20104e58157c69029a11594Tom Gundersen
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define MAX3(a,b,c) \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen MAX(MAX(a,b),c)
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#ifndef MIN
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define MIN(a,b) \
2dead8129f7b6fe644e17e1dc1739bebacfe1364Tom Gundersen __extension__ ({ \
99634696183dfabae20104e58157c69029a11594Tom Gundersen typeof(a) _a = (a); \
2dead8129f7b6fe644e17e1dc1739bebacfe1364Tom Gundersen typeof(b) _b = (b); \
2dead8129f7b6fe644e17e1dc1739bebacfe1364Tom Gundersen _a < _b ? _a : _b; \
20af7091de0cdf92bf299addfc3f96c3ef805bd8Tom Gundersen })
99634696183dfabae20104e58157c69029a11594Tom Gundersen#endif
99634696183dfabae20104e58157c69029a11594Tom Gundersen
99634696183dfabae20104e58157c69029a11594Tom Gundersen#define MIN3(a,b,c) \
99634696183dfabae20104e58157c69029a11594Tom Gundersen MIN(MIN(a,b),c)
99634696183dfabae20104e58157c69029a11594Tom Gundersen
20af7091de0cdf92bf299addfc3f96c3ef805bd8Tom Gundersen#define CLAMP(x, low, high) \
20af7091de0cdf92bf299addfc3f96c3ef805bd8Tom Gundersen __extension__ ({ \
20af7091de0cdf92bf299addfc3f96c3ef805bd8Tom Gundersen typeof(x) _x = (x); \
20af7091de0cdf92bf299addfc3f96c3ef805bd8Tom Gundersen typeof(low) _low = (low); \
04c0136989b7eb896bfb0fb176e11233d69e1453Lennart Poettering typeof(high) _high = (high); \
756775814cf69471f74ce853745bba69f2ba94efThomas Hindoe Paaboel Andersen ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
7c16313f11e3953f3fe4dbf544f2d36f58d14138Tom Gundersen })
7c16313f11e3953f3fe4dbf544f2d36f58d14138Tom Gundersen
7c16313f11e3953f3fe4dbf544f2d36f58d14138Tom Gundersen#define assert_se(expr) \
7c16313f11e3953f3fe4dbf544f2d36f58d14138Tom Gundersen do { \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen if (_unlikely_(!(expr))) \
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering log_assert_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering } while (false) \
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering/* We override the glibc assert() here. */
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering#undef assert
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering#ifdef NDEBUG
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen#define assert(expr) do {} while(false)
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen#else
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen#define assert(expr) assert_se(expr)
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen#endif
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define assert_not_reached(t) \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen do { \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen } while (false)
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#if defined(static_assert)
1e2527a6fede996a429bd44b30a15e76ee293437Tom Gundersen#define assert_cc(expr) \
b826ab586c9e0a9c0d438a75c28cf3a8ab485929Tom Gundersen do { \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen static_assert(expr, #expr); \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen } while (false)
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#else
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define assert_cc(expr) \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen do { \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen switch (0) { \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen case 0: \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen case !!(expr): \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen ; \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen } \
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen } while (false)
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#endif
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p)))
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt#define UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u)))
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt#define PTR_TO_ULONG(p) ((unsigned long) ((uintptr_t) (p)))
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt#define ULONG_TO_PTR(u) ((void*) ((uintptr_t) (u)))
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define INT_TO_PTR(u) ((void*) ((intptr_t) (u)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define TO_INT32(p) ((int32_t) ((intptr_t) (p)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define INT32_TO_PTR(u) ((void*) ((intptr_t) (u)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define PTR_TO_LONG(p) ((long) ((intptr_t) (p)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define LONG_TO_PTR(u) ((void*) ((intptr_t) (u)))
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering#define memzero(x,l) (memset((x), 0, (l)))
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen#define zero(x) (memzero(&(x), sizeof(x)))
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering#define char_array_0(x) x[sizeof(x)-1] = 0;
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering#define IOVEC_SET_STRING(i, s) \
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering do { \
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering struct iovec *_i = &(i); \
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering char *_s = (char *)(s); \
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering _i->iov_base = _s; \
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen _i->iov_len = strlen(_s); \
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering } while(false)
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poetteringstatic inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned n) {
87322b3aee0dc649ff1ae7a403dcc9d7305baba2Tom Gundersen unsigned j;
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering size_t r = 0;
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering
8eb9058dc1f99a5eb9b8726a978fcc0720837a10Lennart Poettering for (j = 0; j < n; j++)
1a04db0fc9d08fffe80d6d7b5b60459295922b11Lennart Poettering r += i[j].iov_len;
1a04db0fc9d08fffe80d6d7b5b60459295922b11Lennart Poettering
8eb9058dc1f99a5eb9b8726a978fcc0720837a10Lennart Poettering return r;
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering}
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poetteringstatic inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering unsigned j;
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering
3bdace9bf779ce051f00c14914b35c3a26164aa9Lennart Poettering for (j = 0; j < n; j++) {
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen size_t sub;
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen if (_unlikely_(k <= 0))
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break;
3a864fe4a894745ac61f1ecabd7cadf04139a284Tom Gundersen
4afd3348c7506dd1d36305b7bcb9feb8952b9d6bLennart Poettering sub = MIN(i[j].iov_len, k);
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen i[j].iov_len -= sub;
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen i[j].iov_base = (uint8_t*) i[j].iov_base + sub;
3a864fe4a894745ac61f1ecabd7cadf04139a284Tom Gundersen k -= sub;
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen }
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen return k;
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen}
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen
3733eec3e292e4ddb4cba5eb8d3bd8cbee7102d8Lennart Poettering#define _cleanup_free_ __attribute__((cleanup(freep)))
8de4a226c71ef43e652274b33b5d19211a44ac7bTom Gundersen#define _cleanup_fclose_ __attribute__((cleanup(fclosep)))
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen#define _cleanup_close_ __attribute__((cleanup(closep)))
20af7091de0cdf92bf299addfc3f96c3ef805bd8Tom Gundersen#define _cleanup_closedir_ __attribute__((cleanup(closedirp)))
59b8f6b628145586e87b8a4f6e29c755ad7d61edTom Gundersen#define _cleanup_umask_ __attribute__((cleanup(umaskp)))
b3ec603ce8053ba3f95da1d36f15ea762c83d1e1Lennart Poettering#define _cleanup_set_free_ __attribute__((cleanup(set_freep)))
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt#define _cleanup_strv_free_ __attribute__((cleanup(strv_freep)))
586ac6f711e2eccceb12421df22fca4f117226c4Lennart Poettering
586ac6f711e2eccceb12421df22fca4f117226c4Lennart Poettering#define VA_FORMAT_ADVANCE(format, ap) \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersendo { \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen int _argtypes[128]; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen size_t _i, _k; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen _k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen assert(_k < ELEMENTSOF(_argtypes)); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen for (_i = 0; _i < _k; _i++) { \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen if (_argtypes[_i] & PA_FLAG_PTR) { \
a6f1e036de8f212f33ead7f5387c297afd8be26eTom Gundersen (void) va_arg(ap, void*); \
a6f1e036de8f212f33ead7f5387c297afd8be26eTom Gundersen continue; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen } \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen switch (_argtypes[_i]) { \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_INT: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_INT|PA_FLAG_SHORT: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_CHAR: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (void) va_arg(ap, int); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_INT|PA_FLAG_LONG: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (void) va_arg(ap, long int); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_INT|PA_FLAG_LONG_LONG: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (void) va_arg(ap, long long int); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_WCHAR: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (void) va_arg(ap, wchar_t); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_WSTRING: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_STRING: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_POINTER: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (void) va_arg(ap, void*); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_FLOAT: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_DOUBLE: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (void) va_arg(ap, double); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen case PA_DOUBLE|PA_FLAG_LONG_DOUBLE: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen (void) va_arg(ap, long double); \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen break; \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen default: \
b44cd8821087f2afebf85fec5b588f5720a9415cTom Gundersen assert_not_reached("Unknown format string argument."); \
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen } \
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen } \
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen} while(false)
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen#include "log.h"
ff734080aa02cd70b13bc0fdeec4a5886166163aTom Gundersen