view main/database/src/wrap_endian.h @ 12718:1af86934c14e octave-forge

Make compatible with Octaves new exception-based error handling. Retain compatibility with Octaves old error handling based on error_state. * src/error_helpers.[h,cc]: Added. * src/Makefile.in: Integrate error-helpers.[h,cc]. * src/config.h.in: Added. * configure.ac, src/config.h.in: Test presence of 'error_state' and presence of 'verror (octave_execution_exception&, const char *, va_list)'. * src/__pq_connect__.cc, src/command.cc, src/command.h, src/converters.cc, src/converters_arr_comp.cc, src/pq_connection.cc, src/pq_conninfo.cc, src/pq_exec.cc, src/pq_lo.cc, src/pq_update_types.cc: If necessary, include error-helpers.h, replace error() with c_verror(), set and check a different error indicator than error_state, use CHECK_ERROR or SET_ERR, explicitely check for errors instead of relying on Octave checking error_state when returning to the prompt.
author i7tiol
date Sat, 27 Feb 2016 11:11:04 +0000
parents 67adec29dee0
children
line wrap: on
line source

/*

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

#ifdef __MINGW32__
#include <winsock2.h>

#define htobe16(x) htons(x)
#define htole16(x) (x)
#define be16toh(x) ntohs(x)
#define le16toh(x) (x)
 
#define htobe32(x) htonl(x)
#define htole32(x) (x)
#define be32toh(x) ntohl(x)
#define le32toh(x) (x)
 
#define htobe64(x) (((uint64_t)htonl((uint32_t)(x>>32)))|(((uint64_t)htonl(x&0xFFFFFFFF))<<32LL))
#define htole64(x) (x)
#define be64toh(x) (((uint64_t)ntohl((uint32_t)(x>>32)))|(((uint64_t)ntohl(x&0xFFFFFFFF))<<32LL))
#define le64toh(x) (x)
 
#else
#include <endian.h>
#endif

#endif

#endif // __OCT_PQ_WRAP_ENDIAN__