Opening Win32 pipe strange behaviour

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Hi Lutz!

Well, good news: it works!! See the GTK-server demo program below. With the Borland-binary this program will not run.

But for some strange reason, the (sleep x) function does not work anymore with the MinGW binary, so I simulated a sleep with a large (for) loop.

Anyway, I volunteer to test the MinGW version of newLisp in the next future. If you are OK, I will use it in all my Win32 newLisp programs and submit problems to this forum...? (So one problem already is the 'sleep' function... ;0) )

Thank you for the extremely good and fast support.

Regards

Peter

============================

;------------------------------------------------
;
; Demonstration on how to use the GTK-server with NEWLISP by FIFO.
; Tested with newLISP 8.0.9 compiled with MinGW on WindowsXP.
;
; July 17, 2004 by Pjot.
;
;------------------------------------------------

; Define communication function
(define (gtk str)
(write-buffer pipeout str)
(read-buffer pipein 'tmp 128)
tmp)

; Start the gtk-server
(process "gtk-server fifo log")
(for (x 1 2000000))

; Connect to the GTK-server
(set 'pipeout (open {\\.\pipe\out} "w"))
(println pipeout)
(set 'pipein (open {\\.\pipe\in} "r"))
(println pipein)

; Setup GUI
(gtk "gtk_init(NULL, NULL)")
(set 'win (gtk "gtk_window_new(0)"))
(gtk (append "gtk_window_set_title (" win ", This is a title)"))
(gtk (append "gtk_window_set_default_size (" win ", 100, 100)"))
(gtk (append "gtk_window_set_position (" win ", 1 )"))
(set 'table (gtk "gtk_table_new(30, 30, 1 )"))
(gtk (append "gtk_container_add (" win "," table ")"))
(set 'button1 (gtk "gtk_button_new_with_label (Exit)"))
(gtk (append "gtk_table_attach_defaults(" table ", " button1 ", 17, 28, 20, 25)"))
(set 'button2 (gtk "gtk_button_new_with_label (Print text)"))
(gtk (append "gtk_table_attach_defaults (" table ", " button2 ", 2, 13, 20, 25)"))
(set 'entry (gtk "gtk_entry_new()"))
(gtk (append "gtk_table_attach_defaults (" table ", " entry ", 2, 28, 5, 15)"))
(gtk (append "gtk_widget_show_all(" win ")"))
(gtk (append "gtk_widget_grab_focus(" entry ")"))

; Initialize
(set 'cb1 0)
(set 'cb2 0)
(set 'event 0)

; This is the mainloop
(while (= (integer event) 0)
(gtk "gtk_main_iteration_do(0)")
(set 'cb1 (gtk (append "gtk_server_callback(" button2 ")")))
(set 'cb2 (gtk (append "gtk_server_callback(" entry ")")))
(if (or (= (integer cb1) 1) (= (integer cb2) 1))
(begin
(set 'tmp (gtk (append "gtk_entry_get_text(" entry ")")))
(println tmp)
(gtk (append "gtk_editable_delete_text(" entry ", 0, -1)"))
(gtk (append "gtk_widget_grab_focus(" entry ")"))
))
(set 'event (gtk (append "gtk_server_callback(" button1 ")"))))

(write-buffer pipeout "gtk_exit(0)")
(exit)

adamss3
Posts: 14
Joined: Mon Oct 14, 2002 11:53 am

Post by adamss3 »

It might be that we need to define another conditional compiler point in the p_sleep routine to call the Win32 Sleep() function (in Kernel32.dll). That should fix the sleep problem.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Good News! Turns out I was linking unnecessary libraries. The new version of newlisp-mingw.exe is only 143Kbyte, that is a similar size as on Linux and BSD. I also could fix the 'sleep' error.

I have replaced the newlisp-mingw.exe with the smaller one with the sleep fix on the usual http://newlisp.org/downloads/development/

We will have a new development release with an improved 'net-sessions' during the coming week.

Thanks for doing more testing. I am very encouraged now with the smaller size of the exe file and might consider to make MinGW the default for the Win32 distribution.

Lutz

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Perfect.

With this new binary everything in the demoprogram works. I have replaced the (for) for a (sleep 1000). I have also put the final demoscript for newLisp with Win32 Named Pipes at my site http://www.gtk-server.org

NewLisp is the first non-basic language to support named pipes in Win32 with the GTK-server. The advantage is obvious: TCP ports will remain available for real network applications. Named Pipe support for Linux already worked.

Lutz, thanks again for your efforts. And I am happy to know that you are considering MinGW as your default compiler! I will use the MinGW port from now on myself, and let you know about difficulties or strange behaviour.

Thanks!

Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

>I am very encouraged now with the smaller size of the exe file and might consider to make MinGW the default for the Win32 distribution.

Will then the DLL also compiled with MinGW?
Will the size reduced about the same size?
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Testing a little bit with the MinGw.exe, everything works so far.

I only see little performance differences:

Code: Select all

Borland:
(setq y 1)
1
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4094
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4125
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4094
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4109
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4172
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4109
> 

MinGW:
> (setq y 1)
1
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4609
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4578
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4594
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4578
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4625
> (time(dotimes (x 10000000)(setq y (+ y 1))))
4640
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Just digging a bit around with the newLISP-versions, I take a look with the dependency-walker at them:

Both version's and the DLL gets:
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

MPR.DLL (18.08.2001 55808 Bytes)
I have no idea for what it is good and if it is a problem.
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

About that performance: as with Borland, there are many optimization options with MinGW, also for speed and performance. Probably these were not applied with the MinGW version of newLisp. I sought for the Makefile but couldn't find it (yet) on the newLisp FTP server.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Yes, that is correct, I was playing around with the optimization options, and settled on -O3 which gives me close to the same performance and a 165K executable, which is still smaller than the 198K before.

The benchmark I am running is a mixture of different tasks of aritmetik, call overhead, list manipulation and string manipulation.

I got UTF-8 going without a problem, but I am still working on the DLL with MinGW.


Lutz

ps: don't think that the MPR.DLL message is a problem, seems to be internal to some of the Win libraries. I guess you would get this message on any previous version too.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

latest versions of newlisp.exe and newlisp.dll compiled with MinGW and based on v8.0.9 are in:

http://newlisp.org/downloads/development/MinGW/

makefiles for this will be released this week in 8.0.10

Lutz

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

Great! It's too late for me now to test this binary but I'll check it out tomorrow.

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

A quick test here in the office shows that most things are working. Performance is now identical with the BCC-version.

I found one problem with the DLL. Using my demo-app for neobook, it terminates the whole app when using the (Restart:run) function from the last demo-page. It close the app (and also the whole neobook IDE) without any message, when it comes back from a command sequence. I have to further investigate, when I am back home.
Hans-Peter

pjot
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

No problems here, all my newLisp applications work a 100% OK. Including the TCP demo-scripts for the GTK-server.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Hans-Peter,

looks like Steve (adamss3 on this board) has similar problems using the MinGW compiled DLL, he is working on it and it seems to be fixed, I will put an update of newlisp.dll later. This needs thorough testing !!!. So far odbc.lsp (stdcall conventions) and sqlite.lsp (cdecl call conventions) seem to work fine. And Steve has a whole lot of other stdcall stuff in test.

Lutz

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Posted newlisp-8010.exe and newlisp-8010.dll in development/MinGW, this hopefully fixes HPW DLL restart problems in NeoBook. 8.0.10 also contains the mod to 'net-sessions' (requested by Norman) which now also reports client connections.

If HPW and Steve don't have any other issues I can make a 8.0.10 development release later this afternoon.

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Still in the office, but tested just the new 8010-release. Problems has gone and demo-app runs without any problems. Seems to be another great step so far. Will test further when I am back home.
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

After some tests at home, I have released a new ZIP with the neobook plugin marked as a beta, so that neobook user can also test it. Compressed with a runtime-packer it is now whopping 88KB.
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

I left long string printing with [text] [/text] tags for less 100 charcacters, instead of 2048 while debugging. I will probably make a new 8.0.11 today fixing that.

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

I just tried to use link.lsp with the new MinGW-EXE.
Seems to me no more working.
The EXE starts but does not execute the linked code.
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

I am looking into it ...

Lutz

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

There is a fix for the link problem in http://newlisp.org/downloads/development/HPW/

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Thanks for the fix. Works again.
The UdpListener from the neobook sample pubs is now 167 KB instead of 195 KB.
Hans-Peter

Locked