Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 May 2016 12:46:35 +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: r300415 - in head/sys: amd64/amd64 i386/i386 powerpc/powerpc sparc64/sparc64 sys
Message-ID:  <201605221246.u4MCkZfH076150@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun May 22 12:46:34 2016
New Revision: 300415
URL: https://svnweb.freebsd.org/changeset/base/300415

Log:
  Add macro to convert errno and use it when appropriate.
  
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c
  head/sys/powerpc/powerpc/exec_machdep.c
  head/sys/sparc64/sparc64/vm_machdep.c
  head/sys/sys/sysent.h

Modified: head/sys/amd64/amd64/vm_machdep.c
==============================================================================
--- head/sys/amd64/amd64/vm_machdep.c	Sun May 22 12:37:40 2016	(r300414)
+++ head/sys/amd64/amd64/vm_machdep.c	Sun May 22 12:46:34 2016	(r300415)
@@ -414,13 +414,7 @@ cpu_set_syscall_retval(struct thread *td
 		break;
 
 	default:
-		if (td->td_proc->p_sysent->sv_errsize) {
-			if (error >= td->td_proc->p_sysent->sv_errsize)
-				error = -1;	/* XXX */
-			else
-				error = td->td_proc->p_sysent->sv_errtbl[error];
-		}
-		td->td_frame->tf_rax = error;
+		td->td_frame->tf_rax = SV_ABI_ERRNO(td->td_proc, error);
 		td->td_frame->tf_rflags |= PSL_C;
 		break;
 	}

Modified: head/sys/i386/i386/vm_machdep.c
==============================================================================
--- head/sys/i386/i386/vm_machdep.c	Sun May 22 12:37:40 2016	(r300414)
+++ head/sys/i386/i386/vm_machdep.c	Sun May 22 12:46:34 2016	(r300415)
@@ -451,13 +451,7 @@ cpu_set_syscall_retval(struct thread *td
 		break;
 
 	default:
-		if (td->td_proc->p_sysent->sv_errsize) {
-			if (error >= td->td_proc->p_sysent->sv_errsize)
-				error = -1;	/* XXX */
-			else
-				error = td->td_proc->p_sysent->sv_errtbl[error];
-		}
-		td->td_frame->tf_eax = error;
+		td->td_frame->tf_eax = SV_ABI_ERRNO(td->td_proc, error);
 		td->td_frame->tf_eflags |= PSL_C;
 		break;
 	}

Modified: head/sys/powerpc/powerpc/exec_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/exec_machdep.c	Sun May 22 12:37:40 2016	(r300414)
+++ head/sys/powerpc/powerpc/exec_machdep.c	Sun May 22 12:46:34 2016	(r300415)
@@ -908,11 +908,7 @@ cpu_set_syscall_retval(struct thread *td
 		tf->srr0 -= 4;
 		break;
 	default:
-		if (p->p_sysent->sv_errsize) {
-			error = (error < p->p_sysent->sv_errsize) ?
-			    p->p_sysent->sv_errtbl[error] : -1;
-		}
-		tf->fixreg[FIRSTARG] = error;
+		tf->fixreg[FIRSTARG] = SV_ABI_ERRNO(p, error);
 		tf->cr |= 0x10000000;		/* Set summary overflow */
 		break;
 	}

Modified: head/sys/sparc64/sparc64/vm_machdep.c
==============================================================================
--- head/sys/sparc64/sparc64/vm_machdep.c	Sun May 22 12:37:40 2016	(r300414)
+++ head/sys/sparc64/sparc64/vm_machdep.c	Sun May 22 12:46:34 2016	(r300415)
@@ -167,13 +167,7 @@ cpu_set_syscall_retval(struct thread *td
 		break;
 
 	default:
-		if (td->td_proc->p_sysent->sv_errsize) {
-			if (error >= td->td_proc->p_sysent->sv_errsize)
-				error = -1;	/* XXX */
-			else
-				error = td->td_proc->p_sysent->sv_errtbl[error];
-		}
-		td->td_frame->tf_out[0] = error;
+		td->td_frame->tf_out[0] = SV_ABI_ERRNO(td->td_proc, error);
 		td->td_frame->tf_tstate |= TSTATE_XCC_C;
 		break;
 	}

Modified: head/sys/sys/sysent.h
==============================================================================
--- head/sys/sys/sysent.h	Sun May 22 12:37:40 2016	(r300414)
+++ head/sys/sys/sysent.h	Sun May 22 12:46:34 2016	(r300415)
@@ -141,6 +141,8 @@ struct sysentvec {
 #define	SV_TIMEKEEP	0x040000
 
 #define	SV_ABI_MASK	0xff
+#define	SV_ABI_ERRNO(p, e)	((p)->p_sysent->sv_errsize <= 0 ? e :	\
+	((e) >= (p)->p_sysent->sv_errsize ? -1 : (p)->p_sysent->sv_errtbl[e]))
 #define	SV_PROC_FLAG(p, x)	((p)->p_sysent->sv_flags & (x))
 #define	SV_PROC_ABI(p)		((p)->p_sysent->sv_flags & SV_ABI_MASK)
 #define	SV_CURPROC_FLAG(x)	SV_PROC_FLAG(curproc, x)



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