The R Project SVN R

Rev

Rev 86177 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 86177 Rev 87545
Line 5... Line 5...
5
#include <stdint.h>
5
#include <stdint.h>
6
 
6
 
7
/* Local mod: assumes _WIN32 is i386 and little-endian generic is 32-bit */
7
/* Local mod: assumes _WIN32 is i386 and little-endian generic is 32-bit */
8
#if defined(_WIN32) || defined(__CYGWIN__)
8
#if defined(_WIN32) || defined(__CYGWIN__)
9
static uint32_t ntohl(uint32_t x)
9
static uint32_t ntohl(uint32_t x)
-
 
10
{ 
-
 
11
# ifdef XDR_ASSEMBLY
10
{ /* could write VC++ inline assembler, but not worth it for now */
12
#  undef XDR_ASSEMBLY
-
 
13
# endif
-
 
14
 
11
#if (defined(__i386) || defined(__x86_64)) && !defined(_MSC_VER)
15
# if (defined(__i386) || defined(__x86_64)) && !defined(_MSC_VER)
-
 
16
#  define XDR_ASSEMBLY
-
 
17
# endif
-
 
18
 
-
 
19
# if defined(XDR_ASSEMBLY) && defined(__has_feature)
-
 
20
#  if __has_feature(address_sanitizer)
-
 
21
#   undef XDR_ASSEMBLY
-
 
22
#  endif
-
 
23
# endif
-
 
24
 
-
 
25
# if defined(XDR_ASSEMBLY) && \
-
 
26
     (defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__))
-
 
27
#  undef XDR_ASSEMBLY
-
 
28
# endif
-
 
29
 
-
 
30
# ifdef XDR_ASSEMBLY
-
 
31
  /* could write VC++ inline assembler, but not worth it for now */
12
  __asm__("xchgb %b0,%h0\n\t"	/* swap lower bytes	*/
32
  __asm__("xchgb %b0,%h0\n\t"	/* swap lower bytes	*/
13
	  "rorl $16,%0\n\t"	/* swap words		*/
33
	  "rorl $16,%0\n\t"	/* swap words		*/
14
	  "xchgb %b0,%h0"       /* swap higher bytes	*/
34
	  "xchgb %b0,%h0"       /* swap higher bytes	*/
15
	  :"=q" (x)
35
	  :"=q" (x)
16
	  : "0" (x));
36
	  : "0" (x));
17
  return x;
37
  return x;
18
#else
38
# else
19
  return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
39
  return((x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24));
20
#endif
40
# endif
-
 
41
 
-
 
42
# ifdef XDR_ASSEMBLY
-
 
43
#  undef XDR_ASSEMBLY
-
 
44
# endif
21
}
45
}
22
#else /* net is big-endian: little-endian hosts need byte-swap code */
46
#else /* net is big-endian: little-endian hosts need byte-swap code */
23
#ifndef WORDS_BIGENDIAN
47
#ifndef WORDS_BIGENDIAN
24
/* #ifdef LITTLE_ENDIAN */
48
/* #ifdef LITTLE_ENDIAN */
25
static uint32_t ntohl (uint32_t x)
49
static uint32_t ntohl (uint32_t x)