Author Topic: Compiling a PM sample with GCC (2023)  (Read 77162 times)

Lars

  • Hero Member
  • *****
  • Posts: 1263
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #150 on: June 05, 2023, 02:21:48 pm »
Try "DosSleep(1)" instead of "DosSleep(0)" in the drawing thread. That should already slow down things considerably.
DosSleep(0) will only yield the CPU if there is another thread of same or higher prio in the ready state (ready and waiting to be doing work).
DosSleep(1) will yield the CPU if there is another thread of any prio in the ready state. Since you typically have a bunch of daemons etc. running in the background that also schedule threads of idle (very low) prio, that should always trigger a yield.
And yielding means to give away your time slice and it takes the OS ages (in computer terms) to regain a time slice/next chance to execute the thread.
Might still not be enough on a multi-core system (where you have multiple CPUs that could do work ...).

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4759
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #151 on: June 05, 2023, 04:26:42 pm »
Yes, changing the DosSleep() to one at line 339 fixes the speed, about 33 frames/sec and can see the airplane on this 4 core I5.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4668
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #152 on: June 05, 2023, 05:18:12 pm »
Thanks for the feedback

Dave, I have DIVE.DLL on the libpath. I had tried in two enviroments, the development VM and a Thinkpad L420 and in both I can not see any image on the window.

I'm attaching the "Query Caps" of the Thinkpad L420. should I can try putting the colors on 64K?
Update: Indeed, I changed it to 64K and now I can see the image (very fast)

I will check Lars' suggestion to see if it slows down.

Regards
« Last Edit: June 05, 2023, 05:22:18 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4668
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #153 on: June 05, 2023, 11:02:59 pm »
Hello

Thanks for the feedback. The show sample (Jet) is working fine.
https://github.com/OS2World/DEV-SAMPLES-C-PM-DIVE-ShowJet

My only question remains, why it does not work on 16M Colors? Is some limitation there that I don't know? I always used to set the colors to 16M and didn't have any problems that I can notice, until working with this sample.

Regards
« Last Edit: June 06, 2023, 12:01:55 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4759
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #154 on: June 06, 2023, 02:30:12 am »
Tested here with 16m colours, same results as you except one of the options, Dive Blitter I think it was, froze the system and after 10-15 seconds crashed,
Code: [Select]
06-05-2023  16:08:07  SYS3175  PID 0065  TID 0003  Slot 0080
H:\TMP\SHOW_DIVE_B1\SHOW.EXE
c0000005
1fe22505
P1=00000001  P2=00000000  P3=XXXXXXXX  P4=XXXXXXXX
EAX=02a83880  EBX=00000000  ECX=00000140  EDX=00000500
ESI=00000000  EDI=02a83880
DS=0053  DSACC=d0f3  DSLIM=9fffffff
ES=0053  ESACC=d0f3  ESLIM=9fffffff
FS=150b  FSACC=00f3  FSLIM=00000030
GS=0000  GSACC=****  GSLIM=********
CS:EIP=005b:1fe22505  CSACC=d0df  CSLIM=9fffffff
SS:ESP=0053:03271f20  SSACC=d0f3  SSLIM=9fffffff
EBP=03271ff4  FLG=00010202

LIBCN0.DLL 0001:00082505

Perhaps Lars has an idea.

Flashback

  • Newbie
  • *
  • Posts: 6
  • Karma: +3/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #155 on: June 06, 2023, 06:38:20 pm »
My only question remains, why it does not work on 16M Colors?
Because support for 32bits per pixel is not fully implemented in DIVE. You may want to try the attached patch...

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4668
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #156 on: June 07, 2023, 04:09:39 am »
Thanks Flashback.

It run fine here with 16M Colors on the VM.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4668
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #157 on: June 07, 2023, 04:19:10 am »
Hi

Now I'm trying framctlit is a nice sample.
https://github.com/OS2World/DEV-SAMPLES-C-PM-framctl

It compiles, and removed all warnings I can, but I still get this warning on framctl3.

Quote
gcc -Wall -Zomf -c -O2 framectl.c -o framectl.obj
framectl.c: In function 'FrameWndProc':
framectl.c:363:14: warning: unused variable 'rc' [-Wunused-variable]
  363 |         BOOL rc = (BOOL)DefFrameWndProc( hWnd, msg, mp1, mp2 );
      |              ^~
