Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
psse_time.c File Reference
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include "memory/conspage.h"
#include "memory/consspaceobject.h"
#include "arith/integer.h"
#include "time/psse_time.h"
Include dependency graph for psse_time.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 
#define seconds_per_year   31557600L
 

Functions

struct cons_pointer lisp_time (struct stack_frame *frame, struct cons_pointer frame_pointer, struct cons_pointer env)
 Function; return a time representation of the first argument in the frame; further arguments are ignored.
 
long int lisp_time_to_unix_time (struct cons_pointer t)
 Return the UNIX time value which represents this time, if it falls within the period representable in UNIX time, or zero otherwise.
 
struct cons_pointer make_time (struct cons_pointer integer_or_nil)
 
struct cons_pointer time_to_string (struct cons_pointer pointer)
 This is temporary, for bootstrapping.
 
unsigned __int128 unix_time_to_lisp_time (time_t t)
 

Variables

unsigned __int128 epoch_offset
 PSSE Lisp epoch is 14 Bn years, or 441,806,400,000,000,000 seconds, before the UNIX epoch; the value in microseconds will break the C reader.
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 23 of file psse_time.c.

◆ seconds_per_year

#define seconds_per_year   31557600L

Definition at line 25 of file psse_time.c.

Function Documentation

◆ lisp_time()

struct cons_pointer lisp_time ( struct stack_frame frame,
struct cons_pointer  frame_pointer,
struct cons_pointer  env 
)

Function; return a time representation of the first argument in the frame; further arguments are ignored.

  • (time integer_or_nil)
Parameters
framemy stack_frame.
frame_pointera pointer to my stack_frame.
envmy environment.
Returns
a lisp time; if integer_or_nil is an integer, return a time which is that number of microseconds after the notional big bang; else the current time.

Definition at line 86 of file psse_time.c.

References make_time().

Referenced by main().

◆ lisp_time_to_unix_time()

long int lisp_time_to_unix_time ( struct cons_pointer  t)

Return the UNIX time value which represents this time, if it falls within the period representable in UNIX time, or zero otherwise.

Definition at line 39 of file psse_time.c.

References epoch_offset, pointer2cell, and timep.

Referenced by time_to_string().

◆ make_time()

struct cons_pointer make_time ( struct cons_pointer  integer_or_nil)

◆ time_to_string()

struct cons_pointer time_to_string ( struct cons_pointer  pointer)

This is temporary, for bootstrapping.

Definition at line 95 of file psse_time.c.

References c_string_to_lisp_string(), lisp_time_to_unix_time(), and NIL.

Referenced by print().

◆ unix_time_to_lisp_time()

unsigned __int128 unix_time_to_lisp_time ( time_t  t)

Definition at line 53 of file psse_time.c.

References epoch_offset.

Referenced by make_time().

Variable Documentation

◆ epoch_offset

unsigned __int128 epoch_offset
Initial value:
=
( ( __int128 ) ( seconds_per_year * 1000000000L ) *
( __int128 ) ( 14L * 1000000000L ) )
#define seconds_per_year
Definition psse_time.c:25

PSSE Lisp epoch is 14 Bn years, or 441,806,400,000,000,000 seconds, before the UNIX epoch; the value in microseconds will break the C reader.

Definition at line 31 of file psse_time.c.

Referenced by lisp_time_to_unix_time(), and unix_time_to_lisp_time().