Change in libosmocore[master]: Fix embedded (arm-none-eabi) builds

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jun 28 09:01:40 UTC 2018


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/9758


Change subject: Fix embedded (arm-none-eabi) builds
......................................................................

Fix embedded (arm-none-eabi) builds

Due to OS#3360, build testing for arm-none-eabi was unfortunately
skipped for a long time.  This is a number of fixes that make the
compile test pass again.

Related: OS#3360
Change-Id: I88e3c8e1a8786ca2a6a023b0d27c74be200a8588
---
M configure.ac
M src/logging.c
M src/pseudotalloc/pseudotalloc.c
M src/pseudotalloc/talloc.h
M src/timer_clockgettime.c
5 files changed, 28 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/58/9758/1

diff --git a/configure.ac b/configure.ac
index cb580a3..dd5f15b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,8 @@
 CFLAGS="$saved_CFLAGS"
 AC_SUBST(SYMBOL_VISIBILITY)
 
+AC_CHECK_FUNCS(clock_gettime localtime_r)
+
 AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
   AC_CACHE_CHECK(
     [whether struct tm has tm_gmtoff member],
diff --git a/src/logging.c b/src/logging.c
index 147b1fb..1dfd484 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -356,6 +356,7 @@
 	}
 	if (!cont) {
 		if (target->print_ext_timestamp) {
+#ifdef HAVE_LOCALTIME_R
 			struct tm tm;
 			struct timeval tv;
 			osmo_gettimeofday(&tv, NULL);
@@ -367,6 +368,7 @@
 			if (ret < 0)
 				goto err;
 			OSMO_SNPRINTF_RET(ret, rem, offset, len);
+#endif
 		} else if (target->print_timestamp) {
 			char *timestr;
 			time_t tm;
diff --git a/src/pseudotalloc/pseudotalloc.c b/src/pseudotalloc/pseudotalloc.c
index 2a99066..89e6269 100644
--- a/src/pseudotalloc/pseudotalloc.c
+++ b/src/pseudotalloc/pseudotalloc.c
@@ -96,3 +96,19 @@
 	va_end(args);
 	return buf;
 }
+
+void *talloc_steal(const void *new_ctx, const void *obj)
+{
+	/* as we don't do hierarchical allocations, this is simply a NOP */
+	return (void *)obj;
+}
+
+char *talloc_vasprintf(const void *t, const char *fmt, va_list ap)
+{
+	/* we have a hard-coded maximum string length of 128 bytes in this pseudo implementation */
+	char *buf = pseudotalloc_malloc(128);
+	if (!buf)
+		return NULL;
+	vsnprintf(buf, 128, fmt, ap);
+	return buf;
+}
diff --git a/src/pseudotalloc/talloc.h b/src/pseudotalloc/talloc.h
index ae2e1fc..34088af 100644
--- a/src/pseudotalloc/talloc.h
+++ b/src/pseudotalloc/talloc.h
@@ -59,3 +59,6 @@
 			 unsigned count,
 			 const char *name);
 char *talloc_asprintf(const void *ctx, const char *fmt, ...);
+
+void *talloc_steal(const void *new_ctx, const void *obj);
+char *talloc_vasprintf(const void *t, const char *fmt, va_list ap);
diff --git a/src/timer_clockgettime.c b/src/timer_clockgettime.c
index 8d9760c..7b17fd1 100644
--- a/src/timer_clockgettime.c
+++ b/src/timer_clockgettime.c
@@ -44,6 +44,9 @@
 /*! \file timer_clockgettime.c
  */
 
+#include "config.h"
+#ifdef HAVE_CLOCK_GETTIME
+
 #include <stdlib.h>
 #include <stdbool.h>
 #include <sys/time.h>
@@ -135,4 +138,6 @@
 		timespecadd(&c->time, &val, &c->time);
 }
 
+#endif /* HAVE_CLOCK_GETTIME */
+
 /*! @} */

-- 
To view, visit https://gerrit.osmocom.org/9758
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I88e3c8e1a8786ca2a6a023b0d27c74be200a8588
Gerrit-Change-Number: 9758
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180628/50f99e82/attachment.htm>


More information about the gerrit-log mailing list