|
|
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » How to write a dll using Ultimate++?
|
Re: How to write a dll using Ultimate++? [message #11383 is a reply to message #11352] |
Mon, 10 September 2007 19:08 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
luzr wrote on Sat, 08 September 2007 10:24 |
Have you tested with MSC?
Mirek
|
Checked at home (I ran these tests two or three years back) ...
Windows MSVC v7.1
Windows cygwin gcc v3.4.4
Windows MinGW gcc v3.4.5
Linux GCC 3.4.0 (Slackware)
Solaris GCC v4.0.1
I'll also try to find testing results at work. I had a lot of them.
I'm really interested in discussion about troubles with DLLs on COFF and ELF platforms because this is a part of my job.
Regards,
Novo
[Updated on: Mon, 10 September 2007 19:36] Report message to a moderator
|
|
|
Re: How to write a dll using Ultimate++? [message #11385 is a reply to message #11383] |
Mon, 10 September 2007 19:34 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
An example of test output.
Windows cygwin gcc v3.4.4 ...
Run test_dll_app_01
+ 0 Created : test_dll_01 global
+ 1 Registered atexit_funct: test_dll_01 global
+ 2 Created : test_dll_app_01 global
+ 3 Registered atexit_funct: test_dll_app_01 global
+ 4 Created : test_dll_app_01 local static
+ 5 Registered atexit_funct: test_dll_app_01 local
+ 6 Created : test_dll_01 local static do_it
+ 7 Registered atexit_funct: test_dll_01 local do_it
- 0 Destroyed: test_dll_01 global
- 7 Called atexit_funct: test_dll_01 local do_it
- 6 Destroyed: test_dll_01 local static do_it
- 5 Called atexit_funct: test_dll_app_01 local
- 4 Destroyed: test_dll_app_01 local static
- 2 Destroyed: test_dll_app_01 global
- 3 Called atexit_funct: test_dll_app_01 global
- 1 Called atexit_funct: test_dll_01 global
Run test_dll_app_02
+ 0 Created : test_dll_app_02 global
+ 1 Registered atexit_funct: test_dll_app_02 global
+ 2 Created : test_dll_app_02 local static
+ 3 Registered atexit_funct: test_dll_app_02 local
Load test_dll_01 manually ...
+ 4 Created : test_dll_01 global
+ 5 Registered atexit_funct: test_dll_01 global
+ 6 Created : test_dll_01 local static do_it
+ 7 Registered atexit_funct: test_dll_01 local do_it
Unoad test_dll_01 manually ...
- 4 Destroyed: test_dll_01 global
- 7 Called atexit_funct: test_dll_01 local do_it
- 6 Destroyed: test_dll_01 local static do_it
- 5 Called atexit_funct: test_dll_01 global
- 3 Called atexit_funct: test_dll_app_02 local
- 2 Destroyed: test_dll_app_02 local static
- 0 Destroyed: test_dll_app_02 global
- 1 Called atexit_funct: test_dll_app_02 global
Run test_dll_app_02 -n (Do not unload DLLs)
+ 0 Created : test_dll_app_02 global
+ 1 Registered atexit_funct: test_dll_app_02 global
+ 2 Created : test_dll_app_02 local static
+ 3 Registered atexit_funct: test_dll_app_02 local
Load test_dll_01 manually ...
+ 4 Created : test_dll_01 global
+ 5 Registered atexit_funct: test_dll_01 global
+ 6 Created : test_dll_01 local static do_it
+ 7 Registered atexit_funct: test_dll_01 local do_it
- 4 Destroyed: test_dll_01 global
- 7 Called atexit_funct: test_dll_01 local do_it
- 6 Destroyed: test_dll_01 local static do_it
- 5 Called atexit_funct: test_dll_01 global
- 3 Called atexit_funct: test_dll_app_02 local
- 2 Destroyed: test_dll_app_02 local static
- 0 Destroyed: test_dll_app_02 global
- 1 Called atexit_funct: test_dll_app_02 global
Run test_dll_app_03
+ 0 Created : test_dll_01 global
+ 1 Registered atexit_funct: test_dll_01 global
+ 2 Created : test_dll_02 global
+ 3 Registered atexit_funct: test_dll_02 global
+ 4 Created : test_dll_app_03 global
+ 5 Registered atexit_funct: test_dll_app_03 global
+ 6 Created : test_dll_app_03 local static
+ 7 Registered atexit_funct: test_dll_app_03 local
+ 8 Created : test_dll_02 local static do_it
+ 9 Registered atexit_funct: test_dll_02 local do_it
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
- 0 Destroyed: test_dll_01 global
- 2 Destroyed: test_dll_02 global
- 11 Called atexit_funct: test_dll_01 local do_it
- 10 Destroyed: test_dll_01 local static do_it
- 9 Called atexit_funct: test_dll_02 local do_it
- 8 Destroyed: test_dll_02 local static do_it
- 7 Called atexit_funct: test_dll_app_03 local
- 6 Destroyed: test_dll_app_03 local static
- 4 Destroyed: test_dll_app_03 global
- 5 Called atexit_funct: test_dll_app_03 global
- 3 Called atexit_funct: test_dll_02 global
- 1 Called atexit_funct: test_dll_01 global
Run test_dll_app_04
+ 0 Created : test_dll_app_04 global
+ 1 Registered atexit_funct: test_dll_app_04 global
+ 2 Created : test_dll_app_04 local static
+ 3 Registered atexit_funct: test_dll_app_04 local
Load test_dll_02 manually ...
+ 4 Created : test_dll_01 global
+ 5 Registered atexit_funct: test_dll_01 global
+ 6 Created : test_dll_02 global
+ 7 Registered atexit_funct: test_dll_02 global
+ 8 Created : test_dll_02 local static do_it
+ 9 Registered atexit_funct: test_dll_02 local do_it
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
Unoad test_dll_02 manually ...
- 6 Destroyed: test_dll_02 global
- 4 Destroyed: test_dll_01 global
8 [main] test_dll_app_04 2504 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
1658 [main] test_dll_app_04 2504 open_stackdumpfile: Dumping stack trace to test_dll_app_04.exe.stackdump
Run test_dll_app_04 -n (Do not unload DLLs)
+ 0 Created : test_dll_app_04 global
+ 1 Registered atexit_funct: test_dll_app_04 global
+ 2 Created : test_dll_app_04 local static
+ 3 Registered atexit_funct: test_dll_app_04 local
Load test_dll_02 manually ...
+ 4 Created : test_dll_01 global
+ 5 Registered atexit_funct: test_dll_01 global
+ 6 Created : test_dll_02 global
+ 7 Registered atexit_funct: test_dll_02 global
+ 8 Created : test_dll_02 local static do_it
+ 9 Registered atexit_funct: test_dll_02 local do_it
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
- 6 Destroyed: test_dll_02 global
- 4 Destroyed: test_dll_01 global
4 [main] test_dll_app_04 2748 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
1414 [main] test_dll_app_04 2748 open_stackdumpfile: Dumping stack trace to test_dll_app_04.exe.stackdump
Run test_dll_app_05
+ 0 Created : test_dll_03 global
+ 1 Registered atexit_funct: test_dll_03 global
+ 2 Created : test_dll_app_05 global
+ 3 Registered atexit_funct: test_dll_app_05 global
+ 4 Created : test_dll_app_05 local static
+ 5 Registered atexit_funct: test_dll_app_05 local
+ 6 Created : test_dll_03 local static do_it
+ 7 Registered atexit_funct: test_dll_03 local do_it
Load test_dll_01 manually from test_dll_03 ...
+ 8 Created : test_dll_01 global
+ 9 Registered atexit_funct: test_dll_01 global
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
Unload test_dll_01 manually from test_dll_03 ...
- 8 Destroyed: test_dll_01 global
- 0 Destroyed: test_dll_03 global
8 [main] test_dll_app_05 2428 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
1475 [main] test_dll_app_05 2428 open_stackdumpfile: Dumping stack trace to test_dll_app_05.exe.stackdump
Run test_dll_app_06
+ 0 Created : test_dll_app_06 global
+ 1 Registered atexit_funct: test_dll_app_06 global
+ 2 Created : test_dll_app_06 local static
+ 3 Registered atexit_funct: test_dll_app_06 local
Load test_dll_03 manually ...
+ 4 Created : test_dll_03 global
+ 5 Registered atexit_funct: test_dll_03 global
+ 6 Created : test_dll_03 local static do_it
+ 7 Registered atexit_funct: test_dll_03 local do_it
Load test_dll_01 manually from test_dll_03 ...
+ 8 Created : test_dll_01 global
+ 9 Registered atexit_funct: test_dll_01 global
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
Unload test_dll_01 manually from test_dll_03 ...
- 8 Destroyed: test_dll_01 global
UnLoad test_dll_03 manually ...
- 4 Destroyed: test_dll_03 global
8 [main] test_dll_app_06 1900 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
1792 [main] test_dll_app_06 1900 open_stackdumpfile: Dumping stack trace to test_dll_app_06.exe.stackdump
Run test_dll_app_06 -n (Do not unload DLLs)
+ 0 Created : test_dll_app_06 global
+ 1 Registered atexit_funct: test_dll_app_06 global
+ 2 Created : test_dll_app_06 local static
+ 3 Registered atexit_funct: test_dll_app_06 local
Load test_dll_03 manually ...
+ 4 Created : test_dll_03 global
+ 5 Registered atexit_funct: test_dll_03 global
+ 6 Created : test_dll_03 local static do_it
+ 7 Registered atexit_funct: test_dll_03 local do_it
Load test_dll_01 manually from test_dll_03 ...
+ 8 Created : test_dll_01 global
+ 9 Registered atexit_funct: test_dll_01 global
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
Unload test_dll_01 manually from test_dll_03 ...
- 8 Destroyed: test_dll_01 global
- 4 Destroyed: test_dll_03 global
8 [main] test_dll_app_06 2024 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
1434 [main] test_dll_app_06 2024 open_stackdumpfile: Dumping stack trace to test_dll_app_06.exe.stackdump
Run test_dll_app_07
+ 0 Created : test_dll_04 global
+ 1 Registered atexit_funct: test_dll_04 global
+ 2 Created : test_dll_app_07 global
+ 3 Registered atexit_funct: test_dll_app_07 global
+ 4 Created : test_dll_app_07 local static
+ 5 Registered atexit_funct: test_dll_app_07 local
+ 6 Created : test_dll_04 local static do_it
+ 7 Registered atexit_funct: test_dll_04 local do_it
Load test_dll_01 manually from test_dll_04 ...
+ 8 Created : test_dll_01 global
+ 9 Registered atexit_funct: test_dll_01 global
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
- 0 Destroyed: test_dll_04 global
- 8 Destroyed: test_dll_01 global
- 11 Called atexit_funct: test_dll_01 local do_it
- 10 Destroyed: test_dll_01 local static do_it
- 9 Called atexit_funct: test_dll_01 global
- 7 Called atexit_funct: test_dll_04 local do_it
- 6 Destroyed: test_dll_04 local static do_it
- 5 Called atexit_funct: test_dll_app_07 local
- 4 Destroyed: test_dll_app_07 local static
- 2 Destroyed: test_dll_app_07 global
- 3 Called atexit_funct: test_dll_app_07 global
- 1 Called atexit_funct: test_dll_04 global
Run test_dll_app_08
+ 0 Created : test_dll_app_08 global
+ 1 Registered atexit_funct: test_dll_app_08 global
+ 2 Created : test_dll_app_08 local static
+ 3 Registered atexit_funct: test_dll_app_08 local
Load test_dll_04 manually ...
+ 4 Created : test_dll_04 global
+ 5 Registered atexit_funct: test_dll_04 global
+ 6 Created : test_dll_04 local static do_it
+ 7 Registered atexit_funct: test_dll_04 local do_it
Load test_dll_01 manually from test_dll_04 ...
+ 8 Created : test_dll_01 global
+ 9 Registered atexit_funct: test_dll_01 global
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
UnLoad test_dll_04 manually ...
- 4 Destroyed: test_dll_04 global
- 8 Destroyed: test_dll_01 global
- 11 Called atexit_funct: test_dll_01 local do_it
- 10 Destroyed: test_dll_01 local static do_it
- 9 Called atexit_funct: test_dll_01 global
4 [main] test_dll_app_08 2024 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
1477 [main] test_dll_app_08 2024 open_stackdumpfile: Dumping stack trace to test_dll_app_08.exe.stackdump
Run test_dll_app_08 -n (Do not unload DLLs)
+ 0 Created : test_dll_app_08 global
+ 1 Registered atexit_funct: test_dll_app_08 global
+ 2 Created : test_dll_app_08 local static
+ 3 Registered atexit_funct: test_dll_app_08 local
Load test_dll_04 manually ...
+ 4 Created : test_dll_04 global
+ 5 Registered atexit_funct: test_dll_04 global
+ 6 Created : test_dll_04 local static do_it
+ 7 Registered atexit_funct: test_dll_04 local do_it
Load test_dll_01 manually from test_dll_04 ...
+ 8 Created : test_dll_01 global
+ 9 Registered atexit_funct: test_dll_01 global
+ 10 Created : test_dll_01 local static do_it
+ 11 Registered atexit_funct: test_dll_01 local do_it
- 4 Destroyed: test_dll_04 global
- 8 Destroyed: test_dll_01 global
- 11 Called atexit_funct: test_dll_01 local do_it
- 10 Destroyed: test_dll_01 local static do_it
- 9 Called atexit_funct: test_dll_01 global
7 [main] test_dll_app_08 1900 _cygtls::handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
1720 [main] test_dll_app_08 1900 open_stackdumpfile: Dumping stack trace to test_dll_app_08.exe.stackdump
Regards,
Novo
|
|
|
Re: How to write a dll using Ultimate++? [message #11407 is a reply to message #11383] |
Tue, 11 September 2007 17:54 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
Novo wrote on Mon, 10 September 2007 13:08 |
Checked at home (I ran these tests two or three years back) ...
Windows MSVC v7.1
Windows cygwin gcc v3.4.4
Windows MinGW gcc v3.4.5
Linux GCC 3.4.0 (Slackware)
Solaris GCC v4.0.1
|
Checked at work (newer version of the test) ...
FreeBSD (4.x) GCC 3.4.2 ...
IRIX GCC 3.3.0 ...
IRIX MIPSpro73 ...
Linux (Slackware) GCC v3.4.0 ...
Linux (Slackware) ICC v9.0.0 ...
OSF1 GCC 3.3.2 ...
Solaris GCC v4.0.1 ...
Solaris 10 WorkShop v5.5 ...
Windows MSVC v7.1 ...
Windows MinGW gcc v3.4.5 ...
Windows cygwin gcc v3.4.4 ...
Regards,
Novo
|
|
|
Re: How to write a dll using Ultimate++? [message #11413 is a reply to message #11352] |
Tue, 11 September 2007 23:04 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
luzr wrote on Sat, 08 September 2007 10:24 | Have you tested with MSC?
Mirek
|
BTW, I also have performance test with embedded databases:
Sqlite;
MSJET (ODBC and ADO);
Firebird;
This test is quite simple and designed after a similar test for SQLITE.
If somebody is interested in benchmarks and comparing different implementations of database access layer I can upload it. I currently have only version for Windows.
Regards,
Novo
[Updated on: Wed, 12 September 2007 20:15] Report message to a moderator
|
|
|
|
|
|
Re: How to write a dll using Ultimate++? [message #11506 is a reply to message #11501] |
Sun, 16 September 2007 03:41 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
luzr wrote on Sat, 15 September 2007 18:54 |
Novo wrote on Tue, 11 September 2007 17:04 |
luzr wrote on Sat, 08 September 2007 10:24 | Have you tested with MSC?
Mirek
|
BTW, I also have performance test with embedded databases:
Sqlite;
MSJET (ODBC and ADO);
Firebird;
This test is quite simple and designed after a similar test for SQLITE.
If somebody is interested in benchmarks and comparing different implementations of database access layer I can upload it. I currently have only version for Windows.
|
I am always interested in benchmarks!
Mirek
|
Done.
http://www.ultimatepp.org/forum/index.php?t=msg&goto=115 05&#msg_11505
Regards,
Novo
|
|
|
|
Re: How to write a dll using Ultimate++? [message #11508 is a reply to message #11507] |
Sun, 16 September 2007 08:25 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Novo wrote on Sat, 15 September 2007 22:01 |
luzr wrote on Sat, 15 September 2007 18:53 | As for global vars and DLL, perhaps I was not specific.
The problem is not global var per see, but what you cannot do is to reference the global variable of other .dll.
In other words, "extern" does not work for data from another dll.
(It does with some trickery, witch involves converting the access to data to call to a function that returns a pointer to data).
Mirek
|
That is not a problem at all comparing to real problems.
That is some sort of small inconvenience. I believe you can export data from DLL using __declspec( dllexport ).
|
Well, AFAIK, you cannot with MSC.
Quote: |
Using of a function, which returns a pointer to data, is another solution.
|
Yes. Anyway, in some cases, this leads to much slower code. E.g. look into Core/Charset.h, to the set of definitions starting with IsLetter (there are two paths; for SO version you cannot use the inlines).
Mirek
|
|
|
Re: How to write a dll using Ultimate++? [message #11653 is a reply to message #11508] |
Thu, 20 September 2007 16:57 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
luzr wrote on Sun, 16 September 2007 02:25 |
Well, AFAIK, you cannot with MSC.
|
Check that with *Dependency Walker* yourself. I've attached an example.
Quote: |
Quote: |
Using of a function, which returns a pointer to data, is another solution.
|
Yes. Anyway, in some cases, this leads to much slower code. E.g. look into Core/Charset.h, to the set of definitions starting with IsLetter (there are two paths; for SO version you cannot use the inlines).
Mirek
|
Call to a function in DLL will always be a little bit slower. Same as with virtual functions. As usual, I have a test for this ...
Pointer to a function performance tests ...
Raw function: 0 sec.
Raw pointer to a function: 0.421 sec.
Boost.Function: 0.938 sec.
FastDelegate: 0.797 sec.
Pointer to a function in DLL performance tests ...
Raw function: 0.578 sec.
Raw pointer to a function: 0.594 sec.
Boost.Function: 0.937 sec.
FastDelegate: 0.75 sec.
Method call performance tests ...
Method call: 0 sec.
Raw pointer to a method: 0.391 sec.
Boost.Function: 0.719 sec.
FastDelegate: 0.406 sec.
Method call in DLL performance tests ...
Method call: 0.578 sec.
Raw pointer to a method: 0.609 sec.
Boost.Function: 0.735 sec.
FastDelegate: 0.578 sec.
Virtual method call performance tests ...
Virtual method call: 0.594 sec.
Raw pointer to a virtual method: 0.562 sec.
Boost.Function: 0.953 sec.
FastDelegate: 0.594 sec.
Virtual method call in DLL performance tests ...
Virtual method call: 0.609 sec.
Raw pointer to a virtual method: 0.563 sec.
Boost.Function: 0.922 sec.
FastDelegate: 0.593 sec.
Regards,
Novo
|
|
|
|
Re: How to write a dll using Ultimate++? [message #11660 is a reply to message #11658] |
Thu, 20 September 2007 22:16 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
luzr wrote on Thu, 20 September 2007 15:38 |
Quote: |
Call to a function in DLL will always be a little bit slower.
|
In this case it is not a normal call vs dll call, but inlining vs dll call. For very specific applications, the impact can be huge.
|
I won't argue with you. Words *huge*, *tremendous*, *incredible*, *very specific*, e.t.c. don't explain anything.
I've done my best. You have a DLL, which exports global data, and you have results of a test that clearly shows that there is no significant difference between call to a function in DLL and call via pointer to a function.
The rest is up to you.
Regards,
Novo
|
|
|
|
Re: How to write a dll using Ultimate++? [message #11673 is a reply to message #11660] |
Fri, 21 September 2007 01:40 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Novo wrote on Thu, 20 September 2007 16:16 |
luzr wrote on Thu, 20 September 2007 15:38 |
Quote: |
Call to a function in DLL will always be a little bit slower.
|
In this case it is not a normal call vs dll call, but inlining vs dll call. For very specific applications, the impact can be huge.
|
I won't argue with you. Words *huge*, *tremendous*, *incredible*, *very specific*, e.t.c. don't explain anything.
|
Haha, a very good point I wish I had a spare hour for the benchmark. Anyway, you are absolutely right that guts feeling does not work in most case where the code performance is involved
Mirek
|
|
|
Goto Forum:
Current Time: Sun Apr 28 14:15:22 CEST 2024
Total time taken to generate the page: 0.03221 seconds
|
|
|