Commit bd1dda4d authored by bernd's avatar bernd

use smove for string moves to known buffer sizes

parent c850f9b7
......@@ -2,7 +2,7 @@
85 buffer: 85>chars
s" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"
85>chars swap move
85>chars 85 smove
$80 buffer: chars>85
85 0 [DO] [I] dup 85>chars + c@ chars>85 + c! [LOOP]
......
......@@ -12,7 +12,7 @@ require user-object.fs
2dup + 1- c@ dup >r safe/string r> skip nip 0= ;
: >padded { addr1 u1 addr2 u2 -- }
addr1 addr2 u1 u2 umin move
addr1 u1 addr2 u2 smove
u1 u2 u< IF addr2 u1 u2 >pad 2drop THEN ;
\ For wurstkessel compatibility, the states are all 128 bytes
......
\ generic hash table functions
require string.fs
\ require wurstkessel.fs
require rng.fs
2 64s buffer: hashinit
......@@ -32,19 +31,6 @@ hash-init-rng
false hash-state hashkey2 ;
: hash$ ( -- addr u ) hash-state [ 2 64s ]L ;
[IFDEF] use-hash-wurst
\ hash of the first 510 bytes of the input string, 3 times slower
state# 8 * Constant message#
: string-hash ( addr u -- )
'hashinit wurst-source state# 2* move
message message# erase
dup message message# xc!+? drop
rot umin dup >r move
message r> 6 rshift $11 + rounds message 2 rounds ;
: hash$ ( -- addr u ) wurst-state state# ;
[THEN]
\ hierarchical hash table
......
......@@ -49,12 +49,12 @@ $10 Constant crypt-align
: sec-off ( addr -- ) dup @ dup IF kfree64 off EXIT THEN 2drop ;
: sec! ( addr1 u1 addr2 -- )
over 0= IF sec-off 2drop EXIT THEN
>r r@ kalloc64? dup r> ! swap $40 umin move ;
>r r@ kalloc64? dup r> ! $40 smove ;
: sec@ ( addr -- addr1 u1 )
@ dup IF $40 over $20 + $20 zero32 over str= IF 2/ THEN
ELSE 0 THEN ;
: sec+! ( addr1 u1 addr2 -- )
dup @ 0= IF sec! ELSE sec@ dup >r + swap $40 r> - umin move THEN ;
dup @ 0= IF sec! ELSE sec@ dup >r + $40 r> - smove THEN ;
: sec+[]! ( addr1 u1 addr2 -- ) >r
0 { w^ sec } sec sec! sec cell r> $+! ;
......
......@@ -33,7 +33,7 @@ $11 net2o: addr-pri# ( n -- ) \g priority
+net2o: addr-ipv4 ( n -- ) \g ip address
64>n host-ipv4 be-l! ;
+net2o: addr-ipv6 ( $:ipv6 -- ) \g ipv6 address
$> host-ipv6 swap $10 umin move ;
$> host-ipv6 $10 smove ;
+net2o: addr-portv4 ( n -- ) \g ipv4 port
64>n host-portv4 w! ;
+net2o: addr-portv6 ( n -- ) \g ipv6 port
......@@ -127,7 +127,7 @@ previous
o my-addr[] $[]# my-addr[] $[] ! ;
: !my-addrs ( -- ) n2o:new-addr >o
global-ip6 tuck host-ipv6 swap $10 umin move
global-ip6 tuck host-ipv6 $10 smove
global-ip4 IF be-ul@ host-ipv4 be-l! ELSE drop THEN
my-port# +my-addrs o>
0= IF local-ipv6 IF
......
......@@ -252,12 +252,12 @@ Defer !my-addr
2over ip6::0 over str= >r str= r> r> or or ;
: str>merge ( addr1 u1 addr2 u2 -- )
2dup ip6::0 over str= IF rot umin move ELSE 2drop 2drop THEN ;
2dup ip6::0 over str= IF smove ELSE 2drop 2drop THEN ;
\ insert address for punching
: !temp-addr ( addr u -- ) dup 0<> ind-addr !
temp-addr dup $10 erase swap $10 umin move ;
temp-addr dup $10 erase $10 smove ;
: check-addr1 ( -- addr u flag )
sockaddr1 sock-rest 2dup try-ip
......
......@@ -754,7 +754,7 @@ $40 buffer: nick-buf
: >raw-key ( o -- )
dup 0= !!no-nick!! >o
ke-pk $@ pkc swap pkrk# umin move
ke-pk $@ pkc pkrk# smove
ke-psk sec@ my-0key sec!
ke-sk sec@ skc swap key| move
>sksig o> ;
......
......@@ -70,6 +70,13 @@ word-args
\ string
: smove ( a-from u-from a-to u-to -- )
rot 2dup u< IF
drop move -9 throw
ELSE
nip move
THEN ;
[IFUNDEF] safe/string
: safe/string ( c-addr u n -- c-addr' u' )
\G protect /string against overflows.
......
......@@ -55,7 +55,7 @@ User threefish-t
0 to @threefish crypto-o off ;
: threefish0 ( -- ) threefish-state tf_ctx erase ;
: >threefish ( addr u -- ) threefish-state swap move
: >threefish ( addr u -- ) threefish-state threefish#max smove
threefish-state tf_ctx-tweak sizeof tf_ctx-tweak erase ;
: threefish> ( addr u -- ) threefish-state -rot threefish#max umin move ;
: +threefish ( -- )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment