Remove the unused opr_AssertFailU() function
[openafs.git] / src / opr / opr.h
1 #ifndef OPENAFS_OPR_OPR_H
2 #define OPENAFS_OPR_OPR_H 1
3
4 /* macros */
5
6 /* should use offsetof() if available */
7 #define opr_containerof(ptr, structure, member) \
8    ((structure *)((char *)(ptr)-(char *)(&((structure *)NULL)->member)))
9
10 /* assert.c */
11
12 #ifdef AFS_NT40_ENV
13 # define opr_abort() opr_NTAbort()
14 extern void opr_NTAbort(void);
15 #else
16 # define opr_abort() abort()
17 #endif
18
19 extern void opr_AssertionFailed(const char *, int) AFS_NORETURN;
20
21 /* opr_Assert is designed to work in a similar way to the operating
22  * system's assert function. This means that in future, it may compile
23  * to a no-op if NDEBUG is defined
24  */
25
26 #define __opr_Assert(ex) \
27     do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0)
28
29 #if defined(HAVE__PRAGMA_TAUTOLOGICAL_POINTER_COMPARE) && defined(__clang__)
30 # define opr_Assert(ex) \
31     _Pragma("clang diagnostic push") \
32     _Pragma("clang diagnostic ignored \"-Wtautological-pointer-compare\"") \
33     __opr_Assert(ex) \
34     _Pragma("clang diagnostic pop")
35 #else
36 # define opr_Assert(ex) __opr_Assert(ex)
37 #endif
38
39 /* opr_Verify is an assertion function which is guaranteed to always
40  * invoke its expression, regardless of the debugging level selected
41  * at compile time */
42
43 #define __opr_Verify(ex) \
44     do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0)
45
46 #if defined(HAVE__PRAGMA_TAUTOLOGICAL_POINTER_COMPARE) && defined(__clang__)
47 # define opr_Verify(ex) \
48     _Pragma("clang diagnostic push") \
49     _Pragma("clang diagnostic ignored \"-Wtautological-pointer-compare\"") \
50     __opr_Verify(ex) \
51     _Pragma("clang diagnostic pop")
52 #else
53 # define opr_Verify(ex) __opr_Verify(ex)
54 #endif
55
56 /* opr_StaticAssert is a static build-time assertion, to assert certain
57  * static values (such as sizeof results). If the assertion fails, the
58  * build will fail. */
59
60 #define opr_StaticAssert(ex) \
61     ((void)(sizeof(char[1 - 2 * !(ex)])))
62
63 /* casestrcpy.c */
64 #define lcstring opr_lcstring
65 #define ucstring opr_ucstring
66 #define stolower opr_stolower
67 #define stoupper opr_stoupper
68 /* XXX str* is in the implementation namespace when <string.h> is included */
69 #define strcompose opr_strcompose
70
71 extern char *opr_lcstring(char *d, const char *s, int n) AFS_NONNULL((1,2));
72 extern char *opr_ucstring(char *d, const char *s, int n) AFS_NONNULL((1,2));
73 extern void opr_stolower(char *s) AFS_NONNULL(());
74 extern void opr_stoupper(char *s) AFS_NONNULL(());
75 extern char *opr_strcompose(char *buf, size_t len, ...) AFS_NONNULL((1));
76
77 #endif