The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/osf1/osf1_time.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: osf1_time.c,v 1.16 2007/12/20 23:03:03 dsl Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Christopher G. Demetriou
   17  *      for the NetBSD Project.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 #include <sys/cdefs.h>
   34 __KERNEL_RCSID(0, "$NetBSD: osf1_time.c,v 1.16 2007/12/20 23:03:03 dsl Exp $");
   35 
   36 #include <sys/param.h>
   37 #include <sys/systm.h>
   38 #include <sys/namei.h>
   39 #include <sys/proc.h>
   40 #include <sys/file.h>
   41 #include <sys/mount.h>
   42 #include <sys/syscallargs.h>
   43 
   44 #include <compat/osf1/osf1.h>
   45 #include <compat/osf1/osf1_syscallargs.h>
   46 #include <compat/osf1/osf1_cvt.h>
   47 
   48 int
   49 osf1_sys_gettimeofday(struct lwp *l, const struct osf1_sys_gettimeofday_args *uap, register_t *retval)
   50 {
   51         struct osf1_timeval otv;
   52         struct osf1_timezone otz;
   53         struct timeval tv;
   54         int error;
   55 
   56         microtime(&tv);
   57         memset(&otv, 0, sizeof otv);
   58         otv.tv_sec = tv.tv_sec;
   59         otv.tv_usec = tv.tv_usec;
   60         error = copyout(&otv, SCARG(uap, tp), sizeof otv);
   61 
   62         if (error == 0 && SCARG(uap, tzp) != NULL) {
   63                 memset(&otz, 0, sizeof otz);
   64                 error = copyout(&otz, SCARG(uap, tzp), sizeof otz);
   65         }
   66         return (error);
   67 }
   68 
   69 int
   70 osf1_sys_setitimer(struct lwp *l, const struct osf1_sys_setitimer_args *uap, register_t *retval)
   71 {
   72         struct osf1_itimerval o_itv, o_oitv;
   73         struct itimerval b_itv, b_oitv;
   74         int which;
   75         int error;
   76 
   77         switch (SCARG(uap, which)) {
   78         case OSF1_ITIMER_REAL:
   79                 which = ITIMER_REAL;
   80                 break;
   81 
   82         case OSF1_ITIMER_VIRTUAL:
   83                 which = ITIMER_VIRTUAL;
   84                 break;
   85 
   86         case OSF1_ITIMER_PROF:
   87                 which = ITIMER_PROF;
   88                 break;
   89 
   90         default:
   91                 return (EINVAL);
   92         }
   93 
   94         /* get the OSF/1 itimerval argument */
   95         error = copyin(SCARG(uap, itv), &o_itv, sizeof o_itv);
   96         if (error != 0)
   97                 return error;
   98 
   99         /* fill in and the NetBSD timeval */
  100         memset(&b_itv, 0, sizeof b_itv);
  101         b_itv.it_interval.tv_sec = o_itv.it_interval.tv_sec;
  102         b_itv.it_interval.tv_usec = o_itv.it_interval.tv_usec;
  103         b_itv.it_value.tv_sec = o_itv.it_value.tv_sec;
  104         b_itv.it_value.tv_usec = o_itv.it_value.tv_usec;
  105 
  106         if (SCARG(uap, oitv) != NULL) {
  107                 dogetitimer(l->l_proc, which, &b_oitv);
  108                 if (error)
  109                         return error;
  110         }
  111                 
  112         error = dosetitimer(l->l_proc, which, &b_itv);
  113 
  114         if (error == 0 || SCARG(uap, oitv) == NULL)
  115                 return error;
  116 
  117         /* fill in and copy out the old timeval */
  118         memset(&o_oitv, 0, sizeof o_oitv);
  119         o_oitv.it_interval.tv_sec = b_oitv.it_interval.tv_sec;
  120         o_oitv.it_interval.tv_usec = b_oitv.it_interval.tv_usec;
  121         o_oitv.it_value.tv_sec = b_oitv.it_value.tv_sec;
  122         o_oitv.it_value.tv_usec = b_oitv.it_value.tv_usec;
  123 
  124         return copyout(&o_oitv, SCARG(uap, oitv), sizeof o_oitv);
  125 }
  126 
  127 int
  128 osf1_sys_getitimer(struct lwp *l, const struct osf1_sys_getitimer_args *uap, register_t *retval)
  129 {
  130         struct osf1_itimerval o_oitv;
  131         struct itimerval b_oitv;
  132         int which;
  133         int error;
  134 
  135         switch (SCARG(uap, which)) {
  136         case OSF1_ITIMER_REAL:
  137                 which = ITIMER_REAL;
  138                 break;
  139         case OSF1_ITIMER_VIRTUAL:
  140                 which = ITIMER_VIRTUAL;
  141                 break;
  142         case OSF1_ITIMER_PROF:
  143                 which = ITIMER_PROF;
  144                 break;
  145         default:
  146                 return (EINVAL);
  147         }
  148 
  149         error = dogetitimer(l->l_proc, which, &b_oitv);
  150         if (error != 0 || SCARG(uap, itv) == NULL)
  151                 return error;
  152 
  153         /* fill in and copy out the osf1 timeval */
  154         memset(&o_oitv, 0, sizeof o_oitv);
  155         o_oitv.it_interval.tv_sec = b_oitv.it_interval.tv_sec;
  156         o_oitv.it_interval.tv_usec = b_oitv.it_interval.tv_usec;
  157         o_oitv.it_value.tv_sec = b_oitv.it_value.tv_sec;
  158         o_oitv.it_value.tv_usec = b_oitv.it_value.tv_usec;
  159         return copyout(&o_oitv, SCARG(uap, itv), sizeof o_oitv);
  160 }
  161 
  162 int
  163 osf1_sys_settimeofday(struct lwp *l, const struct osf1_sys_settimeofday_args *uap, register_t *retval)
  164 {
  165         struct osf1_timeval otv;
  166         struct timeval tv, *tvp;
  167         int error = 0;
  168 
  169         if (SCARG(uap, tv) == NULL)
  170                 tvp = NULL;
  171         else {
  172                 /* get the OSF/1 timeval argument */
  173                 error = copyin(SCARG(uap, tv), &otv, sizeof otv);
  174                 if (error != 0)
  175                         return error;
  176 
  177                 tv.tv_sec = otv.tv_sec;
  178                 tv.tv_usec = otv.tv_usec;
  179                 tvp = &tv;
  180         }
  181 
  182         /* NetBSD ignores the timezone field */
  183 
  184         return settimeofday1(tvp, false, (const void *)SCARG(uap, tzp), l, true);
  185 }

Cache object: d052e0494c3ae78048fc70cd65a4bb60


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.