summaryrefslogtreecommitdiff
path: root/src/plot.h
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-09-04 14:55:49 +0100
committerVincent Sanders <vince@kyllikki.org>2016-09-04 14:55:49 +0100
commit6fe884b805a97e4185703afb62de4da8bdf3edde (patch)
treede810a26840a82ce80240845bb8403f57a3a8a36 /src/plot.h
parent327f0f92b6ce25591568535d3b8a33b5e11e8698 (diff)
downloadlibnsfb-6fe884b805a97e4185703afb62de4da8bdf3edde.tar.gz
libnsfb-6fe884b805a97e4185703afb62de4da8bdf3edde.tar.bz2
Make endianess detection more robust
This moves the byte order detection into the internal plot header and makes teh detection much more robust searching for more macros in common use. This should fix compilation on big endian openBSD systems Thanks to Anthony J. Bentley for a patch used as inspiration for this change
Diffstat (limited to 'src/plot.h')
-rw-r--r--src/plot.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/plot.h b/src/plot.h
index 4b1545d..6e67ca6 100644
--- a/src/plot.h
+++ b/src/plot.h
@@ -1,4 +1,52 @@
+/*
+ * Copyright 2009 Vincent Sanders <vince@simtec.co.uk>
+ *
+ * This file is part of libnsfb, http://www.netsurf-browser.org/
+ * Licenced under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ */
+
+/**
+ * \file internal plotter interace.
+ */
+#ifndef LIBNSFB_PLOT_H
+#define LIBNSFB_PLOT_H
+
+/*
+ * Do the best we can to determine integer byte ordering
+ *
+ * This series of tests attempts to determine, at compile time, if the integer
+ * ordering in memory is big or little endian. This allows the plotters to make
+ * assumptions about memory ordering to greatly improve software rendering
+ * performance.
+ *
+ * \note This utterly ignores PDP endianess
+ */
+#undef NSFB_BE_BYTE_ORDER
+#if defined(_WIN32)
+ /* windows does not have endian.h but uses these macros */
+ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ #define NSFB_BE_BYTE_ORDER
+ #endif
+#else /* defined(_WIN32) */
+ #include <endian.h>
+ #if defined(__BYTE_ORDER__)
+ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ #define NSFB_BE_BYTE_ORDER
+ #endif
+ #elif defined(__BYTE_ORDER)
+ #if __BYTE_ORDER == __BIG_ENDIAN
+ #define NSFB_BE_BYTE_ORDER
+ #endif
+ #elif defined(BYTE_ORDER)
+ #if BYTE_ORDER == BIG_ENDIAN
+ #define NSFB_BE_BYTE_ORDER
+ #endif
+ #else
+ #error "Endian determination failed"
+ #endif
+#endif
/** Clears plotting area to a flat colour (if needed)
*/
@@ -127,3 +175,4 @@ typedef struct nsfb_plotter_fns_s {
bool select_plotters(nsfb_t *nsfb);
+#endif