1 /*	$NetBSD: svr4_types.h,v 1.14 2008/04/28 20:23:45 martin Exp $	 */
2 
3 /*-
4  * Copyright (c) 1994 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Christos Zoulas.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef	_SVR4_TYPES_H_
33 #define	_SVR4_TYPES_H_
34 
35 typedef u_quad_t	 svr4_ino64_t;
36 typedef quad_t		 svr4_off64_t;
37 typedef quad_t		 svr4_blkcnt64_t;
38 typedef u_quad_t	 svr4_fsblkcnt64_t;
39 
40 typedef long  		 svr4_off_t;
41 typedef int  		 svr4_off32_t;
42 typedef u_long		 svr4_dev_t;
43 typedef u_long		 svr4_ino_t;
44 typedef u_int		 svr4_mode_t;
45 typedef u_int		 svr4_nlink_t;
46 typedef int		 svr4_uid_t;
47 typedef int		 svr4_gid_t;
48 typedef long		 svr4_daddr_t;
49 typedef int		 svr4_pid_t;
50 typedef long		 svr4_time_t;
51 typedef int		 svr4_time32_t;
52 typedef long		 svr4_blkcnt_t;
53 typedef u_long		 svr4_fsblkcnt_t;
54 typedef char		*svr4_caddr_t;
55 typedef u_long		 svr4_size_t;
56 
57 typedef short		 svr4_o_dev_t;
58 typedef short		 svr4_o_pid_t;
59 typedef u_short		 svr4_o_ino_t;
60 typedef u_short		 svr4_o_mode_t;
61 typedef short		 svr4_o_nlink_t;
62 typedef u_short		 svr4_o_uid_t;
63 typedef u_short		 svr4_o_gid_t;
64 typedef long		 svr4_clock_t;
65 typedef int		 svr4_key_t;
66 
67 #ifdef _LP64
68 /*
69  * Solaris uses a `long' time_t.
70  */
71 typedef struct {
72 	svr4_time_t	tv_sec;		/* seconds */
73 	long		tv_nsec;	/* and nanoseconds */
74 } svr4_timestruc_t;
75 #else
76 typedef struct timespec  svr4_timestruc_t;
77 #endif
78 
79 #define	svr4_omajor(x)		((int32_t)((((x) & 0x7f00) >> 8)))
80 #define	svr4_ominor(x)		((int32_t)((((x) & 0x00ff) >> 0)))
81 #define	svr4_omakedev(x,y)	((svr4_o_dev_t)((((x) << 8) & 0x7f00) | \
82 						(((y) << 0) & 0x00ff)))
83 #define svr4_to_bsd_odev_t(d)	makedev(svr4_omajor(d), svr4_ominor(d))
84 #define bsd_to_svr4_odev_t(d)	svr4_omakedev(major(d), minor(d))
85 
86 #define	svr4_major(x)		((int32_t)((((x) & 0xfffc0000) >> 18)))
87 #define	svr4_minor(x)		((int32_t)((((x) & 0x0003ffff) >>  0)))
88 #define	svr4_makedev(x,y)	((svr4_dev_t)((((x) << 18) & 0xfffc0000) | \
89 					      (((y) <<  0) & 0x0003ffff)))
90 #define svr4_to_bsd_dev_t(d)	makedev(svr4_major(d), svr4_minor(d))
91 #define bsd_to_svr4_dev_t(d)	svr4_makedev(major(d), minor(d))
92 
93 #endif /* !_SVR4_TYPES_H_ */
94