Merge branch 'test' of https://github.com/urbit/urbit into test

ssary,
This commit is contained in:
C. Guy Yarvin 2014-11-04 16:41:26 -08:00
commit f1ee2f6e90
7 changed files with 145 additions and 44 deletions

View File

@ -263,6 +263,7 @@ V_OFILES=\
v/raft.o \
v/reck.o \
v/sist.o \
v/temp.o \
v/term.o \
v/time.o \
v/unix.o \

View File

@ -1001,6 +1001,7 @@
# define c3__teal c3_s4('t','e','a','l')
# define c3__teck c3_s4('t','e','c','k')
# define c3__tell c3_s4('t','e','l','l')
# define c3__temp c3_s4('t','e','m','p')
# define c3__terg c3_s4('t','e','r','g')
# define c3__term c3_s4('t','e','r','m')
# define c3__test c3_s4('t','e','s','t')
@ -1008,6 +1009,7 @@
# define c3__this c3_s4('t','h','i','s')
# define c3__thin c3_s4('t','h','i','n')
# define c3__thud c3_s4('t','h','u','d')
# define c3__time c3_s4('t','i','m','e')
# define c3__tgbn c3_s4('t','g','b','n')
# define c3__tgbr c3_s4('t','g','b','r')
# define c3__tgdg c3_s4('t','g','d','g')

View File

@ -349,9 +349,7 @@
/* u3_unix: clay support system, also
*/
typedef struct _u3_unix {
uv_timer_t tim_u; // clay timer
uv_check_t syn_u; // fs sync check
u3_bean alm; // alarm
u3_uhot* hot_u; // host state
u3_usig* sig_u; // signal list
#ifdef SYNCLOG
@ -368,12 +366,20 @@
/* u3_batz: just a timer for now
*/
typedef struct _u3_batz {
uv_timer_t tim_u; // clay timer
uv_timer_t tim_u; // batz timer
c3_w run_w; // run of consecutive alarms
u3_bean alm; // alarm
} u3_batz;
/* u3_utfo: unix terminfo strings.
/* u3_temp: just a timer for ever
*/
typedef struct _u3_temp {
uv_timer_t tim_u; // temp timer
c3_w run_w; // run of consecutive alarms
u3_bean alm; // alarm
} u3_temp;
/* u2_utfo: unix terminfo strings.
*/
typedef struct {
struct {
@ -552,6 +558,7 @@
u3_opts ops_u; // commandline options
u3_unix unx_u; // sync and clay
u3_batz beh_u; // batz timer
u3_temp teh_u; // temp timer
u3_bean liv; // if u3_no, shut down
c3_i xit_i; // exit code for shutdown
void* ssl_u; // struct SSL_CTX*
@ -974,6 +981,24 @@
u3_batz_io_poll(void);
/** Temp, just a timer.
**/
/* u2_temp_io_init(): initialize temp timer.
*/
void
u2_temp_io_init(void);
/* u2_temp_io_exit(): terminate timer.
*/
void
u2_temp_io_exit(void);
/* u2_temp_io_poll(): update temp IO state.
*/
void
u2_temp_io_poll(void);
/** HTTP server.
**/
/* u3_http_ef_thou(): send %thou effect to http.
@ -1098,6 +1123,23 @@
void
u3_sist_get(const c3_c* key_c, c3_y* val_y);
/** New timer system.
**/
/* u3_temp_io_init(): initialize time timer.
*/
void
u3_temp_io_init(void);
/* u3_temp_io_exit(): terminate timer.
*/
void
u3_temp_io_exit(void);
/* u3_temp_io_poll(): update temp IO state.
*/
void
u3_temp_io_poll(void);
/** HTTP client.
**/

View File

@ -174,6 +174,7 @@ _lo_init()
u3_cttp_io_init();
u3_save_io_init();
u3_batz_io_init();
u3_temp_io_init();
}
/* _lo_talk(): bring up listeners across the process.
@ -199,6 +200,7 @@ u3_lo_exit(void)
u3_cttp_io_exit();
u3_save_io_exit();
u3_batz_io_exit();
u3_temp_io_exit();
}
/* _lo_poll(): reset event flags across the process.
@ -212,6 +214,7 @@ _lo_poll(void)
u3_save_io_poll();
u3_unix_io_poll();
u3_batz_io_poll();
u3_temp_io_poll();
}
#if 0
@ -225,6 +228,7 @@ _lo_how(u3_noun how)
case c3__ames: return "ames";
case c3__batz: return "batz";
case c3__temp: return "temp";
case c3__term: return "cons";
case c3__htcn: return "http-conn";
case c3__htls: return "http-lisn";

View File

@ -1562,6 +1562,7 @@ _raft_punk(u3_noun ovo)
//
if ( c3__wake != u3h(u3t(ovo)) ) {
u3_Host.beh_u.run_w = 0;
u3_Host.teh_u.run_w = 0;
}
#ifdef GHETTO

91
v/temp.c Normal file
View File

@ -0,0 +1,91 @@
/* v/temp.c
**
** This file is in the public domain.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <setjmp.h>
#include <gmp.h>
#include <dirent.h>
#include <stdint.h>
#include <uv.h>
#include <curses.h>
#include <termios.h>
#include <term.h>
#include <errno.h>
#include "all.h"
#include "v/vere.h"
/* u3_temp(): initialize time timer.
*/
void
u3_temp_io_init(void)
{
u3_temp* teh_u = &u3_Host.teh_u;
uv_timer_init(u3L, &teh_u->tim_u);
teh_u->alm = u3_no;
}
/* u3_temp_io_exit(): terminate timer.
*/
void
u3_temp_io_exit(void)
{
}
/* _temp_time_cb(): timer callback.
*/
static void
_temp_time_cb(uv_timer_t* tim_u)
{
u3_temp* teh_u = &u3_Host.teh_u;
if(teh_u->run_w < 1024) {
teh_u->run_w++;
}
u3_lo_open();
{
u3_cv_plan
(u3nt(u3_blip, c3__temp, u3_nul),
u3nc(c3__wake, u3_nul));
}
u3_lo_shut(u3_no);
}
/* u3_temp_io_poll(): update temp IO state.
*/
void
u3_temp_io_poll(void)
{
u3_temp* teh_u = &u3_Host.teh_u;
u3_noun wen = u3_cv_keep(u3nt(u3_blip, c3__temp, u3_nul));
if ( (u3_nul != wen) &&
(u3_yes == u3du(wen)) &&
(u3_yes == u3ud(u3t(wen))) )
{
c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen)));
gap_d += teh_u->run_w;
if ( u3_yes == teh_u->alm ) {
uv_timer_stop(&teh_u->tim_u);
}
else teh_u->alm = u3_yes;
uv_timer_start(&teh_u->tim_u, _temp_time_cb, gap_d, 0);
}
else {
if ( u3_yes == teh_u->alm ) {
uv_timer_stop(&teh_u->tim_u);
}
teh_u->alm = u3_no;
}
u3z(wen);
}

