HAMMER VFS - Implement inode number matching against the directory hash
[dragonfly.git] / test / sysmsg / syscall.h
blob5e1f28e70afe5bf1fe44ba120efc443ba7a7fa20
1 /*
2 * Copyright (c) 2004 Eirik Nygaard. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of The DragonFly Project nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific, prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * $DragonFly: src/test/sysmsg/syscall.h,v 1.1 2004/09/02 11:21:12 eirikn Exp $
32 /* XXX: eirik */
33 #define _MMAP_DECLARED
34 #define _LSEEK_DECLARED
35 #define _TRUNCATE_DECLARED
36 #define _FTRUNCATE_DECLARED
38 #define __syscall_args nosys_args
40 #include <sys/types.h>
41 #include <sys/msgport.h>
42 #include <sys/syscall.h>
43 #include <sys/sysproto.h>
45 #include <stdlib.h>
46 #include <errno.h>
48 #define INITMSGSYSCALL(name, flags) do { \
49 bzero(&__CONCAT(name, msg), sizeof(__CONCAT(name, msg))); \
50 (__CONCAT(name, msg)).usrmsg.umsg.ms_cmd.cm_op = \
51 (__CONCAT(SYS_,name)); \
52 (__CONCAT(name, msg)).usrmsg.umsg.ms_flags = (flags); \
53 } while (0)
55 #define DOMSGSYSCALL(name) do { \
56 error = sendsys(NULL, &__CONCAT(name,msg).usrmsg, \
57 sizeof(__CONCAT(name,msg))); \
58 } while (0)
60 #define FINISHMSGSYSCALL(name, error) do { \
61 if (__CONCAT(name,msg).usrmsg.umsg.ms_error == EASYNC) { \
62 for (;;) { \
63 int rmsg; \
64 rmsg = waitsys(NULL, (void *)error, 0); \
65 if (error == rmsg) \
66 break; \
67 else if (rmsg != 0) { \
68 errno = rmsg; \
69 return(-1); \
70 } \
71 } \
72 } \
73 if (__CONCAT(name,msg).usrmsg.umsg.ms_error) { \
74 errno = __CONCAT(name,msg).usrmsg.umsg.ms_error; \
75 return(-1); \
76 } \
77 else \
78 return(__CONCAT(name,msg).usrmsg.umsg.u.ms_result); \
79 } while(0)
81 static __inline int
82 sendsys(void *port, void *msg, int msgsize)
84 int error;
86 __asm __volatile("int $0x81" : "=a"(error), "=c"(msg), "=d"(msgsize) :
87 "0"(port), "1"(msg), "2"(msgsize) : "memory");
88 return(error);
91 static __inline int
92 waitsys(void *port, void *msg, int msgsize)
94 int error;
96 __asm __volatile("int $0x82" : "=a"(error), "=c"(msg),
97 "=d"(msgsize) : "0"(port), "1"(msg), "2"(msgsize) :
98 "memory");
99 return(error);