Skip to content

Commit

Permalink
Merge pull request #3 from myfreeweb/master
Browse files Browse the repository at this point in the history
Fix FreeBSD build
  • Loading branch information
haberman committed Nov 10, 2016
2 parents ca41835 + cf8a125 commit 515bed5
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/bloaty.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

#include <stdlib.h>
#include <stdint.h>
#ifdef __FreeBSD__
#include <sys/endian.h>
#endif

#include <memory>
#include <set>
Expand Down Expand Up @@ -392,17 +395,35 @@ struct ByteSwapper<T, 1> {

template <class T>
struct ByteSwapper<T, 2> {
T operator()(T val) { return __bswap_16(val); }
T operator()(T val) {
#ifdef __FreeBSD__
return bswap16(val);
#else
return __bswap_16(val);
#endif
}
};

template <class T>
struct ByteSwapper<T, 4> {
T operator()(T val) { return __bswap_32(val); }
T operator()(T val) {
#ifdef __FreeBSD__
return bswap32(val);
#else
return __bswap_32(val);
#endif
}
};

template <class T>
struct ByteSwapper<T, 8> {
T operator()(T val) { return __bswap_64(val); }
T operator()(T val) {
#ifdef __FreeBSD__
return bswap64(val);
#else
return __bswap_64(val);
#endif
}
};

template <class T>
Expand Down

0 comments on commit 515bed5

Please sign in to comment.