summaryrefslogtreecommitdiffstats
path: root/runtime/io.c
diff options
context:
space:
mode:
authorhunt <hunt>2007-01-30 19:18:06 +0000
committerhunt <hunt>2007-01-30 19:18:06 +0000
commiteaa5bbf4b8703e3794943f27d3fb9c1265dfd418 (patch)
tree354d34ca2b46ddd86f0f5de26345ce4fc753d6a9 /runtime/io.c
parentd21d36c05265b136246ae2c4ee9b5a38af46f45c (diff)
downloadsystemtap-steved-eaa5bbf4b8703e3794943f27d3fb9c1265dfd418.tar.gz
systemtap-steved-eaa5bbf4b8703e3794943f27d3fb9c1265dfd418.tar.xz
systemtap-steved-eaa5bbf4b8703e3794943f27d3fb9c1265dfd418.zip
2007-01-30 Martin Hunt <hunt@redhat.com>
* io.c (_stp_vlog): Use dynamic percpu allocations instead of very wasteful static allocations. * print.c (_stp_print_init): Do percpu allocations for io.c. (_stp_print_cleanup): Free percpu allocations. * string.c (_stp_sprintf): Overflow check needed to be >= instead of >.
Diffstat (limited to 'runtime/io.c')
-rw-r--r--runtime/io.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/runtime/io.c b/runtime/io.c
index 5ef88957..1483acfd 100644
--- a/runtime/io.c
+++ b/runtime/io.c
@@ -1,6 +1,6 @@
/* -*- linux-c -*-
* I/O for printing warnings, errors and debug messages
- * Copyright (C) 2005, 2006 Red Hat Inc.
+ * Copyright (C) 2005, 2006, 2007 Red Hat Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -23,23 +23,24 @@ void _stp_string_cat_cstr (String str1, const char *str2);
* @{
*/
-/** private buffer for _stp_log() */
-#define STP_LOG_BUF_LEN 2047
#define WARN_STRING "WARNING: "
#define ERR_STRING "ERROR: "
+enum code { INFO=0, WARN, ERROR, DBUG };
-static char _stp_lbuf[NR_CPUS][STP_LOG_BUF_LEN + 1];
+/** private buffer for _stp_log() */
+#define STP_LOG_BUF_LEN 256
-enum code { INFO=0, WARN, ERROR, DBUG };
+typedef char _stp_lbuf[STP_LOG_BUF_LEN];
+void *Stp_lbuf = NULL;
static void _stp_vlog (enum code type, const char *func, int line, const char *fmt, va_list args)
{
int num;
- char *buf = &_stp_lbuf[get_cpu()][0];
+ char *buf = per_cpu_ptr(Stp_lbuf, smp_processor_id());
int start = 0;
if (type == DBUG) {
- start = scnprintf(buf, STP_LOG_BUF_LEN, "\033[36m%s:%d:\033[0m ", func, line);
+ start = _stp_snprintf(buf, STP_LOG_BUF_LEN, "\033[36m%s:%d:\033[0m ", func, line);
} else if (type == WARN) {
strcpy (buf, WARN_STRING);
start = sizeof(WARN_STRING) - 1;
@@ -48,14 +49,14 @@ static void _stp_vlog (enum code type, const char *func, int line, const char *f
start = sizeof(ERR_STRING) - 1;
}
- num = vscnprintf (buf + start, STP_LOG_BUF_LEN - start, fmt, args);
+ num = _stp_vscnprintf (buf + start, STP_LOG_BUF_LEN - start - 1, fmt, args);
if (num + start) {
if (buf[num + start - 1] != '\n') {
buf[num + start] = '\n';
num++;
+ buf[num + start] = '\0';
}
- buf[num + start] = '\0';
-
+
if (type != DBUG)
_stp_write(STP_OOB_DATA, buf, start + num + 1);
else {
@@ -63,7 +64,6 @@ static void _stp_vlog (enum code type, const char *func, int line, const char *f
_stp_print_flush();
}
}
- put_cpu();
}
/** Logs Data.