Modified Hashkit class (turned it into an actual class).
[m6w6/libmemcached] / libmemcached / watchpoint.h
1 /* LibMemcached
2 * Copyright (C) 2006-2009 Brian Aker
3 * All rights reserved.
4 *
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
7 *
8 * Summary: Localized copy of WATCHPOINT debug symbols
9 *
10 */
11
12 #ifndef __LIBMEMCACHED_WATCHPOINT_H__
13 #define __LIBMEMCACHED_WATCHPOINT_H__
14
15 /* Some personal debugging functions */
16 #if defined(DEBUG)
17
18 #include <assert.h>
19
20 #define WATCHPOINT do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout); } while (0)
21 #define WATCHPOINT_ERROR(A) do {fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0)
22 #define WATCHPOINT_IFERROR(A) do { if(A != MEMCACHED_SUCCESS)fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0)
23 #define WATCHPOINT_STRING(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); } while (0)
24 #define WATCHPOINT_STRING_LENGTH(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout); } while (0)
25 #define WATCHPOINT_NUMBER(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %zu\n", __FILE__, __LINE__,__func__,(size_t)(A));fflush(stdout); } while (0)
26 #define WATCHPOINT_ERRNO(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout); } while (0)
27 #define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWATCHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, (B),(C));fprintf(stderr,"\n");fflush(stdout);}assert((A)); } while (0)
28 #define WATCHPOINT_ASSERT(A) assert((A))
29 #define WATCHPOINT_ASSERT_INITIALIZED(A) assert(memcached_is_initialized((A)))
30
31 #else
32
33 #define WATCHPOINT
34 #define WATCHPOINT_ERROR(A)
35 #define WATCHPOINT_IFERROR(A)
36 #define WATCHPOINT_STRING(A)
37 #define WATCHPOINT_NUMBER(A)
38 #define WATCHPOINT_ERRNO(A)
39 #define WATCHPOINT_ASSERT_PRINT(A,B,C)
40 #define WATCHPOINT_ASSERT(A)
41 #define WATCHPOINT_ASSERT_INITIALIZED(A)
42
43 #endif /* DEBUG */
44
45 #endif /* __LIBMEMCACHED_WATCHPOINT_H__ */