Mark unused arguments in many modules.
[ccan] / ccan / order / order.c
1 /* CC0 license (public domain) - see LICENSE file for details */
2
3 #include <ccan/order/order.h>
4
5 #define SCALAR_ORDER(_oname, _type)                                     \
6         int _order_##_oname(const void *a,                              \
7                             const void *b,                              \
8                             void *ctx)                                  \
9         {                                                               \
10                 ptrdiff_t offset = ptr2int(ctx);                        \
11                 const _type *aa = (const _type *)((char *)a + offset);  \
12                 const _type *bb = (const _type *)((char *)b + offset);  \
13                                                                         \
14                 if (*aa < *bb) {                                        \
15                         return -1;                                      \
16                 } else if (*aa > *bb) {                                 \
17                         return 1;                                       \
18                 } else {                                                \
19                         assert(*aa == *bb);                             \
20                         return 0;                                       \
21                 }                                                       \
22         }                                                               \
23         int order_##_oname(const _type *a,                              \
24                            const _type *b,                              \
25                            void *ctx)                                   \
26         {                                                               \
27                 (void)ctx; return _order_##_oname(a, b, int2ptr(0));    \
28         }                                                               \
29         int _order_##_oname##_reverse(const void *a,                    \
30                                       const void *b,                    \
31                                       void *ctx)                        \
32         {                                                               \
33                 return -_order_##_oname(a, b, ctx);                     \
34         }                                                               \
35         int order_##_oname##_reverse(const _type *a,                    \
36                                      const _type *b,                    \
37                                      void *ctx)                         \
38         {                                                               \
39                 (void)ctx;                                              \
40                 return _order_##_oname##_reverse(a, b, int2ptr(0));     \
41         }                                                               \
42         int order_##_oname##_noctx(const void *a,                       \
43                                    const void *b)                       \
44         {                                                               \
45                 return _order_##_oname(a, b, int2ptr(0));               \
46         }                                                               \
47         int order_##_oname##_reverse_noctx(const void *a,               \
48                                            const void *b)               \
49         {                                                               \
50                 return _order_##_oname##_reverse(a, b, int2ptr(0));     \
51         }
52
53 SCALAR_ORDER(s8, int8_t)
54 SCALAR_ORDER(s16, int16_t)
55 SCALAR_ORDER(s32, int32_t)
56 SCALAR_ORDER(s64, int64_t)
57
58 SCALAR_ORDER(u8, uint8_t)
59 SCALAR_ORDER(u16, uint16_t)
60 SCALAR_ORDER(u32, uint32_t)
61 SCALAR_ORDER(u64, uint64_t)
62
63 SCALAR_ORDER(int, int)
64 SCALAR_ORDER(uint, unsigned int)
65 SCALAR_ORDER(long, long)
66 SCALAR_ORDER(ulong, unsigned long)
67 SCALAR_ORDER(size, size_t)
68 SCALAR_ORDER(ptrdiff, ptrdiff_t)
69
70 SCALAR_ORDER(float, float)
71 SCALAR_ORDER(double, double)