From 3d4bc8bea6b45893bd4b49f44df26bd602b4cba5 Mon Sep 17 00:00:00 2001 From: hunt Date: Thu, 7 Apr 2005 15:17:29 +0000 Subject: Update to use relayfs. --- runtime/docs/html/scbuf_8c-source.html | 164 +++++++++++++++++++-------------- 1 file changed, 94 insertions(+), 70 deletions(-) (limited to 'runtime/docs/html/scbuf_8c-source.html') diff --git a/runtime/docs/html/scbuf_8c-source.html b/runtime/docs/html/scbuf_8c-source.html index a9e9ddc8..ffdfaac7 100644 --- a/runtime/docs/html/scbuf_8c-source.html +++ b/runtime/docs/html/scbuf_8c-source.html @@ -5,75 +5,99 @@
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages
-

scbuf.c

00001 #ifndef _SCBUF_C_
-00002 #define _SCBUF_C_
+

scbuf.c

00001 #ifndef _SCBUF_C_ /* -*- linux-c -*- */
+00002 #define _SCBUF_C_
 00003 
-00004 /* -*- linux-c -*- */
-00005 /** @file scbuf.c
-00006  * @addtogroup scbuf Scratch Buffer
-00007  * Scratch Buffer Functions.
-00008  * The scratch buffer is for collecting output before storing in a map,
-00009  * printing, etc. This is a per-cpu static buffer.  It is necessary because 
-00010  * of the limited stack space available in the kernel.
-00011  * @{
-00012  */
-00013 
-00014 /** Maximum size of buffer, not including terminating NULL */
-00015 #define STP_BUF_LEN 8191
-00016 
-00017 /** Scratch buffer for printing, building strings, etc */
-00018 char _stp_scbuf[STP_BUF_LEN+1];
-00019 static int _stp_scbuf_len = STP_BUF_LEN;
-00020 
-00021 /** Sprint into the scratch buffer.
-00022  * Like printf, except output goes into  #_stp_scbuf,
-00023  * which will contain the null-terminated output.
-00024  * Safe because overflowing #_stp_scbuf is not allowed.
-00025  * Size is limited by length of scratch buffer, STP_BUF_LEN.
-00026  *
-00027  * @param fmt A printf-style format string followed by a 
-00028  * variable number of args.
-00029  * @sa _stp_scbuf_clear
-00030  */
-00031 
-00032 void _stp_sprint (const char *fmt, ...)
-00033 {
-00034   int num;
-00035   va_list args;
-00036   char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
-00037   va_start(args, fmt);
-00038   num = vscnprintf(buf, _stp_scbuf_len, fmt, args);
-00039   va_end(args);
-00040   if (num > 0)
-00041     _stp_scbuf_len -= num;
-00042 }
-00043 
-00044 void _stp_sprint_str (const char *str)
-00045 {
-00046   char *buf = _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
-00047   int num = strlen (str);
-00048   if (num > _stp_scbuf_len)
-00049     num = _stp_scbuf_len;
-00050   strncpy (buf, str, num);
-00051   _stp_scbuf_len -= num;
-00052 }
-00053 
-00054 /** Clear the scratch buffer.
-00055  * Output from _stp_sprint() will accumulate in the buffer
-00056  * until this is called.
-00057  */
-00058 
-00059 void _stp_scbuf_clear (void)
-00060 {
-00061   _stp_scbuf_len = STP_BUF_LEN;
-00062   _stp_scbuf[0] = 0;
-00063 }
-00064 
-00065 static char *_stp_scbuf_cur (void)
-00066 {
-00067   return _stp_scbuf + STP_BUF_LEN - _stp_scbuf_len;
-00068 }
-00069 
-00070 /** @} */
-00071 #endif /* _SCBUF_C_ */
+00004 #include <linux/config.h>
+00005 
+00006 /** @file scbuf.c
+00007  * @addtogroup scbuf Scratch Buffer
+00008  * Scratch Buffer Functions.
+00009  * The scratch buffer is for collecting output before storing in a map,
+00010  * printing, etc. This is a per-cpu static buffer.  It is necessary because 
+00011  * of the limited stack space available in the kernel.
+00012  * @todo Need careful review of these to insure safety.
+00013  * @{
+00014  */
+00015 
+00016 /** Maximum size of buffer, not including terminating NULL */
+00017 #define STP_BUF_LEN 8191
+00018 
+00019 /** Scratch buffer for printing, building strings, etc */
+00020 static char _stp_scbuf[NR_CPUS][STP_BUF_LEN+1];
+00021 static int _stp_scbuf_len[NR_CPUS];
+00022 
+00023 /** Sprint into the scratch buffer.
+00024  * Like printf, except output goes into a global scratch buffer
+00025  * which will contain the null-terminated output.
+00026  * Safe because overflowing the buffer is not allowed.
+00027  * Size is limited by length of scratch buffer, STP_BUF_LEN.
+00028  *
+00029  * @param fmt A printf-style format string followed by a 
+00030  * variable number of args.
+00031  * @sa _stp_scbuf_clear
+00032  */
+00033 
+00034 void _stp_sprint (const char *fmt, ...)
+00035 {
+00036         int num;
+00037         va_list args;
+00038         int cpu = smp_processor_id();
+00039         char *buf = _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
+00040         va_start(args, fmt);
+00041         num = vscnprintf(buf, _stp_scbuf_len[cpu], fmt, args);
+00042         va_end(args);
+00043         if (num > 0)
+00044                 _stp_scbuf_len[cpu] -= num;
+00045 }
+00046 
+00047 /** Write a string into the scratch buffer.
+00048  * Copies a string into a global scratch buffer.
+00049  * Safe because overflowing the buffer is not allowed.
+00050  * Size is limited by length of scratch buffer, STP_BUF_LEN.
+00051  * This is more efficient than using _stp_sprint().
+00052  *
+00053  * @param str A string.
+00054  */
+00055 
+00056 void _stp_sprint_str (const char *str)
+00057 {
+00058         int cpu = smp_processor_id();
+00059         char *buf = _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
+00060         int num = strlen (str);
+00061         if (num > _stp_scbuf_len[cpu])
+00062                 num = _stp_scbuf_len[cpu];
+00063         strncpy (buf, str, num);
+00064         _stp_scbuf_len[cpu] -= num;
+00065 }
+00066 
+00067 /** Clear the scratch buffer.
+00068  * This function should be called before anything is written to 
+00069  * the scratch buffer.  Output will accumulate in the buffer
+00070  * until this function is called again.  
+00071  * @returns A pointer to the buffer.
+00072  */
+00073 
+00074 char *_stp_scbuf_clear (void)
+00075 {
+00076         int cpu = smp_processor_id();
+00077         _stp_scbuf_len[cpu] = STP_BUF_LEN;
+00078         *_stp_scbuf[cpu] = 0;
+00079         return _stp_scbuf[cpu];
+00080 }
+00081 
+00082 /** Get the current top of the scratch buffer.
+00083  * This returns the address of the location where
+00084  * data will be written next in the scratch buffer.
+00085  * @returns A pointer
+00086  */
+00087 
+00088 static char *_stp_scbuf_cur (void)
+00089 {
+00090         int cpu = smp_processor_id();
+00091         return _stp_scbuf[cpu] + STP_BUF_LEN - _stp_scbuf_len[cpu];
+00092 }
+00093 
+00094 /** @} */
+00095 #endif /* _SCBUF_C_ */
 
-- cgit