From bbc97f1733868d076deefb999878f75b5d505ae9 Mon Sep 17 00:00:00 2001 From: Sergey Polyakov Date: Sun, 6 Nov 2016 22:03:59 +0200 Subject: [PATCH] gcc 5.4.x fixes --- build/module.mk | 9 +++--- communication/src/dtls_message_channel.cpp | 1 + communication/src/publisher.h | 2 ++ communication/src/spark_protocol.cpp | 1 + hal/src/core/sources.mk | 4 --- modules/electron/system-part3/src/export_rt.c | 5 +++ modules/photon/system-part1/linker.ld | 2 +- modules/photon/system-part2/src/export_rt.c | 5 +++ newlib_nano/src/mallocr.c | 3 +- platform/NET/build.mk | 4 --- user/build.mk | 5 --- wiring/inc/spark_wiring_character.h | 14 ++------- wiring/src/spark_wiring_character.cpp | 31 +++++++++++++++++++ 13 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 wiring/src/spark_wiring_character.cpp diff --git a/build/module.mk b/build/module.mk index a9dd245a09..51be5bc14e 100644 --- a/build/module.mk +++ b/build/module.mk @@ -29,10 +29,9 @@ CFLAGS += $(addprefix -D,$(GLOBAL_DEFINES)) export GLOBAL_DEFINES endif -# fixes build errors on ubuntu with arm gcc 5.3.1 -# GNU_SOURCE is needed for isascii/toascii -# WINSOCK_H stops select.h from being used which conflicts with CC3000 headers -CFLAGS += -D_GNU_SOURCE -D_WINSOCK_H +# fixes build errors on ubuntu with arm gcc 5.x +# _POSIX_C_SOURCE selects latest POSIX-conforming API +CFLAGS += -D_POSIX_C_SOURCE=200809 # Global category name for logging ifneq (,$(LOG_MODULE_CATEGORY)) @@ -280,7 +279,7 @@ $(BUILD_PATH)/%.o : $(COMMON_BUILD)/arm/%.S $(VERBOSE)$(CC) $(ASFLAGS) -c -o $@ $< $(call echo,) - + # Other Targets clean: clean_deps $(VERBOSE)$(RM) $(ALLOBJ) $(ALLDEPS) $(TARGET) diff --git a/communication/src/dtls_message_channel.cpp b/communication/src/dtls_message_channel.cpp index 01a5473c5a..6510812cdd 100644 --- a/communication/src/dtls_message_channel.cpp +++ b/communication/src/dtls_message_channel.cpp @@ -26,6 +26,7 @@ #include "timer_hal.h" #include #include +#include #include "dtls_session_persist.h" #include "service_debug.h" diff --git a/communication/src/publisher.h b/communication/src/publisher.h index ccedffc679..ed4fa8755a 100644 --- a/communication/src/publisher.h +++ b/communication/src/publisher.h @@ -26,6 +26,8 @@ #include "completion_handler.h" +#include + namespace particle { namespace protocol diff --git a/communication/src/spark_protocol.cpp b/communication/src/spark_protocol.cpp index a8e13e7ec0..0df8455060 100644 --- a/communication/src/spark_protocol.cpp +++ b/communication/src/spark_protocol.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "device_keys.h" #include "service_debug.h" #include "messages.h" diff --git a/hal/src/core/sources.mk b/hal/src/core/sources.mk index 5e94f10ca4..e8047e6be2 100644 --- a/hal/src/core/sources.mk +++ b/hal/src/core/sources.mk @@ -22,7 +22,3 @@ CPPSRC += $(call target_files,$(HAL_SRC_STM32_PATH)/,*.cpp) # ASM source files included in this build. ASRC += - -# Stick to some POSIX-conforming API to disable BSD extensions -CFLAGS += -D_POSIX_C_SOURCE=200809 - diff --git a/modules/electron/system-part3/src/export_rt.c b/modules/electron/system-part3/src/export_rt.c index caf4523dd8..fe6d1b2e1c 100644 --- a/modules/electron/system-part3/src/export_rt.c +++ b/modules/electron/system-part3/src/export_rt.c @@ -1,4 +1,9 @@ #define DYNALIB_EXPORT + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE // for siprintf(), siscanf() and other extensions +#endif + #include // for malloc, free, realloc #include #include // for va_list diff --git a/modules/photon/system-part1/linker.ld b/modules/photon/system-part1/linker.ld index aeabd2a1bc..5f28b46feb 100644 --- a/modules/photon/system-part1/linker.ld +++ b/modules/photon/system-part1/linker.ld @@ -3,7 +3,7 @@ MEMORY APP_FLASH (rx) : ORIGIN = 0x08020000, LENGTH = 256K /* todo - SRAM must start also at an offset after what has been reserved for system-module 1 */ - SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 384 + SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 1K } INCLUDE module_system_part1_export.ld diff --git a/modules/photon/system-part2/src/export_rt.c b/modules/photon/system-part2/src/export_rt.c index caf4523dd8..fe6d1b2e1c 100644 --- a/modules/photon/system-part2/src/export_rt.c +++ b/modules/photon/system-part2/src/export_rt.c @@ -1,4 +1,9 @@ #define DYNALIB_EXPORT + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE // for siprintf(), siscanf() and other extensions +#endif + #include // for malloc, free, realloc #include #include // for va_list diff --git a/newlib_nano/src/mallocr.c b/newlib_nano/src/mallocr.c index 915cdeb96b..3c27364bc8 100644 --- a/newlib_nano/src/mallocr.c +++ b/newlib_nano/src/mallocr.c @@ -43,7 +43,8 @@ #define DEFINE_FREE #define DEFINE_REALLOC #define DEFINE_CALLOC -#define DEFINE_MALLOC_STATS +// Do not compile malloc_stats() function (dumps memory usage stats to console) +// #define DEFINE_MALLOC_STATS #define DEFINE_MALLOC_USABLE_SIZE #define DEFINE_MALLOPT #define DEFINE_PALLOC diff --git a/platform/NET/build.mk b/platform/NET/build.mk index 30fd12a270..361da5f901 100644 --- a/platform/NET/build.mk +++ b/platform/NET/build.mk @@ -5,7 +5,3 @@ PLATFORM_NET_PATH = $(PLATFORM_MODULE_PATH)/NET/$(PLATFORM_NET) include $(call rwildcard,$(PLATFORM_NET_PATH)/,sources.mk) - -# Stick to some POSIX-conforming API to disable BSD extensions -CFLAGS += -D_POSIX_C_SOURCE=200809 - diff --git a/user/build.mk b/user/build.mk index e0ad8f8e72..850a71258e 100644 --- a/user/build.mk +++ b/user/build.mk @@ -76,11 +76,6 @@ CFLAGS += $(addprefix -fno-builtin-,$(BUILTINS_EXCLUDE)) CFLAGS += $(EXTRA_CFLAGS) -ifeq ("$(PLATFORM_NET)", "CC3000") -# Stick to some POSIX-conforming API to disable BSD extensions -CPPFLAGS += -D_POSIX_C_SOURCE=200809 -endif - # Use application source info regardless of release/debug build CFLAGS += -DLOG_INCLUDE_SOURCE_INFO=1 LOG_MODULE_CATEGORY = app diff --git a/wiring/inc/spark_wiring_character.h b/wiring/inc/spark_wiring_character.h index b7d1db1e8d..9ffe620f45 100644 --- a/wiring/inc/spark_wiring_character.h +++ b/wiring/inc/spark_wiring_character.h @@ -44,11 +44,6 @@ inline boolean isAlphaNumeric(int c) return toBoolean(isalnum(c)); } -inline boolean isAscii(int c) -{ - return toBoolean(isascii(c)); -} - inline boolean isControl(int c) { return toBoolean(iscntrl(c)); @@ -99,11 +94,6 @@ inline boolean isWhitespace(int c) return toBoolean(isblank(c)); } -inline int toAscii(int c) -{ - return toascii(c); -} - inline int toLowerCase(int c) { return tolower(c); @@ -114,5 +104,7 @@ inline int toUpperCase(int c) return toupper(c); } -#endif /* SPARK_WIRING_CHARACTER_H */ +boolean isAscii(int c); +int toAscii(int c); +#endif /* SPARK_WIRING_CHARACTER_H */ diff --git a/wiring/src/spark_wiring_character.cpp b/wiring/src/spark_wiring_character.cpp new file mode 100644 index 0000000000..39a46c1c81 --- /dev/null +++ b/wiring/src/spark_wiring_character.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Particle Industries, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE // for isascii() and toascii() +#endif +#include + +#include "spark_wiring_character.h" + +boolean isAscii(int c) { + return toBoolean(isascii(c)); +} + +int toAscii(int c) { + return toascii(c); +}