Export symbols in order to support shared libraries (#54)

* Add BAC_ROUTING compile definition

* Reorder cmake

* Fix OpenSSL support: support both 1.0 and 1.1t pus

* Explicitly export symbols, hidden by default

* Build shared libraries on travis using cmake

* Learn Makefile about static library

* Fix build using mingw with cmake

* Do not cleanup twice or after potential free
This commit is contained in:
Anonymous Maarten
2020-03-06 22:42:03 +01:00
committed by GitHub
parent bb5fafc06a
commit 4a916468c6
174 changed files with 2200 additions and 91 deletions
+3
View File
@@ -24,6 +24,8 @@
#ifndef BIGEND_H
#define BIGEND_H
#include "bacnet/bacnet_stack_exports.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -44,6 +46,7 @@ extern "C" {
/* x[2] = 0x03 */
/* x[3] = 0x04 */
BACNET_STACK_EXPORT
int big_endian(
void);
+2
View File
@@ -27,6 +27,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include "bacnet/bacnet_stack_exports.h"
#include "bacnet/bacdef.h"
#ifndef DEBUG_ENABLED
@@ -37,6 +38,7 @@
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
void debug_printf(
const char *format,
...);
+13
View File
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "bacnet/bacnet_stack_exports.h"
/**
* FIFO data structure
@@ -31,43 +32,54 @@ typedef struct fifo_buffer_t FIFO_BUFFER;
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
unsigned FIFO_Count(
FIFO_BUFFER const *b);
BACNET_STACK_EXPORT
bool FIFO_Full(
FIFO_BUFFER const *b);
BACNET_STACK_EXPORT
bool FIFO_Available(
FIFO_BUFFER const *b,
unsigned count);
BACNET_STACK_EXPORT
bool FIFO_Empty(
FIFO_BUFFER const *b);
BACNET_STACK_EXPORT
uint8_t FIFO_Peek(
FIFO_BUFFER const *b);
BACNET_STACK_EXPORT
uint8_t FIFO_Get(
FIFO_BUFFER * b);
BACNET_STACK_EXPORT
unsigned FIFO_Pull(
FIFO_BUFFER * b,
uint8_t * data_bytes,
unsigned length);
BACNET_STACK_EXPORT
bool FIFO_Put(
FIFO_BUFFER * b,
uint8_t data_byte);
BACNET_STACK_EXPORT
bool FIFO_Add(
FIFO_BUFFER * b,
uint8_t * data_bytes,
unsigned count);
BACNET_STACK_EXPORT
void FIFO_Flush(
FIFO_BUFFER * b);
/* note: buffer_len must be a power of two */
BACNET_STACK_EXPORT
void FIFO_Init(
FIFO_BUFFER * b,
volatile uint8_t * buffer,
@@ -75,6 +87,7 @@ extern "C" {
#ifdef TEST
#include "ctest.h"
BACNET_STACK_EXPORT
void testFIFOBuffer(
Test * pTest);
#endif
+3
View File
@@ -24,10 +24,13 @@
#ifndef FILENAME_H
#define FILENAME_H
#include "bacnet/bacnet_stack_exports.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
char *filename_remove_path(
const char *filename_in);
+14
View File
@@ -24,6 +24,7 @@
#ifndef KEYLIST_H
#define KEYLIST_H
#include "bacnet/bacnet_stack_exports.h"
#include "key.h"
/* This is a key sorted linked list data library that */
@@ -48,68 +49,81 @@ extern "C" {
#endif /* __cplusplus */
/* returns head of the list or NULL on failure. */
BACNET_STACK_EXPORT
OS_Keylist Keylist_Create(
void);
/* delete specified list */
/* note: you should pop all the nodes off the list first. */
BACNET_STACK_EXPORT
void Keylist_Delete(
OS_Keylist list);
/* inserts a node into its sorted position */
/* returns the index where it was added */
BACNET_STACK_EXPORT
int Keylist_Data_Add(
OS_Keylist list,
KEY key,
void *data);
/* deletes a node specified by its key */
BACNET_STACK_EXPORT
/* returns the data from the node */
void *Keylist_Data_Delete(
OS_Keylist list,
KEY key);
/* deletes a node specified by its index */
BACNET_STACK_EXPORT
/* returns the data from the node */
void *Keylist_Data_Delete_By_Index(
OS_Keylist list,
int index);
/* returns the data from last node, and removes it from the list */
BACNET_STACK_EXPORT
void *Keylist_Data_Pop(
OS_Keylist list);
/* returns the data from the node specified by key */
BACNET_STACK_EXPORT
void *Keylist_Data(
OS_Keylist list,
KEY key);
/* returns the index from the node specified by key */
BACNET_STACK_EXPORT
int Keylist_Index(
OS_Keylist list,
KEY key);
/* returns the data specified by key */
BACNET_STACK_EXPORT
void *Keylist_Data_Index(
OS_Keylist list,
int index);
/* return the key at the given index */
BACNET_STACK_EXPORT
KEY Keylist_Key(
OS_Keylist list,
int index);
/* returns the next empty key from the list */
BACNET_STACK_EXPORT
KEY Keylist_Next_Empty_Key(
OS_Keylist list,
KEY key);
/* returns the number of items in the list */
BACNET_STACK_EXPORT
int Keylist_Count(
OS_Keylist list);
#ifdef TEST
#include "ctest.h"
BACNET_STACK_EXPORT
void testKeyList(
Test * pTest);
#endif
+11
View File
@@ -20,6 +20,8 @@
#ifndef MSTIMER_H_
#define MSTIMER_H_
#include "bacnet/bacnet_stack_exports.h"
/**
* A timer.
*
@@ -46,18 +48,27 @@ struct mstimer_callback_data_t {
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
void mstimer_set(struct mstimer *t, unsigned long interval);
BACNET_STACK_EXPORT
void mstimer_reset(struct mstimer *t);
BACNET_STACK_EXPORT
void mstimer_restart(struct mstimer *t);
BACNET_STACK_EXPORT
int mstimer_expired(struct mstimer *t);
BACNET_STACK_EXPORT
unsigned long mstimer_remaining(struct mstimer *t);
BACNET_STACK_EXPORT
unsigned long mstimer_interval(struct mstimer *t);
/* HAL implementation */
BACNET_STACK_EXPORT
unsigned long mstimer_now(void);
BACNET_STACK_EXPORT
void mstimer_callback(
struct mstimer_callback_data_t *cb,
mstimer_callback_function callback,
unsigned long milliseconds);
BACNET_STACK_EXPORT
void mstimer_init(void);
#ifdef __cplusplus
+18
View File
@@ -11,6 +11,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "bacnet/bacnet_stack_exports.h"
/**
* ring buffer power of two alignment macro
@@ -53,30 +54,43 @@ typedef struct ring_buffer_t RING_BUFFER;
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
unsigned Ringbuf_Count(RING_BUFFER const *b);
BACNET_STACK_EXPORT
unsigned Ringbuf_Depth(RING_BUFFER const *b);
BACNET_STACK_EXPORT
unsigned Ringbuf_Depth_Reset(RING_BUFFER *b);
BACNET_STACK_EXPORT
unsigned Ringbuf_Size(RING_BUFFER const *b);
BACNET_STACK_EXPORT
bool Ringbuf_Full(RING_BUFFER const *b);
BACNET_STACK_EXPORT
bool Ringbuf_Empty(RING_BUFFER const *b);
/* tail */
BACNET_STACK_EXPORT
volatile uint8_t *Ringbuf_Peek(RING_BUFFER const *b);
bool Ringbuf_Pop(RING_BUFFER * b,
uint8_t * data_element);
BACNET_STACK_EXPORT
bool Ringbuf_Pop_Element(RING_BUFFER * b,
uint8_t * this_element,
uint8_t * data_element);
BACNET_STACK_EXPORT
bool Ringbuf_Put_Front(RING_BUFFER * b,
uint8_t * data_element);
/* head */
BACNET_STACK_EXPORT
bool Ringbuf_Put(RING_BUFFER * b,
uint8_t * data_element);
/* pair of functions to use head memory directly */
BACNET_STACK_EXPORT
volatile uint8_t *Ringbuf_Data_Peek(RING_BUFFER * b);
volatile uint8_t *Ringbuf_Peek_Next(RING_BUFFER const *b,
uint8_t * data_element);
BACNET_STACK_EXPORT
bool Ringbuf_Data_Put(RING_BUFFER * b, volatile uint8_t *data_element);
/* Note: element_count must be a power of two */
BACNET_STACK_EXPORT
bool Ringbuf_Init(RING_BUFFER * b,
volatile uint8_t * buffer,
unsigned element_size,
@@ -84,9 +98,13 @@ extern "C" {
#ifdef TEST
#include "ctest.h"
BACNET_STACK_EXPORT
void testRingBufPowerOfTwo(Test * pTest);
BACNET_STACK_EXPORT
void testRingBufSizeSmall(Test * pTest);
BACNET_STACK_EXPORT
void testRingBufSizeLarge(Test * pTest);
BACNET_STACK_EXPORT
void testRingBufSizeInvalid(Test * pTest);
#endif
+9
View File
@@ -29,6 +29,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "bacnet/bacnet_stack_exports.h"
struct static_buffer_t {
char *data; /* block of memory or array of data */
@@ -41,35 +42,43 @@ typedef struct static_buffer_t STATIC_BUFFER;
extern "C" {
#endif /* __cplusplus */
BACNET_STACK_EXPORT
void sbuf_init(
STATIC_BUFFER * b, /* static buffer structure */
char *data, /* data block */
unsigned size); /* actual size, in bytes, of the data block or array of data */
/* returns true if size==0, false if size > 0 */
BACNET_STACK_EXPORT
bool sbuf_empty(
STATIC_BUFFER const *b);
/* returns the data block, or NULL if not initialized */
BACNET_STACK_EXPORT
char *sbuf_data(
STATIC_BUFFER const *b);
/* returns the max size of the data block */
BACNET_STACK_EXPORT
unsigned sbuf_size(
STATIC_BUFFER * b);
/* returns the number of bytes used in the data block */
BACNET_STACK_EXPORT
unsigned sbuf_count(
STATIC_BUFFER * b);
/* returns true if successful, false if not enough room to append data */
BACNET_STACK_EXPORT
bool sbuf_put(
STATIC_BUFFER * b, /* static buffer structure */
unsigned offset, /* where to start */
char *data, /* data to add */
unsigned data_size); /* how many to add */
/* returns true if successful, false if not enough room to append data */
BACNET_STACK_EXPORT
bool sbuf_append(
STATIC_BUFFER * b, /* static buffer structure */
char *data, /* data to append */
unsigned data_size); /* how many to append */
/* returns true if successful, false if count is bigger than size */
BACNET_STACK_EXPORT
bool sbuf_truncate(
STATIC_BUFFER * b, /* static buffer structure */
unsigned count); /* new number of bytes used in buffer */