Add core stack headers into bacdef.h and cleanup includes. (#602)
* Added dependent BACnet stack headers into bacdef.h file. * Changed bacdef.h and other stack includes in c/h files to have a common pattern. * Moved bits.h, bytes.h, and bacnet_stack_exports.h under bacnet/basic/sys/ folder.
This commit is contained in:
@@ -3,24 +3,20 @@
|
||||
* @author Steve Karg
|
||||
* @date 2022
|
||||
* @brief Platform libc and compiler abstraction layer
|
||||
*
|
||||
*
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* This libc and compiler abstraction layer assists with differences
|
||||
* between compiler and libc versions, capabilities, and standards.
|
||||
* between compiler and libc versions, capabilities, and C standards.
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (C) 2022 Steve Karg <skarg@users.sourceforge.net>
|
||||
* @copyright 2022 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
*/
|
||||
#ifndef BACNET_SYS_PLATFORM_H
|
||||
#define BACNET_SYS_PLATFORM_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
|
||||
#ifndef islessgreater
|
||||
#define islessgreater(x, y) ((x) < (y) || (x) > (y))
|
||||
@@ -32,14 +28,14 @@
|
||||
|
||||
/* marking some code as 'deprecated' */
|
||||
#if defined(BACNET_STACK_DEPRECATED_DISABLE)
|
||||
# define BACNET_STACK_DEPRECATED(message)
|
||||
#define BACNET_STACK_DEPRECATED(message)
|
||||
#elif defined(_MSC_VER)
|
||||
# define BACNET_STACK_DEPRECATED(message) __declspec(deprecated(message))
|
||||
#define BACNET_STACK_DEPRECATED(message) __declspec(deprecated(message))
|
||||
#elif defined(__GNUC__)
|
||||
# define BACNET_STACK_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
# else
|
||||
# define BACNET_STACK_DEPRECATED(message)
|
||||
# endif
|
||||
#define BACNET_STACK_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
#else
|
||||
#define BACNET_STACK_DEPRECATED(message)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#ifndef strcasecmp
|
||||
@@ -54,8 +50,8 @@
|
||||
#define snprintf c99_snprintf
|
||||
#define vsnprintf c99_vsnprintf
|
||||
|
||||
__inline int c99_vsnprintf(char *outBuf, size_t size, const char *format,
|
||||
va_list ap)
|
||||
__inline int c99_vsnprintf(
|
||||
char *outBuf, size_t size, const char *format, va_list ap)
|
||||
{
|
||||
int count = -1;
|
||||
|
||||
@@ -80,25 +76,40 @@ __inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
|
||||
}
|
||||
#endif
|
||||
#elif defined(__ZEPHYR__)
|
||||
# include <strings.h>
|
||||
# endif
|
||||
#include <strings.h>
|
||||
/* For some reason my Zephyr build for non-native targets does not
|
||||
* see a definition for strnlen(), but it is visible in when
|
||||
* compiling for native_posix. This results in the compiler
|
||||
* emitting a warning, forcing Zephyr's sanitycheck() script to stop.
|
||||
* Until this is chased down, the definition is being provided here.
|
||||
*/
|
||||
#if !CONFIG_NATIVE_APPLICATION
|
||||
size_t strnlen(const char *, size_t);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* some common min/max as defined in windef.h */
|
||||
#ifndef NOMINMAX
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#endif /* NOMINMAX */
|
||||
#endif /* NOMINMAX */
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#define BACNET_STACK_FALLTHROUGH() /* fall through */
|
||||
#elif defined(__GNUC__)
|
||||
#define BACNET_STACK_FALLTHROUGH() __attribute__ ((fallthrough))
|
||||
#define BACNET_STACK_FALLTHROUGH() __attribute__((fallthrough))
|
||||
#else
|
||||
#define BACNET_STACK_FALLTHROUGH() /* fall through */
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
/* Silence the warnings about unsafe versions of library functions */
|
||||
/* as we need to keep the code portable */
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user