Fix localtime_r and gmtmime_r signatures

This commit is contained in:
Sergey Lyubka 2022-01-11 19:15:38 +00:00
parent 456e8bd249
commit 6c79a406cd
3 changed files with 28 additions and 26 deletions

View File

@ -77,21 +77,21 @@ extern "C" {
#if MG_ARCH == MG_ARCH_AZURERTOS
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <stdint.h>
#include <stdio.h>
#include <tx_api.h>
#include <fx_api.h>
#include <time.h>
#include <fx_api.h>
#include <tx_api.h>
#include <tx_port.h>
#include <nx_port.h>
#include <nx_api.h>
#include <nx_bsd.h>
#include <nx_port.h>
#include <tx_port.h>
#ifdef __REDLIB__
#define va_copy(d,s)__builtin_va_copy(d,s)
#define va_copy(d, s) __builtin_va_copy(d, s)
#endif
#define PATH_MAX FX_MAXIMUM_PATH
@ -102,9 +102,10 @@ extern "C" {
#define gmtime_r(a, b) gmtime(a)
#define MG_INT64_FMT "%lld"
static __inline struct tm *localtime_r(time_t *t, struct tm *tm) {
(void) tm;
return localtime(t);
static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) {
struct tm *x = localtime(t);
*tm = *x;
return tm;
}
#undef FOPEN_MAX
@ -428,13 +429,13 @@ typedef int socklen_t;
#endif
// https://lgtm.com/rules/2154840805/ -gmtime, localtime, ctime and asctime
static __inline struct tm *gmtime_r(time_t *t, struct tm *tm) {
static __inline struct tm *gmtime_r(const time_t *t, struct tm *tm) {
struct tm *x = gmtime(t);
*tm = *x;
return tm;
}
static __inline struct tm *localtime_r(time_t *t, struct tm *tm) {
static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) {
struct tm *x = localtime(t);
*tm = *x;
return tm;

View File

@ -3,21 +3,21 @@
#if MG_ARCH == MG_ARCH_AZURERTOS
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <stdint.h>
#include <stdio.h>
#include <tx_api.h>
#include <fx_api.h>
#include <time.h>
#include <fx_api.h>
#include <tx_api.h>
#include <tx_port.h>
#include <nx_port.h>
#include <nx_api.h>
#include <nx_bsd.h>
#include <nx_port.h>
#include <tx_port.h>
#ifdef __REDLIB__
#define va_copy(d,s)__builtin_va_copy(d,s)
#define va_copy(d, s) __builtin_va_copy(d, s)
#endif
#define PATH_MAX FX_MAXIMUM_PATH
@ -28,9 +28,10 @@
#define gmtime_r(a, b) gmtime(a)
#define MG_INT64_FMT "%lld"
static __inline struct tm *localtime_r(time_t *t, struct tm *tm) {
(void) tm;
return localtime(t);
static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) {
struct tm *x = localtime(t);
*tm = *x;
return tm;
}
#undef FOPEN_MAX

View File

@ -90,13 +90,13 @@ typedef int socklen_t;
#endif
// https://lgtm.com/rules/2154840805/ -gmtime, localtime, ctime and asctime
static __inline struct tm *gmtime_r(time_t *t, struct tm *tm) {
static __inline struct tm *gmtime_r(const time_t *t, struct tm *tm) {
struct tm *x = gmtime(t);
*tm = *x;
return tm;
}
static __inline struct tm *localtime_r(time_t *t, struct tm *tm) {
static __inline struct tm *localtime_r(const time_t *t, struct tm *tm) {
struct tm *x = localtime(t);
*tm = *x;
return tm;