C68 4k Buffers on Stack SMSq/e

Anything QL Software or Programming Related.
User avatar
XorA
Super Gold Card
Posts: 510
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

C68 4k Buffers on Stack SMSq/e

Postby XorA » Thu Dec 14, 2017 4:42 pm

Are there any known issues with the combo in the topic?

Trying to debug a difference in behaviour in a program between Qemulator and QPC2 and narrowed it down to a 4k buffer as a local variable which seems to be corrupting something to do with file handling. When I move the buffer to a global variable it moves the issue to the next place a 4k buffer is used locally.

Before I replace these with malloc I thought I would check with the QDOS gods!


User avatar
tofro
QL Wafer Drive
Posts: 1378
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: C68 4k Buffers on Stack SMSq/e

Postby tofro » Thu Dec 14, 2017 5:14 pm

What's the dataspace you have given to that job?

What's the value of the global variable _stack (that's the stack size given to your job, and default is 2kBytes only)?

Tobias


User avatar
XorA
Super Gold Card
Posts: 510
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: C68 4k Buffers on Stack SMSq/e

Postby XorA » Thu Dec 14, 2017 5:29 pm

tofro wrote:What's the dataspace you have given to that job?


Whatever C68 said it was in the Xtcc field

What's the value of the global variable _stack (that's the stack size given to your job, and default is 2kBytes only)?


That would certainly explain the problem as the stack of the program is certainly well over 16k (old unix program).

Id have to look at the value when Im next at devel machine!


User avatar
tofro
QL Wafer Drive
Posts: 1378
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: C68 4k Buffers on Stack SMSq/e

Postby tofro » Thu Dec 14, 2017 5:51 pm

Simply increase the stack space of your program by placing an

Code: Select all

extern long _stack = 16384;


declaration somewhere in your program (to set the stack to 16k, for example) and you're done.

Tobias


User avatar
XorA
Super Gold Card
Posts: 510
Joined: Thu Jun 02, 2011 11:31 am
Location: Shotts, North Lanarkshire, Scotland, UK

Re: C68 4k Buffers on Stack SMSq/e

Postby XorA » Thu Dec 14, 2017 5:57 pm

Thanks Tobias, saved me hours of puzzling ;-)

Is this info somewhere modern PC readable these days? Trying to apply my *nix C skills to QL!


User avatar
tofro
QL Wafer Drive
Posts: 1378
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: C68 4k Buffers on Stack SMSq/e

Postby tofro » Thu Dec 14, 2017 6:05 pm

Dilwyn has some of the C68 manuals on his homepage as e-book and pdf here:

http://www.dilwyn.me.uk/docs/ebooks/index.html

Tobias



Return to “Software & Programming”

Who is online

Users browsing this forum: No registered users and 2 guests