[Cbe-oss-dev] [PATCH 1/3] libspe2: add nanosleep assist call
Patrick Mansfield
patmans at us.ibm.com
Tue Jun 5 02:26:52 EST 2007
Add an assist call for:
int nanosleep(struct timespec *req, struct timespec *rem)
Signed-off-by: Patrick Mansfield <patmans at us.ibm.com>
Index: libspe2/spebase/default_posix1_handler.c
===================================================================
--- libspe2.orig/spebase/default_posix1_handler.c
+++ libspe2/spebase/default_posix1_handler.c
@@ -119,6 +119,7 @@ enum {
SPE_POSIX1_ACCESS,
SPE_POSIX1_DUP,
SPE_POSIX1_TIME,
+ SPE_POSIX1_NANOSLEEP,
SPE_POSIX1_LAST_OPCODE,
};
#define SPE_POSIX1_NR_OPCODES \
@@ -1176,6 +1177,34 @@ int default_posix1_handler_gettimeofday(
return 0;
}
+/**
+ * default_posix1_handler_nanosleep
+ * @ls: base pointer to local store area.
+ * @opdata: POSIX.1 call opcode & data.
+ *
+ * Implement:
+ * int nanosleep(struct timespec *req, struct timespec *rem);
+ */
+int default_posix1_handler_nanosleep(char *ls, unsigned long opdata)
+{
+ DECL_2_ARGS();
+ DECL_RET();
+ struct timespec *req;
+ struct timespec *rem;
+ int rc;
+
+ DEBUG_PRINTF("%s\n", __func__);
+ req = GET_LS_PTR(arg0->slot[0]);
+ if (arg1->slot[0] == 0) {
+ rem = NULL;
+ } else {
+ rem = GET_LS_PTR(arg1->slot[0]);
+ }
+ rc = nanosleep(req, rem);
+ 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,
@@ -1209,6 +1238,7 @@ int (*default_posix1_funcs[SPE_POSIX1_NR
[SPE_POSIX1_ACCESS] = default_posix1_handler_access,
[SPE_POSIX1_DUP] = default_posix1_handler_dup,
[SPE_POSIX1_TIME] = default_posix1_handler_time,
+ [SPE_POSIX1_NANOSLEEP] = default_posix1_handler_nanosleep,
};
/**
Index: libspe2/spebase/default_posix1_handler.h
===================================================================
--- libspe2.orig/spebase/default_posix1_handler.h
+++ libspe2/spebase/default_posix1_handler.h
@@ -54,5 +54,6 @@ extern int default_posix1_handler_ftrunc
extern int default_posix1_handler_access(char *ls, unsigned long args);
extern int default_posix1_handler_dup(char *ls, unsigned long args);
extern int default_posix1_handler_time(char *ls, unsigned long args);
+extern int default_posix1_handler_nanosleep(char *ls, unsigned long opdata);
#endif /* __DEFAULT_POSIX1_HANDLER_H__ */
More information about the cbe-oss-dev
mailing list