mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
fuzzing/common: Common definitions
Change-Id: I5a3718b9c19800bd6615b52a050f6f443394136e
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
include $(top_srcdir)/globals.mk
|
||||
|
||||
AM_CXXFLAGS += -I$(top_srcdir)/src -I.
|
||||
AM_CXXFLAGS += -I$(top_srcdir)/src -I. -include common.h
|
||||
AM_LDFLAGS += $(top_builddir)/src/libring.la
|
||||
check_PROGRAMS =
|
||||
|
||||
|
46
test/fuzzing/common.h
Normal file
46
test/fuzzing/common.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
# define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
static inline bool
|
||||
streq(const char* A, const char* B)
|
||||
{
|
||||
return 0 == strcmp(A, B);
|
||||
}
|
||||
|
||||
#define BEGIN_WRAPPER_PRIMITIVE(SYM, RET, NAME, ARGS...) \
|
||||
RET NAME(ARGS) \
|
||||
{ \
|
||||
RET (*this_func)(ARGS) = nullptr; \
|
||||
\
|
||||
if (nullptr == this_func) { \
|
||||
this_func = (typeof(this_func)) dlsym(RTLD_NEXT, #SYM); \
|
||||
assert(this_func); \
|
||||
}
|
||||
|
||||
#define BEGIN_METHOD_WRAPPER(SYM, RET, NAME, ARGS...) \
|
||||
RET NAME(ARGS) \
|
||||
{ \
|
||||
RET (*this_func)(typeof(this), ##ARGS) = nullptr; \
|
||||
\
|
||||
if (nullptr == this_func) { \
|
||||
this_func = (typeof(this_func)) dlsym(RTLD_NEXT, #SYM); \
|
||||
assert(this_func); \
|
||||
}
|
||||
|
||||
#define BEGIN_WRAPPER(RET, NAME, ARGS...) BEGIN_WRAPPER_PRIMITIVE(NAME, RET, NAME, ARGS)
|
||||
#define END_WRAPPER(ARGS...) } static_assert(true, "")
|
||||
|
||||
#define __weak __attribute__((weak))
|
||||
#define __used __attribute__((used))
|
||||
|
||||
#define array_size(arr) (sizeof(arr) / sizeof((arr)[0]))
|
Reference in New Issue
Block a user