first i would like to say hello as i'm new here (been lurking for some time).
Recently i started to mess with Python port and noticed that functions in libc do not set
errno when sce* functions fail. I think this is not ok as it may break programs that expect
non zero value in errno when function fails (it also helps to debug).
I implemented a naive approach to solve this problem in libcglue.c.
I implemented this function:
Code: Select all
#define __PSP_FACILITY_ERRNO (0x80010000)
static int psp_set_errno(int code)
{
if (code & 0x80000000)
{
if (code & __PSP_FACILITY_ERRNO)
{
code &= 0x0000FFFF;
switch(code)
{
case 0x24:
code = ENAMETOOLONG;
break;
case 0x62:
code = EADDRINUSE;
break;
case 0x67:
code = ECONNABORTED;
break;
case 0x6E:
code = ETIMEDOUT;
break;
case 0x7B:
code = ENOMEDIUM;
break;
}
}
errno = code;
return -1;
}
else
{
return code;
}
}
Code: Select all
int mkdir(const char *pathname, mode_t mode)
{
char dest[MAXPATHLEN + 1];
if(__psp_path_absolute(pathname, dest, MAXPATHLEN) < 0) {
errno = ENAMETOOLONG;
return -1;
}
return psp_set_errno(sceIoMkdir(dest, mode));
}
Would that be acceptable approach, or is there another way?
BR,
Robert