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

Fix RVec for gcc4 forward declaration not supported ##build #22774

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions libr/bin/format/elf/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ typedef struct r_bin_elf_lib_t {
} RBinElfLib;

#include <r_vec.h>
R_VEC_FORWARD_DECLARE (RVecRBinElfSymbol);
R_VEC_TYPE (RVecRBinElfSymbol, RBinElfSymbol);

struct Elf_(obj_t) {
Expand Down
1 change: 1 addition & 0 deletions libr/bin/format/mach0/mach0.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ static inline void r_bin_section_fini(RBinSection *bs) {
}
}

R_VEC_FORWARD_DECLARE (RVecSegment);
R_VEC_TYPE_WITH_FINI(RVecSegment, RBinSection, r_bin_section_fini);

struct MACH0_(obj_t) {
Expand Down
1 change: 1 addition & 0 deletions libr/core/agraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ static const char * const mousemodes[] = {

#define NORMALIZE_MOV(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))

R_VEC_FORWARD_DECLARE (RVecAnalRef);
R_VEC_TYPE (RVecAnalRef, RAnalRef);

static void hash_set(Sdb *db, const void *k, ut64 v) {
Expand Down
1 change: 1 addition & 0 deletions libr/core/anal_objc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <r_core.h>
#include <r_vec.h>

R_VEC_FORWARD_DECLARE (RVecAnalRef);
R_VEC_TYPE(RVecAnalRef, RAnalRef);

typedef struct {
Expand Down
3 changes: 3 additions & 0 deletions libr/core/anal_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#define D if (false)
#define DD if (false)

R_VEC_FORWARD_DECLARE(RVecUT64);
R_VEC_FORWARD_DECLARE(RVecBuf);
R_VEC_TYPE (RVecUT64, ut64);
R_VEC_TYPE (RVecBuf, ut8);

Expand Down Expand Up @@ -319,6 +321,7 @@ static _RAnalCond cond_invert(RAnal *anal, _RAnalCond cond) {
}

typedef const char* String;
R_VEC_FORWARD_DECLARE (RVecString);
R_VEC_TYPE (RVecString, String); // no fini, these are owned by SDB

static bool parse_format(RCore *core, const char *fmt, RVecString *vec) {
Expand Down
1 change: 1 addition & 0 deletions libr/core/canal.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

HEAPTYPE (ut64);

R_VEC_FORWARD_DECLARE(RVecAnalRef);
R_VEC_TYPE (RVecAnalRef, RAnalRef);

static R_TH_LOCAL RCore *mycore = NULL;
Expand Down
3 changes: 3 additions & 0 deletions libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#define MAX_SCAN_SIZE 0x7ffffff

R_VEC_FORWARD_DECLARE(RVecUT64);
R_VEC_FORWARD_DECLARE(RVecAddr);
R_VEC_TYPE (RVecUT64, ut64);
R_VEC_TYPE (RVecAddr, ut64); // DUPE

Expand Down Expand Up @@ -4251,6 +4253,7 @@ typedef struct {
char *regstate;
} BlockItem;

R_VEC_FORWARD_DECLARE(RVecBlocks);
R_VEC_TYPE (RVecBlocks, BlockItem);

static BlockItem *find_predecessor(RVecBlocks *blocks, BlockItem *b0) {
Expand Down
1 change: 1 addition & 0 deletions libr/core/cmd_debug.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5366,6 +5366,7 @@ static ut8 *getFileData(RCore *core, const char *arg, int *sz) {
return out;
}

R_VEC_FORWARD_DECLARE(RVecDebugTracepoint);
R_VEC_TYPE(RVecDebugTracepoint, RDebugTracepoint);

static int cmd_debug(void *data, const char *input) {
Expand Down
1 change: 1 addition & 0 deletions libr/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define DB core->sdb

R_LIB_VERSION (r_core);
R_VEC_FORWARD_DECLARE(RVecAnalRef);
R_VEC_TYPE (RVecAnalRef, RAnalRef);

static ut64 letter_divs[R_CORE_ASMQJMPS_LEN_LETTERS - 1] = {
Expand Down
2 changes: 2 additions & 0 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "r_core.h"
#include <r_vec.h>

R_VEC_FORWARD_DECLARE(RVecAnalRef);
R_VEC_TYPE(RVecAnalRef, RAnalRef);

#define HASRETRY 1
Expand Down Expand Up @@ -3857,6 +3858,7 @@ static void ds_print_bytes(RDisasmState *ds) {
core->print->flags = oldFlags;
}

R_VEC_FORWARD_DECLARE(RVecUT64);
R_VEC_TYPE(RVecUT64, ut64);

static int bb_cmp(const void *a, const void *b) {
Expand Down
1 change: 1 addition & 0 deletions libr/core/visual.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <r_core.h>
#include <r_vec.h>

R_VEC_FORWARD_DECLARE(RVecAnalRef);
R_VEC_TYPE(RVecAnalRef, RAnalRef);

#define NPF 5
Expand Down
1 change: 1 addition & 0 deletions libr/core/vmenus_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <r_core.h>
#include <r_vec.h>

R_VEC_FORWARD_DECLARE(RVecAnalRef);
R_VEC_TYPE(RVecAnalRef, RAnalRef);

#define SORT_ADDRESS 0
Expand Down
2 changes: 1 addition & 1 deletion libr/debug/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static inline void debug_plugin_session_fini(RDebugPluginSession *ds) {
R_FREE (ds->plugin_data);
}

R_VEC_TYPE_WITH_FINI(RVecDebugPluginSession, RDebugPluginSession, debug_plugin_session_fini);
R_VEC_TYPE_WITH_FINI (RVecDebugPluginSession, RDebugPluginSession, debug_plugin_session_fini);

static RDebugPlugin *debug_static_plugins[] = {
R_DEBUG_STATIC_PLUGINS
Expand Down
1 change: 1 addition & 0 deletions libr/include/r_anal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,7 @@ R_API bool r_anal_tid_select(RAnal *anal, int tid);

// bt

R_VEC_FORWARD_DECLARE(RVecBacktrace);
R_VEC_TYPE (RVecBacktrace, ut64);
R_API void r_anal_backtrace_add(RAnal *a, ut64 addr, RVecBacktrace *bt);
R_API void r_anal_backtrace_del(RAnal *a, ut64 addr);
Expand Down
4 changes: 4 additions & 0 deletions libr/include/r_bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,13 @@ typedef struct r_bin_import_t {
// XXX only forward declare here for better compile times
R_API void r_bin_symbol_fini(RBinSymbol *sym);
R_API void r_bin_import_fini(RBinImport *sym);
R_VEC_FORWARD_DECLARE (RVecRBinImport);
R_VEC_TYPE_WITH_FINI (RVecRBinImport, RBinImport, r_bin_import_fini);
R_VEC_FORWARD_DECLARE (RVecRBinSymbol);
R_VEC_TYPE_WITH_FINI (RVecRBinSymbol, RBinSymbol, r_bin_symbol_fini);
R_VEC_FORWARD_DECLARE (RVecRBinSection);
R_VEC_TYPE(RVecRBinSection, RBinSection);
R_VEC_FORWARD_DECLARE (RVecRBinEntry);
R_VEC_TYPE(RVecRBinEntry, RBinSymbol);

typedef struct r_bin_object_t {
Expand Down
1 change: 1 addition & 0 deletions libr/include/r_cons.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ typedef struct r_cons_fd_pair {
st16 fd_bak; // backup of target fd in a new dupped fd
} RConsFdPair;

R_VEC_FORWARD_DECLARE (RVecFdPairs);
R_VEC_TYPE (RVecFdPairs, RConsFdPair);
R_API void r_cons_mark_flush(void);
R_API void r_cons_mark(ut64 addr, const char *name);
Expand Down
1 change: 0 additions & 1 deletion libr/include/r_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ R_API RList* r_core_anal_graph_to(RCore *core, ut64 addr, int n);
R_API int r_core_anal_ref_list(RCore *core, int rad);
R_API int r_core_anal_all(RCore *core);
R_API RList* r_core_anal_cycles(RCore *core, int ccl);
typedef struct r_vec_RVecAnalRef_t RVecAnalRef;
R_API RVecAnalRef *r_core_anal_fcn_get_calls(RCore *core, RAnalFunction *fcn); // get all calls from a function

/*tp.c*/
Expand Down
14 changes: 7 additions & 7 deletions libr/include/r_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ typedef struct r_snap_entry {
int perm;
} RSnapEntry;

R_VEC_FORWARD_DECLARE(RVecDebugTracepoint);
R_VEC_FORWARD_DECLARE (RVecDebugTracepoint);

typedef struct r_debug_trace_t {
RVecDebugTracepoint *traces;
int count;
int enabled;
int tag;
int dup;
// int dupe;
char *addresses;
HtPP *ht; // use rbtree like the iocache?
} RDebugTrace;
Expand Down Expand Up @@ -290,7 +290,7 @@ typedef struct r_debug_desc_plugin_t {
RList* (*list)(int pid);
} RDebugDescPlugin;

typedef struct r_debug_plugin_session_t RDebugPluginSession;
typedef struct r_debug_plugin_session_t _RDebugPluginSession;
typedef int (*RDebugCmdCb)(RDebug *dbg, const char *cmd);
typedef struct r_debug_plugin_t {
RPluginMeta meta;
Expand All @@ -299,8 +299,8 @@ typedef struct r_debug_plugin_t {
int canstep;
int keepio;
/* life */
bool (*init_plugin)(RDebug *dbg, RDebugPluginSession *ds);
bool (*fini_plugin)(RDebug *dbg, RDebugPluginSession *ds);
bool (*init_plugin)(RDebug *dbg, _RDebugPluginSession *ds);
bool (*fini_plugin)(RDebug *dbg, _RDebugPluginSession *ds);
RDebugInfo* (*info)(RDebug *dbg, const char *arg);
int (*startv)(int argc, char **argv);
bool (*attach)(RDebug *dbg, int pid);
Expand Down Expand Up @@ -347,7 +347,7 @@ typedef struct r_debug_plugin_session_t {

R_VEC_FORWARD_DECLARE (RVecDebugPluginSession);

typedef struct r_debug_t {
struct r_debug_t {
// R2_590 use RArchConfig instead
char *arch;
int bits; /// XXX: MUST SET ///
Expand Down Expand Up @@ -436,7 +436,7 @@ typedef struct r_debug_t {
bool glibc_version_resolved; /* is the libc version resolved already? */
int glibc_version;
double glibc_version_d; // TODO: move over to this only
} RDebug;
}; // declared above

// TODO: rename to r_debug_process_t ? maybe a thread too ?
typedef struct r_debug_pid_t {
Expand Down
3 changes: 3 additions & 0 deletions libr/include/r_esil.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ static inline void fini_access(REsilTraceAccess *access) {
free (access->mem.data);
}

R_VEC_FORWARD_DECLARE(RVecTraceOp);
R_VEC_TYPE(RVecTraceOp, REsilTraceOp);

R_VEC_FORWARD_DECLARE(RVecAccess);
R_VEC_TYPE_WITH_FINI(RVecAccess, REsilTraceAccess, fini_access);

typedef struct {
Expand Down
1 change: 1 addition & 0 deletions libr/include/r_util/r_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ typedef struct {
ut16 to;
} RStringSlice;

R_VEC_FORWARD_DECLARE (RVecStringSlice);
R_VEC_TYPE (RVecStringSlice, RStringSlice);


Expand Down
2 changes: 1 addition & 1 deletion libr/include/r_vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ extern "C" {
type *_start; \
type *_end; \
size_t _capacity; \
} vec_type; \
}; \
typedef void (*R_VEC_COPY(vec_type))(type *dst, type const *src); \
typedef int (*R_VEC_CMP(vec_type))(type const *a, type const *b); \
typedef int (*R_VEC_FIND_CMP(vec_type))(type const *a, const void *b); \
Expand Down
2 changes: 2 additions & 0 deletions libr/io/p/io_dsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef struct {

static void r_io_dsc_rebase_infos_free(RDyldRebaseInfosEntry * entry);

R_VEC_FORWARD_DECLARE (RIODscRebaseInfos);
R_VEC_TYPE_WITH_FINI (RIODscRebaseInfos, RDyldRebaseInfosEntry, r_io_dsc_rebase_infos_free);

typedef struct {
Expand All @@ -106,6 +107,7 @@ typedef struct {

static void r_io_dsc_slice_free(RIODscSlice * slice);

R_VEC_FORWARD_DECLARE (RIODscSlices);
R_VEC_TYPE_WITH_FINI (RIODscSlices, RIODscSlice, r_io_dsc_slice_free);

typedef struct {
Expand Down
3 changes: 3 additions & 0 deletions libr/lang/p/qjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ static void arch_plugin_fini(QjsArchPlugin *ap) {
free (ap->arch);
}

R_VEC_FORWARD_DECLARE (RVecCorePlugin);
R_VEC_FORWARD_DECLARE (RVecArchPlugin);
R_VEC_FORWARD_DECLARE (RVecIoPlugin);
R_VEC_TYPE_WITH_FINI (RVecCorePlugin, QjsCorePlugin, core_plugin_fini);
R_VEC_TYPE_WITH_FINI (RVecArchPlugin, QjsArchPlugin, arch_plugin_fini);
R_VEC_TYPE (RVecIoPlugin, QjsIoPlugin); // R2_590 add finalizer function
Expand Down
2 changes: 1 addition & 1 deletion libr/util/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ typedef struct r_table_visual_state_t {
bool va;
RenderTableRows render_fn;
void *user;
} TableVisualState;
};

static void r_table_visual_row(RTable *table, const RListInfo *info, int i, TableVisualState *state) {
RCons *cons = (RCons *) table->cons;
Expand Down