02:03
<
aw- >
morning, it seems pil21.tgz is not compiling anymore
02:03
<
aw- >
make: opt: Command not found
02:05
<
aw- >
ah i see.. it's a symlink to /usr/bin/opt-7 or opt-8 or opt-9 ...
02:05
<
aw- >
ok i'll fix my build scripts
02:33
aw- has quit [Quit: Leaving.]
03:43
patrixl has quit [Read error: Connection reset by peer]
03:49
patrixl has joined #picolisp
04:44
orivej has joined #picolisp
05:51
aw- has joined #picolisp
06:03
<
Regenaxer >
Hi aw-, I reverted yesterday's change to mkStr()
06:03
<
Regenaxer >
I think it works correctly
06:03
<
Regenaxer >
No, it worked before
06:04
<
Regenaxer >
A single null byte returns NIL
06:04
<
Regenaxer >
so all was ok
06:04
<
Regenaxer >
What did you test?
06:04
<
aw- >
ok one sec let me try/test
06:05
<
Regenaxer >
btw, the same with 'buf':
06:05
<
Regenaxer >
(buf P 10 (byte P 0) (%@ "strdup" 'S P))
06:05
<
aw- >
did you release the code?
06:05
<
Regenaxer >
but yesterday's code behaved the same
06:05
<
Regenaxer >
I just removed the additional check again
06:06
<
Regenaxer >
as it was before
06:06
<
aw- >
!? (byte P 0)
06:06
<
aw- >
NIL -- Number expected
06:06
<
Regenaxer >
So it seems I misunderstood the problem
06:06
<
aw- >
arm64 problem?
06:06
<
Regenaxer >
what is 'P'?
06:06
<
aw- >
forgot to malloc
06:06
<
Regenaxer >
or see 'buf' above
06:07
<
Regenaxer >
is shorter and does not need free()
06:10
<
Regenaxer >
Also, in fact strdup() is not a good idea
06:10
<
Regenaxer >
it creates a memory leak, no way to free it
06:12
<
Regenaxer >
better use 'struct'
06:12
<
Regenaxer >
: (buf P 10 (byte P 65) (byte (inc P) 0) (struct
06:12
rob_w has joined #picolisp
06:13
<
aw- >
what is (buf) ?
06:13
<
aw- >
theres no docs
06:13
<
Regenaxer >
A new function
06:13
<
Regenaxer >
I mentioned yesterday
06:13
<
Regenaxer >
check the logs
06:13
<
aw- >
ok but my code needs to run on pil64
06:14
<
Regenaxer >
I said it is faster and needs no free()
06:14
<
aw- >
right but i can't code
**only** for pil21
06:15
<
aw- >
let me try some things
06:15
<
aw- >
strdup can't be free'd ? that's not good
06:16
<
aw- >
sorry, yesterday i didnt realize (buf) is only for pil21
06:16
<
Regenaxer >
'native' does not know that it allocates new memory
06:17
<
Regenaxer >
see pil21/doc/diff
06:17
<
Regenaxer >
The 'P' spec also does not exist in pil64
06:17
<
Regenaxer >
but (struct P 'S) instead of strdup works
06:17
<
Regenaxer >
and is more efficient
06:17
<
aw- >
you're missing what i'm saying
06:17
<
aw- >
i can
**NOT** code only for pil21
06:18
<
aw- >
even though pil21 has these nice functions, my code is for pil64
06:18
<
Regenaxer >
yes, but where is the problem?
06:18
<
Regenaxer >
you use malloc()
06:18
<
Regenaxer >
everything else works
06:18
<
Regenaxer >
'P -> 'N of course
06:18
<
aw- >
ok so you're saying i need to use two different approaches for reading data?
06:18
<
aw- >
one for pil21, one for pil64?
06:19
<
Regenaxer >
you are not reading ;)
06:21
<
Regenaxer >
Anyway, what was your null-byte-problem yesterday?
06:35
mtsd has joined #picolisp
06:37
<
aw- >
how can i use this with (native) ?
06:37
<
aw- >
i'm not storing a byte in memory
06:37
<
Regenaxer >
It is just an example
06:37
<
aw- >
i'm retrieving bytes from a (native)
06:37
<
Regenaxer >
yes, same
06:38
<
Regenaxer >
I thought you read a string from a memory locatiin
06:38
<
Regenaxer >
I understood some function fills a buffer you provide
06:39
<
aw- >
i call (native "lib" "fun" 'I Buffer) and it returns the bytes in Buffer
06:39
<
Regenaxer >
Exactly what I say!
06:39
<
Regenaxer >
As in the above example
06:40
<
Regenaxer >
'byte' is used to fill the buffer :)
06:40
<
Regenaxer >
Must telephone, bbl
06:41
<
aw- >
(byte P (native ...)) ?
06:43
<
aw- >
i have no idea how (byte) works, let me figure that out first
06:45
<
Regenaxer >
(byte P (char "A")) is as (byte P 65) above
06:46
<
aw- >
but i'm trying to read more than 1 byte
06:47
<
aw- >
not store 1 byte
06:47
<
aw- >
it makes no sense
06:47
<
aw- >
you're explaining the exact opposite of what i want to do
06:47
<
Regenaxer >
See above!
06:47
<
Regenaxer >
I stored "A" and null
06:47
<
Regenaxer >
and got the string "A"
06:47
<
aw- >
stop giving me solutions, you don't know what i'm trying to do
06:47
<
aw- >
let me explain first
06:48
<
Regenaxer >
But you should try to understand the example
06:48
<
Regenaxer >
most basic mechanisms
06:48
<
aw- >
i am but you keep throwing code at me and telling me "LOOK IT WORKS"
06:48
<
aw- >
im trying to understand but you keep giving examples which don't apply
06:49
<
Regenaxer >
it was all the same, basically a single example
06:49
<
Regenaxer >
storing two bytes, giving "A\0"
06:49
<
aw- >
ok but i am NOT storing bytes!
06:49
<
aw- >
i keep telling you this
06:50
<
Regenaxer >
not you, but the function
06:50
<
aw- >
i dont know the memory location where the data is stored
06:50
<
aw- >
unless there's a way to get it?
06:50
<
beneroth >
do you have to allocate the buffer, or is the lib allocating the buffer?
06:50
<
aw- >
the function wants a buffer to store the bytes
06:50
<
beneroth >
hi aw-, Regenaxer :)
06:50
<
aw- >
i have to allocate it
06:50
<
Regenaxer >
telephone
06:51
<
beneroth >
so your question is: how to allocate a buffer for native to write in?
06:51
<
aw- >
i know how to do that
06:51
<
aw- >
i'm trying to figure out how (byte) can be used with (native)
06:52
<
beneroth >
I understand byte (first form with single argument) as: reads a single byte from the pointer you give it
06:52
<
beneroth >
the number argument being a pointer
06:53
<
beneroth >
so I guess you could use the address of the buffer you give into native as argument to (byte) to get the number representation of the first byte in the buffer
06:54
<
aw- >
(native "lib" "fun" 'I Msg) # Msg = buffer which receives the message, 'I = number of bytes (size) of message
06:54
<
Regenaxer >
'byte' has nothing at all to do with 'native'
06:54
<
beneroth >
message format is text or binary, aw- ?
06:55
<
beneroth >
Regenaxer, T, I understand it as: turns raw bytes into picolisp numbers
06:55
<
aw- >
beneroth: it's just bytes, could be text, could be random garbage
06:55
<
beneroth >
so binary, as far as it concerns you
06:55
<
aw- >
i wrote my (native) code above, how do I get the string from Msg? (byte Msg) ?
06:56
<
aw- >
(byte Msg) (struct Msg 'S) ?
06:56
<
Regenaxer >
Sorry, on phone
07:04
<
Regenaxer >
(byte Msg (char "a")) (byte (+ Msg 1) (char "b")) (byte (+ Msg 2) (char "c")) (byte (+ Msg 3) 0)
07:04
<
Regenaxer >
gives "abc" in C
07:07
<
Regenaxer >
get the string "abc" with (struct Msg 'S)
07:08
<
Regenaxer >
a string in C is an array of bytes, with null at the end
07:09
<
aw- >
so i dont need (byte)
07:10
<
aw- >
with (struct Msg 'S) i still get the same problem with pil21
07:11
<
Regenaxer >
Then 'fun' is wrong
07:12
<
aw- >
yes yes i didnt give the full spec
07:12
<
aw- >
it's actually (native "lib" "fun" 'I Fd Msg Size)
07:12
<
aw- >
Size being the size of the buffer I created with malloc
07:14
<
aw- >
your example is fine, seems my code is doing something weird
07:21
<
Regenaxer >
phone done
07:22
<
aw- >
i found the bug
07:22
<
aw- >
the problem is not at all with the receiving function
07:22
<
aw- >
it's the sending
07:22
<
Regenaxer >
filling the buffer?
07:22
<
aw- >
when i send only a null byte, the Size should be 0, not 1..
07:23
<
Regenaxer >
the returned size, yes
07:23
<
aw- >
yes so i was always adding +1 for regular strings because they include the nullbyte
07:23
<
Regenaxer >
but the size is not needed to get the string into Lisp
07:24
<
Regenaxer >
strdup or (struct Msg 'S)
07:24
<
aw- >
the C (native) function needs it
07:24
<
Regenaxer >
perfect
07:24
<
aw- >
however it doesn't explain why i had no problem in pil64
07:25
<
Regenaxer >
so the strange result yesteday is gone?
07:25
<
aw- >
and only discover this issue in pil21
07:25
<
aw- >
i think the bug gis in pil21 actually
07:25
<
Regenaxer >
What exactly happened?
07:25
<
Regenaxer >
does it still appear?
07:25
<
Regenaxer >
and different in 64 and 21?
07:25
<
aw- >
i wonder if NIL is a null byte?
07:26
<
Regenaxer >
NIL is a symbol, and a byte is a number
07:26
<
Regenaxer >
"" is
*read* as NIL
07:26
<
Regenaxer >
in C "" is a single null byte
07:39
<
beneroth >
NIL is not the same thing as NULL byte, generally in picolisp
07:40
<
beneroth >
e.g. there is a encoding for NIL in plio, afaik
07:40
<
beneroth >
empty string and empty list are NIL
07:41
<
aw- >
"Also note that specifying NIL as an argument passes an empty string ("", which also reads as NIL in PicoLisp) to the C function. Physically, this is a pointer to a NULL-byte"
07:42
<
aw- >
my question: how many bytes in "" ?
07:43
<
Regenaxer >
"" is a pointer to a single null byte
07:43
<
Regenaxer >
strlen() gives zero
07:43
<
Regenaxer >
Like I did above (byte P 0) (struct P 'S) -> NIL
07:43
<
aw- >
ok i'm seeing the same thing
07:44
<
Regenaxer >
Mysterious what it was yesterday
07:44
<
aw- >
in pil64, when I send the value "", i also send the string size 1
07:44
<
Regenaxer >
I think you saw "^@" ?
07:44
<
aw- >
because "" is 1 byte
07:45
<
Regenaxer >
yes, but the size is not used here
07:45
<
Regenaxer >
the length
07:45
<
aw- >
but in pil21, when I send the value "", i have to send the string size 0, otherwise i get back some garbage
07:45
<
aw- >
size/length..
07:45
<
Regenaxer >
With "send" you mean "store in buffer"?
07:45
<
aw- >
there's definitely a problem somewhere either in pil21 or pil64
07:46
<
aw- >
yes, and then send to the (native) function
07:46
<
aw- >
in pil21 and pil64, i always store the exact same value: "", and supply the exact same string length: 1
07:46
<
Regenaxer >
We should clear up that "problem somewhere either in pil21 or pil64"
07:46
<
aw- >
but in pil21 it returns garbage when i try to read the value
07:47
<
Regenaxer >
how do you store "" ?
07:47
<
Regenaxer >
I C you do *p = '\0';
07:47
<
Regenaxer >
if 'p' is the buffer pointer
07:47
<
Regenaxer >
you cant *store" ""
07:48
<
aw- >
(native "lib" "fun" 'I Fd NIL (+ (size NIL) 1))
07:48
<
beneroth >
string length vs. buffer length ?
07:48
<
aw- >
string length
07:48
<
Regenaxer >
(size NIL) ?
07:48
<
beneroth >
string length should be 0 with buffer length 1
07:49
<
beneroth >
(for empty string)
07:49
<
aw- >
i'm not using a buffer here
07:49
<
aw- >
just passing the value directly
07:49
<
Regenaxer >
I don't get it
07:49
<
Regenaxer >
what you are really doing
07:49
<
aw- >
actually it's: (native "lib" "fun" 'I Fd Msg (+ (size Msg) 1))
07:49
<
aw- >
Msg can be anything, like "hello" or "test" or ""
07:50
<
beneroth >
why (size Msg) and not (length Msg) ?
07:50
<
aw- >
string length (in bytes)
07:50
<
aw- >
i believe it's in bytes, handles utf-8 correctly
07:51
<
Regenaxer >
So what goes wrong in pil64 or pil21?
07:51
<
aw- >
so the problem is when I try to re-read that string once more with (native) and the C code
07:52
<
Regenaxer >
first 'fun' runs
07:52
<
Regenaxer >
it gets the string Msg
07:52
<
Regenaxer >
what does it do?
07:53
<
Regenaxer >
There is no buffer involved
07:53
<
aw- >
I do (native "lib" "fun2" 'I Fd Buf Size) # get the data into 'Buf' buffer
07:53
<
Regenaxer >
yesterday you said you get the wrong string from the buffer
07:53
<
Regenaxer >
ok, fun2
07:53
<
aw- >
in pil21 i get garbage
07:53
<
aw- >
it's always different
07:53
<
aw- >
like a non null-terminated string
07:54
<
Regenaxer >
Buf is malloc'ed?
07:54
<
Regenaxer >
and then (struct Buf 'S) ?
07:55
<
Regenaxer >
are you sure it is not fun2 filling in garbage?
07:55
<
Regenaxer >
I don't believe we have a bug here in pil
07:55
<
Regenaxer >
it is too basic
07:55
<
Regenaxer >
It would never work
07:55
<
aw- >
wait let me try some more tests
08:02
<
aw- >
when i receive just \0 (null byte) in pil21, it spits out the entire library I loaded with (load)
08:03
<
Regenaxer >
whole memory
08:03
<
aw- >
i think because my buffer is 8K
08:03
<
Regenaxer >
The buffer contains only '\0'?
08:03
<
Regenaxer >
pil does not care about the size
08:03
<
Regenaxer >
it goes till '\0'
08:04
<
Regenaxer >
I think pil21 is correct
08:06
<
Regenaxer >
tested with
08:06
<
Regenaxer >
: (buf P 10 (byte P 0) (struct P 'S))
08:06
<
Regenaxer >
There is not more to it!
08:06
<
aw- >
i'm debugging my code now
08:07
<
Regenaxer >
I think fun2 does not store the null byte
08:07
<
aw- >
i trust you more than myself for pil code haha
08:07
<
Regenaxer >
then the result depends on the random memory layoout
08:10
<
aw- >
wow i'm so stupid
08:10
<
aw- >
ok before i tell you
08:10
<
aw- >
can you explain this argument for (native):
08:10
<
aw- >
(native "lib" "fun" 'I (list 'Attr (64 N . 4) 0))
08:11
<
aw- >
there is something wrong with that
08:11
<
Regenaxer >
hmm, looks good
08:11
<
Regenaxer >
a 64 byte buffer
08:11
<
Regenaxer >
but only the first byte is set to 0
08:12
<
Regenaxer >
you could (64 N . 4) . 0)
08:12
<
Regenaxer >
this fills all 64 bytes
08:12
<
Regenaxer >
and 32 would be enough
08:12
<
Regenaxer >
for long[4]
08:14
<
aw- >
the result is stored in Attr right?
08:15
<
aw- >
i wonder if this is a bug in the native C function
08:16
<
Regenaxer >
yes, Attr receives 4 numbers
08:16
<
Regenaxer >
as a list
08:18
<
aw- >
it seems like there's memory not being free'd somewhere
08:18
<
Regenaxer >
This has not yet been tested in pil21 perhaps
08:19
<
Regenaxer >
How do you notice? Called in a loop?
08:19
<
aw- >
when i make a call to malloc, after using that (native) i showed above, then that buffer gets filled with... my source code
08:19
<
aw- >
i change the malloc to 256 and it fills it with 256 bytes of my source code haha
08:20
<
aw- >
only happens after i use that structure to get a 64-byte result
08:20
<
aw- >
which works perfectly
08:20
<
aw- >
i get '(0 10 8192 1)' from that native call
08:20
<
Regenaxer >
but 4 * 8 is 32
08:21
<
aw- >
err not 64-byte sorry, 8 longs
08:21
<
Regenaxer >
(64 N . 4)
08:22
<
aw- >
ok my problem is fixed
08:22
<
aw- >
wow what a fail
08:22
<
aw- >
guhhhhhhhhhhh
08:22
<
aw- >
i can't believe I did (64 N . 4) ahahaha
08:22
<
Regenaxer >
happens to me too
08:22
<
aw- >
wait let me test again to confirm
08:22
<
Regenaxer >
confusing with cell size
08:24
<
aw- >
the problem is (struct) in pil21
08:24
<
aw- >
but only when the value is a null-byte
08:25
<
aw- >
i tried so many things, and narrow it down to (struct Msg 'S) where Msg points to a memory location containing only a null-byte
08:25
<
aw- >
it fills my malloc'd buffer with.. my source code
08:25
<
Regenaxer >
: (buf P 10 (byte P 0) (struct P 'S))
08:25
<
Regenaxer >
this is the minimal tes
08:26
<
Regenaxer >
this can't be different in your case
08:26
<
aw- >
but this only happens after I call (native) with the structure above
08:26
<
aw- >
i dont know why
08:26
<
aw- >
something is not being free'd
08:26
<
aw- >
yes the simple test/example works fine for me too
08:26
<
Regenaxer >
This has nothing to do with freeing
08:26
<
Regenaxer >
You see a memory leak if you make a loop
08:27
<
Regenaxer >
and watch the process size grow
08:27
<
Regenaxer >
getting garbage has nothing to do with not freeing
08:27
<
aw- >
ok let me try that
08:27
<
Regenaxer >
free() just does some pointer changes in the heap
08:29
<
aw- >
i will try this code on a different machine, different kernel
08:30
<
Regenaxer >
I do a loop now
08:30
<
Regenaxer >
(%@ "localtime" '(I . 9) ...
08:30
<
Regenaxer >
ok, memory is not increasing :)
08:30
<
Regenaxer >
No leak
08:43
<
aw- >
Regenaxer: (list 'Attr (64 N . 8) . 0)
08:44
<
aw- >
this result specification, is there another way to write it?
08:45
<
aw- >
perhaps i can malloc 64 bytes
08:45
<
aw- >
and store into that
08:46
<
Regenaxer >
You can also (64 (N . 8))
08:46
<
Regenaxer >
malloc is ok, but native does exactly that
08:46
<
Regenaxer >
in pil21 even on the stack iirc
08:50
<
Regenaxer >
but (64 (N . 8)) will give ((...))
08:51
<
Regenaxer >
and (64 ((N . 8))) gives (((...)))
09:03
<
aw- >
Regenaxer: with this: (struct Mem 'N (0 . 8) (0 . 8) (0 . 8) (0 . 8))
09:03
<
aw- >
is it similar to struct mystruct { long a; long b; long c; long d; } ?
09:05
<
Regenaxer >
hmm, (0 . 8) is a fixpoint number
09:05
<
Regenaxer >
And what is 'N' ?
09:06
<
Regenaxer >
{ long a; long b; long c; long d; } is simply (N N N N)
09:06
<
aw- >
ok so (struct Mem '(N N N N)) ?
09:07
<
Regenaxer >
'(N N N N) is the returned list
09:07
<
Regenaxer >
no initialization
09:09
<
Regenaxer >
Sorry, I was wrong with the fixpoint
09:09
<
Regenaxer >
for
*init* items (0 . 8) is fine
09:09
<
Regenaxer >
a long with value zero
09:10
<
Regenaxer >
I confused with 'native' arguments
09:14
<
Regenaxer >
It
*is* confusing
09:14
<
aw- >
in pil64, if I use malloc to allocate a 256 byte buffer
09:14
<
Regenaxer >
C has so many argument types
09:16
<
aw- >
and then (native "lib" "fun2" 'I Fd Buf 256)
09:17
<
aw- >
the result in Buf is different between pil21 and pil64
09:17
<
aw- >
but only IF Buf "only" contains a null-byte
09:17
<
aw- >
does that make sense?
09:17
<
aw- >
in pil21, that null byte ends up doing something weird and the Buf gets filled with the source code of my library
09:18
<
Regenaxer >
hmm, strange
09:18
<
Regenaxer >
you then do (struct Buf 'S) ?
09:18
<
aw- >
i am using (struct Buf 'S) to get the actual string
09:19
<
Regenaxer >
But (struct Buf 'S) can't be wrong
09:19
<
Regenaxer >
Have you looked directly into the memory?
09:19
<
Regenaxer >
What gives (struct Buf B B B B B B B) ?
09:19
<
aw- >
can you tell me
09:20
<
aw- >
is this wrong: (let Str (struct Msg 'S) ... )
09:20
<
Regenaxer >
no, fine
09:20
<
aw- >
i mean.. does the value end up in Str or in Msg ?
09:20
<
Regenaxer >
Msg is a number
09:20
<
Regenaxer >
struct returns a Lisp symbol for 'S' spec
09:21
<
aw- >
so i'm correct to use Str
09:21
<
Regenaxer >
the 'let' is irrelevant here
09:21
<
aw- >
ok let me inspect the bytes directly
09:22
<
aw- >
(78 40 83 105 122 101 32 32)
09:22
<
aw- >
("N" "(" "S" "i" "z" "e" " " " ")
09:22
<
aw- >
this is in my source code
09:23
<
Regenaxer >
wrong above of course, must be (struct P '(B B B B B B))
09:23
<
Regenaxer >
we want the list of raw bytes
09:23
<
aw- >
i fixed it ;)
09:24
<
Regenaxer >
So (78 40 83 105 122 101 32 32) does not start with 0
09:24
<
Regenaxer >
fun2 does not fill the buffer correctly
09:25
<
Regenaxer >
It is normal that an uninitialized buffer contains some old data
09:25
<
Regenaxer >
from a previously free'd buffer
09:25
<
Regenaxer >
can be anything
09:26
<
Regenaxer >
So why is there no null byte in the first position?
09:26
<
aw- >
but i'm sending NIL as an argument in my (native) call
09:26
<
aw- >
good question
09:26
<
aw- >
wait let me try the same test with pil64
09:27
<
aw- >
(0 138 121 123 127 0 0 0)
09:27
<
aw- >
100% exact same code
09:27
<
Regenaxer >
but fun2 is wrong
09:27
<
Regenaxer >
it does not fill the buffer
09:29
<
aw- >
hmmm ok that makes sense
09:29
<
aw- >
ok let me try
09:31
<
aw- >
would this work: (struct Msg 'N (0 . 256))
09:32
<
Regenaxer >
Not (struct Msg 'S (0 . 256)) ?
09:33
<
Regenaxer >
N returns the pointer
09:34
<
aw- >
that makes no sense
09:34
<
aw- >
why would i fill it with zeros
_after_ calling (native) ?
09:35
<
Regenaxer >
with 'struct' or 'byte'
09:35
<
aw- >
you mean fill it
_before_ (native), right?
09:35
<
aw- >
so i am calling (struct) twice?
09:36
<
Regenaxer >
the arguments to 'native' only fill the
*temporary* buffer
09:36
<
Regenaxer >
allocated and freed by native
09:36
<
Regenaxer >
struct takes a pointer to an
*existing* buffer
09:37
<
aw- >
(let Msg (native "@" "malloc" 'N 256)
09:37
<
aw- >
Buf (struct Msg 'S (0 . 256))
09:37
<
aw- >
Res (native "lib" "fun" 'I Fd Msg 256)
09:37
<
aw- >
Str (struct Msg 'S)
09:38
<
Regenaxer >
looks good
09:38
<
aw- >
but when i print out Str
09:38
<
Regenaxer >
Why is the init necessary
09:39
<
Regenaxer >
fun2 fills the buffer
09:39
<
aw- >
yes it's not necessary
09:39
<
aw- >
for some reason, in pil21 it fills the buffer with my source code
09:39
<
Regenaxer >
you call "fun"
09:39
<
Regenaxer >
I thought "fun2"
09:39
<
aw- >
same thing.. im renaming things everywhere and testing
09:39
<
aw- >
sorry for the name change
09:40
<
Regenaxer >
no problem
09:40
<
aw- >
my code is a huge mess now haha
09:40
<
Regenaxer >
I understand it is pseudo code
09:40
<
Regenaxer >
I would test it all in the repl
09:40
<
Regenaxer >
not messing with sources
09:41
<
aw- >
yeah i wrote a script to run the tests so it's fairly quick
09:41
<
Regenaxer >
I did all above tests only in repls on 64 and 21
09:41
<
Regenaxer >
T, reload is even faster
09:41
<
aw- >
i will write some more here
09:42
<
aw- >
i init the buffer to 256 0s, then call (native) which fills the buffer with data, then call (struct) to extract the string
09:43
<
aw- >
when the buffer
_only_ contains a null-byte, I instead get (78 0 0 0 0 0 0 0) as a result using (struct Msg '(B B B B B B B B))
09:43
<
aw- >
which is crazy
09:43
<
aw- >
i'm not sure why
09:43
<
aw- >
in pil64 i get: (0 0 0 0 0 0 0 0)
09:57
<
aw- >
is the first letter from NIL
09:57
<
aw- >
i wonder if it's taking just the first byte from NIL and returning that
09:57
<
aw- >
instead of converting NIL to a null-byte
09:57
<
aw- >
Regenaxer i think i found the problem
10:01
<
Regenaxer >
phone done
10:02
<
Regenaxer >
yes, "" stores the string "NIL", both in 64 and 21
10:05
<
Regenaxer >
ha! no!
10:05
<
Regenaxer >
only in pil21!!!
10:05
<
Regenaxer >
So that is it!
10:05
<
Regenaxer >
: (native "@" "strdup" 'S "")
10:05
<
Regenaxer >
-> "NIL"
10:05
<
Regenaxer >
This is wrong
10:05
<
aw- >
that's what i'm seeing
10:06
<
Regenaxer >
pil64 returns NIL
10:06
<
Regenaxer >
ok, I will check
10:07
<
aw- >
i wish i knew enough native/C to debug this a lot quicker haha
10:07
<
Regenaxer >
no problem
10:07
<
Regenaxer >
I will try to find it
10:07
<
Regenaxer >
forgot the internals of 'native' meanwhile
10:08
<
aw- >
i'll be back later, dinner time :)
10:08
<
Regenaxer >
struct in pil64 behaves the same
10:09
<
Regenaxer >
(struct P 'S '("" . 4)) -> "NIL"
10:09
<
Regenaxer >
this is in both
10:09
<
Regenaxer >
ok, later, enjoy dinner!
10:10
mtsd_ has joined #picolisp
10:10
mtsd_ has quit [Client Quit]
10:12
mtsd has quit [Ping timeout: 260 seconds]
10:28
<
Regenaxer >
Fixed and released it
10:30
<
Regenaxer >
Note that in pil64 it is still wrong:
10:30
<
Regenaxer >
: (setq P (native "@" "malloc" 'N 99))
10:30
<
Regenaxer >
-> 494132412416
10:30
<
Regenaxer >
: (struct P 'S '("" . 4))
10:30
<
Regenaxer >
-> "NIL"
10:30
<
Regenaxer >
: (struct P '(B B B B))
10:30
<
Regenaxer >
-> (78 73 76 0)
10:31
<
Regenaxer >
pil21 now does:
10:31
<
Regenaxer >
: (setq P (native "@" "malloc" 'N 99))
10:31
<
Regenaxer >
-> 533404266496
10:31
<
Regenaxer >
: (struct P 'S '("" . 4))
10:31
<
Regenaxer >
: (struct P '(B B B B))
10:31
<
Regenaxer >
-> (0 0 0 0)
10:32
<
Regenaxer >
i.e. for string pointers in structures
10:32
<
Regenaxer >
as native *argument*s now both do:
10:32
<
Regenaxer >
: (native "@" "strdup" 'S "")
10:33
<
Regenaxer >
(this gave "NIL" in pil21 before)
10:41
mtsd has joined #picolisp
10:43
<
Regenaxer >
Hmm, aw-, I still don't understand
10:43
<
Regenaxer >
The above is about cases where the buffer is filled from Lisp
10:43
<
Regenaxer >
but in your case your C function filled it
11:00
<
aw- >
works on pil21!
11:00
<
aw- >
pil64 seems fine though
11:01
<
aw- >
but i'm not sure why
11:01
<
Regenaxer >
so it is not fun?
11:01
<
Regenaxer >
You fill the buffer from Lisp, as the above examples?
11:02
<
Regenaxer >
I'm confused
11:02
<
aw- >
(let Msg (native "@" "malloc" 'N 256)
11:02
<
aw- >
Buf (struct Msg 'S (0 . 256))
11:02
<
Regenaxer >
anyway, makes sense then
11:03
<
Regenaxer >
(struct Msg 'S (0 . 256) worked though
11:03
<
aw- >
no, i dont think so
11:03
<
aw- >
is there a way to check?
11:03
<
Regenaxer >
No, this always worked
11:03
<
Regenaxer >
What I changed now is NIL or "" argument
11:03
<
Regenaxer >
grr, why is this such a mess?
11:04
<
aw- >
haha you're asking me?
11:04
<
Regenaxer >
It is not clear at all what you are doing
11:04
<
aw- >
i will release my code shortly and you can review if you want
11:04
<
aw- >
just need to finish my documentation
11:05
<
Regenaxer >
You said all the time that the C function fills the buffer, and you want to fetch the value from Lisp
11:05
<
Regenaxer >
Anyway, pil21 'native' was wrong
11:06
<
Regenaxer >
and pil64 'struct' is still wrong, I won't fix
11:06
<
Regenaxer >
Well, not "wrong"
11:06
<
aw- >
wait i broke something.. not sure if the new release works
11:06
<
Regenaxer >
but it is more useful if NIL is stored as empty string
11:07
<
Regenaxer >
As I said, it is not clear at all what you want to do
11:07
<
aw- >
ok yes it's fixed
11:07
<
aw- >
my code was broken, reverted everything and all tests pass now
11:08
<
Regenaxer >
So you have code that passes NIL
11:09
<
aw- >
the new release fixed it
11:09
<
Regenaxer >
great! :)
11:17
orivej has quit [Ping timeout: 260 seconds]
11:17
orivej has joined #picolisp
11:42
<
aw- >
Regenaxer: i copied your (sysdefs) from lib.l
11:43
<
Regenaxer >
good idea
11:43
<
aw- >
so no need to check which version anymore
11:44
<
Regenaxer >
OS version?
11:44
<
aw- >
(> (version T) (21)) not needed
11:46
mtsd has quit [Quit: Leaving]
12:49
<
aw- >
ok Regenaxer thanks for your help!
12:52
aw- has quit [Quit: Leaving.]
13:01
rob_w has quit [Quit: Leaving]
13:51
orivej has quit [Ping timeout: 272 seconds]
13:52
orivej has joined #picolisp
13:59
orivej has quit [Ping timeout: 264 seconds]
15:12
DKordic has joined #picolisp
17:13
orivej has joined #picolisp
18:06
<
tankf33der >
i've found code which 4x faster on pil21 than on pil64.
18:06
<
tankf33der >
of course pil21 opted.
18:07
<
Regenaxer >
Rather long functions, right?
18:07
<
Regenaxer >
I.e. little function call overhead
18:07
<
tankf33der >
yea, big math of rsa.l
18:08
<
Regenaxer >
this can be optimized
18:08
<
Regenaxer >
register usage
18:08
<
Regenaxer >
The problem is many small functions calling each other
18:09
<
Regenaxer >
the interpreter itself
18:09
<
Regenaxer >
But 4 times is really a lot
18:10
<
Regenaxer >
Would be interesting to know
*which* function
18:10
<
Regenaxer >
eg. '*' or '/'
18:10
<
tankf33der >
prime? of rsa.l
18:11
<
Regenaxer >
perhaps 'bit?' ?
18:12
<
Regenaxer >
it calls almost everything
18:12
<
Regenaxer >
also div
23:38
orivej has quit [Ping timeout: 256 seconds]
23:55
jibanes has quit [Ping timeout: 265 seconds]
23:57
jibanes has joined #picolisp