The R Project SVN R

Rev

Rev 56448 | Rev 78131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 56448 Rev 56474
Line 1... Line 1...
1
#ifdef HAVE_CONFIG_H
1
#ifdef HAVE_CONFIG_H
2
#include <config.h>
2
#include <config.h>
3
#endif
3
#endif
4
 
4
 
5
#ifdef HAVE_INTTYPES_H
-
 
6
# include <inttypes.h>
5
#include <stdint.h>
7
#endif
-
 
8
 
6
 
9
#if !defined(HAVE_UINTPTR_T) && !defined(uintptr_t)
7
#if !defined(HAVE_UINTPTR_T) && !defined(uintptr_t)
10
 typedef unsigned long uintptr_t;
8
 typedef unsigned long uintptr_t;
11
#endif
9
#endif
12
 
10
 
13
#if SIZEOF_LONG > 4
-
 
14
#error This XDR implementation assumes 4-byte longs
-
 
15
#endif
-
 
16
 
-
 
17
/* Local mod: assumes WIN32 is i386 and little-endian generic is 32-bit */
11
/* Local mod: assumes WIN32 is i386 and little-endian generic is 32-bit */
18
#if defined(WIN32) || defined(__CYGWIN__)
12
#if defined(WIN32) || defined(__CYGWIN__)
19
static unsigned long int ntohl(unsigned long int x)
13
static uint32_t ntohl(uint32_t x)
20
{ /* could write VC++ inline assembler, but not worth it for now */
14
{ /* could write VC++ inline assembler, but not worth it for now */
21
#ifdef _MSC_VER
15
#ifdef _MSC_VER
22
  return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
16
  return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
23
#else
17
#else
24
  __asm__("xchgb %b0,%h0\n\t"	/* swap lower bytes	*/
18
  __asm__("xchgb %b0,%h0\n\t"	/* swap lower bytes	*/
Line 29... Line 23...
29
  return x;
23
  return x;
30
#endif 
24
#endif 
31
}
25
}
32
#else /* net is big-endian: little-endian hosts need byte-swap code */
26
#else /* net is big-endian: little-endian hosts need byte-swap code */
33
#ifndef WORDS_BIGENDIAN
27
#ifndef WORDS_BIGENDIAN
34
static unsigned long int ntohl (unsigned long int x)
28
static uint32_t ntohl (uint32_t x)
35
{
29
{
36
  return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
30
  return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
37
}
31
}
38
#else
32
#else
39
#define ntohl(x) (x)
33
#define ntohl(x) (x)
Line 146... Line 140...
146
	/*XDR *xdrs;*/
140
	/*XDR *xdrs;*/
147
{
141
{
148
}
142
}
149
 
143
 
150
static bool_t
144
static bool_t
151
xdrmem_getlong(xdrs, lp)
145
xdrmem_getlong(XDR *xdrs, int32_t *lp)
152
	register XDR *xdrs;
-
 
153
	long *lp;
-
 
154
{
146
{
155
 
147
 
156
	if ((xdrs->x_handy -= 4) < 0)
148
	if ((xdrs->x_handy -= 4) < 0)
157
		return (FALSE);
149
		return (FALSE);
158
	*lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private))));
150
	*lp = (int32_t)ntohl((uint32_t)(*((int32_t *)(xdrs->x_private))));
159
	xdrs->x_private += 4; /* This relies on 4 bytes/long */
151
	xdrs->x_private += 4; /* This relies on 4 bytes/long */
160
	return (TRUE);
152
	return (TRUE);
161
}
153
}
162
 
154
 
163
static bool_t
155
static bool_t
164
xdrmem_putlong(xdrs, lp)
156
xdrmem_putlong(XDR *xdrs, int32_t *lp)
165
	register XDR *xdrs;
-
 
166
	long *lp;
-
 
167
{
157
{
168
 
158
 
169
	if ((xdrs->x_handy -= 4) < 0)
159
	if ((xdrs->x_handy -= 4) < 0)
170
		return (FALSE);
160
		return (FALSE);
171
	*(long *)xdrs->x_private = (long)htonl((u_long)(*lp));
161
	*(int32_t *)xdrs->x_private = (int32_t)htonl((uint32_t)(*lp));
172
	xdrs->x_private += 4;
162
	xdrs->x_private += 4;
173
	return (TRUE);
163
	return (TRUE);
174
}
164
}
175
 
165
 
176
static bool_t
166
static bool_t