changeset 11644:eb48ca3b21a1 octave-forge

Fix #include <endian.h> for Apple, reported by Kamil Badyla.
author i7tiol
date Mon, 22 Apr 2013 10:56:37 +0000
parents 4c9a22aa2e70
children bd5a8f1bdfb8
files main/database/DESCRIPTION main/database/NEWS main/database/src/converters.h main/database/src/converters_arr_comp.cc main/database/src/wrap_endian.h
diffstat 5 files changed, 45 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/main/database/DESCRIPTION	Sun Apr 21 17:52:00 2013 +0000
+++ b/main/database/DESCRIPTION	Mon Apr 22 10:56:37 2013 +0000
@@ -1,6 +1,6 @@
 Name: database
 Version: 2.1.1
-Date: 2013-04-16
+Date: 2013-04-22
 Author: Olaf Till <i7tiol@t-online.de>
 Maintainer: Olaf Till <i7tiol@t-online.de>
 Title: Database.
--- a/main/database/NEWS	Sun Apr 21 17:52:00 2013 +0000
+++ b/main/database/NEWS	Mon Apr 22 10:56:37 2013 +0000
@@ -1,3 +1,5 @@
+ ** Fix for includes on Apple.
+
 database 2.1.1:
 ---------------
 
--- a/main/database/src/converters.h	Sun Apr 21 17:52:00 2013 +0000
+++ b/main/database/src/converters.h	Mon Apr 22 10:56:37 2013 +0000
@@ -24,13 +24,14 @@
 #include <octave/oct.h>
 
 #include <stdint.h>
-#include <endian.h>
 
 #include <vector>
 #include <string>
 
 #include <libpq-fe.h>
 
+#include "wrap_endian.h"
+
 #define OCT_PQ_NUM_CONVERTERS 13
 
 typedef std::vector<char> oct_pq_dynvec_t;
--- a/main/database/src/converters_arr_comp.cc	Sun Apr 21 17:52:00 2013 +0000
+++ b/main/database/src/converters_arr_comp.cc	Mon Apr 22 10:56:37 2013 +0000
@@ -23,8 +23,8 @@
 #include <octave/lo-ieee.h>
 
 #include <stdint.h>
-#include <endian.h>
 
+#include "wrap_endian.h"
 #include "command.h"
 
 octave_idx_type command::count_row_major_order (dim_vector &dv,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/database/src/wrap_endian.h	Mon Apr 22 10:56:37 2013 +0000
@@ -0,0 +1,39 @@
+/*
+
+This file is in the public domain. The Apple-specific include and
+defines were taken from a public domain file at this site:
+
+https://gist.github.com/yinyin/2027912
+
+*/
+
+#ifndef __OCT_PQ_WRAP_ENDIAN__
+
+#define __OCT_PQ_WRAP_ENDIAN__
+
+#ifdef __APPLE__
+
+#include <libkern/OSByteOrder.h>
+ 
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+ 
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+ 
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+ 
+#else
+
+#include <endian.h>
+
+#endif
+
+#endif // __OCT_PQ_WRAP_ENDIAN__