Add Windows specific code

This commit is contained in:
Grégory Soutadé
2011-02-05 21:02:03 +01:00
parent bd4809042b
commit 0c344a0273
13 changed files with 185 additions and 143 deletions

View File

@@ -28,9 +28,35 @@
/* this is only to get definitions for memcpy(), ntohl() and htonl() */
//#include "../git-compat-util.h"
#include <string.h>
#include <arpa/inet.h>
#include "sha1.h"
#ifndef WIN32
#include <arpa/inet.h>
#else
#if BYTE_ORDER == BIG_ENDIAN
#define htons(n) (n)
#define ntohs(n) (n)
#define htonl(n) (n)
#define ntohl(n) (n)
#else
#define htons(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8))
#define ntohs(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8))
#define htonl(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
((((unsigned long)(n) & 0xFF00)) << 8) | \
((((unsigned long)(n) & 0xFF0000)) >> 8) | \
((((unsigned long)(n) & 0xFF000000)) >> 24))
#define ntohl(n) (((((unsigned long)(n) & 0xFF)) << 24) | \
((((unsigned long)(n) & 0xFF00)) << 8) | \
((((unsigned long)(n) & 0xFF0000)) >> 8) | \
((((unsigned long)(n) & 0xFF000000)) >> 24))
#endif
#endif
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
/*