time: do not depend on gint headers

They're usually not installed yet
This commit is contained in:
Lephenixnoir 2021-12-31 19:48:43 +01:00
parent bd0dd3a8d2
commit f7b85f18bd
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 20 additions and 4 deletions

View file

@ -1,6 +1,7 @@
#include <time.h>
#include <gint/rtc.h>
#include <gint/defs/attributes.h>
#include <inttypes.h>
uint32_t rtc_ticks(void);
static clock_t clock_init;
@ -9,7 +10,8 @@ static clock_t clock_abs(void)
return (CLOCKS_PER_SEC * (uint64_t)rtc_ticks()) / 128;
}
GCONSTRUCTOR static void clock_initialize(void)
__attribute__((constructor))
static void clock_initialize(void)
{
clock_init = clock_abs();
}

View file

@ -1,5 +1,19 @@
#include <time.h>
#include <gint/rtc.h>
typedef struct
{
uint16_t year;
uint8_t week_day;
uint8_t month;
uint8_t month_day;
uint8_t hours;
uint8_t minutes;
uint8_t seconds;
uint8_t ticks;
} rtc_time_t;
void rtc_get_time(rtc_time_t *time);
time_t time(time_t *timeptr)
{