01:44
_whitelogger has joined #picolisp
01:47
aw- has quit [Quit: Leaving.]
03:08
orivej has joined #picolisp
04:20
_whitelogger has joined #picolisp
04:30
aw- has joined #picolisp
04:42
<
DKordic >
""read""ers will ""poll"" after non-blocking ""open"", and ""write""rs will check for ""errno(3)"" ""ENOXIO"" after ""open"".
04:44
<
Regenaxer >
Right. As we discussed yesterday
04:44
<
Regenaxer >
Same for non-named pipes
04:45
<
Regenaxer >
The pil kernel does this for sibling processes
04:45
<
Regenaxer >
nonblock, poll()
04:45
<
Regenaxer >
The hard thing is what to do with the
*data* if the reader is not ready
04:46
<
Regenaxer >
so the parent maintains growing buffers
04:46
<
Regenaxer >
and if the reading end closes (the sibling terminated), the buffers are discarded
04:47
<
Regenaxer >
(the whole 'child' structure)
04:47
<
DKordic >
Well ""read""er should signal (by convention) that it is ready by opening for read-only.
04:48
<
Regenaxer >
it
*is* open already
05:05
<
DKordic >
Which means the ""read""er is ready?
05:06
<
Regenaxer >
well, it is ready until the pipe is full
05:06
<
Regenaxer >
PIPE_BUF
05:07
<
DKordic >
Then it could signify it by closing the ""fifo"?
05:07
<
Regenaxer >
poll() indicates that the
*write* would not block
05:08
<
Regenaxer >
No, why should it close? We don't want to lose data, no?
05:08
<
Regenaxer >
The
*writer* must delay sending until the reader is ready (or gone)
05:08
<
Regenaxer >
See waitFd in pil
05:08
<
Regenaxer >
pil32, pil64 or pil21
05:09
<
DKordic >
Yes, and I am saying that ""read""er
_could_ signify that it is not
_ready_ by closing the fifo. Will it be useful?
05:10
<
Regenaxer >
I do not think so. The writer has to wait then.
05:10
<
Regenaxer >
poll() and write() with nonblocking handles all that
05:10
<
Regenaxer >
no need for a signal
05:10
<
DKordic >
Sorry, I am not speaking about the pil "tell" mechanism, but an application speciffic fifo.
05:11
<
Regenaxer >
yes. I just gave pil as an example for an implementation
05:11
<
Regenaxer >
for completely transparent pipes
05:11
<
Regenaxer >
the application logic does not care
05:12
<
Regenaxer >
just sends to the pipes what it needs to
05:12
<
DKordic >
I do not mean ""signal(7)"", only ""errno(3)"".
05:13
<
Regenaxer >
so we are back at write()
05:14
<
Regenaxer >
returns EAGAIN
05:14
<
Regenaxer >
see the sources of wrChild() in pil
05:16
<
Regenaxer >
All this is needed because the kernel buffers for (named or not) pipes are so small
05:16
<
Regenaxer >
PIPE_BUF size
05:16
<
Regenaxer >
so you must maintain buffers to avoind blocking
05:16
<
Regenaxer >
(unless you can simply discard the data)
05:17
<
DKordic >
How will ""read""er signify that it is _ready_? My 2 cent sugestion is by ""open""ing the fifo.
05:17
<
Regenaxer >
No, it is really simple
05:18
<
Regenaxer >
write() returns -1 and errno is EAGAIN
05:18
<
aw- >
DKordic: thanks
05:18
<
Regenaxer >
meaning that the nonblocking write did not succeed
05:19
<
Regenaxer >
DKordic, sure, opening is the premisse
05:19
<
aw- >
i'm no sure what i did yesterday, it looked like the read was blocking
05:19
<
aw- >
anyways i deleted all the code but i couldn't debug it correctly
05:19
<
Regenaxer >
the fd must be nonblocking for the above
05:20
<
aw- >
i use mkfifo to create the named pipe
05:20
<
aw- >
is tthere an option to make it non-blocking?
05:20
<
aw- >
or i need (native) ?
05:21
<
Regenaxer >
(open / does not set to nonblock
05:22
<
aw- >
that's what i was looking for yesterday
05:22
<
aw- >
(out) uses (open), correct?
05:22
<
Regenaxer >
not directly
05:22
<
Regenaxer >
it calls open()
05:23
<
aw- >
ahh wow there's a LOT of options for open()
05:24
<
Regenaxer >
I set nonblocking with fcntl()
05:25
<
Regenaxer >
In pil21 it is the easiest
05:26
<
Regenaxer >
you can call nonBlocking() with 'native'
05:26
<
Regenaxer >
needs only a FD
05:26
<
Regenaxer >
(let Fd (open ..) (%@ "nonBlocking" Fd) ...
05:26
<
Regenaxer >
but it does not help
05:27
<
Regenaxer >
there is no interface to poll() or select() for writing on the Lisp level :(
05:27
<
Regenaxer >
*Run only handles reading and timeouts
05:27
<
aw- >
i can just use (native @ "open" ...)
05:27
<
Regenaxer >
yes, but you need the C constants
05:28
<
aw- >
(native "@" "open"...
05:28
<
aw- >
ah, for O_NONBLOCK etc?
05:28
<
Regenaxer >
no real problem
05:28
<
Regenaxer >
just portability
05:29
<
aw- >
pil64 also has nonblocking
05:29
<
Regenaxer >
yes, but not directly callable by 'native'
05:29
<
Regenaxer >
it is all asm
05:29
<
aw- >
so that's a pil21 feature
05:29
<
DKordic >
As we can see ""portability"" is an excuse of C(11) programmers.
05:30
<
Regenaxer >
Anyway the problem is that (poll ..) does not handle writes
05:30
<
aw- >
yes, that too
05:31
<
Regenaxer >
What was the purpose? Avoid blocking when writing to the pipes, right?
05:31
<
aw- >
(and (poll *Fd) (out @ ...)) would be nice
05:31
<
Regenaxer >
The easiest is using the internal pil mechanism
05:31
<
aw- >
is there a way to check if an *Fd (pipe) has a reader?
05:32
<
Regenaxer >
use a sibling process
05:32
<
Regenaxer >
write gives EAGAIN
05:32
<
Regenaxer >
see above
05:32
<
aw- >
ah yes, correct
05:32
<
aw- >
but only in NONBLOCKING mode
05:32
<
aw- >
i read that yesterday before dozing off
05:33
<
Regenaxer >
As I said, the problems start
*after* you get EAGAIN
05:33
<
Regenaxer >
what to do on the sender`s side?
05:33
<
Regenaxer >
you must buffer the data
05:33
<
Regenaxer >
otherwise you are "blocked" again
05:34
<
Regenaxer >
Pil RPC handles that
05:34
<
Regenaxer >
So I would use a separate process
05:34
<
Regenaxer >
it gets the data via 'tell' and then may block without harm
05:34
<
Regenaxer >
the sender will not block
05:34
<
aw- >
no no, i can handle it my own way
05:35
<
aw- >
if I get EGAIN, i can choose what to do
05:35
<
aw- >
dont need picolisp to decide for me
05:35
<
aw- >
just "knowing" the write fail would be sufficient
05:35
<
Regenaxer >
And discard the data?
05:36
<
Regenaxer >
losing the data is OK?
05:36
<
aw- >
why lose the data? i have the data
05:37
<
Regenaxer >
yes, but you get EAGAIN if the pipe is full, e.g. because the reveiver is busy
05:37
<
Regenaxer >
then you block
05:37
<
Regenaxer >
it is the
*only* reason for the blocking
05:38
<
Regenaxer >
the receiver is not fast enough to handle the data
05:38
<
Regenaxer >
otherwis no worry about the pipe
05:38
<
aw- >
yes i guess the only real solution is to have a buffer
05:39
<
Regenaxer >
or have the sender block for a moment
05:39
<
Regenaxer >
in worst cases
05:39
<
Regenaxer >
The pil kernel cannot allow to block
05:40
<
Regenaxer >
sender may be in a DB commit
05:40
<
Regenaxer >
that's why all the trouble
05:40
<
aw- >
maybe i'll use POSIX message queues with librt.so
05:41
<
aw- >
it's actually exactly what i want to do
05:42
<
Regenaxer >
They have bigger buffers?
05:42
<
aw- >
instead of trying to bend picolisp code for something not obvious
05:42
<
aw- >
no they have very small buffers by default
05:42
<
aw- >
you have to change the settings to get larger buffers
05:43
<
aw- >
i think max is 16MiB, but the default is like 256 Bytes or something ridiculous
05:43
<
aw- >
and linux/freebsd only
05:44
<
aw- >
a few limitations, but actually my use-case is exactly that: extremely small/lightweight message queue
05:46
<
aw- >
perhaps that could be my first pil21 (native) project ;)
05:47
<
aw- >
i like old stuff that's built-into linux kernel by default, much less headache than these big buggy softwares/protocols like MQTT
06:07
<
DKordic >
Regenaxer, beneroth: Please try
http://www.netsurf-browser.org/ ! It seems to be as efficient as w3m! A GUI alternative. Doesn't depend on WebKit or something like that.
06:12
<
Regenaxer >
DKordic, does it support VI-style key bindings? Does it run in Termux?
06:13
<
Regenaxer >
aw-: It is really a bad design that the buffer size is not dynamic
06:13
<
Regenaxer >
you either waste space or lose data
06:17
<
tankf33der >
morning.
06:18
<
Regenaxer >
Hi tankf33der!
06:19
<
aw- >
sorry, default is 8KB
06:22
mtsd has joined #picolisp
06:27
mtsd_ has joined #picolisp
06:27
<
DKordic >
Regenaxer: Not in Terminal, it has GUI. No vi key bindings that I am aware of. Key bindings seems to be like FireFox.
06:29
<
Regenaxer >
Not Terminal, but Termux. My working environment
06:29
mtsd has quit [Ping timeout: 240 seconds]
06:29
<
Regenaxer >
also VI bindings are essential
06:29
<
DKordic >
Good morning everyone.
06:30
<
tankf33der >
DKordic: correct, use it
06:30
<
Regenaxer >
yeah, good morning :)
06:39
rob_w has joined #picolisp
06:40
<
DKordic >
tankf33der: Thank You.
06:42
<
Regenaxer >
Yeah. And in fact I use tmux inside termux :)
06:51
mtsd has joined #picolisp
06:52
mtsd_ has quit [Ping timeout: 240 seconds]
07:05
<
aw- >
Regenaxer: in pil64, shouldn't 'src64/sysdefs' be compiled automatically with 'make' ? or has that changed now?
07:06
<
Regenaxer >
I don't remember well. I think it is not needed for normal pil64
07:06
<
Regenaxer >
it uses src64/sys/*.l
07:06
<
Regenaxer >
only for 'emu' sysdefs is used
07:06
<
Regenaxer >
(or initially to create src64/sys/*.l)
07:07
<
aw- >
is there another way to obtain those values through (native) ?
07:07
<
Regenaxer >
native does not help. We need to parse the include files
07:07
<
Regenaxer >
can be done with gcc -E perhaps
07:08
<
aw- >
we discussed this 2 years ago
07:08
<
Regenaxer >
but the easiest is to build a C program
07:08
<
aw- >
when i wanted to create an atomic file
07:08
<
aw- >
but i was wondering why on this system @src64/sysdefs wasnt there.. had to 'make sysdefs'
07:09
<
Regenaxer >
yeah, not in the targets
07:10
<
Regenaxer >
pil21 always builds it (for a different usage)
07:11
<
aw- >
ohh yeah you're right
07:11
<
aw- >
in @lib/sysdefs
07:11
<
aw- >
not many values in there
07:12
<
Regenaxer >
yeah, not needed yet
07:12
<
Regenaxer >
only for pil21 itself
07:12
<
Regenaxer >
The idea is to create such files app-specific
07:13
<
Regenaxer >
for using them with 'sysdefs' in @lib.l
07:13
<
aw- >
how is it loaded?
07:14
<
aw- >
oh never mind, we discussed this already
07:14
<
Regenaxer >
yeah, 'sysdefs' simply opens such a file
07:15
<
Regenaxer >
like in @lib/net.l
07:31
<
Regenaxer >
Hi Nistur
07:32
<
beneroth >
DKordic, thanks for the hint! Will look into it!
07:32
<
beneroth >
Ahoy Nistur!
07:32
<
beneroth >
Hi Regenaxer, aw- :)
07:33
<
Regenaxer >
Hi beneroth!
07:33
<
beneroth >
Hey mtsd :)
07:34
<
Regenaxer >
Hi mtsd!
09:45
mario-goulart has quit [Remote host closed the connection]
09:45
mario-goulart has joined #picolisp
10:08
<
Regenaxer >
Hmm, looks like the pil21 base system in done
10:08
<
Regenaxer >
DB not really tested yet
10:08
<
Regenaxer >
but works basically
10:09
<
Regenaxer >
Probably still lots of bugs
10:39
<
tankf33der >
what i need to get (rel) function in pil21 ?
10:40
<
Regenaxer >
I have not yet put @lib/btree.l and @lib/db.l into pil21/lib/
10:40
<
Regenaxer >
First wanted to make sure plain external symbols work
10:40
<
Regenaxer >
Soon :)
10:43
<
Regenaxer >
new, zap, commit, rollback, dbck seem to work
10:43
<
Regenaxer >
not sure if correct in all situations
10:43
<
tankf33der >
db tests from pil64 passed.
10:43
<
Regenaxer >
What do they involve?
10:44
<
tankf33der >
id, new, mark, dbck, lieu, commit, rollback.
10:44
<
Regenaxer >
wow, thats cool
10:45
<
Regenaxer >
I did not expect that it really works
10:45
<
Regenaxer >
good news indeed
10:46
<
Regenaxer >
I just coded without testing because all these functions only work together
10:46
<
Regenaxer >
Then I did some singular tests and fixed some errors today
10:46
<
Regenaxer >
But I thought there must be more
10:53
<
tankf33der >
i cant test db, i dont understands it. i have several trivial tests and 1 complex. lets see.
12:43
<
aw- >
Regenaxer: how to access 'errno' with (native) ?
12:43
patrixl has quit [Read error: Connection reset by peer]
12:45
<
aw- >
my call returns -1
12:45
<
Regenaxer >
yeah, there is no way
12:45
<
aw- >
but according to the docs 'errno' is set with the error
12:45
<
Regenaxer >
errno is not a global
12:45
<
Regenaxer >
usually highly system dependent
12:45
<
aw- >
i tried (native "@" "errno" 'I)
12:45
patrixl has joined #picolisp
12:45
<
Regenaxer >
pil21 has a glue function
12:46
<
Regenaxer >
errno was never a
*function*
12:46
<
Regenaxer >
In ancient Unix it used to be a global
12:46
<
Regenaxer >
But all Unixes handle it as a macro now
12:46
<
Regenaxer >
No way to access by a native call
12:46
<
Regenaxer >
See what pil21 does
12:47
<
Regenaxer >
it has a Lisp level function (errno)
12:47
<
Regenaxer >
It boils down to a function nErrno() in src/lib.c
12:48
<
Regenaxer >
So the target platform's C compiler expands the macro in a proper way
12:48
<
Regenaxer >
If you need to use pil64 for now,
12:48
<
Regenaxer >
let me check
12:49
<
Regenaxer >
You can call with 'native' the right function from sys/<arch>.code.l
12:49
<
Regenaxer >
(native "@" "errno_A" 'I)
*might* work (never tried)
12:49
<
Regenaxer >
I looked in sys/x86-64.linux.code.l
12:50
<
Regenaxer >
Yes, 'errno_A' is in all sys/<arch>.code.l
12:50
<
Regenaxer >
You can see that it is different for each version
12:56
<
aw- >
ok i will use this
12:56
<
Regenaxer >
Later with pil21 it will be more portable
12:57
<
aw- >
looking forward to it
12:58
<
aw- >
(native "@" "perror" 'S)
12:58
<
aw- >
returns garbage: String
12:58
<
aw- >
it returns more than a string
12:59
<
aw- >
oh.. it doesnt return anything
12:59
mtsd has quit [Quit: Leaving]
13:00
<
Regenaxer >
head, void
13:01
<
aw- >
i look the man page
13:01
<
Regenaxer >
Yep, void perror(const char *s);
13:02
<
aw- >
i use strerror() instead
13:07
orivej has quit [Ping timeout: 265 seconds]
13:09
<
aw- >
haven't worked with (native) in so long
13:09
<
aw- >
i don't remember anything haha
13:10
<
Regenaxer >
Now I released PilBox for API 29
13:11
<
Regenaxer >
No more starting of dynamically loaded bin/picolisp, bin/ssl etc
13:11
<
Regenaxer >
So I do no longer support 32-bit mobiles via 'emu'
13:11
<
aw- >
almost everything is 64-bit nowadays
13:12
<
Regenaxer >
(which is a good thing)
13:12
<
aw- >
good riddance
13:12
<
Regenaxer >
But I hate restricting Android more and more
13:12
<
aw- >
i can still see the benefit of 8-bit and 16-bit systems, but 32-bit is useless
13:13
<
Regenaxer >
A slight cost advantage in hardware perhaps
13:17
<
aw- >
we have (errno)
13:18
<
aw- >
i just found it in the docs
13:18
<
Regenaxer >
in pil64 too?
13:18
<
Regenaxer >
makes sense
13:19
<
Regenaxer >
Seems I already garbage collected pil64 in my memory
13:20
<
aw- >
you didn't implement it in pil21?
13:20
<
Regenaxer >
No, it is there
13:20
<
aw- >
ah yes, returns 0 when no error
13:20
<
Regenaxer >
That's why I said the issue will be no problem in pil21
13:21
<
Regenaxer >
I think it always returns the last value
13:21
<
aw- >
forgot it was also in pil64
13:21
<
Regenaxer >
Like in C
13:32
<
aw- >
how would you convert this argument to a struct: (list NIL (4 (N . 0) (N . 1) (N . 2) (N . 0)) 0 100 1024 0)
13:33
<
aw- >
struct mystuct { long a; long b; long c; long d; };
13:33
<
aw- >
is that correct?
13:33
<
aw- >
hmm i think that's wrong
13:34
<
Regenaxer >
yes (N . 0) is not good
13:34
<
Regenaxer >
just N is a long
13:34
<
Regenaxer >
(N . 4) would be long[4]
13:35
<
aw- >
so the size of the struct is wrong too, should be 16 ?
13:35
<
aw- >
(list NIL (16 ..?
13:36
<
Regenaxer >
one long has 8 bytes, so 32
13:37
<
aw- >
hmm.. can I just do (list NIL (32 (N N N N)) ...?
13:37
<
Regenaxer >
and the init is wrong too
13:37
<
Regenaxer >
it is
*bytes*
13:37
<
aw- >
so 1024 is too big
13:37
<
Regenaxer >
no init then
13:37
<
Regenaxer >
yes, and needs more zeroes
13:37
<
Regenaxer >
lots of zeroes ;)
13:37
<
aw- >
right, 32 bytes
13:38
<
Regenaxer >
'(NIL (32 N N N N) . 0)
13:38
<
Regenaxer >
this would init all to zero
13:38
<
aw- >
i want to initialize some of them though
13:38
<
Regenaxer >
then use struct
13:38
<
Regenaxer >
'struct'
13:38
<
Regenaxer >
allocated with malloc()
13:39
<
Regenaxer >
pil21 has a function for a local buffer
13:39
<
Regenaxer >
on the stack
13:39
<
Regenaxer >
no need for malloc/free then
13:40
<
Regenaxer >
Is used in @lib/net.l
13:40
<
Regenaxer >
(buf Addr sockaddr_in6 ...
13:41
<
aw- >
ok let me try some things
13:56
<
aw- >
Regenaxer: what's the advantage of using (struct) compared to just sending the arguments?
13:56
<
aw- >
i'm trying to send a simple struct like: struct mystuct { long a; long b; long c; long d; }; ... where a=0,b=1,c=2,d=0
13:56
<
Regenaxer >
You can fill in data, which is not possible with the above init bytes
13:58
<
aw- >
can only provide 'fill' bytes
13:59
<
Regenaxer >
I think there is some explanation in doc/native.html in the distro
13:59
<
aw- >
same approach in pil21?
13:59
<
aw- >
from native.html 'The CDR is ignored for input-only arguments, '
13:59
<
Regenaxer >
With some minor "improvements"
14:00
<
Regenaxer >
I used native extensively in pil21/lib/net.l
14:00
<
Regenaxer >
kind of first real usage
14:00
<
Regenaxer >
except for simple system calls
14:01
<
Regenaxer >
So in fact it might be a good idea if you test your code also in pil21
14:01
<
aw- >
you're using (struct) without calling malloc, how?
14:02
<
aw- >
yes i will test in pil21 once i get it working
14:02
<
Regenaxer >
In pil21 there is 'buf', which allocates on the stack
14:02
<
Regenaxer >
like a C automatic variable
14:03
<
Regenaxer >
a little faster I suppose
14:03
<
Regenaxer >
doc/ref is still missing though
14:03
<
Regenaxer >
but I think you know what to do
14:03
<
aw- >
yes no problem
14:04
<
Regenaxer >
best and first example is net.l :)
14:04
<
Regenaxer >
You can compare with pil32 src/net.c
14:04
<
Regenaxer >
should be analog
14:28
<
aw- >
ok good night, will continue tomorrow
14:28
<
aw- >
thanks for the help
14:31
aw- has quit [Quit: Leaving.]
14:50
rob_w has quit [Quit: Leaving]
15:43
orivej has joined #picolisp
16:43
orivej has quit [Remote host closed the connection]
16:44
orivej has joined #picolisp
17:33
orivej has quit [Ping timeout: 260 seconds]
17:59
_whitelogger has joined #picolisp
18:35
<
tankf33der >
tests for @lib/math.l passed.
19:30
<
Regenaxer >
Thanks!
19:30
<
Regenaxer >
We are progressing fast :)