forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pspsdk strncat broken

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Thu Dec 22, 2005 9:46 pm    Post subject: pspsdk strncat broken Reply with quote

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
View user's profile Send private message
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Fri Dec 23, 2005 8:08 am    Post subject: Reply with quote

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
View user's profile Send private message
mrbrown



Joined: 17 Jan 2004
Posts: 1536

PostPosted: Fri Dec 23, 2005 10:20 am    Post subject: Re: pspsdk strncat broken Reply with quote

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
View user's profile Send private message
fl0w



Joined: 09 Dec 2005
Posts: 5

PostPosted: Fri Dec 23, 2005 8:13 pm    Post subject: Re: pspsdk strncat broken Reply with quote

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
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Fri Dec 23, 2005 9:40 pm    Post subject: Re: pspsdk strncat broken Reply with quote

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
View user's profile Send private message
fl0w



Joined: 09 Dec 2005
Posts: 5

PostPosted: Fri Dec 23, 2005 10:14 pm    Post subject: Reply with quote

Aaaah thanks, jimparis !
Back to top
View user's profile Send private message
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Fri Dec 23, 2005 10:24 pm    Post subject: Reply with quote

or just edit the toolchain script to don't delete it :P
Back to top
View user's profile Send private message Visit poster's website
fl0w



Joined: 09 Dec 2005
Posts: 5

PostPosted: Fri Dec 23, 2005 10:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Sat Dec 24, 2005 11:45 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group