From: hunt Date: Fri, 22 Sep 2006 16:37:51 +0000 (+0000) Subject: 2006-09-22 Martin Hunt X-Git-Tag: release-0.5.10~50 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=43d7488cffb2e6eab87af36b8db51e60acb2f5c5;p=systemtap.git 2006-09-22 Martin Hunt * print.c: Replace STP_PRINT_BUF_LEN with STP_BUFFER_SIZE. * string.c: Ditto. --- diff --git a/runtime/ChangeLog b/runtime/ChangeLog index f98136166..92db11606 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,8 @@ +2006-09-22 Martin Hunt + + * print.c: Replace STP_PRINT_BUF_LEN with STP_BUFFER_SIZE. + * string.c: Ditto. + 2006-09-21 Martin Hunt PR 3232 * print.c (_stp_print_init): New. Alloc per-cpu buffers. diff --git a/runtime/print.c b/runtime/print.c index 674bd4a02..904104f80 100644 --- a/runtime/print.c +++ b/runtime/print.c @@ -41,14 +41,11 @@ #define STP_PRINT_BUF_START (STP_TIMESTAMP_SIZE) -#ifndef STP_PRINT_BUF_LEN -#define STP_PRINT_BUF_LEN 8192 -#endif typedef struct __stp_pbuf { uint32_t len; /* bytes used in the buffer */ char timestamp[STP_TIMESTAMP_SIZE]; - char buf[STP_PRINT_BUF_LEN]; + char buf[STP_BUFFER_SIZE]; } _stp_pbuf; void *Stp_pbuf = NULL; @@ -118,10 +115,10 @@ static void * _stp_reserve_bytes (int numbytes) static void * _stp_reserve_bytes (int numbytes) { _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); - int size = STP_PRINT_BUF_LEN - pb->len; + int size = STP_BUFFER_SIZE - pb->len; void * ret; - if (unlikely(numbytes == 0 || numbytes > STP_PRINT_BUF_LEN)) + if (unlikely(numbytes == 0 || numbytes > STP_BUFFER_SIZE)) return NULL; if (numbytes > size) diff --git a/runtime/string.c b/runtime/string.c index 4c92f5910..6615d741e 100644 --- a/runtime/string.c +++ b/runtime/string.c @@ -60,7 +60,7 @@ void _stp_sprintf (String str, const char *fmt, ...) if (str == _stp_stdout) { _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); char *buf = pb->buf + pb->len; - int size = STP_PRINT_BUF_LEN - pb->len; + int size = STP_BUFFER_SIZE - pb->len; va_start(args, fmt); num = _stp_vsnprintf(buf, size, fmt, args); va_end(args); @@ -69,7 +69,7 @@ void _stp_sprintf (String str, const char *fmt, ...) if (pb->len == 0) { /* A single print request exceeded the buffer size. */ /* Should not be possible with Systemtap-generated code. */ - pb->len = STP_PRINT_BUF_LEN; + pb->len = STP_BUFFER_SIZE; _stp_print_flush(); num = 0; } else { @@ -78,7 +78,7 @@ void _stp_sprintf (String str, const char *fmt, ...) /* try again */ va_start(args, fmt); - num = _stp_vsnprintf(pb->buf, STP_PRINT_BUF_LEN, fmt, args); + num = _stp_vsnprintf(pb->buf, STP_BUFFER_SIZE, fmt, args); va_end(args); } } @@ -102,14 +102,14 @@ void _stp_vsprintf (String str, const char *fmt, va_list args) if (str == _stp_stdout) { _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); char *buf = pb->buf + pb->len; - int size = STP_PRINT_BUF_LEN - pb->len; + int size = STP_BUFFER_SIZE - pb->len; num = _stp_vsnprintf(buf, size, fmt, args); if (unlikely(num > size)) { /* overflowed the buffer */ if (pb->len == 0) { /* A single print request exceeded the buffer size. */ /* Should not be possible with Systemtap-generated code. */ - pb->len = STP_PRINT_BUF_LEN; + pb->len = STP_BUFFER_SIZE; _stp_print_flush(); num = 0; } else { @@ -117,7 +117,7 @@ void _stp_vsprintf (String str, const char *fmt, va_list args) _stp_print_flush(); /* try again */ - num = _stp_vsnprintf(pb->buf, STP_PRINT_BUF_LEN, fmt, args); + num = _stp_vsnprintf(pb->buf, STP_BUFFER_SIZE, fmt, args); } } pb->len += num; @@ -139,11 +139,11 @@ void _stp_string_cat_cstr (String str1, const char *str2) int num = strlen (str2); if (str1 == _stp_stdout) { _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); - int size = STP_PRINT_BUF_LEN - pb->len; + int size = STP_BUFFER_SIZE - pb->len; if (num > size) { _stp_print_flush(); - if (num > STP_PRINT_BUF_LEN) - num = STP_PRINT_BUF_LEN; + if (num > STP_BUFFER_SIZE) + num = STP_BUFFER_SIZE; } memcpy (pb->buf + pb->len, str2, num); pb->len += num; @@ -174,7 +174,7 @@ void _stp_string_cat_char (String str1, const char c) { if (str1 == _stp_stdout) { _stp_pbuf *pb = per_cpu_ptr(Stp_pbuf, smp_processor_id()); - int size = STP_PRINT_BUF_LEN - pb->len; + int size = STP_BUFFER_SIZE - pb->len; char *buf; if (1 >= size)