Even that is says the variable is unused, if I comment rc, the sample does not longer run. I need to keep this line and warning to have the sample working. Any ideas if there is something else I can do to remove this warning?

Regards
« Last Edit: June 07, 2023, 04:35:44 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4759
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #158 on: June 07, 2023, 05:18:19 am »
Add -Wno-unused-variable to the CFLAGS.
Code: [Select]
--- makefile.orig       2023-06-06 20:15:24.000000000 -0700
+++ makefile    2023-06-06 20:15:58.000000000 -0700
@@ -12,7 +12,7 @@


 framectl.obj : framectl.c framectl.h
-       gcc -Wall -Zomf -c -O2 framectl.c -o framectl.obj
+       gcc -Wall -Zomf -c -O2 -Wno-unused-variable framectl.c -o framectl.obj

 framectl.res : framectl.rc
        wrc -r framectl.rc

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4759
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #159 on: June 07, 2023, 05:26:44 am »
This works as well,
Code: [Select]
--- FRAMECTL.C.orig     2023-06-06 20:22:56.000000000 -0700
+++ FRAMECTL.C  2023-06-06 20:23:04.000000000 -0700
@@ -360,7 +360,7 @@
         /******************************************************************/
         /* Allow default proc to draw all of the frame.                   */
         /******************************************************************/
-        BOOL rc = (BOOL)DefFrameWndProc( hWnd, msg, mp1, mp2 );
+        DefFrameWndProc( hWnd, msg, mp1, mp2 );

         /******************************************************************/
         /* Get presentation space handle for drawing.                     */

But as Lars said, sometimes these variables should be left in as they may be needed for error checking at some point. The toolkit documentation often shows rc = foo()

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4668
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #160 on: June 07, 2023, 06:24:32 pm »
Thanks Dave.

I made your changes and I think it is good enough for the sample.

It's done for me, and I posted it here  to the public.
https://github.com/OS2World/DEV-SAMPLES-C-PM-framctl

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4668
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #161 on: June 07, 2023, 06:54:26 pm »
Hi

Now I'm going after this one:
https://github.com/OS2World/DEV-SAMPLES-C-PM-ListBox2

I haven't fixed the warnings yet. I focused on having the program to compile first. After some effort DRIVER.EXE and LISTBOX.DLL are compiling, but DRIVER.EXE is not showing anything.

I get this on the POPUPLOG
Quote
06-07-2023  11:42:01  SYS2070  PID 017a  TID 0001  Slot 0084
C:\DEV\DEV-SAMPLES-C-PM-LISTBOX2\DRIVER.EXE
DRIVER->LISTBOX.1
182

Any help to show the sample is welcome, if that can be possible, I will go after the warnings.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4759
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #162 on: June 08, 2023, 02:18:34 am »
Your sys2070 says that there is something wrong with the 1st export, ordinal 1, in listbox.dll. Looking at LISTBOX.DEF, there are no exports. Looking at IBM.LNK, it references IBM.DEF which has this,
Code: [Select]
EXPORTS        fRegisterListBox @ 1

solutions, add the above to the end of LISTBOX.DEF or copy IBM.DEF to LISTBOX.DEF or change the makefile to reference IBM.DEF. IBM.DEF will need the protmode option removed.
Personally I prefer using IBM.DEF, as it is for one of the IBM compilers.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4759
  • Karma: +97/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #163 on: June 08, 2023, 06:18:51 am »
I built the DLL with OW and then used it to link the GCC compiled driver.exe, worked fine except wmake did not like the backslash in the objs line. No warnings either.
Edit: the git patch. OS2World wouldn't let me upload the patch until I added a .txt. Seems patches should be allowed.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4668
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #164 on: June 08, 2023, 07:31:41 pm »
Thanks Dave

With your tip it compiles and the sample runs just using with gcc. I have a lot of warning that I have to check, I think I will turn crazy with the braces.

FYI: This little picture helps me with my English, I learned to code in C long time ago in Spanish. And it had been fun to re-learn that stuff.
« Last Edit: June 08, 2023, 10:12:28 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.