dc68054305
- Restore 29 recipe symlinks (libdrm, qtbase, dbus, sddm, pipewire, etc.) - Restore 33 patches (KDE, libdrm, mesa, pipewire, sddm, wireplumber) - Restore 20+ local/scripts (audit, lint, test, build helpers) - Restore src/cook/scheduler.rs, status.rs, gnu-config/ - Restore scripts/patch-inclusion-gate.sh, run_mini1.sh, validate-collision-log.sh - Recover TLC source from HEAD (was overwritten by 0.2.3 checkout) - Recover 11 local/docs plans from HEAD (were overwritten) - Recover qt6-wayland-smoke symlink from HEAD - Fix MOTD: remove garbled ASCII art, use clean text - Update version: 0.2.0 -> 0.2.4 in os-release, motd, config - Reduce filesystem_size: 1536 -> 512 MiB - Add ABSOLUTE RULE to AGENTS.md: never delete/ignore packages - Reduce pcid scheme log verbosity: info -> debug
52 lines
1.6 KiB
C
52 lines
1.6 KiB
C
/* SPDX-License-Identifier: MIT */
|
|
/* Copyright © 2026 Intel Corporation */
|
|
|
|
#ifndef _PICK_H_
|
|
#define _PICK_H_
|
|
|
|
/*
|
|
* Given the first two numbers __a and __b of arbitrarily many evenly spaced
|
|
* numbers, pick the 0-based __index'th value.
|
|
*
|
|
* Always prefer this over _PICK() if the numbers are evenly spaced.
|
|
*/
|
|
#define _PICK_EVEN(__index, __a, __b) ((__a) + (__index) * ((__b) - (__a)))
|
|
|
|
/*
|
|
* Like _PICK_EVEN(), but supports 2 ranges of evenly spaced address offsets.
|
|
* @__c_index corresponds to the index in which the second range starts to be
|
|
* used. Using math interval notation, the first range is used for indexes [ 0,
|
|
* @__c_index), while the second range is used for [ @__c_index, ... ). Example:
|
|
*
|
|
* #define _FOO_A 0xf000
|
|
* #define _FOO_B 0xf004
|
|
* #define _FOO_C 0xf008
|
|
* #define _SUPER_FOO_A 0xa000
|
|
* #define _SUPER_FOO_B 0xa100
|
|
* #define FOO(x) _MMIO(_PICK_EVEN_2RANGES(x, 3, \
|
|
* _FOO_A, _FOO_B, \
|
|
* _SUPER_FOO_A, _SUPER_FOO_B))
|
|
*
|
|
* This expands to:
|
|
* 0: 0xf000,
|
|
* 1: 0xf004,
|
|
* 2: 0xf008,
|
|
* 3: 0xa000,
|
|
* 4: 0xa100,
|
|
* 5: 0xa200,
|
|
* ...
|
|
*/
|
|
#define _PICK_EVEN_2RANGES(__index, __c_index, __a, __b, __c, __d) \
|
|
(BUILD_BUG_ON_ZERO(!__is_constexpr(__c_index)) + \
|
|
((__index) < (__c_index) ? _PICK_EVEN(__index, __a, __b) : \
|
|
_PICK_EVEN((__index) - (__c_index), __c, __d)))
|
|
|
|
/*
|
|
* Given the arbitrary numbers in varargs, pick the 0-based __index'th number.
|
|
*
|
|
* Always prefer _PICK_EVEN() over this if the numbers are evenly spaced.
|
|
*/
|
|
#define _PICK(__index, ...) (((const u32 []){ __VA_ARGS__ })[__index])
|
|
|
|
#endif
|