linux_misc.c (113579) | linux_misc.c (113613) |
---|---|
1/*- 2 * Copyright (c) 1994-1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 1994-1995 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/compat/linux/linux_misc.c 113579 2003-04-16 20:43:10Z jhb $ | 28 * $FreeBSD: head/sys/compat/linux/linux_misc.c 113613 2003-04-17 22:02:47Z jhb $ |
29 */ 30 31#include "opt_mac.h" 32 33#include <sys/param.h> 34#include <sys/blist.h> 35#include <sys/fcntl.h> 36#include <sys/imgact_aout.h> --- 122 unchanged lines hidden (view full) --- 159#endif /*!__alpha__*/ 160 161#ifndef __alpha__ 162int 163linux_alarm(struct thread *td, struct linux_alarm_args *args) 164{ 165 struct itimerval it, old_it; 166 struct timeval tv; | 29 */ 30 31#include "opt_mac.h" 32 33#include <sys/param.h> 34#include <sys/blist.h> 35#include <sys/fcntl.h> 36#include <sys/imgact_aout.h> --- 122 unchanged lines hidden (view full) --- 159#endif /*!__alpha__*/ 160 161#ifndef __alpha__ 162int 163linux_alarm(struct thread *td, struct linux_alarm_args *args) 164{ 165 struct itimerval it, old_it; 166 struct timeval tv; |
167 struct proc *p; |
|
167 168#ifdef DEBUG 169 if (ldebug(alarm)) 170 printf(ARGS(alarm, "%u"), args->secs); 171#endif 172 173 if (args->secs > 100000000) 174 return EINVAL; 175 176 it.it_value.tv_sec = (long)args->secs; 177 it.it_value.tv_usec = 0; 178 it.it_interval.tv_sec = 0; 179 it.it_interval.tv_usec = 0; | 168 169#ifdef DEBUG 170 if (ldebug(alarm)) 171 printf(ARGS(alarm, "%u"), args->secs); 172#endif 173 174 if (args->secs > 100000000) 175 return EINVAL; 176 177 it.it_value.tv_sec = (long)args->secs; 178 it.it_value.tv_usec = 0; 179 it.it_interval.tv_sec = 0; 180 it.it_interval.tv_usec = 0; |
180 PROC_LOCK(td->td_proc); 181 old_it = td->td_proc->p_realtimer; | 181 p = td->td_proc; 182 PROC_LOCK(p); 183 old_it = p->p_realtimer; |
182 getmicrouptime(&tv); 183 if (timevalisset(&old_it.it_value)) | 184 getmicrouptime(&tv); 185 if (timevalisset(&old_it.it_value)) |
184 callout_stop(&td->td_proc->p_itcallout); | 186 callout_stop(&p->p_itcallout); |
185 if (it.it_value.tv_sec != 0) { | 187 if (it.it_value.tv_sec != 0) { |
186 callout_reset(&td->td_proc->p_itcallout, tvtohz(&it.it_value), 187 realitexpire, td->td_proc); | 188 callout_reset(&p->p_itcallout, tvtohz(&it.it_value), 189 realitexpire, p); |
188 timevaladd(&it.it_value, &tv); 189 } | 190 timevaladd(&it.it_value, &tv); 191 } |
190 td->td_proc->p_realtimer = it; 191 PROC_UNLOCK(td->td_proc); | 192 p->p_realtimer = it; 193 PROC_UNLOCK(p); |
192 if (timevalcmp(&old_it.it_value, &tv, >)) { 193 timevalsub(&old_it.it_value, &tv); 194 if (old_it.it_value.tv_usec != 0) 195 old_it.it_value.tv_sec++; 196 td->td_retval[0] = old_it.it_value.tv_sec; 197 } 198 return 0; 199} --- 604 unchanged lines hidden (view full) --- 804{ 805 struct wait_args /* { 806 int pid; 807 int *status; 808 int options; 809 struct rusage *rusage; 810 } */ tmp; 811 int error, tmpstat; | 194 if (timevalcmp(&old_it.it_value, &tv, >)) { 195 timevalsub(&old_it.it_value, &tv); 196 if (old_it.it_value.tv_usec != 0) 197 old_it.it_value.tv_sec++; 198 td->td_retval[0] = old_it.it_value.tv_sec; 199 } 200 return 0; 201} --- 604 unchanged lines hidden (view full) --- 806{ 807 struct wait_args /* { 808 int pid; 809 int *status; 810 int options; 811 struct rusage *rusage; 812 } */ tmp; 813 int error, tmpstat; |
814 struct proc *p; |
|
812 813#ifdef DEBUG 814 if (ldebug(wait4)) 815 printf(ARGS(wait4, "%d, %p, %d, %p"), 816 args->pid, (void *)args->status, args->options, 817 (void *)args->rusage); 818#endif 819 820 tmp.pid = args->pid; 821 tmp.status = args->status; 822 tmp.options = (args->options & (WNOHANG | WUNTRACED)); 823 /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ 824 if (args->options & __WCLONE) 825 tmp.options |= WLINUXCLONE; 826 tmp.rusage = (struct rusage *)args->rusage; 827 828 if ((error = wait4(td, &tmp)) != 0) 829 return error; 830 | 815 816#ifdef DEBUG 817 if (ldebug(wait4)) 818 printf(ARGS(wait4, "%d, %p, %d, %p"), 819 args->pid, (void *)args->status, args->options, 820 (void *)args->rusage); 821#endif 822 823 tmp.pid = args->pid; 824 tmp.status = args->status; 825 tmp.options = (args->options & (WNOHANG | WUNTRACED)); 826 /* WLINUXCLONE should be equal to __WCLONE, but we make sure */ 827 if (args->options & __WCLONE) 828 tmp.options |= WLINUXCLONE; 829 tmp.rusage = (struct rusage *)args->rusage; 830 831 if ((error = wait4(td, &tmp)) != 0) 832 return error; 833 |
831 PROC_LOCK(td->td_proc); 832 SIGDELSET(td->td_proc->p_siglist, SIGCHLD); 833 PROC_UNLOCK(td->td_proc); | 834 p = td->td_proc; 835 PROC_LOCK(p); 836 SIGDELSET(p->p_siglist, SIGCHLD); 837 PROC_UNLOCK(p); |
834 835 if (args->status) { 836 if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) 837 return error; 838 tmpstat &= 0xffff; 839 if (WIFSIGNALED(tmpstat)) 840 tmpstat = (tmpstat & 0xffffff80) | 841 BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); --- 474 unchanged lines hidden --- | 838 839 if (args->status) { 840 if ((error = copyin(args->status, &tmpstat, sizeof(int))) != 0) 841 return error; 842 tmpstat &= 0xffff; 843 if (WIFSIGNALED(tmpstat)) 844 tmpstat = (tmpstat & 0xffffff80) | 845 BSD_TO_LINUX_SIGNAL(WTERMSIG(tmpstat)); --- 474 unchanged lines hidden --- |