[BACK]Return to osf1_time.c CVS log [TXT][DIR] Up to [local] / sys / compat / osf1

Annotation of sys/compat/osf1/osf1_time.c, Revision 1.1

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

CVSweb