Check-in [e036066651]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Move rng files to ~/.config/net2o
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e036066651699984e2663b04236872fd18f4aad1
User & Date: bernd 2019-05-07 23:28:46.778
Context
2019-05-09
18:06
Bump version number check-in: 20289938ce user: bernd tags: trunk, 0.8.8-20190509
2019-05-07
23:28
Move rng files to ~/.config/net2o check-in: e036066651 user: bernd tags: trunk
2019-05-04
23:39
night mode less colorfull check-in: 5faad66ffb user: bernd tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to err.fs.
12
13
14
15
16
17
18

19
20
21
22
23
24
25
26
27

\ You should have received a copy of the GNU Affero General Public License
\ along with this program.  If not, see <http://www.gnu.org/licenses/>.

\ defined exceptions

: throwcode ( addr u -- )  exception Create ,

    [: >body @ >r ]] IF [[ r> ]] literal throw THEN [[ ;] set-compiler
    [: ( flag -- ) @ and throw ;] set-does> ;

\ make sure we start at user defined exeption
\ net2o exception codes should be system-independent
-$1000 next-exception !@

s" gap in file handles"          throwcode !!gap!!
s" invalid file id"              throwcode !!fileid!!







>
|
<







12
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27

\ You should have received a copy of the GNU Affero General Public License
\ along with this program.  If not, see <http://www.gnu.org/licenses/>.

\ defined exceptions

: throwcode ( addr u -- )  exception Create ,
    [: ( flag -- ) @ and throw ;] set-does>
    [: >body @ >r ]] IF [[ r> ]] literal throw THEN [[ ;] set-optimizer ;


\ make sure we start at user defined exeption
\ net2o exception codes should be system-independent
-$1000 next-exception !@

s" gap in file handles"          throwcode !!gap!!
s" invalid file id"              throwcode !!fileid!!
Changes to rng.fs.
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
: rng-step ( -- )
    \G one step of random number generation 
    rng-buffer rngbuf# >rng$ rng-pos off ;

\ init rng to be actually useful

$Variable init-rng$
s" ~/.initrng" init-rng$ $!

: random-init ( -- )
    rng-key c:key# read-rnd ;

: read-initrng ( fd -- flag )  { fd }
    #0. fd reposition-file throw
    rng-key c:key# fd read-file throw c:key# =
    ['] c:diffuse rng-exec  fd close-file throw ;

: write-initrng ( -- )
    init-rng$ $@ r/w create-file throw >r
    rng-buffer c:key# r@ write-file throw
    r> close-file throw  rng-step ;

\ Sanity check

$Variable check-rng$
Variable check-old$
s" ~/.checkrng" check-rng$ $!
$10 cells buffer: rngstat-buf

: rngstat ( addr u -- float )
    \G produces a normalized number, gauss distributed around 0
    rngstat-buf $10 cells erase  dup 3 rshift { e }
    bounds ?DO
	1 I c@ 4 rshift cells rngstat-buf + +!







|


















|







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
: rng-step ( -- )
    \G one step of random number generation 
    rng-buffer rngbuf# >rng$ rng-pos off ;

\ init rng to be actually useful

$Variable init-rng$
"initrng" .net2o-config/ init-rng$ $!

: random-init ( -- )
    rng-key c:key# read-rnd ;

: read-initrng ( fd -- flag )  { fd }
    #0. fd reposition-file throw
    rng-key c:key# fd read-file throw c:key# =
    ['] c:diffuse rng-exec  fd close-file throw ;

: write-initrng ( -- )
    init-rng$ $@ r/w create-file throw >r
    rng-buffer c:key# r@ write-file throw
    r> close-file throw  rng-step ;

\ Sanity check

$Variable check-rng$
Variable check-old$
"checkrng" .net2o-config/ check-rng$ $!
$10 cells buffer: rngstat-buf

: rngstat ( addr u -- float )
    \G produces a normalized number, gauss distributed around 0
    rngstat-buf $10 cells erase  dup 3 rshift { e }
    bounds ?DO
	1 I c@ 4 rshift cells rngstat-buf + +!