| @@ -269,41 +269,41 @@ typedef char* caddr_t; | | | @@ -269,41 +269,41 @@ typedef char* caddr_t; |
269 | #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT | | 269 | #define FOPEN_WRITE_BIN FOPEN_WRITE_TXT |
270 | #endif | | 270 | #endif |
271 | | | 271 | |
272 | /* | | 272 | /* |
273 | * Inline x86 assembler-language versions of ntoh[ls]() and hton[ls](), | | 273 | * Inline x86 assembler-language versions of ntoh[ls]() and hton[ls](), |
274 | * defined if the OS doesn't provide them. These assume no more than | | 274 | * defined if the OS doesn't provide them. These assume no more than |
275 | * an 80386, so, for example, it avoids the bswap instruction added in | | 275 | * an 80386, so, for example, it avoids the bswap instruction added in |
276 | * the 80486. | | 276 | * the 80486. |
277 | * | | 277 | * |
278 | * (We don't use them on OS X; Apple provides their own, which *doesn't* | | 278 | * (We don't use them on OS X; Apple provides their own, which *doesn't* |
279 | * avoid the bswap instruction, as OS X only supports machines that | | 279 | * avoid the bswap instruction, as OS X only supports machines that |
280 | * have it.) | | 280 | * have it.) |
281 | */ | | 281 | */ |
282 | #if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl) | | 282 | #if defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) && !defined(__ntohl) && !defined(ntohl) |
283 | #undef ntohl | | 283 | #undef ntohl |
284 | #undef ntohs | | 284 | #undef ntohs |
285 | #undef htonl | | 285 | #undef htonl |
286 | #undef htons | | 286 | #undef htons |
287 | | | 287 | |
288 | static __inline__ unsigned long __ntohl (unsigned long x); | | 288 | static __inline__ unsigned int __ntohl (unsigned int x); |
289 | static __inline__ unsigned short __ntohs (unsigned short x); | | 289 | static __inline__ unsigned short __ntohs (unsigned short x); |
290 | | | 290 | |
291 | #define ntohl(x) __ntohl(x) | | 291 | #define ntohl(x) __ntohl(x) |
292 | #define ntohs(x) __ntohs(x) | | 292 | #define ntohs(x) __ntohs(x) |
293 | #define htonl(x) __ntohl(x) | | 293 | #define htonl(x) __ntohl(x) |
294 | #define htons(x) __ntohs(x) | | 294 | #define htons(x) __ntohs(x) |
295 | | | 295 | |
296 | static __inline__ unsigned long __ntohl (unsigned long x) | | 296 | static __inline__ unsigned int __ntohl (unsigned int x) |
297 | { | | 297 | { |
298 | __asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */ | | 298 | __asm__ ("xchgb %b0, %h0\n\t" /* swap lower bytes */ |
299 | "rorl $16, %0\n\t" /* swap words */ | | 299 | "rorl $16, %0\n\t" /* swap words */ |
300 | "xchgb %b0, %h0" /* swap higher bytes */ | | 300 | "xchgb %b0, %h0" /* swap higher bytes */ |
301 | : "=q" (x) : "0" (x)); | | 301 | : "=q" (x) : "0" (x)); |
302 | return (x); | | 302 | return (x); |
303 | } | | 303 | } |
304 | | | 304 | |
305 | static __inline__ unsigned short __ntohs (unsigned short x) | | 305 | static __inline__ unsigned short __ntohs (unsigned short x) |
306 | { | | 306 | { |
307 | __asm__ ("xchgb %b0, %h0" /* swap bytes */ | | 307 | __asm__ ("xchgb %b0, %h0" /* swap bytes */ |
308 | : "=q" (x) : "0" (x)); | | 308 | : "=q" (x) : "0" (x)); |
309 | return (x); | | 309 | return (x); |