when calling time(NULL) error linking in pspsdk

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
binch
Posts: 28
Joined: Tue Jul 04, 2006 4:17 pm
Location: China

when calling time(NULL) error linking in pspsdk

Post by binch »

psp-gcc -I. -I/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -L. -L/psp/sdk/lib main.o my.o -lpspumd -lSDL -ljpeg -lpspgu -lpspaudio -lpsphprm -lpng -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o dumper.elf
/lib/gcc/psp/4.1.0/../../../../psp/lib/libc.a(lib_a-timer.o): In function `_times_r':
../../../../../newlib/libc/reent/timer.c:64: undefined reference to `_times'
collect2: ld returned 1 exit status
make: *** [dumper.elf] Error 1

Anybody encounter this before?

thx

bin
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

im not sure....

try linking you're project with the kernel libc instead
- be2003
blog
nataku92
Posts: 5
Joined: Tue Dec 27, 2005 10:33 am

Post by nataku92 »

Hi,

I'm also having the same problem as the topic creator. How would I link my project with the kernel libc?

Thanks
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

This looks like a toolchain regression, probably in the newlib 1.15 patch.

ooPo, I'm having a bit of trouble following the newlib stuff currently in svn.
Did we stop using the drop-in trees for some reason? How do we modify and regenerate newlib-1.15.0.patch in that case?
anhanguera
Posts: 31
Joined: Thu Aug 26, 2004 4:20 pm

Post by anhanguera »

hi,

_times() function should be added to a seperate file (syscalls.c ?!). anyway here is a quick and ugly workaround....

Code: Select all

Index: newlib-psp/newlib/libc/sys/psp/pipe.c
===================================================================
--- newlib-psp/newlib/libc/sys/psp/pipe.c  (revision 2233)
+++ newlib-psp/newlib/libc/sys/psp/pipe.c  (working copy)
@@ -234,3 +234,8 @@
        }
 }

+int __psp_set_errno(int code);
+time_t _times(time_t *t)
+{
+       return __psp_set_errno(sceKernelLibcTime(t));
+}
or,

Code: Select all

Index: psptoolchain/patches/newlib-1.15.0-PSP.patch
===================================================================
--- psptoolchain/patches/newlib-1.15.0-PSP.patch     (revision 2233)
+++ psptoolchain/patches/newlib-1.15.0-PSP.patch     (working copy)
@@ -7484,7 +7484,7 @@
 diff -burN newlib-1.15.0/newlib/libc/sys/psp/pipe.c newlib-psp/newlib/libc/sys/psp/pipe.c
 --- newlib-1.15.0/newlib/libc/sys/psp/pipe.c   1970-01-01 01:00:00.000000000 +0100
 +++ newlib-psp/newlib/libc/sys/psp/pipe.c      2007-03-10 18:02:39.000000000 +0100
-@@ -0,0 +1,271 @@
+@@ -0,0 +1,277 @@
 +/*
 + * PSP Software Development Kit - http://www.pspdev.org
 + * -----------------------------------------------------------------------
@@ -7756,6 +7756,12 @@
 +      }
 +}
 +
++int __psp_set_errno(int code);
++time_t _times(time_t *t)
++{
++      return __psp_set_errno(sceKernelLibcTime(t));
++}
++
 diff -burN newlib-1.15.0/newlib/libc/sys/psp/pspcwd.c newlib-psp/newlib/libc/sys/psp/pspcwd.c
 --- newlib-1.15.0/newlib/libc/sys/psp/pspcwd.c 1970-01-01 01:00:00.000000000 +0100
 +++ newlib-psp/newlib/libc/sys/psp/pspcwd.c    2007-03-10 18:02:39.000000000 +0100
anhanguera.
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

jimparis wrote:ooPo, I'm having a bit of trouble following the newlib stuff currently in svn. Did we stop using the drop-in trees for some reason? How do we modify and regenerate newlib-1.15.0.patch in that case?
Uhm, I hadn't seen much activity with it so I assumed it wasn't really useful for people. I had been planning to just merge new patches manually.

So no real good reason, at least. We can certainly go back to using the trees if you like. :)
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

anhanguera wrote:_times() function should be added to a seperate file (syscalls.c ?!). anyway here is a quick and ugly workaround....
I've merged this into newlib-1.15.0-PSP.patch in the repository.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Ugh, pipe.c is definitely not the right place for that :P

If we're not using drop in trees (which is fine with me), we should delete it from the repository. Maybe a readme describing how to regenerate the patch would be useful. I don't know the best way, maybe: Unpack newlib, make a copy, apply the psp patch, make edits, then diff the two copies?
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

Perhaps pipe.c is a bad place for it, but until a better place is decided we have working code. It is a small change that can be easily removed later.

In the meantime, I'll do up a howto for making patches and how to submit them.
anhanguera
Posts: 31
Joined: Thu Aug 26, 2004 4:20 pm

Post by anhanguera »

i would like to pute _times(..) to a seperated file syscalls.c but there is something with my autoconf, version mismatch i think. when i generate .in and configure files with autotools ./configure gives strange errors in newlib.
Post Reply