Merge "Keep ioprio_value; <linux/ioprio.h> relies on this." into main am: 8fbdc58733 am: 211b6433db

Original change: https://android-review.googlesource.com/c/platform/bionic/+/2787554

Change-Id: I0b2ed6fc60255813654b2450f721a0968c29a60d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Elliott Hughes 2023-10-13 16:47:57 +00:00 committed by Automerger Merge Worker
commit 289b4ef5f9
2 changed files with 9 additions and 2 deletions

View file

@ -63,6 +63,7 @@ kernel_token_replacements = {
# The kernel usage of __unused for unused struct fields conflicts with the macro defined in <sys/cdefs.h>.
"__unused": "__linux_unused",
# The kernel usage of C++ keywords causes problems for C++ code so rename.
"class": "__linux_class",
"private": "__linux_private",
"virtual": "__linux_virtual",
# The non-64 stuff is legacy; msqid64_ds/ipc64_perm is what userspace wants.
@ -125,6 +126,8 @@ kernel_known_generic_statics = set(
# These are required to support the above functions.
"__fswahw32",
"__fswahb32",
# This is used by various macros in <linux/ioprio.h>.
"ioprio_value",
]
)

View file

@ -61,6 +61,10 @@ enum {
IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7,
};
#define IOPRIO_BAD_VALUE(val,max) ((val) < 0 || (val) >= (max))
#define IOPRIO_PRIO_VALUE(class,level) ioprio_value(class, level, IOPRIO_HINT_NONE)
#define IOPRIO_PRIO_VALUE_HINT(class,level,hint) ioprio_value(class, level, hint)
static __always_inline __u16 ioprio_value(int __linux_class, int level, int hint) {
if(IOPRIO_BAD_VALUE(__linux_class, IOPRIO_NR_CLASSES) || IOPRIO_BAD_VALUE(level, IOPRIO_NR_LEVELS) || IOPRIO_BAD_VALUE(hint, IOPRIO_NR_HINTS)) return IOPRIO_CLASS_INVALID << IOPRIO_CLASS_SHIFT;
return(__linux_class << IOPRIO_CLASS_SHIFT) | (hint << IOPRIO_HINT_SHIFT) | level;
}
#define IOPRIO_PRIO_VALUE(class,level) ioprio_value(__linux_class, level, IOPRIO_HINT_NONE)
#define IOPRIO_PRIO_VALUE_HINT(class,level,hint) ioprio_value(__linux_class, level, hint)
#endif