00001 #ifndef _SCBUF_C_
00002 #define _SCBUF_C_
00003
00004 #include <linux/config.h>
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #define STP_BUF_LEN 8191
00018
00019
00020 static char _stp_scbuf[NR_CPUS][STP_BUF_LEN+1];
00021 static int _stp_scbuf_len[NR_CPUS];
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
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
00048
00049
00050
00051
00052
00053
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
00068
00069
00070
00071
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
00083
00084
00085
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