Sat Jun 29 16:50:51 2013 UTC ()
sy_invoke: cache the predicate value and simplify the logic (also, fix the
tab/space mess while here).


(rmind)
diff -r1.7 -r1.8 src/sys/sys/syscallvar.h

cvs diff -r1.7 -r1.8 src/sys/sys/syscallvar.h (expand / switch to unified diff)

--- src/sys/sys/syscallvar.h 2013/06/26 08:30:40 1.7
+++ src/sys/sys/syscallvar.h 2013/06/29 16:50:51 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: syscallvar.h,v 1.7 2013/06/26 08:30:40 matt Exp $ */ 1/* $NetBSD: syscallvar.h,v 1.8 2013/06/29 16:50:51 rmind Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software developed for The NetBSD Foundation 7 * This code is derived from software developed for The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -58,40 +58,40 @@ sy_call(const struct sysent *sy, struct  @@ -58,40 +58,40 @@ sy_call(const struct sysent *sy, struct
58 int error; 58 int error;
59 59
60 l->l_sysent = sy; 60 l->l_sysent = sy;
61 error = (*sy->sy_call)(l, uap, rval); 61 error = (*sy->sy_call)(l, uap, rval);
62 l->l_sysent = NULL; 62 l->l_sysent = NULL;
63 63
64 return error; 64 return error;
65} 65}
66 66
67static inline int 67static inline int
68sy_invoke(const struct sysent *sy, struct lwp *l, const void *uap, 68sy_invoke(const struct sysent *sy, struct lwp *l, const void *uap,
69 register_t *rval, int code) 69 register_t *rval, int code)
70{ 70{
 71 const bool do_trace = l->l_proc->p_trace_enabled &&
 72 (sy->sy_flags & SYCALL_INDIRECT) == 0;
71 int error; 73 int error;
72 74
73 if (!__predict_false(l->l_proc->p_trace_enabled) 75 if (__predict_true(!do_trace) || (error = trace_enter(code, uap,
74 || __predict_false(sy->sy_flags & SYCALL_INDIRECT) 76 sy->sy_narg)) == 0) {
75 || (error = trace_enter(code, uap, sy->sy_narg)) == 0) { 77 rval[0] = 0;
76 rval[0] = 0; 
77#if !defined(__mips__) 78#if !defined(__mips__)
78 /* 79 /*
79 * Due to the mips userland code for SYS_break needing v1 to be 80 * Due to the mips userland code for SYS_break needing v1 to be
80 * preserved, we can't clear this on mips.  81 * preserved, we can't clear this on mips.
81 */ 82 */
82 rval[1] = 0; 83 rval[1] = 0;
83#endif 84#endif
84 error = sy_call(sy, l, uap, rval); 85 error = sy_call(sy, l, uap, rval);
85 }  86 }
86  87
87 if (__predict_false(l->l_proc->p_trace_enabled) 88 if (__predict_false(do_trace)) {
88 && !__predict_false(sy->sy_flags & SYCALL_INDIRECT)) { 89 trace_exit(code, rval, error);
89 trace_exit(code, rval, error); 90 }
90 } 91 return error;
91 return error;  
92} 92}
93 93
94/* inclusion in the kernel currently depends on SYSCALL_DEBUG */ 94/* inclusion in the kernel currently depends on SYSCALL_DEBUG */
95extern const char * const syscallnames[]; 95extern const char * const syscallnames[];
96 96
97#endif /* _SYS_SYSCALLVAR_H_ */ 97#endif /* _SYS_SYSCALLVAR_H_ */