Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add re prefix #659

Merged
merged 2 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/re_mbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
/** Check that mbuf position does not exceed end */
#define MBUF_CHECK_POS(mb) \
if ((mb) && (mb)->pos > (mb)->end) { \
BREAKPOINT; \
RE_BREAKPOINT; \
}
/** Check that mbuf end does not exceed size */
#define MBUF_CHECK_END(mb) \
if ((mb) && (mb)->end > (mb)->size) { \
BREAKPOINT; \
RE_BREAKPOINT; \
}
#else
#define MBUF_CHECK_POS(mb)
Expand Down
21 changes: 9 additions & 12 deletions include/re_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ typedef SSIZE_T ssize_t;


/** Align a value to the boundary of mask */
#define ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
#define RE_ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))

/** Check alignment of pointer (p) and byte count (c) **/
#define is_aligned(p, c) (((uintptr_t)(const void *)(p)) % (c) == 0)
#define re_is_aligned(p, c) (((uintptr_t)(const void *)(p)) % (c) == 0)
#define is_aligned re_is_aligned

/** Get the minimal value */
#undef MIN
Expand All @@ -77,11 +78,15 @@ typedef SSIZE_T ssize_t;

/** Defines a soft breakpoint */
#if (defined(__i386__) || defined(__x86_64__))
#define BREAKPOINT __asm__("int $0x03")
#define RE_BREAKPOINT __asm__("int $0x03")
#else
#define BREAKPOINT
#define RE_BREAKPOINT
#endif

/* Backwards compat */
#define BREAKPOINT RE_BREAKPOINT


/* Error return/goto debug helpers */
#ifdef TRACE_ERR
#define PRINT_TRACE_ERR(err) \
Expand Down Expand Up @@ -235,14 +240,6 @@ typedef SSIZE_T ssize_t;
#define EKEYREJECTED 129
#endif

/*
* Any C compiler conforming to C99 or later MUST support __func__
*/
#if __STDC_VERSION__ >= 199901L
#define __REFUNC__ (const char *)__func__
#else
#define __REFUNC__ __FUNCTION__
#endif

