/usr/include/mapnik/global.hpp is in libmapnik-dev 3.0.19+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_GLOBAL_HPP
#define MAPNIK_GLOBAL_HPP
// stl
#include <cstdint>
#include <cstring>
#include <cmath>
namespace mapnik
{
#define int2net(A) (int16_t) (((std::uint16_t) ((std::uint8_t) (A)[1])) | \
(((std::uint16_t) ((std::uint8_t) (A)[0])) << 8))
#define int4net(A) (int32_t) (((std::uint32_t) ((std::uint8_t) (A)[3])) | \
(((std::uint32_t) ((std::uint8_t) (A)[2])) << 8) | \
(((std::uint32_t) ((std::uint8_t) (A)[1])) << 16) | \
(((std::uint32_t) ((std::uint8_t) (A)[0])) << 24))
#define int8net(A) (int64_t) (((std::uint64_t) ((std::uint8_t) (A)[7])) | \
(((std::uint64_t) ((std::uint8_t) (A)[6])) << 8) | \
(((std::uint64_t) ((std::uint8_t) (A)[5])) << 16) | \
(((std::uint64_t) ((std::uint8_t) (A)[4])) << 24) | \
(((std::uint64_t) ((std::uint8_t) (A)[3])) << 32) | \
(((std::uint64_t) ((std::uint8_t) (A)[2])) << 40) | \
(((std::uint64_t) ((std::uint8_t) (A)[1])) << 48) | \
(((std::uint64_t) ((std::uint8_t) (A)[0])) << 56))
#define float8net(V,M) do { double def_temp; \
((std::uint8_t*) &def_temp)[0]=(M)[7]; \
((std::uint8_t*) &def_temp)[1]=(M)[6]; \
((std::uint8_t*) &def_temp)[2]=(M)[5]; \
((std::uint8_t*) &def_temp)[3]=(M)[4]; \
((std::uint8_t*) &def_temp)[4]=(M)[3]; \
((std::uint8_t*) &def_temp)[5]=(M)[2]; \
((std::uint8_t*) &def_temp)[6]=(M)[1]; \
((std::uint8_t*) &def_temp)[7]=(M)[0]; \
(V) = def_temp; } while(0)
#define float4net(V,M) do { float def_temp; \
((std::uint8_t*) &def_temp)[0]=(M)[3]; \
((std::uint8_t*) &def_temp)[1]=(M)[2]; \
((std::uint8_t*) &def_temp)[2]=(M)[1]; \
((std::uint8_t*) &def_temp)[3]=(M)[0]; \
(V)=def_temp; } while(0)
// read int16_t NDR (little endian)
inline void read_int16_ndr(const char* data, std::int16_t & val)
{
std::memcpy(&val,data,2);
}
// read int32_t NDR (little endian)
inline void read_int32_ndr(const char* data, std::int32_t & val)
{
std::memcpy(&val,data,4);
}
// read double NDR (little endian)
inline void read_double_ndr(const char* data, double & val)
{
std::memcpy(&val,&data[0],8);
}
// read int16_t XDR (big endian)
inline void read_int16_xdr(const char* data, std::int16_t & val)
{
val = static_cast<std::int16_t>((data[3]&0xff) | ((data[2]&0xff)<<8));
}
// read int32_t XDR (big endian)
inline void read_int32_xdr(const char* data, std::int32_t & val)
{
val = (data[3]&0xff) | ((data[2]&0xff)<<8) | ((data[1]&0xff)<<16) | ((data[0]&0xff)<<24);
}
// read double XDR (big endian)
inline void read_double_xdr(const char* data, double & val)
{
std::int64_t bits = (static_cast<std::int64_t>(data[7]) & 0xff) |
(static_cast<std::int64_t>(data[6]) & 0xff) << 8 |
(static_cast<std::int64_t>(data[5]) & 0xff) << 16 |
(static_cast<std::int64_t>(data[4]) & 0xff) << 24 |
(static_cast<std::int64_t>(data[3]) & 0xff) << 32 |
(static_cast<std::int64_t>(data[2]) & 0xff) << 40 |
(static_cast<std::int64_t>(data[1]) & 0xff) << 48 |
(static_cast<std::int64_t>(data[0]) & 0xff) << 56 ;
std::memcpy(&val,&bits,8);
}
#if defined(_MSC_VER) && _MSC_VER < 1800
// msvc doesn't have rint in <cmath>
inline int rint(double val)
{
return int(std::floor(val + 0.5));
}
inline double round(double val)
{
return std::floor(val);
}
#endif
#if defined(_MSC_VER)
#define _USE_MATH_DEFINES
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#endif
}
#endif // MAPNIK_GLOBAL_HPP
|