[Cbe-oss-dev] [PATCH] libspe2 fix 64 bit posix assist calls using time values

Patrick Mansfield patmans at us.ibm.com
Wed Jul 4 02:54:45 EST 2007


The new calls I added that use time variables did not account for the size
change when built with m64, use spe comptabile structures to fix the
problems.

This fixes nanosleep, utime and utimes when run with 64 bit libspe2.

Signed-off-by: Patrick Mansfield <patmans at us.ibm.com>

Index: quilt-libspe2/spebase/default_posix1_handler.c
===================================================================
--- quilt-libspe2.orig/spebase/default_posix1_handler.c
+++ quilt-libspe2/spebase/default_posix1_handler.c
@@ -200,6 +200,16 @@ struct spe_compat_timezone {
     int  tz_dsttime;   
 };
 
+struct spe_compat_timespec {
+    int tv_sec;
+    int tv_nsec;
+};
+
+struct spe_compat_utimbuf {
+    int actime;
+    int modtime;
+};
+
 /* SPE-compatable timex structure. */
 struct spe_compat_timex {
         unsigned int modes;
@@ -1296,18 +1306,28 @@ int default_posix1_handler_nanosleep(cha
 {
     DECL_2_ARGS();
     DECL_RET();
-    struct timespec *req;
-    struct timespec *rem;
+    struct spe_compat_timespec *spereq;
+    struct spe_compat_timespec *sperem;
+    struct timespec req;
+    struct timespec rem, *remp;
     int rc;
 
     DEBUG_PRINTF("%s\n", __func__);
-    req = GET_LS_PTR(arg0->slot[0]);
+    spereq = GET_LS_PTR(arg0->slot[0]);
+    req.tv_sec = spereq->tv_sec;
+    req.tv_nsec = spereq->tv_nsec;
     if (arg1->slot[0] == 0) {
-        rem = NULL;
+        sperem = NULL;
+        remp = NULL;
     } else {
-        rem = GET_LS_PTR(arg1->slot[0]);
+        sperem = GET_LS_PTR(arg1->slot[0]);
+        remp = &rem;
+    }
+    rc = nanosleep(&req, remp);
+    if (remp) {
+        sperem->tv_sec = remp->tv_sec;
+        sperem->tv_nsec = remp->tv_nsec;
     }
-    rc = nanosleep(req, rem);
     PUT_LS_RC(rc, 0, 0, errno);
     return 0;
 }
@@ -2048,13 +2068,16 @@ int default_posix1_handler_utime(char *l
     DECL_2_ARGS();
     DECL_RET();
     char *filename;
-    struct utimbuf *buf;
+    struct utimbuf buf;
+    struct spe_compat_utimbuf *spebuf;
     int rc;
 
     DEBUG_PRINTF("%s\n", __func__);
     filename = GET_LS_PTR(arg0->slot[0]);
-    buf = GET_LS_PTR(arg1->slot[0]);
-    rc = utime(filename, buf);
+    spebuf = GET_LS_PTR(arg1->slot[0]);
+    buf.actime = spebuf->actime;
+    buf.modtime = spebuf->modtime;
+    rc = utime(filename, &buf);
     PUT_LS_RC(rc, 0, 0, errno);
     return 0;
 }
@@ -2072,12 +2095,17 @@ int default_posix1_handler_utimes(char *
     DECL_2_ARGS();
     DECL_RET();
     char *filename;
-    struct timeval *times;
+    struct spe_compat_timeval *spetimes;
+    struct timeval times[2];
     int rc;
 
     DEBUG_PRINTF("%s\n", __func__);
     filename = GET_LS_PTR(arg0->slot[0]);
-    times = GET_LS_PTR(arg1->slot[0]);
+    spetimes = GET_LS_PTR(arg1->slot[0]);
+    times[0].tv_sec = spetimes[0].tv_sec;
+    times[0].tv_usec = spetimes[0].tv_usec;
+    times[1].tv_sec = spetimes[1].tv_sec;
+    times[1].tv_usec = spetimes[1].tv_usec;
     rc = utimes(filename, times);
     PUT_LS_RC(rc, 0, 0, errno);
     return 0;



More information about the cbe-oss-dev mailing list