File: args.h

package info (click to toggle)
linux 6.17.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,734,900 kB
  • sloc: ansic: 26,684,436; asm: 271,195; sh: 147,406; python: 75,980; makefile: 57,306; perl: 36,943; xml: 19,562; cpp: 5,899; yacc: 4,909; lex: 2,943; awk: 1,556; sed: 29; ruby: 25
file content (28 lines) | stat: -rw-r--r-- 1,021 bytes parent folder | download | duplicates (29)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _LINUX_ARGS_H
#define _LINUX_ARGS_H

/*
 * How do these macros work?
 *
 * In __COUNT_ARGS() _0 to _12 are just placeholders from the start
 * in order to make sure _n is positioned over the correct number
 * from 12 to 0 (depending on X, which is a variadic argument list).
 * They serve no purpose other than occupying a position. Since each
 * macro parameter must have a distinct identifier, those identifiers
 * are as good as any.
 *
 * In COUNT_ARGS() we use actual integers, so __COUNT_ARGS() returns
 * that as _n.
 */

/* This counts to 15. Any more, it will return 16th argument. */
#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _n, X...) _n
#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)

/* Concatenate two parameters, but allow them to be expanded beforehand. */
#define __CONCAT(a, b) a ## b
#define CONCATENATE(a, b) __CONCAT(a, b)

#endif	/* _LINUX_ARGS_H */