[Cbe-oss-dev] [PATCH] libspe2 add assist calls for sched_yield, umask, utime and utimes
Patrick Mansfield
patmans at us.ibm.com
Tue Jun 19 09:42:19 EST 2007
OK re-post, only change is to remove the leftover "is this correct" comment.
Add assist calls for:
int sched_yield(void)
mode_t umask(mode_t mask)
int utime(const char *filename, const struct utimbuf *buf)
int utimes(const char *filename, const struct timeval times[2])
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
@@ -37,6 +37,7 @@
#include <stdint.h>
#include <pthread.h>
#include <dirent.h>
+#include <utime.h>
#include "default_posix1_handler.h"
#include "handler_utils.h"
@@ -151,6 +152,10 @@ enum {
SPE_POSIX1_REWINDDIR,
SPE_POSIX1_SEEKDIR,
SPE_POSIX1_TELLDIR,
+ SPE_POSIX1_SCHED_YIELD,
+ SPE_POSIX1_UMASK,
+ SPE_POSIX1_UTIME,
+ SPE_POSIX1_UTIMES,
SPE_POSIX1_LAST_OPCODE,
};
#define SPE_POSIX1_NR_OPCODES \
@@ -1959,6 +1964,96 @@ int default_posix1_handler_telldir(char
return 0;
}
+/**
+ * default_posix1_handler_sched_yield
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data
+ *
+ * Implement:
+ * int sched_yield(void)
+ */
+int default_posix1_handler_sched_yield(char *ls, unsigned long opdata)
+{
+ DECL_0_ARGS();
+ DECL_RET();
+ /*
+ * The kernel will call spu_yield internally, so do nothing here.
+ */
+ DEBUG_PRINTF("%s\n", __func__);
+ PUT_LS_RC(0, 0, 0, 0);
+ return 0;
+}
+
+/**
+ * default_posix1_handler_umask
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data
+ *
+ * Implement:
+ * mode_t umask(mode_t mask)
+ */
+int default_posix1_handler_umask(char *ls, unsigned long opdata)
+{
+ DECL_1_ARGS();
+ DECL_RET();
+ mode_t mask;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ mask = arg0->slot[0];
+ rc = umask(mask);
+ PUT_LS_RC(rc, 0, 0, errno);
+ return 0;
+}
+
+/**
+ * default_posix1_handler_utime
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int utime(const char *filename, const struct utimbuf *buf)
+ */
+int default_posix1_handler_utime(char *ls, unsigned long opdata)
+{
+ DECL_2_ARGS();
+ DECL_RET();
+ char *filename;
+ struct utimbuf *buf;
+ 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);
+ PUT_LS_RC(rc, 0, 0, errno);
+ return 0;
+}
+
+/**
+ * default_posix1_handler_utimes
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int utimes(const char *filename, const struct timeval times[2])
+ */
+int default_posix1_handler_utimes(char *ls, unsigned long opdata)
+{
+ DECL_2_ARGS();
+ DECL_RET();
+ char *filename;
+ struct timeval *times;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ filename = GET_LS_PTR(arg0->slot[0]);
+ times = GET_LS_PTR(arg1->slot[0]);
+ rc = utimes(filename, times);
+ PUT_LS_RC(rc, 0, 0, errno);
+ return 0;
+}
+
int (*default_posix1_funcs[SPE_POSIX1_NR_OPCODES]) (char *, unsigned long) = {
[SPE_POSIX1_UNUSED] = NULL,
[SPE_POSIX1_ADJTIMEX] = default_posix1_handler_adjtimex,
@@ -2021,6 +2116,10 @@ int (*default_posix1_funcs[SPE_POSIX1_NR
[SPE_POSIX1_REWINDDIR] = default_posix1_handler_rewinddir,
[SPE_POSIX1_SEEKDIR] = default_posix1_handler_seekdir,
[SPE_POSIX1_TELLDIR] = default_posix1_handler_telldir,
+ [SPE_POSIX1_SCHED_YIELD] = default_posix1_handler_sched_yield,
+ [SPE_POSIX1_UMASK] = default_posix1_handler_umask,
+ [SPE_POSIX1_UTIME] = default_posix1_handler_utime,
+ [SPE_POSIX1_UTIMES] = default_posix1_handler_utimes,
};
/**
Index: quilt-libspe2/spebase/default_posix1_handler.h
===================================================================
--- quilt-libspe2.orig/spebase/default_posix1_handler.h
+++ quilt-libspe2/spebase/default_posix1_handler.h
@@ -83,5 +83,9 @@ extern int default_posix1_handler_readdi
extern int default_posix1_handler_rewinddir(char *ls, unsigned long args);
extern int default_posix1_handler_seekdir(char *ls, unsigned long args);
extern int default_posix1_handler_telldir(char *ls, unsigned long args);
+extern int default_posix1_handler_sched_yield(char *ls, unsigned long args);
+extern int default_posix1_handler_umask(char *ls, unsigned long args);
+extern int default_posix1_handler_utime(char *ls, unsigned long args);
+extern int default_posix1_handler_utimes(char *ls, unsigned long args);
#endif /* __DEFAULT_POSIX1_HANDLER_H__ */
More information about the cbe-oss-dev
mailing list