From f3d47a5271ef3cbe5755d1dd51bd96508aa0c3bc Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 19 Feb 2024 02:16:22 +0000 Subject: library api's: _ectx_ (command execution context) namespace overhaul. --- include/slibtool/slibtool.h | 12 +++++------- src/internal/slibtool_driver_impl.h | 5 +++++ src/logic/linkcmd/slbt_linkcmd_archive.c | 2 +- src/logic/linkcmd/slbt_linkcmd_dsolib.c | 2 +- src/logic/linkcmd/slbt_linkcmd_executable.c | 2 +- src/logic/slbt_exec_ar.c | 12 ++++++------ src/logic/slbt_exec_compile.c | 20 +++++++++---------- src/logic/slbt_exec_ctx.c | 16 +++++++-------- src/logic/slbt_exec_execute.c | 8 ++++---- src/logic/slbt_exec_install.c | 8 ++++---- src/logic/slbt_exec_link.c | 30 ++++++++++++++--------------- src/logic/slbt_exec_uninstall.c | 8 ++++---- 12 files changed, 64 insertions(+), 61 deletions(-) diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h index 2634632..3a09ba0 100644 --- a/include/slibtool/slibtool.h +++ b/include/slibtool/slibtool.h @@ -355,13 +355,11 @@ slbt_api void slbt_free_driver_ctx (struct slbt_driver_ctx *); slbt_api int slbt_get_driver_fdctx (const struct slbt_driver_ctx *, struct slbt_fd_ctx *); slbt_api int slbt_set_driver_fdctx (struct slbt_driver_ctx *, const struct slbt_fd_ctx *); -/* execution context api */ -slbt_api int slbt_get_exec_ctx (const struct slbt_driver_ctx *, struct slbt_exec_ctx **); -slbt_api void slbt_free_exec_ctx (struct slbt_exec_ctx *); -slbt_api void slbt_reset_argvector (struct slbt_exec_ctx *); -slbt_api void slbt_reset_arguments (struct slbt_exec_ctx *); -slbt_api void slbt_reset_placeholders (struct slbt_exec_ctx *); -slbt_api void slbt_disable_placeholders (struct slbt_exec_ctx *); +/* command execution context api */ +slbt_api int slbt_ectx_get_exec_ctx (const struct slbt_driver_ctx *, struct slbt_exec_ctx **); +slbt_api void slbt_ectx_free_exec_ctx (struct slbt_exec_ctx *); +slbt_api void slbt_ectx_reset_argvector (struct slbt_exec_ctx *); +slbt_api void slbt_ectx_reset_arguments (struct slbt_exec_ctx *); /* core api */ slbt_api int slbt_exec_compile (const struct slbt_driver_ctx *, struct slbt_exec_ctx *); diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index e4c0977..e817ac9 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -282,6 +282,11 @@ int slbt_init_ldrpath( struct slbt_host_params * host); +void slbt_reset_placeholders (struct slbt_exec_ctx *); + +void slbt_disable_placeholders (struct slbt_exec_ctx *); + + static inline struct slbt_archive_ctx_impl * slbt_get_archive_ictx(const struct slbt_archive_ctx * actx) { uintptr_t addr; diff --git a/src/logic/linkcmd/slbt_linkcmd_archive.c b/src/logic/linkcmd/slbt_linkcmd_archive.c index 9fb1778..13abb9f 100644 --- a/src/logic/linkcmd/slbt_linkcmd_archive.c +++ b/src/logic/linkcmd/slbt_linkcmd_archive.c @@ -90,7 +90,7 @@ slbt_hidden int slbt_exec_link_create_archive( dctx,ectx,arfilename); /* initial state */ - slbt_reset_arguments(ectx); + slbt_ectx_reset_arguments(ectx); /* placeholders */ slbt_reset_placeholders(ectx); diff --git a/src/logic/linkcmd/slbt_linkcmd_dsolib.c b/src/logic/linkcmd/slbt_linkcmd_dsolib.c index 8ae9395..b3ff844 100644 --- a/src/logic/linkcmd/slbt_linkcmd_dsolib.c +++ b/src/logic/linkcmd/slbt_linkcmd_dsolib.c @@ -74,7 +74,7 @@ slbt_hidden int slbt_exec_link_create_library( struct slbt_deps_meta depsmeta = {0,0,0,0}; /* initial state */ - slbt_reset_arguments(ectx); + slbt_ectx_reset_arguments(ectx); /* placeholders */ slbt_reset_placeholders(ectx); diff --git a/src/logic/linkcmd/slbt_linkcmd_executable.c b/src/logic/linkcmd/slbt_linkcmd_executable.c index 3a47a49..56070f3 100644 --- a/src/logic/linkcmd/slbt_linkcmd_executable.c +++ b/src/logic/linkcmd/slbt_linkcmd_executable.c @@ -90,7 +90,7 @@ slbt_hidden int slbt_exec_link_create_executable( struct stat st; /* initial state */ - slbt_reset_arguments(ectx); + slbt_ectx_reset_arguments(ectx); /* placeholders */ slbt_reset_placeholders(ectx); diff --git a/src/logic/slbt_exec_ar.c b/src/logic/slbt_exec_ar.c index 95db043..6baba25 100644 --- a/src/logic/slbt_exec_ar.c +++ b/src/logic/slbt_exec_ar.c @@ -56,7 +56,7 @@ static int slbt_ar_usage( } if (ectx) - slbt_free_exec_ctx(ectx); + slbt_ectx_free_exec_ctx(ectx); slbt_argv_free(meta); @@ -69,7 +69,7 @@ static int slbt_exec_ar_fail( int ret) { slbt_argv_free(meta); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret; } @@ -145,13 +145,13 @@ int slbt_exec_ar( /* context */ if (ectx) actx = 0; - else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + else if ((ret = slbt_ectx_get_exec_ctx(dctx,&ectx))) return ret; else actx = ectx; /* initial state, ar mode skin */ - slbt_reset_arguments(ectx); + slbt_ectx_reset_arguments(ectx); slbt_disable_placeholders(ectx); ictx = slbt_get_driver_ictx(dctx); @@ -289,7 +289,7 @@ int slbt_exec_ar( /* defer --version printing to slbt_main() as needed */ if (cctx->drvflags & SLBT_DRIVER_VERSION) { slbt_argv_free(meta); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_OK; } @@ -404,7 +404,7 @@ int slbt_exec_ar( free(arctxv); slbt_argv_free(meta); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret; } diff --git a/src/logic/slbt_exec_compile.c b/src/logic/slbt_exec_compile.c index 3941bf6..d651607 100644 --- a/src/logic/slbt_exec_compile.c +++ b/src/logic/slbt_exec_compile.c @@ -180,7 +180,7 @@ int slbt_exec_compile( /* context */ if (ectx) slbt_reset_placeholders(ectx); - else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + else if ((ret = slbt_ectx_get_exec_ctx(dctx,&ectx))) return ret; else actx = ectx; @@ -193,7 +193,7 @@ int slbt_exec_compile( if (cctx->drvflags & SLBT_DRIVER_SHARED) if (slbt_mkdir(dctx,ectx->ldirname)) { ret = SLBT_SYSTEM_ERROR(dctx,ectx->ldirname); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret; } @@ -231,22 +231,22 @@ int slbt_exec_compile( if (!(cctx->drvflags & SLBT_DRIVER_SILENT)) { if (slbt_output_compile(dctx,ectx)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } } if ((slbt_spawn(ectx,true) < 0) && (ectx->pid < 0)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_SYSTEM_ERROR(dctx,0); } else if (ectx->exitcode) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_COMPILE_ERROR); } if (cctx->drvflags & SLBT_DRIVER_STATIC) - slbt_reset_argvector(ectx); + slbt_ectx_reset_argvector(ectx); } /* static archive object */ @@ -266,23 +266,23 @@ int slbt_exec_compile( if (!(cctx->drvflags & SLBT_DRIVER_SILENT)) { if (slbt_output_compile(dctx,ectx)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } } if ((slbt_spawn(ectx,true) < 0) && (ectx->pid < 0)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_SYSTEM_ERROR(dctx,0); } else if (ectx->exitcode) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_CUSTOM_ERROR(dctx,SLBT_ERR_COMPILE_ERROR); } } ret = slbt_create_object_wrapper(dctx,ectx); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret ? SLBT_NESTED_ERROR(dctx) : 0; } diff --git a/src/logic/slbt_exec_ctx.c b/src/logic/slbt_exec_ctx.c index 8c718ae..5b4b087 100644 --- a/src/logic/slbt_exec_ctx.c +++ b/src/logic/slbt_exec_ctx.c @@ -168,7 +168,7 @@ static struct slbt_exec_ctx_impl * slbt_exec_ctx_alloc( } -int slbt_get_exec_ctx( +int slbt_ectx_get_exec_ctx( const struct slbt_driver_ctx * dctx, struct slbt_exec_ctx ** ectx) { @@ -524,7 +524,7 @@ int slbt_get_exec_ctx( } -static int slbt_free_exec_ctx_impl( +static int slbt_ectx_free_exec_ctx_impl( struct slbt_exec_ctx_impl * ictx, int status) { @@ -539,7 +539,7 @@ static int slbt_free_exec_ctx_impl( } -void slbt_free_exec_ctx(struct slbt_exec_ctx * ctx) +void slbt_ectx_free_exec_ctx(struct slbt_exec_ctx * ctx) { struct slbt_exec_ctx_impl * ictx; uintptr_t addr; @@ -547,12 +547,12 @@ void slbt_free_exec_ctx(struct slbt_exec_ctx * ctx) if (ctx) { addr = (uintptr_t)ctx - offsetof(struct slbt_exec_ctx_impl,ctx); ictx = (struct slbt_exec_ctx_impl *)addr; - slbt_free_exec_ctx_impl(ictx,0); + slbt_ectx_free_exec_ctx_impl(ictx,0); } } -void slbt_reset_arguments(struct slbt_exec_ctx * ectx) +void slbt_ectx_reset_arguments(struct slbt_exec_ctx * ectx) { struct slbt_exec_ctx_impl * ictx; uintptr_t addr; @@ -563,7 +563,7 @@ void slbt_reset_arguments(struct slbt_exec_ctx * ectx) } -void slbt_reset_argvector(struct slbt_exec_ctx * ectx) +void slbt_ectx_reset_argvector(struct slbt_exec_ctx * ectx) { struct slbt_exec_ctx_impl * ictx; uintptr_t addr; @@ -586,7 +586,7 @@ void slbt_reset_argvector(struct slbt_exec_ctx * ectx) } -void slbt_reset_placeholders(struct slbt_exec_ctx * ectx) +slbt_hidden void slbt_reset_placeholders(struct slbt_exec_ctx * ectx) { *ectx->dpic = "-USLIBTOOL_PLACEHOLDER_DPIC"; *ectx->fpic = "-USLIBTOOL_PLACEHOLDER_FPIC"; @@ -610,7 +610,7 @@ void slbt_reset_placeholders(struct slbt_exec_ctx * ectx) *ectx->sentinel= 0; } -void slbt_disable_placeholders(struct slbt_exec_ctx * ectx) +slbt_hidden void slbt_disable_placeholders(struct slbt_exec_ctx * ectx) { *ectx->dpic = 0; *ectx->fpic = 0; diff --git a/src/logic/slbt_exec_execute.c b/src/logic/slbt_exec_execute.c index 84cd282..c9426ab 100644 --- a/src/logic/slbt_exec_execute.c +++ b/src/logic/slbt_exec_execute.c @@ -38,7 +38,7 @@ int slbt_exec_execute( /* context */ if (ectx) slbt_disable_placeholders(ectx); - else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + else if ((ret = slbt_ectx_get_exec_ctx(dctx,&ectx))) return ret; else { actx = ectx; @@ -64,7 +64,7 @@ int slbt_exec_execute( if (slbt_snprintf(wrapper,sizeof(wrapper), "%s.exe.wrapper", exeref) < 0) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_BUFFER_ERROR(dctx); } @@ -91,12 +91,12 @@ int slbt_exec_execute( /* step output */ if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT)) if (slbt_output_execute(dctx,ectx)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } execvp(ectx->cargv[0],ectx->argv); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_SYSTEM_ERROR(dctx,0); } diff --git a/src/logic/slbt_exec_install.c b/src/logic/slbt_exec_install.c index 7b30eb4..bca494b 100644 --- a/src/logic/slbt_exec_install.c +++ b/src/logic/slbt_exec_install.c @@ -59,7 +59,7 @@ static int slbt_exec_install_fail( int ret) { slbt_argv_free(meta); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret; } @@ -736,13 +736,13 @@ int slbt_exec_install( /* context */ if (ectx) actx = 0; - else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + else if ((ret = slbt_ectx_get_exec_ctx(dctx,&ectx))) return ret; else actx = ectx; /* initial state, install mode skin */ - slbt_reset_arguments(ectx); + slbt_ectx_reset_arguments(ectx); slbt_disable_placeholders(ectx); iargv = ectx->cargv; fdout = slbt_driver_fdout(dctx); @@ -919,7 +919,7 @@ int slbt_exec_install( } slbt_argv_free(meta); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return 0; } diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c index a08abd4..e2848ea 100644 --- a/src/logic/slbt_exec_link.c +++ b/src/logic/slbt_exec_link.c @@ -153,7 +153,7 @@ int slbt_exec_link( /* context */ if (ectx) actx = 0; - else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + else if ((ret = slbt_ectx_get_exec_ctx(dctx,&ectx))) return SLBT_NESTED_ERROR(dctx); else actx = ectx; @@ -170,7 +170,7 @@ int slbt_exec_link( dctx->cctx->verinfo.minor, dctx->cctx->verinfo.revision, dctx->cctx->settings.osdfussix) < 0) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_BUFFER_ERROR(dctx); } @@ -203,14 +203,14 @@ int slbt_exec_link( /* .libs directory */ if (slbt_mkdir(dctx,ectx->ldirname)) { ret = SLBT_SYSTEM_ERROR(dctx,ectx->ldirname); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret; } /* non-pic libfoo.a */ if (dot && !strcmp(dot,".a")) if (slbt_exec_link_create_archive(dctx,ectx,output,false)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } @@ -246,7 +246,7 @@ int slbt_exec_link( dctx,ectx, ectx->arfilename, fpic)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } @@ -305,11 +305,11 @@ int slbt_exec_link( ectx->dsobasename, ectx->dsofilename, ectx->relfilename)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return 0; } } @@ -371,7 +371,7 @@ int slbt_exec_link( ectx->dsobasename, ectx->dsofilename, ectx->relfilename)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } @@ -380,7 +380,7 @@ int slbt_exec_link( if (slbt_exec_link_create_library_symlink( dctx,ectx, true)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } @@ -388,7 +388,7 @@ int slbt_exec_link( if (slbt_exec_link_create_library_symlink( dctx,ectx, false)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } } else if (ectx->relfilename) { @@ -396,7 +396,7 @@ int slbt_exec_link( if (slbt_exec_link_create_library_symlink( dctx,ectx, false)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } } @@ -442,14 +442,14 @@ int slbt_exec_link( if (slbt_exec_link_create_executable( dctx,ectx, ectx->exefilename)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } } /* no wrapper? */ if (!dot || strcmp(dot,".la")) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return 0; } @@ -457,7 +457,7 @@ int slbt_exec_link( if (slbt_create_library_wrapper( dctx,ectx, arname,soname,soxyz,solnk)) { - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return SLBT_NESTED_ERROR(dctx); } @@ -479,7 +479,7 @@ int slbt_exec_link( SLBT_NESTED_ERROR(dctx); /* all done */ - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret; } diff --git a/src/logic/slbt_exec_uninstall.c b/src/logic/slbt_exec_uninstall.c index b80da36..8dec7cf 100644 --- a/src/logic/slbt_exec_uninstall.c +++ b/src/logic/slbt_exec_uninstall.c @@ -55,7 +55,7 @@ static int slbt_exec_uninstall_fail( int ret) { slbt_argv_free(meta); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return ret; } @@ -285,13 +285,13 @@ int slbt_exec_uninstall( /* context */ if (ectx) actx = 0; - else if ((ret = slbt_get_exec_ctx(dctx,&ectx))) + else if ((ret = slbt_ectx_get_exec_ctx(dctx,&ectx))) return ret; else actx = ectx; /* initial state, uninstall mode skin */ - slbt_reset_arguments(ectx); + slbt_ectx_reset_arguments(ectx); slbt_disable_placeholders(ectx); iargv = ectx->cargv; fdout = slbt_driver_fdout(dctx); @@ -378,7 +378,7 @@ int slbt_exec_uninstall( SLBT_NESTED_ERROR(dctx)); slbt_argv_free(meta); - slbt_free_exec_ctx(actx); + slbt_ectx_free_exec_ctx(actx); return 0; } -- cgit v1.2.3