ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
time_compat.h File Reference

Reentrant UTC broken-down time, portable across the host and target toolchains. More...

#include <time.h>

Go to the source code of this file.

Functions

struct tm * pc_gmtime_r (const time_t *epoch, struct tm *out)
 Convert epoch to broken-down UTC in caller storage (reentrant).
 

Detailed Description

Reentrant UTC broken-down time, portable across the host and target toolchains.

Responses are formatted from worker threads, so every conversion must write into caller storage - never the shared static tm that gmtime() returns. The toolchains disagree on how to spell that: newlib and glibc have gmtime_r, the Windows CRT has only gmtime_s, with the arguments reversed. This is the one seam that hides the difference, so callers write it once.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file time_compat.h.

Function Documentation

◆ pc_gmtime_r()

struct tm * pc_gmtime_r ( const time_t *  epoch,
struct tm *  out 
)
inline

Convert epoch to broken-down UTC in caller storage (reentrant).

Parameters
epochSeconds since the Unix epoch.
outDestination struct tm (must be non-null).
Returns
out on success, or NULL if epoch cannot be represented.

Definition at line 28 of file time_compat.h.

Referenced by pc_http_date().