PERFORCE change 219715 for review

Robert Watson rwatson at FreeBSD.org
Sat Nov 10 00:33:29 UTC 2012


http://p4web.freebsd.org/@@219715?ac=10

Change 219715 by rwatson at rwatson_svr_ctsrd_mipsbuild on 2012/11/10 00:33:10

	Use gettimeofday() instead of sched_yield() for the sample system
	call -- it is more implemented.
	
	Fix iteration over cheritest arguments, which prevented
	multi-command sequences from running correctly.

Affected files ...

.. //depot/projects/ctsrd/cheribsd/src/bin/cheritest/cheritest.c#6 edit

Differences ...

==== //depot/projects/ctsrd/cheribsd/src/bin/cheritest/cheritest.c#6 (text+ko) ====

@@ -29,13 +29,13 @@
  */
 
 #include <sys/types.h>
+#include <sys/time.h>
 
 #include <machine/cheri.h>
 #include <machine/cpuregs.h>
 
 #include <err.h>
 #include <inttypes.h>
-#include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -70,7 +70,7 @@
 	fprintf(stderr, "cheritest sandbox\n");
 	fprintf(stderr, "cheritest sleep\n");
 	fprintf(stderr, "cheritest unsandbox\n");
-	fprintf(stderr, "cheritest yieldtest\n");
+	fprintf(stderr, "cheritest syscalltest\n");
 	exit(EX_USAGE);
 }
 
@@ -147,7 +147,6 @@
 	 * system calls.
 	 */
 	CHERI_CSETLEN(0, 1, CHERI_CAP_USER_LENGTH - 1);
-
 }
 
 static void
@@ -155,22 +154,23 @@
 {
 
 	/*
-	 * Restore a more privielged C0 so that the kernel will accept system
+	 * Restore a more privileged C0 so that the kernel will accept system
 	 * calls again.
 	 */
 	CHERI_CSETLEN(0, 1, CHERI_CAP_USER_LENGTH);
 }
 
 static void
-cheritest_yieldtest(void)
+cheritest_syscalltest(void)
 {
+	struct timeval tv;
 	int ret;
 
 	cheritest_sandbox();
-	ret = sched_yield();
+	ret = gettimeofday(&tv, NULL);
 	cheritest_unsandbox();
 	if (ret)
-		err(1, "sched_yield");
+		err(1, "gettimeofday");
 
 }
 
@@ -194,20 +194,20 @@
 	CHERI_CMOVE(1, 0);
 
 	for (i = 0; i < argc; i++) {
-		if (strcmp(argv[0], "listregs") == 0)
+		if (strcmp(argv[i], "listregs") == 0)
 			cheritest_listregs();
-		else if (strcmp(argv[0], "copyregs") == 0)
+		else if (strcmp(argv[i], "copyregs") == 0)
 			cheritest_copyregs();
-		else if (strcmp(argv[0], "overrun") == 0)
+		else if (strcmp(argv[i], "overrun") == 0)
 			cheritest_overrun();
-		else if (strcmp(argv[0], "sandbox") == 0)
+		else if (strcmp(argv[i], "sandbox") == 0)
 			cheritest_sandbox();
-		else if (strcmp(argv[0], "sleep") == 0)
+		else if (strcmp(argv[i], "sleep") == 0)
 			sleep(10);
-		else if (strcmp(argv[0], "unsandbox") == 0)
+		else if (strcmp(argv[i], "unsandbox") == 0)
 			cheritest_unsandbox();
-		else if (strcmp(argv[0], "yieldtest") == 0)
-			cheritest_yieldtest();
+		else if (strcmp(argv[i], "syscalltest") == 0)
+			cheritest_syscalltest();
 		else
 			usage();
 	}


More information about the p4-projects mailing list