diff options
-rw-r--r-- | kernel/hrtimer.c | 14 | ||||
-rw-r--r-- | kernel/timer.c | 56 |
2 files changed, 14 insertions, 56 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index 64d37a3c5948..11fde0caee56 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c | |||
@@ -707,6 +707,20 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp, | |||
707 | return -ERESTART_RESTARTBLOCK; | 707 | return -ERESTART_RESTARTBLOCK; |
708 | } | 708 | } |
709 | 709 | ||
710 | asmlinkage long | ||
711 | sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp) | ||
712 | { | ||
713 | struct timespec tu; | ||
714 | |||
715 | if (copy_from_user(&tu, rqtp, sizeof(tu))) | ||
716 | return -EFAULT; | ||
717 | |||
718 | if (!timespec_valid(&tu)) | ||
719 | return -EINVAL; | ||
720 | |||
721 | return hrtimer_nanosleep(&tu, rmtp, HRTIMER_REL, CLOCK_MONOTONIC); | ||
722 | } | ||
723 | |||
710 | /* | 724 | /* |
711 | * Functions related to boot-time initialization: | 725 | * Functions related to boot-time initialization: |
712 | */ | 726 | */ |
diff --git a/kernel/timer.c b/kernel/timer.c index 80bf2acf6b08..4f1cb0ab5251 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -1120,62 +1120,6 @@ asmlinkage long sys_gettid(void) | |||
1120 | return current->pid; | 1120 | return current->pid; |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | static long __sched nanosleep_restart(struct restart_block *restart) | ||
1124 | { | ||
1125 | unsigned long expire = restart->arg0, now = jiffies; | ||
1126 | struct timespec __user *rmtp = (struct timespec __user *) restart->arg1; | ||
1127 | long ret; | ||
1128 | |||
1129 | /* Did it expire while we handled signals? */ | ||
1130 | if (!time_after(expire, now)) | ||
1131 | return 0; | ||
1132 | |||
1133 | expire = schedule_timeout_interruptible(expire - now); | ||
1134 | |||
1135 | ret = 0; | ||
1136 | if (expire) { | ||
1137 | struct timespec t; | ||
1138 | jiffies_to_timespec(expire, &t); | ||
1139 | |||
1140 | ret = -ERESTART_RESTARTBLOCK; | ||
1141 | if (rmtp && copy_to_user(rmtp, &t, sizeof(t))) | ||
1142 | ret = -EFAULT; | ||
1143 | /* The 'restart' block is already filled in */ | ||
1144 | } | ||
1145 | return ret; | ||
1146 | } | ||
1147 | |||
1148 | asmlinkage long sys_nanosleep(struct timespec __user *rqtp, struct timespec __user *rmtp) | ||
1149 | { | ||
1150 | struct timespec t; | ||
1151 | unsigned long expire; | ||
1152 | long ret; | ||
1153 | |||
1154 | if (copy_from_user(&t, rqtp, sizeof(t))) | ||
1155 | return -EFAULT; | ||
1156 | |||
1157 | if ((t.tv_nsec >= 1000000000L) || (t.tv_nsec < 0) || (t.tv_sec < 0)) | ||
1158 | return -EINVAL; | ||
1159 | |||
1160 | expire = timespec_to_jiffies(&t) + (t.tv_sec || t.tv_nsec); | ||
1161 | expire = schedule_timeout_interruptible(expire); | ||
1162 | |||
1163 | ret = 0; | ||
1164 | if (expire) { | ||
1165 | struct restart_block *restart; | ||
1166 | jiffies_to_timespec(expire, &t); | ||
1167 | if (rmtp && copy_to_user(rmtp, &t, sizeof(t))) | ||
1168 | return -EFAULT; | ||
1169 | |||
1170 | restart = ¤t_thread_info()->restart_block; | ||
1171 | restart->fn = nanosleep_restart; | ||
1172 | restart->arg0 = jiffies + expire; | ||
1173 | restart->arg1 = (unsigned long) rmtp; | ||
1174 | ret = -ERESTART_RESTARTBLOCK; | ||
1175 | } | ||
1176 | return ret; | ||
1177 | } | ||
1178 | |||
1179 | /* | 1123 | /* |
1180 | * sys_sysinfo - fill in sysinfo struct | 1124 | * sys_sysinfo - fill in sysinfo struct |
1181 | */ | 1125 | */ |