source: trunk/libs/newlib/src/newlib/libc/xdr/xdr_private.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.3 KB
Line 
1/* xdr_private.h - declarations of utility functions for porting xdr
2 *
3 * Copyright (c) 2009 Charles S. Wilson
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 */
23#ifndef _XDR_PRIVATE_H
24#define _XDR_PRIVATE_H
25
26#include <_ansi.h>
27#include <stdarg.h>
28#include <stdint.h>
29#include <sys/param.h>
30
31/* avoid including stdio header here */
32#ifndef __VALIST
33#ifdef __GNUC__
34#define __VALIST __gnuc_va_list
35#else
36#define __VALIST char*
37#endif
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44typedef void (*xdr_vprintf_t) (const char *, va_list);
45
46xdr_vprintf_t xdr_set_vprintf (xdr_vprintf_t);
47
48void xdr_vwarnx (const char *, __VALIST)
49              _ATTRIBUTE ((__format__ (__printf__, 1, 0)));
50
51void xdr_warnx (const char *, ...)
52              _ATTRIBUTE ((__format__ (__printf__, 1, 2)));
53
54/* endian issues */
55#include <machine/endian.h>
56
57/* byteswap and ntohl stuff; platform may provide optimzed version
58 * of this, but we don't have access to that here.*/
59_ELIDABLE_INLINE uint32_t xdr_ntohl (uint32_t x)
60{
61#if BYTE_ORDER == BIG_ENDIAN
62  return x;
63#elif BYTE_ORDER == LITTLE_ENDIAN
64  u_char *s = (u_char *)&x;
65  return (uint32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
66#else
67# error Unsupported endian type
68#endif
69}
70#define xdr_htonl(x) xdr_ntohl(x)
71
72#ifdef __cplusplus
73}
74#endif
75
76#endif /* _XDR_PRIVATE_H */
77
Note: See TracBrowser for help on using the repository browser.