mirror of
https://github.com/openharmony/resourceschedule_ffrt.git
synced 2026-08-24 18:26:04 -04:00
fix: avoid <linux/futex.h> in job_utils.h to fix __user build break
The kernel's <linux/futex.h> declares `struct robust_list` with fields typed `struct robust_list __user *`. In user-space this relies on `__user` being defined as an empty macro by the toolchain, but where it isn't the header fails to parse (e.g. OH musl's vendored copy omits the <linux/compiler.h> shim, breaking consumers such as netmanager_base that include job_utils.h). job_utils.h only needs FUTEX_WAIT_PRIVATE / FUTEX_WAKE_PRIVATE and SYS_futex. Drop the `<linux/futex.h>` include and define the two FUTEX ops inline (a stable kernel ABI); SYS_futex already comes from <sys/syscall.h>. This removes the dependency on `__user` entirely and also satisfies CERT G.EXP.01-CPP by not defining the reserved identifier `__user`. Signed-off-by: chuchihtung <zhuzhidong2@huawei.com> Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,6 @@
|
||||
#include <climits>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/futex.h>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
@@ -55,6 +54,14 @@
|
||||
#define _ffrt_has_fiber_feature
|
||||
#endif
|
||||
|
||||
// Stable FUTEX ABI; avoids <linux/futex.h>, which needs __user to be defined.
|
||||
#ifndef FUTEX_WAIT_PRIVATE
|
||||
#define FUTEX_WAIT_PRIVATE 128 // FUTEX_WAIT(0) | FUTEX_PRIVATE_FLAG(128)
|
||||
#endif
|
||||
#ifndef FUTEX_WAKE_PRIVATE
|
||||
#define FUTEX_WAKE_PRIVATE 129 // FUTEX_WAKE(1) | FUTEX_PRIVATE_FLAG(128)
|
||||
#endif
|
||||
|
||||
#ifndef FFRT_API_LOGE
|
||||
#define FFRT_API_LOGE(...)
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user