~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/nx-gzip/include/nx_dbg.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /*
  3  * Copyright 2020 IBM Corporation
  4  *
  5  */
  6 
  7 #ifndef _NXU_DBG_H_
  8 #define _NXU_DBG_H_
  9 
 10 #include <sys/file.h>
 11 #include <stdint.h>
 12 #include <stdio.h>
 13 #include <time.h>
 14 #include <pthread.h>
 15 
 16 extern FILE * nx_gzip_log;
 17 extern int nx_gzip_trace;
 18 extern unsigned int nx_gzip_inflate_impl;
 19 extern unsigned int nx_gzip_deflate_impl;
 20 extern unsigned int nx_gzip_inflate_flags;
 21 extern unsigned int nx_gzip_deflate_flags;
 22 
 23 extern int nx_dbg;
 24 pthread_mutex_t mutex_log;
 25 
 26 #define nx_gzip_trace_enabled()       (nx_gzip_trace & 0x1)
 27 #define nx_gzip_hw_trace_enabled()    (nx_gzip_trace & 0x2)
 28 #define nx_gzip_sw_trace_enabled()    (nx_gzip_trace & 0x4)
 29 #define nx_gzip_gather_statistics()   (nx_gzip_trace & 0x8)
 30 #define nx_gzip_per_stream_stat()     (nx_gzip_trace & 0x10)
 31 
 32 #define prt(fmt, ...) do { \
 33         pthread_mutex_lock(&mutex_log);                                 \
 34         flock(nx_gzip_log->_fileno, LOCK_EX);                           \
 35         time_t t; struct tm *m; time(&t); m = localtime(&t);            \
 36         fprintf(nx_gzip_log, "[%04d/%02d/%02d %02d:%02d:%02d] "         \
 37                 "pid %d: " fmt, \
 38                 (int)m->tm_year + 1900, (int)m->tm_mon+1, (int)m->tm_mday, \
 39                 (int)m->tm_hour, (int)m->tm_min, (int)m->tm_sec,        \
 40                 (int)getpid(), ## __VA_ARGS__);                         \
 41         fflush(nx_gzip_log);                                            \
 42         flock(nx_gzip_log->_fileno, LOCK_UN);                           \
 43         pthread_mutex_unlock(&mutex_log);                               \
 44 } while (0)
 45 
 46 /* Use in case of an error */
 47 #define prt_err(fmt, ...) do { if (nx_dbg >= 0) {                       \
 48         prt("%s:%u: Error: "fmt,                                        \
 49                 __FILE__, __LINE__, ## __VA_ARGS__);                    \
 50 }} while (0)
 51 
 52 /* Use in case of an warning */
 53 #define prt_warn(fmt, ...) do { if (nx_dbg >= 1) {                      \
 54         prt("%s:%u: Warning: "fmt,                                      \
 55                 __FILE__, __LINE__, ## __VA_ARGS__);                    \
 56 }} while (0)
 57 
 58 /* Informational printouts */
 59 #define prt_info(fmt, ...) do { if (nx_dbg >= 2) {                      \
 60         prt("Info: "fmt, ## __VA_ARGS__);                               \
 61 }} while (0)
 62 
 63 /* Trace zlib wrapper code */
 64 #define prt_trace(fmt, ...) do { if (nx_gzip_trace_enabled()) {         \
 65         prt("### "fmt, ## __VA_ARGS__);                                 \
 66 }} while (0)
 67 
 68 /* Trace statistics */
 69 #define prt_stat(fmt, ...) do { if (nx_gzip_gather_statistics()) {      \
 70         prt("### "fmt, ## __VA_ARGS__);                                 \
 71 }} while (0)
 72 
 73 /* Trace zlib hardware implementation */
 74 #define hw_trace(fmt, ...) do {                                         \
 75                 if (nx_gzip_hw_trace_enabled())                         \
 76                         fprintf(nx_gzip_log, "hhh " fmt, ## __VA_ARGS__); \
 77         } while (0)
 78 
 79 /* Trace zlib software implementation */
 80 #define sw_trace(fmt, ...) do {                                         \
 81                 if (nx_gzip_sw_trace_enabled())                         \
 82                         fprintf(nx_gzip_log, "sss " fmt, ## __VA_ARGS__); \
 83         } while (0)
 84 
 85 
 86 /**
 87  * str_to_num - Convert string into number and copy with endings like
 88  *              KiB for kilobyte
 89  *              MiB for megabyte
 90  *              GiB for gigabyte
 91  */
 92 uint64_t str_to_num(char *str);
 93 void nx_lib_debug(int onoff);
 94 
 95 #endif  /* _NXU_DBG_H_ */
 96 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php