From c98470f42f3a3a6236dd3a985497c3097f6f9f09 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Wed, 25 Feb 2015 14:28:57 +0100 Subject: [PATCH] - added localtime_s and gmtime_s function calls to GeneralizedTime.c for VC compiler - prepared for release 0.8.5 --- Makefile | 6 +++- src/common/inc/linked_list.h | 2 +- src/common/linked_list.c | 2 +- src/mms/iso_mms/asn1c/GeneralizedTime.c | 39 ++++++++++++++++++++----- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 3fd46ac3..816d55fc 100644 --- a/Makefile +++ b/Makefile @@ -103,8 +103,12 @@ LIB_OBJS = $(call src_to,.o,$(LIB_SOURCES)) CFLAGS += -std=gnu99 #CFLAGS += -Wno-error=format -CFLAGS += -Wstrict-prototypes +CFLAGS += -Wstrict-prototypes + +ifneq ($(HAL_IMPL), WIN32) CFLAGS += -Wuninitialized +endif + CFLAGS += -Wsign-compare CFLAGS += -Wpointer-arith CFLAGS += -Wnested-externs diff --git a/src/common/inc/linked_list.h b/src/common/inc/linked_list.h index 74f48a54..4309e9ab 100644 --- a/src/common/inc/linked_list.h +++ b/src/common/inc/linked_list.h @@ -135,7 +135,7 @@ LinkedList_get(LinkedList self, int index); * \param self the LinkedList instance */ LinkedList -LinkedList_getNext(LinkedList listElement); +LinkedList_getNext(LinkedList self); /** * \brief Get the last element in the list. diff --git a/src/common/linked_list.c b/src/common/linked_list.c index a487b097..65c88bd1 100644 --- a/src/common/linked_list.c +++ b/src/common/linked_list.c @@ -151,7 +151,7 @@ LinkedList_insertAfter(LinkedList list, void* data) return newElement; } -LinkedList inline +LinkedList LinkedList_getNext(LinkedList list) { return list->next; diff --git a/src/mms/iso_mms/asn1c/GeneralizedTime.c b/src/mms/iso_mms/asn1c/GeneralizedTime.c index cf974496..e04df240 100644 --- a/src/mms/iso_mms/asn1c/GeneralizedTime.c +++ b/src/mms/iso_mms/asn1c/GeneralizedTime.c @@ -32,13 +32,8 @@ static struct tm *gmtime_r(const time_t *tloc, struct tm *result) { #endif /* __IAR_SYSTEMS_ICC__ */ #if defined(WIN32) -#pragma message( "PLEASE STOP AND READ!") -#pragma message( " localtime_r is implemented via localtime(), which may be not thread-safe.") -#pragma message( " gmtime_r is implemented via gmtime(), which may be not thread-safe.") -#pragma message( " ") -#pragma message( " You must fix the code by inserting appropriate locking") -#pragma message( " if you want to use asn_GT2time() or asn_UT2time().") -#pragma message( "PLEASE STOP AND READ!") + +#ifdef __GNUC__ static struct tm *localtime_r(const time_t *tloc, struct tm *result) { struct tm *tm; @@ -54,6 +49,36 @@ static struct tm *gmtime_r(const time_t *tloc, struct tm *result) { return 0; } +#else + +int +localtime_s(struct tm* _tm, const time_t *time); + +int +gmtime_s(struct tm* _tm, const time_t* time); + + + +static struct tm* +localtime_r(const time_t *tloc, struct tm *result) +{ + + if(localtime_s(result, tloc) == 0) + return result; + else + return 0; +} + +static struct tm* +gmtime_r(const time_t *tloc, struct tm *result) +{ + if(gmtime_s(result, tloc) == 0) + return result; + else + return 0; +} +#endif /* __GNUC__ */ + #define tzset() _tzset() #define putenv(c) _putenv(c) #define _EMULATE_TIMEGM