treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / tools / lib / traceevent / trace-seq.h
blobd68ec69f8d1a833a4755166d1249049f25318215
1 // SPDX-License-Identifier: LGPL-2.1
2 /*
3 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
5 */
7 #ifndef _TRACE_SEQ_H
8 #define _TRACE_SEQ_H
10 #include <stdarg.h>
11 #include <stdio.h>
13 /* ----------------------- trace_seq ----------------------- */
15 #ifndef TRACE_SEQ_BUF_SIZE
16 #define TRACE_SEQ_BUF_SIZE 4096
17 #endif
19 enum trace_seq_fail {
20 TRACE_SEQ__GOOD,
21 TRACE_SEQ__BUFFER_POISONED,
22 TRACE_SEQ__MEM_ALLOC_FAILED,
26 * Trace sequences are used to allow a function to call several other functions
27 * to create a string of data to use (up to a max of PAGE_SIZE).
30 struct trace_seq {
31 char *buffer;
32 unsigned int buffer_size;
33 unsigned int len;
34 unsigned int readpos;
35 enum trace_seq_fail state;
38 void trace_seq_init(struct trace_seq *s);
39 void trace_seq_reset(struct trace_seq *s);
40 void trace_seq_destroy(struct trace_seq *s);
42 extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
43 __attribute__ ((format (printf, 2, 3)));
44 extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args)
45 __attribute__ ((format (printf, 2, 0)));
47 extern int trace_seq_puts(struct trace_seq *s, const char *str);
48 extern int trace_seq_putc(struct trace_seq *s, unsigned char c);
50 extern void trace_seq_terminate(struct trace_seq *s);
52 extern int trace_seq_do_fprintf(struct trace_seq *s, FILE *fp);
53 extern int trace_seq_do_printf(struct trace_seq *s);
55 #endif /* _TRACE_SEQ_H */