Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2015 18:14:39 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r283498 - head/sys/compat/linux
Message-ID:  <201505241814.t4OIEdDm047045@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun May 24 18:14:38 2015
New Revision: 283498
URL: https://svnweb.freebsd.org/changeset/base/283498

Log:
  Linux nanosleep() and clock_nanosleep() system calls always
  writes the remaining time into the structure pointed to by rmtp
  unless rmtp is NULL. The value of *rmtp can then be used to call
  nanosleep() again and complete the specified pause if the previous
  call was interrupted.
  
  Note. clock_nanosleep() with an absolute time value does not write
  the remaining time.
  
  While here fix whitespaces and typo in SDT_PROBE.

Modified:
  head/sys/compat/linux/linux_time.c

Modified: head/sys/compat/linux/linux_time.c
==============================================================================
--- head/sys/compat/linux/linux_time.c	Sun May 24 18:13:21 2015	(r283497)
+++ head/sys/compat/linux/linux_time.c	Sun May 24 18:14:38 2015	(r283498)
@@ -105,14 +105,12 @@ LIN_SDT_PROBE_DEFINE1(time, linux_clock_
 LIN_SDT_PROBE_DEFINE2(time, linux_nanosleep, entry, "const struct l_timespec *",
     "struct l_timespec *");
 LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, conversion_error, "int");
-LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, nanosleep_error, "int");
 LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, copyout_error, "int");
 LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, copyin_error, "int");
 LIN_SDT_PROBE_DEFINE1(time, linux_nanosleep, return, "int");
 LIN_SDT_PROBE_DEFINE4(time, linux_clock_nanosleep, entry, "clockid_t", "int",
     "struct l_timespec *", "struct l_timespec *");
 LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, conversion_error, "int");
-LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, nanosleep_error, "int");
 LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, copyout_error, "int");
 LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, copyin_error, "int");
 LIN_SDT_PROBE_DEFINE1(time, linux_clock_nanosleep, unsupported_flags, "int");
@@ -468,7 +466,7 @@ linux_nanosleep(struct thread *td, struc
 	struct timespec *rmtp;
 	struct l_timespec lrqts, lrmts;
 	struct timespec rqts, rmts;
-	int error;
+	int error, error2;
 
 	LIN_SDT_PROBE2(time, linux_nanosleep, entry, args->rqtp, args->rmtp);
 
@@ -480,9 +478,9 @@ linux_nanosleep(struct thread *td, struc
 	}
 
 	if (args->rmtp != NULL)
-	   	rmtp = &rmts;
+		rmtp = &rmts;
 	else
-	   	rmtp = NULL;
+		rmtp = NULL;
 
 	error = linux_to_native_timespec(&rqts, &lrqts);
 	if (error != 0) {
@@ -491,25 +489,19 @@ linux_nanosleep(struct thread *td, struc
 		return (error);
 	}
 	error = kern_nanosleep(td, &rqts, rmtp);
-	if (error != 0) {
-		LIN_SDT_PROBE1(time, linux_nanosleep, nanosleep_error, error);
-		LIN_SDT_PROBE1(time, linux_nanosleep, return, error);
-		return (error);
-	}
-
 	if (args->rmtp != NULL) {
-	   	native_to_linux_timespec(&lrmts, rmtp);
-	   	error = copyout(&lrmts, args->rmtp, sizeof(lrmts));
-		if (error != 0) {
+		native_to_linux_timespec(&lrmts, rmtp);
+		error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts));
+		if (error2 != 0) {
 			LIN_SDT_PROBE1(time, linux_nanosleep, copyout_error,
-			    error);
-			LIN_SDT_PROBE1(time, linux_nanosleep, return, error);
-		   	return (error);
+			    error2);
+			LIN_SDT_PROBE1(time, linux_nanosleep, return, error2);
+			return (error2);
 		}
 	}
 
-	LIN_SDT_PROBE1(time, linux_nanosleep, return, 0);
-	return (0);
+	LIN_SDT_PROBE1(time, linux_nanosleep, return, error);
+	return (error);
 }
 
 int
@@ -518,7 +510,7 @@ linux_clock_nanosleep(struct thread *td,
 	struct timespec *rmtp;
 	struct l_timespec lrqts, lrmts;
 	struct timespec rqts, rmts;
-	int error;
+	int error, error2;
 
 	LIN_SDT_PROBE4(time, linux_clock_nanosleep, entry, args->which,
 	    args->flags, args->rqtp, args->rmtp);
@@ -538,7 +530,7 @@ linux_clock_nanosleep(struct thread *td,
 		return (EINVAL);
 	}
 
-	error = copyin(args->rqtp, &lrqts, sizeof lrqts);
+	error = copyin(args->rqtp, &lrqts, sizeof(lrqts));
 	if (error != 0) {
 		LIN_SDT_PROBE1(time, linux_clock_nanosleep, copyin_error,
 		    error);
@@ -547,9 +539,9 @@ linux_clock_nanosleep(struct thread *td,
 	}
 
 	if (args->rmtp != NULL)
-	   	rmtp = &rmts;
+		rmtp = &rmts;
 	else
-	   	rmtp = NULL;
+		rmtp = NULL;
 
 	error = linux_to_native_timespec(&rqts, &lrqts);
 	if (error != 0) {
@@ -559,24 +551,19 @@ linux_clock_nanosleep(struct thread *td,
 		return (error);
 	}
 	error = kern_nanosleep(td, &rqts, rmtp);
-	if (error != 0) {
-		LIN_SDT_PROBE1(time, linux_clock_nanosleep, nanosleep_error,
-		    error);
-		LIN_SDT_PROBE1(time, linux_clock_nanosleep, return, error);
-		return (error);
-	}
-
 	if (args->rmtp != NULL) {
+		/* XXX. Not for TIMER_ABSTIME */
 	   	native_to_linux_timespec(&lrmts, rmtp);
-	   	error = copyout(&lrmts, args->rmtp, sizeof lrmts );
-		if (error != 0) {
+		error2 = copyout(&lrmts, args->rmtp, sizeof(lrmts));
+		if (error2 != 0) {
+			LIN_SDT_PROBE1(time, linux_clock_nanosleep,
+			    copyout_error, error2);
 			LIN_SDT_PROBE1(time, linux_clock_nanosleep,
-			    copyout_error, error);
-			LIN_SDT_PROBE1(time, linux_nanosleep, return, error);
-		   	return (error);
+			    return, error2);
+			return (error2);
 		}
 	}
 
-	LIN_SDT_PROBE1(time, linux_clock_nanosleep, return, 0);
-	return (0);
+	LIN_SDT_PROBE1(time, linux_clock_nanosleep, return, error);
+	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505241814.t4OIEdDm047045>