Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108583468
D1520.id3151.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D1520.id3151.diff
View Options
Index: sys/compat/linux/linux_futex.c
===================================================================
--- sys/compat/linux/linux_futex.c
+++ sys/compat/linux/linux_futex.c
@@ -65,6 +65,7 @@
#include <compat/linux/linux_dtrace.h>
#include <compat/linux/linux_emul.h>
#include <compat/linux/linux_futex.h>
+#include <compat/linux/linux_timer.h>
#include <compat/linux/linux_util.h>
/* DTrace init */
@@ -669,7 +670,8 @@
struct linux_pemuldata *pem;
struct waiting_proc *wp;
struct futex *f, *f2;
- struct l_timespec timeout;
+ struct l_timespec ltimeout;
+ struct timespec timeout;
struct timeval utv, ctv;
int timeout_hz;
int error;
@@ -713,6 +715,38 @@
LINUX_CTR3(sys_futex, "WAIT uaddr %p val 0x%x bitset 0x%x",
args->uaddr, args->val, args->val3);
+ if (args->timeout != NULL) {
+ error = copyin(args->timeout, <imeout, sizeof(ltimeout));
+ if (error) {
+ LIN_SDT_PROBE1(futex, linux_sys_futex, copyin_error,
+ error);
+ LIN_SDT_PROBE1(futex, linux_sys_futex, return, error);
+ return (error);
+ }
+ error = linux_to_native_timespec(&timeout, <imeout);
+ if (error)
+ return (error);
+ TIMESPEC_TO_TIMEVAL(&utv, &timeout);
+ error = itimerfix(&utv);
+ if (error) {
+ LIN_SDT_PROBE1(futex, linux_sys_futex, itimerfix_error,
+ error);
+ LIN_SDT_PROBE1(futex, linux_sys_futex, return, error);
+ return (error);
+ }
+ if (clockrt) {
+ microtime(&ctv);
+ timevalsub(&utv, &ctv);
+ } else if (args->op == LINUX_FUTEX_WAIT_BITSET) {
+ microuptime(&ctv);
+ timevalsub(&utv, &ctv);
+ }
+ if (utv.tv_sec < 0)
+ timevalclear(&utv);
+ timeout_hz = tvtohz(&utv);
+ } else
+ timeout_hz = 0;
+
error = futex_get(args->uaddr, &wp, &f,
flags | FUTEX_CREATE_WP);
if (error) {
@@ -745,37 +779,6 @@
return (EWOULDBLOCK);
}
- if (args->timeout != NULL) {
- error = copyin(args->timeout, &timeout, sizeof(timeout));
- if (error) {
- LIN_SDT_PROBE1(futex, linux_sys_futex, copyin_error,
- error);
- LIN_SDT_PROBE1(futex, linux_sys_futex, return, error);
- futex_put(f, wp);
- return (error);
- }
- TIMESPEC_TO_TIMEVAL(&utv, &timeout);
- error = itimerfix(&utv);
- if (error) {
- LIN_SDT_PROBE1(futex, linux_sys_futex, itimerfix_error,
- error);
- LIN_SDT_PROBE1(futex, linux_sys_futex, return, error);
- futex_put(f, wp);
- return (error);
- }
- if (clockrt) {
- microtime(&ctv);
- timevalsub(&utv, &ctv);
- } else if (args->op == LINUX_FUTEX_WAIT_BITSET) {
- microuptime(&ctv);
- timevalsub(&utv, &ctv);
- }
- if (utv.tv_sec < 0)
- timevalclear(&utv);
- timeout_hz = tvtohz(&utv);
- } else
- timeout_hz = 0;
-
error = futex_wait(f, wp, timeout_hz, args->val3);
break;
Index: sys/compat/linux/linux_misc.c
===================================================================
--- sys/compat/linux/linux_misc.c
+++ sys/compat/linux/linux_misc.c
@@ -88,6 +88,7 @@
#include <compat/linux/linux_file.h>
#include <compat/linux/linux_mib.h>
#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_timer.h>
#include <compat/linux/linux_util.h>
#include <compat/linux/linux_sysproto.h>
#include <compat/linux/linux_emul.h>
@@ -1991,8 +1992,7 @@
PROC_UNLOCK(tdt->td_proc);
if (error != 0)
return (error);
- lts.tv_sec = ts.tv_sec;
- lts.tv_nsec = ts.tv_nsec;
+ native_to_linux_timespec(<s, &ts);
return (copyout(<s, uap->interval, sizeof(lts)));
}
@@ -2145,8 +2145,9 @@
error = copyin(args->tsp, <s, sizeof(lts));
if (error)
return (error);
- uts.tv_sec = lts.tv_sec;
- uts.tv_nsec = lts.tv_nsec;
+ error = linux_to_native_timespec(&uts, <s);
+ if (error)
+ return (error);
TIMESPEC_TO_TIMEVAL(&utv, &uts);
if (itimerfix(&utv))
@@ -2178,8 +2179,7 @@
timevalclear(&utv);
TIMEVAL_TO_TIMESPEC(&utv, &uts);
- lts.tv_sec = uts.tv_sec;
- lts.tv_nsec = uts.tv_nsec;
+ native_to_linux_timespec(<s, &uts);
error = copyout(<s, args->tsp, sizeof(lts));
}
@@ -2211,8 +2211,9 @@
error = copyin(args->tsp, <s, sizeof(lts));
if (error)
return (error);
- uts.tv_sec = lts.tv_sec;
- uts.tv_nsec = lts.tv_nsec;
+ error = linux_to_native_timespec(&uts, <s);
+ if (error)
+ return (error);
nanotime(&ts0);
tsp = &uts;
@@ -2231,8 +2232,7 @@
} else
timespecclear(&uts);
- lts.tv_sec = uts.tv_sec;
- lts.tv_nsec = uts.tv_nsec;
+ native_to_linux_timespec(<s, &uts);
error = copyout(<s, args->tsp, sizeof(lts));
}
Index: sys/compat/linux/linux_time.c
===================================================================
--- sys/compat/linux/linux_time.c
+++ sys/compat/linux/linux_time.c
@@ -119,13 +119,10 @@
LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, unsupported_clockid, "int");
LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, return, "int");
-static void native_to_linux_timespec(struct l_timespec *,
- struct timespec *);
-static int linux_to_native_timespec(struct timespec *,
- struct l_timespec *);
static int linux_to_native_clockid(clockid_t *, clockid_t);
-static void
+
+void
native_to_linux_timespec(struct l_timespec *ltp, struct timespec *ntp)
{
@@ -137,7 +134,7 @@
LIN_SDT_PROBE0(time, native_to_linux_timespec, return);
}
-static int
+int
linux_to_native_timespec(struct timespec *ntp, struct l_timespec *ltp)
{
Index: sys/compat/linux/linux_timer.h
===================================================================
--- sys/compat/linux/linux_timer.h
+++ sys/compat/linux/linux_timer.h
@@ -111,4 +111,9 @@
struct l_timespec it_value;
};
+void native_to_linux_timespec(struct l_timespec *,
+ struct timespec *);
+int linux_to_native_timespec(struct timespec *,
+ struct l_timespec *);
+
#endif /* _LINUX_TIMER_H */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 3:16 PM (3 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16199884
Default Alt Text
D1520.id3151.diff (5 KB)
Attached To
Mode
D1520: Linuxulator. struct timespec conversion.
Attached
Detach File
Event Timeline
Log In to Comment