zephyr/lib/libc/minimal/include/time.h
Peter Bigot 849df51666 lib/libc: rearrange for standard use of extern "C"
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.

Background from issue #17997:

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-08-19 23:36:59 +02:00

59 lines
1.2 KiB
C

/*
* Copyright (c) 2017 Intel Corporation
* Copyright (c) 2019 Peter Bigot Consulting, LLC
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_TIME_H_
#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_TIME_H_
#include <stdint.h>
#include <sys/_types.h>
#include <bits/restrict.h>
#include <sys/_timespec.h>
/* Minimal time.h to fulfill the requirements of certain libraries
* like mbedTLS and to support time APIs.
*/
#ifdef __cplusplus
extern "C" {
#endif
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
#if !defined(__time_t_defined)
#define __time_t_defined
typedef _TIME_T_ time_t;
#endif
#if !defined(__suseconds_t_defined)
#define __suseconds_t_defined
typedef _SUSECONDS_T_ suseconds_t;
#endif
/*
* Conversion between civil time and UNIX time. The companion
* localtime() and inverse mktime() are not provided here since they
* require access to time zone information.
*/
struct tm *gmtime(const time_t *timep);
struct tm *gmtime_r(const time_t *_MLIBC_RESTRICT timep,
struct tm *_MLIBC_RESTRICT result);
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_STDIO_H_ */