了解 Linux 源代码中的函数

Understanding a function in Linux source code

我有一个与调度相关的作业,我需要在其中修改 Linux 源代码。我遇到了一段我不明白的代码。

static inline int entity_before(struct sched_entity *a, struct sched_entity *b) {
     return (s64)(a->vruntime - b->vruntime) < 0;
}

这行 return (s64)(a->vruntime - b->vruntime) < 0; return 是什么意思?对我来说,它似乎是 returning 一个布尔值,如 Java,如果语句为真则它 returns 1 如果它为假则它 returns 0 ?因为C语言没有boolean数据类型。

行returns01。如果条件(逻辑上)为真,则运算符 < 的结果是 1int 值,如果条件(逻辑上)为真,则结果是 int 类型的值 0持有假。

To me it seems it is returning a Boolean value like in java, if the statement is true then it returns 1 and if its false then it returns 0?

是的。

as C language doesn't have a boolean data type.

为 false - C 语言具有 _Bool 数据类型。尽管如此,运算符 < returns 一个 int 不是 一个 _Bool.

cppreference comparision operators