mirror of https://gerrit.osmocom.org/libosmocore
core: Move OSMO_DEPRECATED to new core/defs.h file
Add a new core/defs.h file for definitions that can be used from within header files without including prototypes and extern declarations. It's primarily meant for macro definitions and basic typedefs. Move the definition of OSMO_DEPRECATED there and use compiler version info to avoid compiler errors.
This commit is contained in:
parent
30fbcf5a41
commit
6b2621883f
|
@ -11,6 +11,7 @@ nobase_include_HEADERS = \
|
||||||
osmocom/core/crc64gen.h \
|
osmocom/core/crc64gen.h \
|
||||||
osmocom/core/crc8gen.h \
|
osmocom/core/crc8gen.h \
|
||||||
osmocom/core/crcgen.h \
|
osmocom/core/crcgen.h \
|
||||||
|
osmocom/core/defs.h \
|
||||||
osmocom/core/gsmtap.h \
|
osmocom/core/gsmtap.h \
|
||||||
osmocom/core/gsmtap_util.h \
|
osmocom/core/gsmtap_util.h \
|
||||||
osmocom/core/linuxlist.h \
|
osmocom/core/linuxlist.h \
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
#ifndef OSMOCORE_DEFS_H
|
||||||
|
#define OSMOCORE_DEFS_H
|
||||||
|
|
||||||
|
/*! \defgroup utils General-purpose utility functions
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \file defs.h
|
||||||
|
* \brief General definitions that are meant to be included from header files.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*! \brief Check for gcc and version.
|
||||||
|
*
|
||||||
|
* \note Albeit glibc provides a features.h file that contains a similar
|
||||||
|
* definition (__GNUC_PREREQ), this definition has been copied from there
|
||||||
|
* to have it available with other libraries, too.
|
||||||
|
*
|
||||||
|
* \return != 0 iff gcc is used and it's version is at least maj.min.
|
||||||
|
*/
|
||||||
|
#if defined __GNUC__ && defined __GNUC_MINOR__
|
||||||
|
# define OSMO_GNUC_PREREQ(maj, min) \
|
||||||
|
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||||
|
#else
|
||||||
|
# define OSMO_GNUC_PREREQ(maj, min) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! \brief Set the deprecated attribute with a message.
|
||||||
|
*/
|
||||||
|
#if ! defined(__GNUC__)
|
||||||
|
# define OSMO_DEPRECATED(text)
|
||||||
|
#elif OSMO_GNUC_PREREQ(4,5)
|
||||||
|
# define OSMO_DEPRECATED(text) __attribute__((__deprecated__(text)))
|
||||||
|
#else
|
||||||
|
# define OSMO_DEPRECATED(text) __attribute__((__deprecated__))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! @} */
|
||||||
|
|
||||||
|
#endif
|
|
@ -28,7 +28,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <osmocom/gsm/gsm_utils.h>
|
#include <osmocom/core/defs.h>
|
||||||
|
|
||||||
#define ADD_MODULO(sum, delta, modulo) do { \
|
#define ADD_MODULO(sum, delta, modulo) do { \
|
||||||
if ((sum += delta) >= modulo) \
|
if ((sum += delta) >= modulo) \
|
||||||
|
@ -37,18 +37,6 @@
|
||||||
|
|
||||||
#define GSM_MAX_FN (26*51*2048)
|
#define GSM_MAX_FN (26*51*2048)
|
||||||
|
|
||||||
/*! \brief Set the deprecated attribute with a message.
|
|
||||||
*
|
|
||||||
* \todo Move this to a global header utility file.
|
|
||||||
* \todo Check for compiler version to selectivly enable the message.
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
#define OSMO_DEPRECATED(text) __attribute__((deprecated(text)))
|
|
||||||
#else
|
|
||||||
#define OSMO_DEPRECATED(text) __attribute__((__deprecated__))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
struct gsm_time {
|
struct gsm_time {
|
||||||
uint32_t fn; /* FN count */
|
uint32_t fn; /* FN count */
|
||||||
uint16_t t1; /* FN div (26*51) */
|
uint16_t t1; /* FN div (26*51) */
|
||||||
|
|
Loading…
Reference in New Issue