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:
@@ -0,0 +1,54 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2020 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*********************************************************************/
|
||||
#ifndef BACNET_STACK_EXPORTS_H
|
||||
#define BACNET_STACK_EXPORTS_H
|
||||
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
|
||||
#ifdef BACNET_STACK_STATIC_DEFINE
|
||||
/* We want a static library */
|
||||
# define BACNET_STACK_EXPORT
|
||||
#else
|
||||
/* We want a shared library */
|
||||
# ifdef _MSC_VER
|
||||
# define BACNET_STACK_LIBRARY_IMPORT __declspec(dllimport)
|
||||
# define BACNET_STACK_LIBRARY_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define BACNET_STACK_LIBRARY_IMPORT
|
||||
# define BACNET_STACK_LIBRARY_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BACNET_STACK_EXPORT
|
||||
# ifdef bacnet_stack_EXPORTS
|
||||
/* We are building this library */
|
||||
# define BACNET_STACK_EXPORT BACNET_STACK_LIBRARY_EXPORT
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define BACNET_STACK_EXPORT BACNET_STACK_LIBRARY_IMPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* BACNET_STACK_EXPORTS_H */
|
||||
@@ -24,8 +24,8 @@
|
||||
#ifndef BIGEND_H
|
||||
#define BIGEND_H
|
||||
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file
|
||||
* @author Steve Karg
|
||||
* @date 2022
|
||||
* @brief Bitwise helper macros
|
||||
* @copyright 2012 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef BACNET_SYS_BITS_H
|
||||
#define BACNET_SYS_BITS_H
|
||||
|
||||
/********************************************************************
|
||||
* Bit Masks
|
||||
*********************************************************************/
|
||||
#ifndef BIT
|
||||
#define BIT(x) (1<<(x))
|
||||
#endif
|
||||
#ifndef _BV
|
||||
#define _BV(x) (1<<(x))
|
||||
#endif
|
||||
|
||||
/* a=register, b=bit number to act upon 0-n */
|
||||
#ifndef BIT_SET
|
||||
#define BIT_SET(a,b) ((a) |= (1<<(b)))
|
||||
#endif
|
||||
#ifndef BIT_CLEAR
|
||||
#define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
|
||||
#endif
|
||||
#ifndef BIT_FLIP
|
||||
#define BIT_FLIP(a,b) ((a) ^= (1<<(b)))
|
||||
#endif
|
||||
#ifndef BIT_CHECK
|
||||
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
|
||||
#endif
|
||||
|
||||
/* x=target variable, y=mask */
|
||||
#ifndef BITMASK_SET
|
||||
#define BITMASK_SET(x,y) ((x) |= (y))
|
||||
#endif
|
||||
#ifndef BITMASK_CLEAR
|
||||
#define BITMASK_CLEAR(x,y) ((x) &= (~(y)))
|
||||
#endif
|
||||
#ifndef BITMASK_FLIP
|
||||
#define BITMASK_FLIP(x,y) ((x) ^= (y))
|
||||
#endif
|
||||
#ifndef BITMASK_CHECK
|
||||
#define BITMASK_CHECK(x,y) (((x) & (y)) == (y))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @file
|
||||
* @author Steve Karg
|
||||
* @date 2022
|
||||
* @brief Defines the bit/byte/word/long conversions that are used in code
|
||||
* @copyright 2012 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef BACNET_SYS_BYTES_H
|
||||
#define BACNET_SYS_BYTES_H
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef LO_NIB
|
||||
#define LO_NIB(b) ((b)&0xF)
|
||||
#endif
|
||||
|
||||
#ifndef HI_NIB
|
||||
#define HI_NIB(b) ((b) >> 4)
|
||||
#endif
|
||||
|
||||
#ifndef LO_BYTE
|
||||
#define LO_BYTE(w) ((uint8_t)(w))
|
||||
#endif
|
||||
|
||||
#ifndef HI_BYTE
|
||||
#define HI_BYTE(w) ((uint8_t)((uint16_t)(w) >> 8))
|
||||
#endif
|
||||
|
||||
#ifndef LO_WORD
|
||||
#define LO_WORD(x) ((uint16_t)(x))
|
||||
#endif
|
||||
|
||||
#ifndef HI_WORD
|
||||
#define HI_WORD(x) ((uint16_t)((uint32_t)(x) >> 16))
|
||||
#endif
|
||||
|
||||
#ifndef MAKE_WORD
|
||||
#define MAKE_WORD(lo, hi) \
|
||||
((uint16_t)(((uint8_t)(lo)) | (((uint16_t)((uint8_t)(hi))) << 8)))
|
||||
#endif
|
||||
|
||||
#ifndef MAKE_LONG
|
||||
#define MAKE_LONG(lo, hi) \
|
||||
((uint32_t)(((uint16_t)(lo)) | (((uint32_t)((uint16_t)(hi))) << 16)))
|
||||
#endif
|
||||
|
||||
#endif /* end of header file */
|
||||
@@ -8,8 +8,8 @@
|
||||
#define COLOR_RGB_H
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#define DAYS_H
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
#ifndef DEBUG_ENABLED
|
||||
#define DEBUG_ENABLED 0
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
/**
|
||||
* FIFO buffer power of two alignment macro
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#ifndef FILENAME_H
|
||||
#define FILENAME_H
|
||||
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#define KEY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
/* This file has the macros that encode and decode the */
|
||||
/* keys for the keylist when used with BACnet Object Id's */
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
#ifndef KEYLIST_H
|
||||
#define KEYLIST_H
|
||||
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
#include "bacnet/basic/sys/platform.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
/* BACnet Stack API */
|
||||
#include "bacnet/basic/sys/key.h"
|
||||
|
||||
/* This is a key sorted linked list data library that */
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#ifndef LINEAR_H
|
||||
#define LINEAR_H
|
||||
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef MSTIMER_H_
|
||||
#define MSTIMER_H_
|
||||
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
/**
|
||||
* A timer.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
/**
|
||||
* ring buffer power of two alignment macro
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bacnet/bacdef.h" /* Must be before all other bacnet *.h files */
|
||||
#include "bacnet/bacnet_stack_exports.h"
|
||||
/* BACnet Stack defines - first */
|
||||
#include "bacnet/bacdef.h"
|
||||
|
||||
struct static_buffer_t {
|
||||
char *data; /* block of memory or array of data */
|
||||
|
||||
Reference in New Issue
Block a user