vfs: check userland buffers before reading them.
[haiku.git] / headers / private / graphics / common / log_coll.h
blob007c4d56f37d8ac0927d081007b6d6326149c8e8
1 /*
2 Copyright (c) 2002, Thomas Kurschel
5 Part of Radeon driver
7 Fast logger
9 As syslog is very slow and tends to loose
10 data if its buffer overflows (which occurs much
11 too often), this module provides a fast (and memory-
12 wasting) logging mechanism. You need a seperate
13 application to retrieve the log.
15 Everything is thread-safe.
19 #ifndef __LOG_COLL_H__
20 #define __LOG_COLL_H__
22 #include <SupportDefs.h>
24 // by undefining this flag, all logging functions
25 // are resolved to empty space, so don't add
26 // extra tests in your code
27 #undef ENABLE_LOGGING
28 //#define ENABLE_LOGGING
31 // add log entry with 0..3 (uint32) data
32 #define LOG( li, what ) log( li, what, 0 )
33 #define LOG1( li, what, arg1 ) log( li, what, 1, arg1 );
34 #define LOG2( li, what, arg1, arg2 ) log( li, what, 2, arg1, arg2 );
35 #define LOG3( li, what, arg1, arg2, arg3 ) log( li, what, 3, arg1, arg2, arg3 );
38 // one log entry
39 typedef struct log_entry_t {
40 uint64 tsc;
41 uint16 what;
42 uint8 num_args;
43 uint32 args[1];
44 } log_entry;
46 struct log_info_t;
48 #if defined(__cplusplus)
49 extern "C" {
50 #endif
53 #ifdef ENABLE_LOGGING
54 void log( struct log_info_t *li, uint16 what, const uint8 num_args, ... );
55 #else
56 #define log( a, b, c... )
57 #endif
60 // define LOG_INCLUDE_STARTUP in your device driver
61 #ifdef LOG_INCLUDE_STARTUP
63 uint32 log_getsize( struct log_info_t *li );
64 void log_getcopy( struct log_info_t *li, void *dest, uint32 max_size );
66 #ifdef ENABLE_LOGGING
68 struct log_info_t *log_init( uint32 size );
69 void log_exit( struct log_info_t *li );
71 #else
73 #define log_init( a ) NULL
74 #define log_exit( a )
76 #endif
78 #endif
80 #if defined(__cplusplus)
82 #endif
85 #endif