| View previous topic :: View next topic |
| Author |
Message |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Thu Dec 22, 2005 9:46 pm Post subject: pspsdk strncat broken |
|
|
I've been having some trouble with peldet running out of memory when using newlib, so I decided I'd try the pspsdk libc.
(I seem to recall someone saying that newlib mallocs the largest amount of memory it can and then just assigns from there?)
First thing that hit me was there is no sscanf, that was easy to fix (I wrote some extra code using strtol instead)
This got it compiled and running. It got as far as the first time strncat is called, then the output got a little weird.
Heres strncat from the sdk:
( /trunk/pspsdk/src/libc/string.c - Rev 1486 )
| Code: | #ifdef F_strncat
char *strncat(char *s, const char *append, size_t count)
{
char *pRet = s;
while(*s)
{
s++;
}
while((*append) && (count > 0))
{
*s++ = *append++;
}
*s = 0;
return pRet;
}
#endif |
I think that count needs to be decreased in the while loop.
I'd fix it and test but the toolchain.sh installer doesn't seem to keep a copy of the svn locally and being almost 1am I think its better to leave it in someone elses capable hands while I sleep... |
|
| Back to top |
|
 |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Fri Dec 23, 2005 8:08 am Post subject: |
|
|
Yep, decreasing count in that loop gets it working correctly.
Heres a diff:
| Code: | --- pspsdk_copy/src/libc/string.c 2005-12-23 10:05:41.000000000 +1300
+++ pspsdk/src/libc/string.c 2005-12-23 10:18:27.000000000 +1300
@@ -79,6 +79,7 @@ char *strncat(char *s, const char *appen
while((*append) && (count > 0))
{
*s++ = *append++;
+ count--;
}
*s = 0;
|
|
|
| Back to top |
|
 |
mrbrown
Joined: 17 Jan 2004 Posts: 1536
|
Posted: Fri Dec 23, 2005 10:20 am Post subject: Re: pspsdk strncat broken |
|
|
| danzel wrote: | I've been having some trouble with peldet running out of memory when using newlib, so I decided I'd try the pspsdk libc.
(I seem to recall someone saying that newlib mallocs the largest amount of memory it can and then just assigns from there?) |
For the record, PSPSDK's libc uses the same _sbrk() that newlib does, so they both will try to allocate all of the available system heap unless you instruct them not to.
You can use the PSP_HEAP_SIZE_KB() in pspmoduleinfo.h to explicitly set the heap size. |
|
| Back to top |
|
 |
fl0w
Joined: 09 Dec 2005 Posts: 5
|
Posted: Fri Dec 23, 2005 8:13 pm Post subject: Re: pspsdk strncat broken |
|
|
| danzel wrote: |
I'd fix it and test but the toolchain.sh installer doesn't seem to keep a copy of the svn locally and being almost 1am I think its better to leave it in someone elses capable hands while I sleep... |
I personnally find it very annoying that the script does a checkout each time and then deletes the sources of the sdk (including the samples). I fond very handy to have the sources. Moreover, doing a checkout each time the sdk is being updated is a waste of bandwidth and compilation time.
I think the script has options to keep the sources of gcc, but not those of pspsdk.
If nobody does it before next year :) I can modify the script (if everyone is OK, of course). |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Fri Dec 23, 2005 9:40 pm Post subject: Re: pspsdk strncat broken |
|
|
| fl0w wrote: | | I personnally find it very annoying that the script does a checkout each time and then deletes the sources of the sdk |
Then check it out yourself and use the --pspsdk-src option to point to it. |
|
| Back to top |
|
 |
fl0w
Joined: 09 Dec 2005 Posts: 5
|
Posted: Fri Dec 23, 2005 10:14 pm Post subject: |
|
|
| Aaaah thanks, jimparis ! |
|
| Back to top |
|
 |
weltall
Joined: 20 Feb 2004 Posts: 310
|
Posted: Fri Dec 23, 2005 10:24 pm Post subject: |
|
|
| or just edit the toolchain script to don't delete it :P |
|
| Back to top |
|
 |
fl0w
Joined: 09 Dec 2005 Posts: 5
|
Posted: Fri Dec 23, 2005 10:33 pm Post subject: |
|
|
| weltall wrote: | | or just edit the toolchain script to don't delete it :P |
that's what i've done in the first place, but the toolchain sometimes gets updated so it's not the best solution... |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sat Dec 24, 2005 11:45 am Post subject: |
|
|
| As long as you have a svn checkout of pspsdk you should be able to pass the -P parameter to the toolchain script (passing a directory containing the svn'ed pspsdk after it) and the toolchain script should use that instead of downloading it each time. |
|
| Back to top |
|
 |
|