-
-
Notifications
You must be signed in to change notification settings - Fork 180
fix(futex): 修复futex系统调用参数处理逻辑 #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -47,22 +47,39 @@ impl Syscall for SysFutexHandle { | |||||
| let uaddr = Self::uaddr(args); | ||||||
| let operation = Self::operation(args)?; | ||||||
| let val = Self::val(args); | ||||||
| let utime = Self::utime(args); | ||||||
| // 第4个参数:不同操作下语义不同(可能是 timeout 指针、val2、op 等) | ||||||
| let arg4 = Self::utime(args); | ||||||
| let uaddr2 = Self::uaddr2(args); | ||||||
| let val3 = Self::val3(args); | ||||||
|
|
||||||
| let mut timespec = None; | ||||||
| if utime != 0 { | ||||||
| let reader = UserBufferReader::new( | ||||||
| utime as *const PosixTimeSpec, | ||||||
| core::mem::size_of::<PosixTimeSpec>(), | ||||||
| frame.is_from_user(), | ||||||
| )?; | ||||||
| // 决定是否将第4参解释为超时指针(WAIT* 系列)或数值 val2(REQUEUE/WAKE_OP 等) | ||||||
| let cmd = FutexArg::from_bits(operation.bits() & FutexFlag::FUTEX_CMD_MASK.bits()) | ||||||
| .ok_or(SystemError::ENOSYS)?; | ||||||
|
|
||||||
| timespec = Some(*reader.read_one_from_user::<PosixTimeSpec>(0)?); | ||||||
| } | ||||||
| let (timespec, val2): (Option<PosixTimeSpec>, u32) = match cmd { | ||||||
| // 与 Linux 语义一致:WAIT 使用相对超时;WAIT_BITSET/LOCK_PI2/WAIT_REQUEUE_PI 使用绝对时间(若带 CLOCKRT) | ||||||
|
||||||
| // 与 Linux 语义一致:WAIT 使用相对超时;WAIT_BITSET/LOCK_PI2/WAIT_REQUEUE_PI 使用绝对时间(若带 CLOCKRT) | |
| // 与 Linux 语义一致:WAIT 使用相对超时;WAIT_BITSET/LOCK_PI2/WAIT_REQUEUE_PI 使用绝对时间(若带 CLOCK_REALTIME,即绝对时钟) |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment uses inconsistent terminology '第4参' - should use consistent terminology like '第4个参数' for clarity.
| // 其他操作中,第4参为数值(如 REQUEUE 的 nr_requeue、WAKE_OP 的 nr_wake2 等) | |
| // 其他操作中,第4个参数为数值(如 REQUEUE 的 nr_requeue、WAKE_OP 的 nr_wake2 等) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment uses inconsistent terminology '第4参' - should use consistent terminology like '第4个参数' for clarity.