Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2017-03-24 19:26:37 +0300
committerCorinna Vinschen <corinna@vinschen.de>2017-03-24 19:55:36 +0300
commit663b4ab8243e56052d72217427bc935b3de2e9de (patch)
treed7de027f9cac1e752dd3aae8d93b6828639e16a5 /winsup
parent4dbcfeb7d0c388eba837d5b055f669a85d057442 (diff)
cygserver: Speed up non-debug scenario
_log/_vlog were always called so we always had a function call hit even if we're not debugging. Expand on the debugging macros so the decision to call _log/_vlog is done in the caller already. Also, make a log level difference between syscall_printf and system_printf. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygserver/bsd_helper.cc6
-rw-r--r--winsup/cygserver/bsd_log.cc2
-rw-r--r--winsup/cygserver/bsd_log.h22
-rw-r--r--winsup/cygserver/bsd_mutex.cc6
-rw-r--r--winsup/cygserver/process.h6
-rw-r--r--winsup/cygserver/sysv_msg.cc2
-rw-r--r--winsup/cygserver/woutsup.h2
7 files changed, 30 insertions, 16 deletions
diff --git a/winsup/cygserver/bsd_helper.cc b/winsup/cygserver/bsd_helper.cc
index f4babeec3..ecc90e117 100644
--- a/winsup/cygserver/bsd_helper.cc
+++ b/winsup/cygserver/bsd_helper.cc
@@ -63,9 +63,9 @@ win_copyout (struct thread *td, const void *server_src,
static void
_enter_critical_section (LPCRITICAL_SECTION pcs, const char *file, int line)
{
- _log (file, line, LOG_DEBUG, "Try enter critical section(%p)", pcs);
+ _debug (file, line, "Try enter critical section(%p)", pcs);
EnterCriticalSection (pcs);
- _log (file, line, LOG_DEBUG, "Entered critical section(%p)", pcs);
+ _debug (file, line, "Entered critical section(%p)", pcs);
}
#define leave_critical_section(c) _leave_critical_section((c),__FILE__,__LINE__)
@@ -73,7 +73,7 @@ static void
_leave_critical_section (LPCRITICAL_SECTION pcs, const char *file, int line)
{
LeaveCriticalSection (pcs);
- _log (file, line, LOG_DEBUG, "Left critical section(%p)", pcs);
+ _debug (file, line, "Left critical section(%p)", pcs);
}
CRITICAL_SECTION ipcht_cs;
diff --git a/winsup/cygserver/bsd_log.cc b/winsup/cygserver/bsd_log.cc
index 7c6dcb645..133aa46bc 100644
--- a/winsup/cygserver/bsd_log.cc
+++ b/winsup/cygserver/bsd_log.cc
@@ -93,7 +93,7 @@ _log (const char *file, int line, int level, const char *fmt, ...)
void
_vpanic (const char *file, int line, const char *fmt, va_list ap)
{
- _vlog (file, line, LOG_CRIT, fmt, ap);
+ _vlog (file, line, LOG_EMERG, fmt, ap);
exit (1);
}
diff --git a/winsup/cygserver/bsd_log.h b/winsup/cygserver/bsd_log.h
index 58d05171d..5eae6348a 100644
--- a/winsup/cygserver/bsd_log.h
+++ b/winsup/cygserver/bsd_log.h
@@ -19,12 +19,26 @@ extern tun_bool_t log_stderr;
void loginit (tun_bool_t, tun_bool_t);
void _vlog (const char *, int, int, const char *, va_list);
void _log (const char *, int, int, const char *, ...);
-void _vpanic (const char *, int, const char *, va_list) __attribute__ ((noreturn));
-void _panic (const char *, int, const char *, ...) __attribute__ ((noreturn));
+
#define vlog(l,f,a) _vlog(NULL,0,(l),(f),(a))
#define log(l,f,...) _log(NULL,0,(l),(f),##__VA_ARGS__)
-#define vdebug(f,a) _vlog(__FILE__,__LINE__,LOG_DEBUG,(f),(a))
-#define debug(f,...) _log(__FILE__,__LINE__,LOG_DEBUG,(f),##__VA_ARGS__)
+
+#define _vdebug(F,L,f,a) \
+ do { if (log_debug == TUN_TRUE) \
+ _vlog((F),(L),LOG_DEBUG,(f),(a)) \
+ } while (0)
+
+#define _debug(F,L,f,...) \
+ do { if (log_debug == TUN_TRUE) \
+ _log((F),(L),LOG_DEBUG,(f),##__VA_ARGS__); \
+ } while (0)
+
+#define vdebug(f,a) _vdebug(__FILE__,__LINE__,(f),(a))
+#define debug(f,...) _debug(__FILE__,__LINE__,(f),##__VA_ARGS__)
+
+void _vpanic (const char *, int, const char *, va_list)
+ __attribute__ ((noreturn));
+void _panic (const char *, int, const char *, ...) __attribute__ ((noreturn));
#define vpanic(f,a) _vpanic(__FILE__,__LINE__,(f),(a))
#define panic(f,...) _panic(__FILE__,__LINE__,(f),##__VA_ARGS__)
diff --git a/winsup/cygserver/bsd_mutex.cc b/winsup/cygserver/bsd_mutex.cc
index d546a610c..8bf0888ef 100644
--- a/winsup/cygserver/bsd_mutex.cc
+++ b/winsup/cygserver/bsd_mutex.cc
@@ -40,13 +40,13 @@ mtx_init (mtx *m, const char *name, const void *, int)
void
_mtx_lock (mtx *m, DWORD winpid, const char *file, int line)
{
- _log (file, line, LOG_DEBUG, "Try locking mutex %s (%u) (hold: %u)",
+ _debug (file, line, "Try locking mutex %s (%u) (hold: %u)",
m->name, winpid, m->owner);
if (WaitForSingleObject (m->h, INFINITE) != WAIT_OBJECT_0)
_panic (file, line, "wait for %s in %d failed, %u", m->name, winpid,
GetLastError ());
m->owner = winpid;
- _log (file, line, LOG_DEBUG, "Locked mutex %s/%u (owner: %u)",
+ _debug (file, line, "Locked mutex %s/%u (owner: %u)",
m->name, ++m->cnt, winpid);
}
@@ -89,7 +89,7 @@ _mtx_unlock (mtx *m, const char *file, int line)
_panic (file, line, "release of mutex %s failed, %u", m->name,
GetLastError ());
}
- _log (file, line, LOG_DEBUG, "Unlocked mutex %s/%u (owner: %u)",
+ _debug (file, line, "Unlocked mutex %s/%u (owner: %u)",
m->name, cnt, owner);
}
diff --git a/winsup/cygserver/process.h b/winsup/cygserver/process.h
index 282586e8d..a084fb12d 100644
--- a/winsup/cygserver/process.h
+++ b/winsup/cygserver/process.h
@@ -82,12 +82,12 @@ public:
bool is_active () const { return _exit_status == STILL_ACTIVE; }
void _hold (const char *file, int line) {
- _log (file, line, LOG_DEBUG, "Try hold(%lu)", _cygpid);
+ _debug (file, line, "Try hold(%lu)", _cygpid);
EnterCriticalSection (&_access);
- _log (file, line, LOG_DEBUG, "holding (%lu)", _cygpid);
+ _debug (file, line, "holding (%lu)", _cygpid);
}
void _release (const char *file, int line) {
- _log (file, line, LOG_DEBUG, "leaving (%lu)", _cygpid);
+ _debug (file, line, "leaving (%lu)", _cygpid);
LeaveCriticalSection (&_access);
}
diff --git a/winsup/cygserver/sysv_msg.cc b/winsup/cygserver/sysv_msg.cc
index b3a49900e..87ac1255b 100644
--- a/winsup/cygserver/sysv_msg.cc
+++ b/winsup/cygserver/sysv_msg.cc
@@ -52,7 +52,7 @@ __FBSDID("$FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/kern/sysv_msg.c,v 1.5
#endif /* __CYGWIN__ */
#ifdef MSG_DEBUG
-#define DPRINTF(a) debug_printf a
+#define DPRINTF(a) debug a
#else
#define DPRINTF(a)
#endif
diff --git a/winsup/cygserver/woutsup.h b/winsup/cygserver/woutsup.h
index fbbd4ebc2..272f978c0 100644
--- a/winsup/cygserver/woutsup.h
+++ b/winsup/cygserver/woutsup.h
@@ -50,5 +50,5 @@ extern int cygserver_running;
} while (false)
#define debug_printf(f,...) debug((f),##__VA_ARGS__)
-#define syscall_printf(f,...) log(LOG_ERR,(f),##__VA_ARGS__)
+#define syscall_printf(f,...) log(LOG_INFO,(f),##__VA_ARGS__)
#define system_printf(f,...) log(LOG_ERR,(f),##__VA_ARGS__)