1 /****************************************************************************
3 * Copyright (C) 2005 - 2013 by Vivante Corp.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the license, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *****************************************************************************/
22 #ifndef __gc_hal_kernel_debug_h_
23 #define __gc_hal_kernel_debug_h_
25 #include <gc_hal_kernel_linux.h>
26 #include <linux/spinlock.h>
27 #include <linux/time.h>
34 /******************************************************************************\
35 ****************************** OS-dependent Macros *****************************
36 \******************************************************************************/
38 typedef va_list gctARGUMENTS;
40 #define gcmkARGUMENTS_START(Arguments, Pointer) \
41 va_start(Arguments, Pointer)
43 #define gcmkARGUMENTS_END(Arguments) \
46 #define gcmkDECLARE_LOCK(__spinLock__) \
47 static DEFINE_SPINLOCK(__spinLock__);
49 #define gcmkLOCKSECTION(__spinLock__) \
50 spin_lock(&__spinLock__)
52 #define gcmkUNLOCKSECTION(__spinLock__) \
53 spin_unlock(&__spinLock__)
55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
56 # define gcmkGETPROCESSID() \
57 task_tgid_vnr(current)
59 # define gcmkGETPROCESSID() \
63 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
64 # define gcmkGETTHREADID() \
67 # define gcmkGETTHREADID() \
71 #define gcmkOUTPUT_STRING(String) \
72 if(gckDebugFileSystemIsEnabled()) \
73 gckDebugFileSystemPrint(String);\
76 touch_softlockup_watchdog()
79 #define gcmkSPRINTF(Destination, Size, Message, Value) \
80 snprintf(Destination, Size, Message, Value)
82 #define gcmkSPRINTF2(Destination, Size, Message, Value1, Value2) \
83 snprintf(Destination, Size, Message, Value1, Value2)
85 #define gcmkSPRINTF3(Destination, Size, Message, Value1, Value2, Value3) \
86 snprintf(Destination, Size, Message, Value1, Value2, Value3)
88 #define gcmkVSPRINTF(Destination, Size, Message, Arguments) \
89 vsnprintf(Destination, Size, Message, *(va_list *) &Arguments)
91 #define gcmkSTRCAT(Destination, Size, String) \
92 strncat(Destination, String, Size)
94 /* If not zero, forces data alignment in the variable argument list
95 by its individual size. */
96 #define gcdALIGNBYSIZE 1
102 #endif /* __gc_hal_kernel_debug_h_ */