-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Internal shapelib] Give a try to OSGeo/shapelib#94
- Loading branch information
Showing
6 changed files
with
406 additions
and
463 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#ifndef SHAPEFILE_PRIVATE_H_INCLUDED | ||
#define SHAPEFILE_PRIVATE_H_INCLUDED | ||
|
||
/****************************************************************************** | ||
* | ||
* Project: Shapelib | ||
* Purpose: Private include file for Shapelib. | ||
* Author: Frank Warmerdam, [email protected] | ||
* | ||
****************************************************************************** | ||
* Copyright (c) 1999, Frank Warmerdam | ||
* Copyright (c) 2012-2016, Even Rouault <even dot rouault at spatialys.com> | ||
* | ||
* SPDX-License-Identifier: MIT OR LGPL-2.0-or-later | ||
****************************************************************************** | ||
* | ||
*/ | ||
|
||
#ifdef __cplusplus | ||
#define STATIC_CAST(type, x) static_cast<type>(x) | ||
#define REINTERPRET_CAST(type, x) reinterpret_cast<type>(x) | ||
#define CONST_CAST(type, x) const_cast<type>(x) | ||
#define SHPLIB_NULLPTR nullptr | ||
#else | ||
#define STATIC_CAST(type, x) ((type)(x)) | ||
#define REINTERPRET_CAST(type, x) ((type)(x)) | ||
#define CONST_CAST(type, x) ((type)(x)) | ||
#define SHPLIB_NULLPTR NULL | ||
#endif | ||
|
||
#include "shapefil.h" | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
/************************************************************************/ | ||
/* Little endian <==> big endian byte swap macros. */ | ||
/************************************************************************/ | ||
|
||
#if (defined(__GNUC__) && __GNUC__ >= 5) || \ | ||
(defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 && \ | ||
__GNUC_MINOR__ >= 8) | ||
#define _SHP_SWAP32(x) \ | ||
STATIC_CAST(uint32_t, __builtin_bswap32(STATIC_CAST(uint32_t, x))) | ||
#define _SHP_SWAP64(x) \ | ||
STATIC_CAST(uint64_t, __builtin_bswap64(STATIC_CAST(uint64_t, x))) | ||
#elif defined(_MSC_VER) | ||
#define _SHP_SWAP32(x) \ | ||
STATIC_CAST(uint32_t, _byteswap_ulong(STATIC_CAST(uint32_t, x))) | ||
#define _SHP_SWAP64(x) \ | ||
STATIC_CAST(uint64_t, _byteswap_uint64(STATIC_CAST(uint64_t, x))) | ||
#else | ||
#define _SHP_SWAP32(x) \ | ||
STATIC_CAST(uint32_t, \ | ||
((STATIC_CAST(uint32_t, x) & 0x000000ffU) << 24) | \ | ||
((STATIC_CAST(uint32_t, x) & 0x0000ff00U) << 8) | \ | ||
((STATIC_CAST(uint32_t, x) & 0x00ff0000U) >> 8) | \ | ||
((STATIC_CAST(uint32_t, x) & 0xff000000U) >> 24)) | ||
#define _SHP_SWAP64(x) \ | ||
((STATIC_CAST(uint64_t, _SHP_SWAP32(STATIC_CAST(uint32_t, x))) << 32) | \ | ||
(STATIC_CAST(uint64_t, _SHP_SWAP32(STATIC_CAST( \ | ||
uint32_t, STATIC_CAST(uint64_t, x) >> 32))))) | ||
|
||
#endif | ||
|
||
#define SHP_SWAP32(p) \ | ||
*STATIC_CAST(uint32_t *, p) = _SHP_SWAP32(*STATIC_CAST(uint32_t *, p)) | ||
#define SHP_SWAP64(p) \ | ||
*STATIC_CAST(uint64_t *, p) = _SHP_SWAP64(*STATIC_CAST(uint64_t *, p)) | ||
#define SHP_SWAPDOUBLE(x) \ | ||
do \ | ||
{ \ | ||
uint64_t _n64; \ | ||
void *_lx = x; \ | ||
memcpy(&_n64, _lx, 8); \ | ||
_n64 = SHP_SWAP64(_n64); \ | ||
memcpy(_lx, &_n64, 8); \ | ||
} while (0) | ||
#endif /* ndef SHAPEFILE_PRIVATE_H_INCLUDED */ |
Oops, something went wrong.