diff --git a/src/libcglue/glue.c b/src/libcglue/glue.c index 2c93e999..0a466f08 100644 --- a/src/libcglue/glue.c +++ b/src/libcglue/glue.c @@ -703,7 +703,18 @@ void * _sbrk(ptrdiff_t incr) #ifdef F__gettimeofday int _gettimeofday(struct timeval *tp, struct timezone *tzp) { - return __set_errno(sceKernelLibcGettimeofday(tp, tzp)); + int ret; + struct SceKernelTimeval pspTimeval; + + ret = __set_errno(sceKernelLibcGettimeofday(&pspTimeval, tzp)); + if (ret < 0) + return ret; + + /* Return the actual time since epoch */ + tp->tv_sec = pspTimeval.tv_sec; + tp->tv_usec = pspTimeval.tv_usec; + + return 0; } #endif diff --git a/src/libcglue/select.c b/src/libcglue/select.c index 439f2ffe..ce35841d 100644 --- a/src/libcglue/select.c +++ b/src/libcglue/select.c @@ -31,7 +31,7 @@ static int __poll_select(int n, fd_set *readfds, fd_set *writefds, fd_set *excep fd_set ready_readfds, ready_writefds, ready_exceptfds; fd_set scereadfds, scewritefds; SceKernelMppInfo info; - struct timeval scetv; + struct SceNetInetTimeval scetv; FD_ZERO(&ready_readfds); FD_ZERO(&ready_writefds); diff --git a/src/net/pspnet_inet.h b/src/net/pspnet_inet.h index 611a305f..6b52554a 100644 --- a/src/net/pspnet_inet.h +++ b/src/net/pspnet_inet.h @@ -18,8 +18,17 @@ extern "C" { #endif +/** + * This struct is needed because tv_sec size is different from what newlib expect + * Newlib expects 64bits for seconds and PSP expects 32bits + */ +struct SceNetInetTimeval { + uint32_t tv_sec; + uint32_t tv_usec; +}; + int sceNetInetInit(void); -int sceNetInetSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +int sceNetInetSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct SceNetInetTimeval *timeout); int sceNetInetTerm(void); int sceNetInetGetErrno(void); diff --git a/src/user/psputils.h b/src/user/psputils.h index cc5eeb6f..3f77f331 100644 --- a/src/user/psputils.h +++ b/src/user/psputils.h @@ -30,6 +30,15 @@ extern "C" { #include +/** + * This struct is needed because tv_sec size is different from what newlib expect + * Newlib expects 64bits for seconds and PSP expects 32bits + */ +typedef struct SceKernelTimeval { + uint32_t tv_sec; + uint32_t tv_usec; +} SceKernelTimeval; + /** * Get the time in seconds since the epoc (1st Jan 1970) * @@ -44,7 +53,7 @@ clock_t sceKernelLibcClock(void); /** * Get the current time of time and time zone information */ -int sceKernelLibcGettimeofday(struct timeval *tp, struct timezone *tzp); +int sceKernelLibcGettimeofday(struct SceKernelTimeval *tp, struct timezone *tzp); /** * Write back the data cache to memory