Fix cut-to-width in the presence of bad constants in dead code.
[sbcl.git] / src / runtime / wrap.c
index 8493bf6..7c88568 100644 (file)
@@ -38,7 +38,9 @@
 
 #ifndef LISP_FEATURE_WIN32
 #include <pwd.h>
+#include <time.h>
 #include <sys/wait.h>
+#include <sys/resource.h>
 #include <netdb.h>
 #endif
 #include <stdio.h>
@@ -118,7 +120,7 @@ char * sb_realpath (char *path)
 
     if ((ret = calloc(MAX_PATH, sizeof(char))) == NULL)
         return NULL;
-    if (GetFullPathName(path, MAX_PATH, ret, cp) == 0) {
+    if (GetFullPathName(path, MAX_PATH, ret, &cp) == 0) {
         errnum = errno;
         free(ret);
         errno = errnum;
@@ -317,10 +319,9 @@ uid_username(int uid)
 }
 
 char *
-uid_homedir(uid_t uid)
+passwd_homedir(struct passwd *p)
 {
-    struct passwd *p = getpwuid(uid);
-    if(p) {
+    if (p) {
         /* Let's be careful about this, shall we? */
         size_t len = strlen(p->pw_dir);
         if (p->pw_dir[len-1] == '/') {
@@ -342,6 +343,18 @@ uid_homedir(uid_t uid)
         return 0;
     }
 }
+
+char *
+user_homedir(char *name)
+{
+    return passwd_homedir(getpwnam(name));
+}
+
+char *
+uid_homedir(uid_t uid)
+{
+    return passwd_homedir(getpwuid(uid));
+}
 #endif /* !LISP_FEATURE_WIN32 */
 \f
 /*
@@ -365,7 +378,7 @@ wrapped_environ()
  * faked-up implementation of select(). Right now just enough to get through
  * second genesis.
  */
-int select(int top_fd, DWORD *read_set, DWORD *write_set, DWORD *except_set, time_t *timeout)
+int sb_select(int top_fd, DWORD *read_set, DWORD *write_set, DWORD *except_set, time_t *timeout)
 {
     /*
      * FIXME: Going forward, we may want to use MsgWaitForMultipleObjects
@@ -412,10 +425,18 @@ int select(int top_fd, DWORD *read_set, DWORD *write_set, DWORD *except_set, tim
  * yet, however, and the closest we can easily get to a timeval is the
  * seconds part. So that's what we do.
  */
-int gettimeofday(long *timeval, long *timezone)
+#define UNIX_EPOCH_FILETIME 116444736000000000ULL
+
+int sb_gettimeofday(long *timeval, long *timezone)
 {
-    timeval[0] = time(NULL);
-    timeval[1] = 0;
+    FILETIME ft;
+    ULARGE_INTEGER uft;
+    GetSystemTimeAsFileTime(&ft);
+    uft.LowPart = ft.dwLowDateTime;
+    uft.HighPart = ft.dwHighDateTime;
+    uft.QuadPart -= UNIX_EPOCH_FILETIME;
+    timeval[0] = uft.QuadPart / 10000000;
+    timeval[1] = (uft.QuadPart % 10000000)/10;
 
     return 0;
 }
@@ -493,3 +514,37 @@ int s_issock(mode_t mode)
 #endif
 }
 #endif /* !LISP_FEATURE_WIN32 */
+
+#ifndef LISP_FEATURE_WIN32
+int sb_getrusage(int who, struct rusage *rusage)
+{
+        return getrusage(who, rusage);
+}
+
+int sb_gettimeofday(struct timeval *tp, void *tzp)
+{
+        return gettimeofday(tp, tzp);
+}
+
+int sb_nanosleep(struct timespec *rqtp, struct timespec *rmtp)
+{
+        return nanosleep(rqtp, rmtp);
+}
+
+int sb_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+    struct timeval *timeout)
+{
+        return select(nfds, readfds, writefds, exceptfds, timeout);
+}
+
+int sb_getitimer(int which, struct itimerval *value)
+{
+        return getitimer(which, value);
+}
+
+int sb_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
+{
+        return setitimer(which, value, ovalue);
+}
+#endif /* !LISP_FEATURE_WIN32 */
+