Changeset 22257


Ignore:
Timestamp:
2010-06-11T00:44:22+12:00 (14 years ago)
Author:
davidb
Message:

Minor tweak to support MinGW

Location:
main/trunk/greenstone2/common-src/indexers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/mg/lib/netorder.h

    r16583 r22257  
    8686    }while(0)
    8787
     88
     89#ifdef __MINGW32__
     90
     91static inline short reverseShort(short s)
     92{   
     93  unsigned char c1 = s & 255;
     94  unsigned char c2 = (s >> 8) & 255;
     95   
     96  return (c1 << 8) | c2;
     97}
     98
     99static inline int reverseInt (int i)
     100{
     101  unsigned char c1 = i & 255;
     102  unsigned char c2 = (i >> 8) & 255;
     103  unsigned char c3 = (i >> 16) & 255;
     104  unsigned char c4 = (i >> 24) & 255;
     105
     106  return ((int)c1 << 24) | ((int)c2 << 16) | ((int)c3 << 8) | c4;
     107}
     108
     109#define htonl(l) reverseInt(l)
     110#define htons(s) reverseShort(s)
     111#define ntohl(l) reverseInt(l)
     112#define ntohs(s) reverseShort(s)
     113
     114#endif
     115
    88116/* pointers */
    89117#define HTONP(p)          ((p) = (void *) htonl ((unsigned long) p))
  • main/trunk/greenstone2/common-src/indexers/mgpp/lib/netorder.h

    r16583 r22257  
    8585    }while(0)
    8686
     87#ifdef __MINGW32__
     88
     89static inline short reverseShort(short s)
     90{   
     91  unsigned char c1 = s & 255;
     92  unsigned char c2 = (s >> 8) & 255;
     93   
     94  return (c1 << 8) | c2;
     95}
     96
     97static inline int reverseInt (int i)
     98{
     99  unsigned char c1 = i & 255;
     100  unsigned char c2 = (i >> 8) & 255;
     101  unsigned char c3 = (i >> 16) & 255;
     102  unsigned char c4 = (i >> 24) & 255;
     103
     104  return ((int)c1 << 24) | ((int)c2 << 16) | ((int)c3 << 8) | c4;
     105}
     106
     107#define htonl(l) reverseInt(l)
     108#define htons(s) reverseShort(s)
     109#define ntohl(l) reverseInt(l)
     110#define ntohs(s) reverseShort(s)
     111
     112#endif
     113
     114
    87115/* pointers */
    88116#define HTONP(p)          ((p) = (void *) htonl ((unsigned long) p))
Note: See TracChangeset for help on using the changeset viewer.