/*
* Give the compiler a hint which branch is "likely" or "unlikely" (inspired
Expand Down
2 changes: 1 addition & 1 deletion src/bfcp/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ static int attr_decode(struct bfcp_attr **attrp, struct mbuf *mb,
if (!attr->mand)
break;

if (uma && uma->typec < ARRAY_SIZE(uma->typev))
if (uma && uma->typec < RE_ARRAY_SIZE(uma->typev))
uma->typev[uma->typec++] = attr->type<<1;
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dns/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static int reply_recv(struct dnsc *dnsc, struct mbuf *mb)
nv[2] = dq.hdr.nadd;

DEBUG_INFO("--- ANSWER SECTION id: %d ---\n", q->id);
for (uint32_t i = 0; i < ARRAY_SIZE(nv); i++) {
for (uint32_t i = 0; i < RE_ARRAY_SIZE(nv); i++) {
uint32_t l = nv[i];

if (l > RR_MAX) {
Expand Down Expand Up @@ -1276,7 +1276,7 @@ int dnsc_srv_set(struct dnsc *dnsc, const struct sa *srvv, uint32_t srvc)
if (!dnsc)
return EINVAL;

dnsc->srvc = min((uint32_t)ARRAY_SIZE(dnsc->srvv), srvc);
dnsc->srvc = min((uint32_t)RE_ARRAY_SIZE(dnsc->srvv), srvc);

if (srvv) {
for (i=0; i<dnsc->srvc; i++)
Expand Down
4 changes: 2 additions & 2 deletions src/fmt/pl.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,14 +337,14 @@ int pl_bool(bool *val, const struct pl *pl)
if (!val || !pl)
return EINVAL;

for (i = 0; i < ARRAY_SIZE(tval); ++i) {
for (i = 0; i < RE_ARRAY_SIZE(tval); ++i) {
if (!pl_strcasecmp(pl, tval[i])) {
*val = true;
err = 0;
}
}

for (i = 0; i < ARRAY_SIZE(fval); ++i) {
for (i = 0; i < RE_ARRAY_SIZE(fval); ++i) {
if (!pl_strcasecmp(pl, fval[i])) {
*val = false;
err = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/fmt/regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ int re_regex(const char *ptr, size_t len, const char *expr, ...)
}

chr:
if (n >= ARRAY_SIZE(chrv))
if (n >= RE_ARRAY_SIZE(chrv))
break;

chrv[n].max = tolower(*ep);
Expand Down
10 changes: 5 additions & 5 deletions src/fmt/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ int fmt_gmtime(struct re_printf *pf, void *ts)
#endif

return re_hprintf(pf, "%s, %02u %s %u %02u:%02u:%02u GMT",
dayv[min((unsigned)tm.tm_wday, ARRAY_SIZE(dayv)-1)],
tm.tm_mday,
monv[min((unsigned)tm.tm_mon, ARRAY_SIZE(monv)-1)],
tm.tm_year + 1900,
tm.tm_hour, tm.tm_min, tm.tm_sec);
dayv[min((unsigned)tm.tm_wday, RE_ARRAY_SIZE(dayv)-1)],
tm.tm_mday,
monv[min((unsigned)tm.tm_mon, RE_ARRAY_SIZE(monv)-1)],
tm.tm_year + 1900,
tm.tm_hour, tm.tm_min, tm.tm_sec);
}


Expand Down
2 changes: 1 addition & 1 deletion src/http/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ static bool rr_handler(struct dnsrr *rr, void *arg)
{
struct http_req *req = arg;

if (req->srvc >= ARRAY_SIZE(req->srvv))
if (req->srvc >= RE_ARRAY_SIZE(req->srvv))
return true;

switch (rr->type) {
Expand Down
4 changes: 2 additions & 2 deletions src/mem/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ static inline void mem_unlock(void)
#define MAGIC_CHECK(_m) \
if (mem_magic != (_m)->magic) { \
DEBUG_WARNING("%s: magic check failed 0x%08zx (%p)\n", \
__REFUNC__, (_m)->magic, get_mem_data((_m))); \
BREAKPOINT; \
__func__, (_m)->magic, get_mem_data((_m))); \
RE_BREAKPOINT; \
}
#else
#define STAT_ALLOC(_m, _size) (_m)->size = (uint32_t)(_size);
Expand Down
2 changes: 1 addition & 1 deletion src/rtmp/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static bool rr_handler(struct dnsrr *rr, void *arg)
{
struct rtmp_conn *conn = arg;

if (conn->srvc >= ARRAY_SIZE(conn->srvv))
if (conn->srvc >= RE_ARRAY_SIZE(conn->srvv))
return true;

switch (rr->type) {
Expand Down
6 changes: 3 additions & 3 deletions src/sdp/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void destructor(void *arg)
return;
}

for (i=0; i<ARRAY_SIZE(m->protov); i++)
for (i=0; i<RE_ARRAY_SIZE(m->protov); i++)
mem_deref(m->protov[i]);

list_unlink(&m->le);
Expand Down Expand Up @@ -196,7 +196,7 @@ bool sdp_media_proto_cmp(struct sdp_media *m, const struct pl *proto,
if (!pl_strcmp(proto, m->proto))
return true;

for (i=0; i<ARRAY_SIZE(m->protov); i++) {
for (i=0; i<RE_ARRAY_SIZE(m->protov); i++) {

if (!m->protov[i] || pl_strcmp(proto, m->protov[i]))
continue;
Expand Down Expand Up @@ -364,7 +364,7 @@ int sdp_media_set_alt_protos(struct sdp_media *m, unsigned protoc, ...)

va_start(ap, protoc);

for (i=0; i<ARRAY_SIZE(m->protov); i++) {
for (i=0; i<RE_ARRAY_SIZE(m->protov); i++) {

m->protov[i] = mem_deref(m->protov[i]);

Expand Down
4 changes: 2 additions & 2 deletions src/stun/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ int stun_attr_decode(struct stun_attr **attrp, struct mbuf *mb,
for (i=0; i<len/2; i++) {
uint16_t type = ntohs(mbuf_read_u16(mb));

if (i >= ARRAY_SIZE(attr->v.unknown_attr.typev))
if (i >= RE_ARRAY_SIZE(attr->v.unknown_attr.typev))
continue;

attr->v.unknown_attr.typev[i] = type;
Expand Down Expand Up @@ -325,7 +325,7 @@ int stun_attr_decode(struct stun_attr **attrp, struct mbuf *mb,
if (attr->type >= 0x8000)
break;

if (ua && ua->typec < ARRAY_SIZE(ua->typev))
if (ua && ua->typec < RE_ARRAY_SIZE(ua->typev))
ua->typev[ua->typec++] = attr->type;
break;
}
Expand Down