From 67bdd80a96bdfc49d1aadbd32cca2b53f123d180 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 15 Jan 2017 17:56:11 +0100 Subject: stats: Disable stats*.c on embedded targets Change-Id: I6beb4fcc394ed7d3f8dd7a097b6e998245ecf401 --- include/osmocom/core/stats.h | 10 ++++++++++ src/stats.c | 14 ++++++++++++++ src/stats_statsd.c | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/include/osmocom/core/stats.h b/include/osmocom/core/stats.h index f754e41d..09b836ab 100644 --- a/include/osmocom/core/stats.h +++ b/include/osmocom/core/stats.h @@ -19,7 +19,15 @@ */ #pragma once +/* a bit of a crude way to disable building/using this on (bare iron) + * embedded systems. We cannot use the autoconf-defined HAVE_... macros + * here, as that only works at library compile time, not at application + * compile time */ +#ifdef unix + #include +#include + #include #include @@ -119,3 +127,5 @@ int osmo_stats_reporter_send(struct osmo_stats_reporter *srep, const char *data, int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep); int osmo_stats_reporter_udp_open(struct osmo_stats_reporter *srep); int osmo_stats_reporter_udp_close(struct osmo_stats_reporter *srep); + +#endif /* unix */ diff --git a/src/stats.c b/src/stats.c index 9c826ccf..a5232595 100644 --- a/src/stats.c +++ b/src/stats.c @@ -21,6 +21,9 @@ * */ +#include "config.h" +#if !defined(EMBEDDED) + #include #include @@ -30,9 +33,12 @@ #include #include #include + +#ifdef HAVE_SYS_SOCKET_H #include #include #include +#endif #include #include @@ -163,6 +169,8 @@ struct osmo_stats_reporter *osmo_stats_reporter_find(enum osmo_stats_reporter_ty return NULL; } +#ifdef HAVE_SYS_SOCKET_H + int osmo_stats_reporter_set_remote_addr(struct osmo_stats_reporter *srep, const char *addr) { int rc; @@ -240,6 +248,7 @@ int osmo_stats_reporter_set_mtu(struct osmo_stats_reporter *srep, int mtu) return update_srep_config(srep); } +#endif /* HAVE_SYS_SOCKETS_H */ int osmo_stats_reporter_set_max_class(struct osmo_stats_reporter *srep, enum osmo_stats_class class_id) @@ -289,6 +298,8 @@ int osmo_stats_reporter_disable(struct osmo_stats_reporter *srep) /*** i/o helper functions ***/ +#ifdef HAVE_SYS_SOCKET_H + int osmo_stats_reporter_udp_open(struct osmo_stats_reporter *srep) { int sock; @@ -381,6 +392,7 @@ int osmo_stats_reporter_send_buffer(struct osmo_stats_reporter *srep) return rc; } +#endif /* HAVE_SYS_SOCKET_H */ /*** log reporter ***/ @@ -611,3 +623,5 @@ int osmo_stats_report() return 0; } + +#endif /* !EMBEDDED */ diff --git a/src/stats_statsd.c b/src/stats_statsd.c index 8b53881e..342bb88e 100644 --- a/src/stats_statsd.c +++ b/src/stats_statsd.c @@ -21,6 +21,9 @@ * */ +#include "config.h" +#if !defined(EMBEDDED) + #include #include @@ -167,3 +170,4 @@ static int osmo_stats_reporter_statsd_send_item(struct osmo_stats_reporter *srep statg->idx, desc->name, value, unit); } +#endif /* !EMBEDDED */ -- cgit v1.2.3