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>
8f11ee
#include "mdso_dprintf_impl.h"
a5071f
#include "argv/argv.h"
a5071f
5fdd8e
#ifdef  __PE__
7999c7
#define MDSO_DRIVER_PE_HOST	(1)
7999c7
#else
7999c7
#define MDSO_DRIVER_PE_HOST	(0)
7999c7
#endif
7999c7
7999c7
#ifdef  __WINNT__
7999c7
#define MDSO_DRIVER_WINNT_HOST	(1)
7999c7
#else
7999c7
#define MDSO_DRIVER_WINNT_HOST	(0)
7999c7
#endif
7999c7
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,
c12a92
	TAG_ASM,
3e55ee
	TAG_OBJ,
7c0ec4
	TAG_QUAD_PTR,
c70c0a
	TAG_IMPLIB,
6848b7
	TAG_LIBPATH,
d8c2b3
	TAG_LIBNAME,
d8c2b3
	TAG_DSTDIR,
8cfad6
	TAG_PRETTY,
8cfad6
	TAG_EXPSYMS,
cde03b
};
cde03b
43f283
struct mdso_expsyms {
43f283
	char *		buffer;
63cd76
	int *		stype;
43f283
	const char *	syms[];
43f283
};
43f283
cde03b
struct mdso_driver_ctx_impl {
2c8758
	struct mdso_common_ctx          cctx;
2c8758
	struct mdso_driver_ctx          ctx;
f1dbc6
	struct mdso_fd_ctx		fdctx;
2c8758
	char *                          asmbase;
c70c0a
	char *				implib;
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
f1dbc6
static inline int mdso_driver_fdin(const struct mdso_driver_ctx * dctx)
f1dbc6
{
f1dbc6
	struct mdso_fd_ctx fdctx;
f1dbc6
	mdso_get_driver_fdctx(dctx,&fdctx);
f1dbc6
	return fdctx.fdin;
f1dbc6
}
f1dbc6
f1dbc6
static inline int mdso_driver_fdout(const struct mdso_driver_ctx * dctx)
f1dbc6
{
f1dbc6
	struct mdso_fd_ctx fdctx;
f1dbc6
	mdso_get_driver_fdctx(dctx,&fdctx);
f1dbc6
	return fdctx.fdout;
f1dbc6
}
f1dbc6
f1dbc6
static inline int mdso_driver_fderr(const struct mdso_driver_ctx * dctx)
f1dbc6
{
f1dbc6
	struct mdso_fd_ctx fdctx;
f1dbc6
	mdso_get_driver_fdctx(dctx,&fdctx);
f1dbc6
	return fdctx.fderr;
f1dbc6
}
f1dbc6
f1dbc6
static inline int mdso_driver_fdlog(const struct mdso_driver_ctx * dctx)
f1dbc6
{
f1dbc6
	struct mdso_fd_ctx fdctx;
f1dbc6
	mdso_get_driver_fdctx(dctx,&fdctx);
f1dbc6
	return fdctx.fdlog;
f1dbc6
}
f1dbc6
f1dbc6
static inline int mdso_driver_fdcwd(const struct mdso_driver_ctx * dctx)
f1dbc6
{
f1dbc6
	struct mdso_fd_ctx fdctx;
f1dbc6
	mdso_get_driver_fdctx(dctx,&fdctx);
f1dbc6
	return fdctx.fdcwd;
f1dbc6
}
f1dbc6
f1dbc6
static inline int mdso_driver_fddst(const struct mdso_driver_ctx * dctx)
f1dbc6
{
f1dbc6
	struct mdso_fd_ctx fdctx;
f1dbc6
	mdso_get_driver_fdctx(dctx,&fdctx);
f1dbc6
	return fdctx.fddst;
f1dbc6
}
f1dbc6
cde03b
#endif