spinn_common  development
Support code for SpiNNaker applications.
spin-print.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 The University of Manchester
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
51 #ifndef __SPIN_PRINT_H__
52 #define __SPIN_PRINT_H__
53 
55 
56 static inline void skip(void)
57 {
58  return;
59 }
60 
61 #ifdef DEBUG_ON_HOST
62 #include <stdlib.h>
63 #include <stdio.h>
64 
68 #define __log_message(type, message, ...) \
69  do { \
70  fprintf(stderr, type "(%s:%4d): " message "\n", \
71  __FILENAME__, __LINE__, ##__VA_ARGS__); \
72  } while (0)
73 
78 #define __log(level, message, ...) \
79  do { \
80  if (level <= LOG_LEVEL) { \
81  __log_message(message, ##__VA_ARGS__); \
82  } \
83  } while (0)
84 
87 #define log_info(message, ...) \
88  __log(LOG_INFO, "[INFO] ", message, ##__VA_ARGS__)
89 
90 #define spin1_dma_transfer(tag, s, t, d, ln) \
91  do { log_info("spin1_dma_transfer (%u, %u)", (s), (t)); } while (0)
92 
93 #define spin1_trigger_user_event(a, b) \
94  do { log_info("spin1_trigger_user_event (%d, %d)", (a), (b)); } while (0)
95 
96 #define c_main \
97  c_main(void); int main(void) { c_main(); return 0; } void c_main
98 
99 #else /* DEBUG_ON_HOST */
100 #include "sark.h"
101 #include "spin1_api.h"
102 
104 #undef malloc
105 #define malloc spin1_malloc
107 #undef srandom
108 #define srandom spin1_srand
110 #undef random
111 #define random spin1_rand
113 #undef fprintf
114 #define fprintf io_printf
116 #undef stdout
117 #define stdout IO_BUF
119 #undef stderr
120 #define stderr IO_BUF
122 #undef printf
123 #define printf(s, ...) \
124  do { io_printf(IO_BUF, s, ##__VA_ARGS__); } while (0)
126 #undef putchar
127 #define putchar(c) \
128  do { io_printf(IO_BUF, "%c", c); } while (0)
130 #undef exit
131 #define exit(n) \
132  do { spin1_exit(n); } while (0)
133 
134 #endif /* DEBUG_ON_HOST */
135 #endif /* __SPIN_PRINT_H__ */
static void skip(void)
This function is used to represent doing nothing.
Definition: spin-print.h:56