View File

@ -1427,20 +1427,6 @@ _unix_ef_sync(uv_check_t* han_u)
u3_lo_shut(u3_yes);
}
/* _unix_time_cb(): timer callback.
*/
static void
_unix_time_cb(uv_timer_t* tim_u)
{
u3_lo_open();
{
u3_cv_plan
(u3nt(u3_blip, c3__clay, u3_nul),
u3nc(c3__wake, u3_nul));
}
u3_lo_shut(u3_no);
}
/* _unix_sign_cb: signal callback.
*/
static void
@ -1499,9 +1485,6 @@ u3_unix_io_init(void)
{
u3_unix* unx_u = &u3_Host.unx_u;
uv_timer_init(u3L, &unx_u->tim_u);
unx_u->alm = u3_no;
{
u3_usig* sig_u;
@ -1576,27 +1559,4 @@ u3_unix_io_exit(void)
void
u3_unix_io_poll(void)
{
u3_unix* unx_u = &u3_Host.unx_u;
u3_noun wen = u3_cv_keep(u3nt(u3_blip, c3__clay, u3_nul));
if ( (u3_nul != wen) &&
(u3_yes == u3du(wen)) &&
(u3_yes == u3ud(u3t(wen))) )
{
c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen)));
if ( u3_yes == unx_u->alm ) {
uv_timer_stop(&unx_u->tim_u);
}
else unx_u->alm = u3_yes;
uv_timer_start(&unx_u->tim_u, _unix_time_cb, gap_d, 0);
}
else {
if ( u3_yes == unx_u->alm ) {
uv_timer_stop(&unx_u->tim_u);
}
unx_u->alm = u3_no;
}
u3z(wen);
}