]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
9bccf70c | 2 | * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved. |
1c79356b A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
26 | /* | |
27 | * Copyright (c) 1989, 1993 | |
28 | * The Regents of the University of California. All rights reserved. | |
29 | * | |
30 | * The NEXTSTEP Software License Agreement specifies the terms | |
31 | * and conditions for redistribution. | |
32 | * | |
33 | * This code is derived from software contributed to Berkeley by | |
34 | * Rick Macklem at The University of Guelph. | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * 1. Redistributions of source code must retain the above copyright | |
40 | * notice, this list of conditions and the following disclaimer. | |
41 | * 2. Redistributions in binary form must reproduce the above copyright | |
42 | * notice, this list of conditions and the following disclaimer in the | |
43 | * documentation and/or other materials provided with the distribution. | |
44 | * 3. All advertising materials mentioning features or use of this software | |
45 | * must display the following acknowledgement: | |
46 | * This product includes software developed by the University of | |
47 | * California, Berkeley and its contributors. | |
48 | * 4. Neither the name of the University nor the names of its contributors | |
49 | * may be used to endorse or promote products derived from this software | |
50 | * without specific prior written permission. | |
51 | * | |
52 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
53 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
54 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
55 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
56 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
57 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
58 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
59 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
60 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
61 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
62 | * SUCH DAMAGE. | |
63 | * | |
64 | * @(#)xdr_subs.h 8.3 (Berkeley) 3/30/95 | |
65 | * FreeBSD-Id: xdr_subs.h,v 1.9 1997/02/22 09:42:53 peter Exp $ | |
66 | */ | |
67 | ||
68 | ||
69 | #ifndef _NFS_XDR_SUBS_H_ | |
70 | #define _NFS_XDR_SUBS_H_ | |
71 | ||
9bccf70c A |
72 | #include <sys/appleapiopts.h> |
73 | ||
74 | #ifdef __APPLE_API_PRIVATE | |
1c79356b A |
75 | /* |
76 | * Macros used for conversion to/from xdr representation by nfs... | |
77 | * These use the MACHINE DEPENDENT routines ntohl, htonl | |
78 | * As defined by "XDR: External Data Representation Standard" RFC1014 | |
79 | * | |
80 | * To simplify the implementation, we use ntohl/htonl even on big-endian | |
81 | * machines, and count on them being `#define'd away. Some of these | |
82 | * might be slightly more efficient as quad_t copies on a big-endian, | |
83 | * but we cannot count on their alignment anyway. | |
84 | */ | |
85 | ||
86 | #define fxdr_unsigned(t, v) ((t)ntohl((long)(v))) | |
87 | #define txdr_unsigned(v) (htonl((long)(v))) | |
88 | ||
89 | #define fxdr_nfsv2time(f, t) { \ | |
90 | (t)->tv_sec = ntohl(((struct nfsv2_time *)(f))->nfsv2_sec); \ | |
91 | if (((struct nfsv2_time *)(f))->nfsv2_usec != 0xffffffff) \ | |
92 | (t)->tv_nsec = 1000 * ntohl(((struct nfsv2_time *)(f))->nfsv2_usec); \ | |
93 | else \ | |
94 | (t)->tv_nsec = 0; \ | |
95 | } | |
96 | #define txdr_nfsv2time(f, t) { \ | |
97 | ((struct nfsv2_time *)(t))->nfsv2_sec = htonl((f)->tv_sec); \ | |
98 | if ((f)->tv_nsec != -1) \ | |
99 | ((struct nfsv2_time *)(t))->nfsv2_usec = htonl((f)->tv_nsec / 1000); \ | |
100 | else \ | |
101 | ((struct nfsv2_time *)(t))->nfsv2_usec = 0xffffffff; \ | |
102 | } | |
103 | ||
104 | #define fxdr_nfsv3time(f, t) { \ | |
105 | (t)->tv_sec = ntohl(((struct nfsv3_time *)(f))->nfsv3_sec); \ | |
106 | (t)->tv_nsec = ntohl(((struct nfsv3_time *)(f))->nfsv3_nsec); \ | |
107 | } | |
108 | #define txdr_nfsv3time(f, t) { \ | |
109 | ((struct nfsv3_time *)(t))->nfsv3_sec = htonl((f)->tv_sec); \ | |
110 | ((struct nfsv3_time *)(t))->nfsv3_nsec = htonl((f)->tv_nsec); \ | |
111 | } | |
112 | ||
113 | #define fxdr_hyper(f, t) { \ | |
114 | ((long *)(t))[_QUAD_HIGHWORD] = ntohl(((long *)(f))[0]); \ | |
115 | ((long *)(t))[_QUAD_LOWWORD] = ntohl(((long *)(f))[1]); \ | |
116 | } | |
117 | #define txdr_hyper(f, t) { \ | |
118 | ((long *)(t))[0] = htonl(((long *)(f))[_QUAD_HIGHWORD]); \ | |
119 | ((long *)(t))[1] = htonl(((long *)(f))[_QUAD_LOWWORD]); \ | |
120 | } | |
121 | ||
9bccf70c A |
122 | #endif /* __APPLE_API_PRIVATE */ |
123 | #endif /* _NFS_XDR_SUBS_H_ */ |