Blame src/internal/mdso_driver_impl.h

cde03b
#ifndef MDSO_DRIVER_IMPL_H
cde03b
#define MDSO_DRIVER_IMPL_H
cde03b
cde03b
#include <stdint.h>
cde03b
#include <stdio.h>
cde03b
#include <sys/types.h>
cde03b
cde03b
#include <mdso/mdso.h>
a5071f
#include "argv/argv.h"
a5071f
a6c8d0
#define MDSO_OPTV_ELEMENTS 64
a6c8d0
a5071f
extern const struct argv_option mdso_default_options[];
cde03b
cde03b
enum app_tags {
cde03b
	TAG_HELP,
cde03b
	TAG_VERSION,
7c0ec4
	TAG_QUAD_PTR,
6848b7
	TAG_LIBPATH,
d8c2b3
	TAG_LIBNAME,
d8c2b3
	TAG_DSTDIR,
8cfad6
	TAG_PRETTY,
8cfad6
	TAG_EXPSYMS,
cde03b
};
cde03b
43f283
struct mdso_expsyms {
43f283
	char *		buffer;
43f283
	const char *	syms[];
43f283
};
43f283
cde03b
struct mdso_driver_ctx_impl {
2c8758
	struct mdso_common_ctx          cctx;
2c8758
	struct mdso_driver_ctx          ctx;
2c8758
	char *                          asmbase;
2c8758
	int                             fddst;
2c8758
	int                             fdtmpin;
2c8758
	const struct mdso_unit_ctx *    euctx;
2c8758
	const char *                    eunit;
2c8758
	struct mdso_error_info**        errinfp;
2c8758
	struct mdso_error_info**        erricap;
2c8758
	struct mdso_error_info *        erriptr[64];
2c8758
	struct mdso_error_info          erribuf[64];
cde03b
};
cde03b
cde03b
struct mdso_unit_ctx_impl {
cde03b
	const char *		path;
cde03b
	struct mdso_input	map;
43f283
	struct mdso_expsyms *	expsyms;
cde03b
	struct mdso_common_ctx	cctx;
cde03b
	struct mdso_unit_ctx	uctx;
cde03b
};
cde03b
3a9f95
static inline struct mdso_driver_ctx_impl * mdso_get_driver_ictx(
3a9f95
	const struct mdso_driver_ctx * dctx)
3a9f95
{
3a9f95
        uintptr_t addr;
3a9f95
3a9f95
        if (dctx) {
3a9f95
                addr = (uintptr_t)dctx - offsetof(struct mdso_driver_ctx_impl,ctx);
3a9f95
                return (struct mdso_driver_ctx_impl *)addr;
3a9f95
        }
3a9f95
3a9f95
        return 0;
3a9f95
}
3a9f95
a8dd47
static inline void mdso_driver_set_ectx(
a8dd47
	const struct mdso_driver_ctx * dctx,
a8dd47
	const struct mdso_unit_ctx *   uctx,
a8dd47
	const char *                   unit)
a8dd47
{
a8dd47
	struct mdso_driver_ctx_impl *  ictx;
a8dd47
a8dd47
	ictx        = mdso_get_driver_ictx(dctx);
a8dd47
	ictx->euctx = uctx;
a8dd47
	ictx->eunit = unit;
a8dd47
}
a8dd47
cde03b
#endif