[BACK]Return to rumpuser_int.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / librumpuser

Annotation of src/lib/librumpuser/rumpuser_int.h, Revision 1.7

1.7     ! pooka       1: /*     $NetBSD: rumpuser_int.h,v 1.6 2013/04/29 12:56:04 pooka Exp $   */
1.1       pooka       2:
                      3: /*
                      4:  * Copyright (c) 2008 Antti Kantee.  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:  *
                     15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
                     16:  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
                     17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     18:  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     19:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     20:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
                     21:  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     23:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25:  * SUCH DAMAGE.
                     26:  */
                     27:
1.3       pooka      28: #include <stdlib.h>
                     29:
1.1       pooka      30: #include <rump/rumpuser.h>
                     31:
1.7     ! pooka      32: #define seterror(value) do { if (error) *error = value;} while (/*CONSTCOND*/0)
        !            33:
        !            34: extern struct rumpuser_hyperup rumpuser__hyp;
        !            35:
        !            36: static inline void
        !            37: rumpkern_unsched(int *nlocks, void *interlock)
        !            38: {
        !            39:
        !            40:        rumpuser__hyp.hyp_backend_unschedule(0, nlocks, interlock);
        !            41: }
        !            42:
        !            43: static inline void
        !            44: rumpkern_sched(int nlocks, void *interlock)
        !            45: {
1.1       pooka      46:
1.7     ! pooka      47:        rumpuser__hyp.hyp_backend_schedule(nlocks, interlock);
        !            48: }
1.4       pooka      49:
1.1       pooka      50: #define KLOCK_WRAP(a)                                                  \
                     51: do {                                                                   \
                     52:        int nlocks;                                                     \
1.7     ! pooka      53:        rumpkern_unsched(&nlocks, NULL);                                \
1.1       pooka      54:        a;                                                              \
1.7     ! pooka      55:        rumpkern_sched(nlocks, NULL);                                   \
1.1       pooka      56: } while (/*CONSTCOND*/0)
                     57:
                     58: #define DOCALL(rvtype, call)                                           \
1.2       pooka      59: {                                                                      \
1.1       pooka      60:        rvtype rv;                                                      \
                     61:        rv = call;                                                      \
                     62:        if (rv == -1)                                                   \
1.4       pooka      63:                seterror(errno);                                        \
1.1       pooka      64:        else                                                            \
1.4       pooka      65:                seterror(0);                                            \
1.2       pooka      66:        return rv;                                                      \
                     67: }
1.1       pooka      68:
                     69: #define DOCALL_KLOCK(rvtype, call)                                     \
1.2       pooka      70: {                                                                      \
1.1       pooka      71:        rvtype rv;                                                      \
                     72:        int nlocks;                                                     \
1.7     ! pooka      73:        rumpkern_unsched(&nlocks, NULL);                                \
1.1       pooka      74:        rv = call;                                                      \
1.7     ! pooka      75:        rumpkern_sched(nlocks, NULL);                                   \
1.1       pooka      76:        if (rv == -1)                                                   \
1.4       pooka      77:                seterror(errno);                                        \
1.1       pooka      78:        else                                                            \
1.4       pooka      79:                seterror(0);                                            \
1.2       pooka      80:        return rv;                                                      \
                     81: }
1.5       pooka      82:
                     83: void rumpuser__thrinit(void);
1.6       pooka      84:
                     85: #define NOFAIL(a) do {if (!(a)) abort();} while (/*CONSTCOND*/0)
                     86:
                     87: #define NOFAIL_ERRNO(a)                                                        \
                     88: do {                                                                   \
                     89:        int fail_rv = (a);                                              \
                     90:        if (fail_rv) {                                                  \
                     91:                printf("panic: rumpuser fatal failure %d (%s)\n",       \
                     92:                    fail_rv, strerror(fail_rv));                        \
                     93:                abort();                                                \
                     94:        }                                                               \
                     95: } while (/*CONSTCOND*/0)

CVSweb <webmaster@jp.NetBSD.org>