Check for getuid and cope when it's not there.

The ps3toolchain doesn't have getuid or getpwent. Nor does it have
timeGetTime, so use Sys_DoubleTime instead.
This commit is contained in:
Bill Currie 2012-08-18 21:37:54 +09:00
parent 6200d35109
commit 3b047a3cc1
2 changed files with 12 additions and 6 deletions

View file

@ -10,8 +10,8 @@ AC_FUNC_VPRINTF
AC_FUNC_VA_COPY
AC_FUNC__VA_COPY
AC_CHECK_FUNCS(
access _access gethostname gethostbyname connect gettimeofday getwd \
mkdir _mkdir ftime _ftime fcntl stat putenv select socket strerror \
access _access gethostname gethostbyname connect gettimeofday getuid \
getwd mkdir _mkdir ftime _ftime fcntl stat putenv select socket strerror \
strcasestr strnlen strstr snprintf _snprintf vsnprintf _vsnprintf \
strsep dlopen getaddrinfo getnameinfo mprotect getpagesize
)

View file

@ -488,10 +488,10 @@ VISIBLE int
Sys_TimeID (void) //FIXME I need a new name, one that doesn't make me feel 3 feet thick
{
int val;
#ifdef _WIN32
val = ((int) (timeGetTime () * 1000) * time (NULL)) & 0xffff;
#else
#ifdef HAVE_GETUID
val = ((int) (getpid () + getuid () * 1000) * time (NULL)) & 0xffff;
#else
val = ((int) (Sys_DoubleTime () * 1000) * time (NULL)) & 0xffff;
#endif
return val;
}
@ -813,10 +813,12 @@ Sys_CreatePath (const char *path)
char *
Sys_ExpandSquiggle (const char *path)
{
char *home;
const char *home;
#ifndef _WIN32
# ifdef HAVE_GETUID
struct passwd *pwd_ent;
# endif
#endif
if (strncmp (path, "~/", 2) != 0) {
@ -830,10 +832,14 @@ Sys_ExpandSquiggle (const char *path)
if (!home || !home[0])
home = getenv ("WINDIR");
#else
# ifdef HAVE_GETUID
if ((pwd_ent = getpwuid (getuid ()))) {
home = pwd_ent->pw_dir;
} else
home = getenv ("HOME");
# else
home = ""; //FIXME configurable?
# endif
#endif
if (home)