diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-26 16:34:28 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-26 16:34:28 -0800 |
commit | 94ed7bbaa739995a9815b5f1c916d9e24575368c (patch) | |
tree | 587c4f268721cf156aab92c60aae4ec530c7ce17 /starts/meaning-vm/level-2/sugar.hpp | |
parent | fe2a9b21e655041ef14e34c94509c6974f294866 (diff) | |
download | standingwithresilience-94ed7bbaa739995a9815b5f1c916d9e24575368c.tar.gz standingwithresilience-94ed7bbaa739995a9815b5f1c916d9e24575368c.zip |
level2 compiles, nothing visible yet
Diffstat (limited to 'starts/meaning-vm/level-2/sugar.hpp')
-rw-r--r-- | starts/meaning-vm/level-2/sugar.hpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp index adedaa9..04393a1 100644 --- a/starts/meaning-vm/level-2/sugar.hpp +++ b/starts/meaning-vm/level-2/sugar.hpp @@ -1,11 +1,15 @@ #pragma once -#include <stdlib.h> // int rand(); void srand(int seed); -#include <time.h> // int time(0); int clock_gettime(CLOCK_REALTIME, struct timespec *tp{tv_sec,tv_nsec}) -#include <unistd.h> // usleep(unsigned int usecs) - #undef self +namespace intellect { +namespace level2 { + +namespace sugar { + void usleep(unsigned int usecs); + double rand(double min, double max); +} + // habits have a structure such that they contain information about their positional // arguments. they are made with a macro that turns the args into local variables. // the function to call them takes any number of arguments, and these are placed in the @@ -28,8 +32,8 @@ [&](ref ctx) \ { \ { \ - static int delay = (double(rand()) / RAND_MAX * 400000 + 200000); \ - usleep(delay); \ + static int delay = sugar::rand(200000, 400000); \ + sugar::usleep(delay); \ } \ ref self = ref(#name); (void)self; \ ref result("nothing"); (void)result; \ @@ -55,10 +59,6 @@ ref tok = ctx.linked(ref(#name)) ? ctx[ref(#name)] : ref(#__VA_ARGS__); #define _macro_habit_assume(info, tok, ...) \ if ((#__VA_ARGS__)[0] != 0) { intellect::level2::habitassume(_macro_habit_name, ref(#info), ref(#__VA_ARGS__)); } - - // seed random number generator statically, for habit delay - namespace _macro_habit { - static struct timespec tp; - static int timeres = clock_gettime(CLOCK_REALTIME, &tp); - static int seed = (srand(tp.tv_nsec), tp.tv_nsec); - } + +} +} |