picow-http
1.1.0-2-ga16b87a
HTTP server for the Raspberry Pi PicoW
assertion.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 Geoff Simmons <geoff@simmons.de>
3
*
4
* SPDX-License-Identifier: BSD-2-Clause
5
* See LICENSE
6
*/
7
63
#include <string.h>
64
65
#include "pico/version.h"
66
67
#if PICO_SDK_VERSION_MAJOR < 2
68
#include "pico/platform.h"
69
#else
70
#include "pico.h"
71
#endif
72
94
#if defined (NDEBUG) && !defined(__DOXYGEN__)
95
#define PICOW_HTTP_ASSERT(c) ((void)(c))
96
#else
97
#define PICOW_HTTP_ASSERT(c) do { \
98
if (!(c)) \
99
panic("%s(): "
#c " false", __func__); \
100
} while (0)
101
#endif
102
124
#define AZ(x) do { PICOW_HTTP_ASSERT((x) == 0); } while (0)
125
147
#define AN(x) do { PICOW_HTTP_ASSERT((x) != 0); } while (0)
148
149
/*
150
* The following does not include ALLOC_OBJ and FREE_OBJ from Varnish
151
* miniobj.h, because we may want to use LWIP custom memory pools.
152
*/
153
173
#define ZERO_OBJ(to, sz) \
174
do { \
175
void *(*volatile z_obj)(void *, int, size_t) = memset; \
176
(void)z_obj(to, 0, sz); \
177
} while (0)
178
206
#define INIT_OBJ(to, type_magic) \
207
do { \
208
ZERO_OBJ(to, sizeof *(to)); \
209
(to)->magic = (type_magic); \
210
} while (0)
211
246
#define FINI_OBJ(to) \
247
do { \
248
ZERO_OBJ(&(to)->magic, sizeof (to)->magic); \
249
to = NULL; \
250
} while (0)
251
286
#define VALID_OBJ(ptr, type_magic) \
287
((ptr) != NULL && (ptr)->magic == (type_magic))
288
327
#define CHECK_OBJ(ptr, type_magic) \
328
do { \
329
PICOW_HTTP_ASSERT((ptr)->magic == type_magic); \
330
} while (0)
331
368
#define CHECK_OBJ_NOTNULL(ptr, type_magic) \
369
do { \
370
PICOW_HTTP_ASSERT((ptr) != NULL); \
371
PICOW_HTTP_ASSERT((ptr)->magic == type_magic); \
372
} while (0)
373
414
#define CHECK_OBJ_ORNULL(ptr, type_magic) \
415
do { \
416
if ((ptr) != NULL) \
417
PICOW_HTTP_ASSERT((ptr)->magic == type_magic); \
418
} while (0)
419
465
#define CAST_OBJ(to, from, type_magic) \
466
do { \
467
(to) = (from); \
468
if ((to) != NULL) \
469
CHECK_OBJ((to), (type_magic)); \
470
} while (0)
471
512
#define CAST_OBJ_NOTNULL(to, from, type_magic) \
513
do { \
514
(to) = (from); \
515
AN((to)); \
516
CHECK_OBJ((to), (type_magic)); \
517
} while (0)
picow_http
assertion.h
Generated by
1.9.4