2 * Copyright (c) 2011-2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 * @brief BFD global declarations
19 #ifndef __included_bfd_debug_h__
20 #define __included_bfd_debug_h__
22 /* controls debug prints */
26 #define BFD_DEBUG_FILE_DEF \
27 static const char *__file = NULL; \
29 __file = strrchr (__FILE__, '/'); \
40 #define BFD_DBG(fmt, ...) \
44 static u8 *_s = NULL; \
45 vlib_main_t *vm = vlib_get_main (); \
46 _s = format (_s, "%6.02f:DBG:%s:%d:%s():" fmt, vlib_time_now (vm), \
47 __file, __LINE__, __func__, ##__VA_ARGS__); \
48 printf ("%.*s\n", vec_len (_s), _s); \
49 vec_reset_length (_s); \
53 #define BFD_ERR(fmt, ...) \
57 static u8 *_s = NULL; \
58 vlib_main_t *vm = vlib_get_main (); \
59 _s = format (_s, "%6.02f:ERR:%s:%d:%s():" fmt, vlib_time_now (vm), \
60 __file, __LINE__, __func__, ##__VA_ARGS__); \
61 printf ("%.*s\n", vec_len (_s), _s); \
62 vec_reset_length (_s); \
66 #define BFD_CLK_FMT "%luus/%lu nsec/%.2fs"
67 #define BFD_CLK_PRN(nsec) \
68 (nsec * NSEC_PER_SEC), (nsec), (((f64)nsec) / NSEC_PER_SEC)
75 #endif /* __included_bfd_debug_h__ */
78 * fd.io coding-style-patch-verification: ON
81 * eval: (c-set-style "gnu")