RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 15-Apr-2009 20:41:30 Branch: HEAD Handle: 2009041518412901 Modified files: rpm CHANGES rpm/rpmio macro.c poptIO.c rpmio.c rpmperl.c rpmperl.h rpmpython.c rpmpython.h rpmruby.c rpmruby.h rpmtcl.c rpmtcl.h Log: - map NULL interp to lazily instantiated globally persistent instance. Summary: Revision Changes Path 1.2934 +1 -0 rpm/CHANGES 2.223 +7 -15 rpm/rpmio/macro.c 1.46 +5 -16 rpm/rpmio/poptIO.c 1.190 +8 -20 rpm/rpmio/rpmio.c 2.7 +21 -2 rpm/rpmio/rpmperl.c 2.3 +3 -5 rpm/rpmio/rpmperl.h 2.8 +17 -0 rpm/rpmio/rpmpython.c 2.4 +4 -6 rpm/rpmio/rpmpython.h 2.7 +16 -0 rpm/rpmio/rpmruby.c 2.2 +3 -0 rpm/rpmio/rpmruby.h 2.6 +26 -7 rpm/rpmio/rpmtcl.c 2.5 +5 -2 rpm/rpmio/rpmtcl.h ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.2933 -r1.2934 CHANGES --- rpm/CHANGES 15 Apr 2009 12:38:13 -0000 1.2933 +++ rpm/CHANGES 15 Apr 2009 18:41:29 -0000 1.2934 @@ -1,5 +1,6 @@ 5.2a4 -> 5.2b1: + - jbj: map NULL interp to lazily instantiated globally persistent instance. - rse: RPM_CHECK_LIB: correctly handle library names like "libpython2.6" and "libdb-4.7" - rse: place XZ code under WITH_XZ (RPM_CHECK_LIB based) instead of HAVE_LZMA_H (standard Autoconf header check) - rse: place BZip2 code under WITH_BZIP2 (RPM_CHECK_LIB based) instead of HAVE_BZLIB_H (standard Autoconf header check) @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/macro.c ============================================================================ $ cvs diff -u -r2.222 -r2.223 macro.c --- rpm/rpmio/macro.c 13 Apr 2009 16:32:43 -0000 2.222 +++ rpm/rpmio/macro.c 15 Apr 2009 18:41:30 -0000 2.223 @@ -70,21 +70,10 @@ #include <rpmlua.h> #endif -#ifdef WITH_PERLEMBED #include <rpmperl.h> -#endif - -#ifdef WITH_PYTHONEMBED #include <rpmpython.h> -#endif - -#ifdef WITH_RUBYEMBED #include <rpmruby.h> -#endif - -#ifdef WITH_TCL #include <rpmtcl.h> -#endif #endif @@ -95,6 +84,9 @@ #include "debug.h" +/*...@unchecked@*/ +static int _globalI = 1; + #if defined(__LCLINT__) /*...@-exportheader@*/ extern const unsigned short int **__ctype_b_loc (void) /*...@*/; @@ -1729,7 +1721,7 @@ #ifdef WITH_PERLEMBED if (STREQ("perl", f, fn)) { - rpmperl perl = rpmperlNew(NULL, 0); + rpmperl perl = (!_globalI ? rpmperlNew(NULL, 0) : NULL); const char *ls = s+sizeof("{perl:")-1; const char *lse = se-sizeof("}")+1; char *scriptbuf = (char *)xmalloc((lse-ls)+1); @@ -1759,7 +1751,7 @@ #ifdef WITH_PYTHONEMBED if (STREQ("python", f, fn)) { - rpmpython python = rpmpythonNew(NULL, 0); + rpmpython python = (!_globalI ? rpmpythonNew(NULL, 0) : NULL); const char *ls = s+sizeof("{python:")-1; const char *lse = se-sizeof("}")+1; char *script = (char *)xmalloc((lse-ls)+1); @@ -1789,7 +1781,7 @@ #ifdef WITH_RUBYEMBED if (STREQ("ruby", f, fn)) { - rpmruby ruby = rpmrubyNew(NULL, 0); + rpmruby ruby = (!_globalI ? rpmrubyNew(NULL, 0) : NULL); const char *ls = s+sizeof("{ruby:")-1; const char *lse = se-sizeof("}")+1; char *scriptbuf = (char *)xmalloc((lse-ls)+1); @@ -1819,7 +1811,7 @@ #ifdef WITH_TCL if (STREQ("tcl", f, fn)) { - rpmtcl tcl = rpmtclNew(NULL, 0); + rpmtcl tcl = (!_globalI ? rpmtclNew(NULL, 0) : NULL); const char *ls = s+sizeof("{tcl:")-1; const char *lse = se-sizeof("}")+1; char *scriptbuf = (char *)xmalloc((lse-ls)+1); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/poptIO.c ============================================================================ $ cvs diff -u -r1.45 -r1.46 poptIO.c --- rpm/rpmio/poptIO.c 15 Apr 2009 12:12:46 -0000 1.45 +++ rpm/rpmio/poptIO.c 15 Apr 2009 18:41:30 -0000 1.46 @@ -25,6 +25,11 @@ #include <rpmssl.h> #endif +#include <rpmperl.h> +#include <rpmpython.h> +#include <rpmruby.h> +#include <rpmtcl.h> + #include "debug.h" const char *__progname; @@ -68,16 +73,8 @@ /*...@unchecked@*/ extern int _rpmlua_debug; /*...@unchecked@*/ -extern int _rpmperl_debug; -/*...@unchecked@*/ -extern int _rpmpython_debug; -/*...@unchecked@*/ -extern int _rpmruby_debug; -/*...@unchecked@*/ extern int _rpmsq_debug; /*...@unchecked@*/ -extern int _rpmtcl_debug; -/*...@unchecked@*/ extern int _rpmzq_debug; /*...@unchecked@*/ extern int _tar_debug; @@ -421,24 +418,16 @@ #endif { "rpmmgdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmmg_debug, -1, N_("Debug rpmmg magic"), NULL}, -#ifdef WITH_PERLEMBED { "rpmperldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmperl_debug, -1, N_("Debug embedded Perl interpreter"), NULL}, -#endif -#ifdef WITH_PYTHONEMBED { "rpmpythondebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmpython_debug, -1, N_("Debug embedded Python interpreter"), NULL}, -#endif -#ifdef WITH_RUBYEMBED { "rpmrubydebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmruby_debug, -1, N_("Debug embedded Ruby interpreter"), NULL}, -#endif { "rpmsqdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmsq_debug, -1, N_("Debug rpmsq Signal Queue"), NULL}, -#ifdef WITH_TCL { "rpmtcldebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmtcl_debug, -1, N_("Debug embedded TCL interpreter"), NULL}, -#endif #ifdef WITH_BZIP2 { "rpmzqdebug", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &_rpmzq_debug, -1, N_("Debug rpmzq Job Queuing"), NULL}, @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmio.c ============================================================================ $ cvs diff -u -r1.189 -r1.190 rpmio.c --- rpm/rpmio/rpmio.c 15 Apr 2009 12:15:52 -0000 1.189 +++ rpm/rpmio/rpmio.c 15 Apr 2009 18:41:30 -0000 1.190 @@ -65,6 +65,10 @@ #include <rpmiotypes.h> #include <rpmmacro.h> /* XXX rpmioAccess needs rpmCleanPath() */ #include <rpmlua.h> /* XXX rpmioClean() calls rpmluaFree() */ +#include <rpmperl.h> +#include <rpmpython.h> +#include <rpmruby.h> +#include <rpmtcl.h> #if defined(HAVE_LIBIO_H) && defined(_G_IO_IO_FILE_VERSION) #define _USE_LIBIO 1 @@ -3127,22 +3131,12 @@ extern rpmioPool _htPool; /*...@=shadow@*/ extern rpmioPool _rpmmgPool; -#if defined(WITH_LUA) extern rpmioPool _rpmluavPool; extern rpmioPool _rpmluaPool; -#endif -#if defined(WITH_TCL) extern rpmioPool _rpmtclPool; -#endif -#if defined(WITH_PERLEMBED) extern rpmioPool _rpmperlPool; -#endif -#if defined(WITH_PYTHONEMBED) extern rpmioPool _rpmpythonPool; -#endif -#if defined(WITH_RUBYEMBED) extern rpmioPool _rpmrubyPool; -#endif /*...@=nestedextern@*/ #if defined(WITH_LUA) @@ -3159,22 +3153,16 @@ #endif urlFreeCache(); -#if defined(WITH_RUBYEMBED) + _rpmrubyI = rpmrubyFree(_rpmrubyI); _rpmrubyPool = rpmioFreePool(_rpmrubyPool); -#endif -#if defined(WITH_PYTHONEMBED) + _rpmpythonI = rpmpythonFree(_rpmpythonI); _rpmpythonPool = rpmioFreePool(_rpmpythonPool); -#endif -#if defined(WITH_PERLEMBED) + _rpmperlI = rpmperlFree(_rpmperlI); _rpmperlPool = rpmioFreePool(_rpmperlPool); -#endif -#if defined(WITH_TCL) + _rpmtclI = rpmtclFree(_rpmtclI); _rpmtclPool = rpmioFreePool(_rpmtclPool); -#endif -#if defined(WITH_LUA) _rpmluavPool = rpmioFreePool(_rpmluavPool); _rpmluaPool = rpmioFreePool(_rpmluaPool); -#endif _mirePool = rpmioFreePool(_mirePool); _rpmmgPool = rpmioFreePool(_rpmmgPool); _htPool = rpmioFreePool(_htPool); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmperl.c ============================================================================ $ cvs diff -u -r2.6 -r2.7 rpmperl.c --- rpm/rpmio/rpmperl.c 14 Apr 2009 18:18:18 -0000 2.6 +++ rpm/rpmio/rpmperl.c 15 Apr 2009 18:41:30 -0000 2.7 @@ -5,13 +5,21 @@ #define _RPMPERL_INTERNAL #include "rpmperl.h" -#include "debug.h" +#if defined(WITH_PERLEMBED) +#include <EXTERN.h> +#include <perl.h> +#endif -#define my_perl ((PerlInterpreter *)perl->I) +#include "debug.h" /*...@unchecked@*/ int _rpmperl_debug = 0; +/*...@unchecked@*/ /*...@relnull@*/ +rpmperl _rpmperlI = NULL; + +#define my_perl ((PerlInterpreter *)perl->I) + static void rpmperlFini(void * _perl) /*...@globals fileSystem @*/ /*...@modifies *_perl, fileSystem @*/ @@ -98,6 +106,15 @@ return rpmperlLink(perl); } +static rpmperl rpmperlI(void) + /*...@globals _rpmperlI @*/ + /*...@modifies _rpmperlI @*/ +{ + if (_rpmperlI == NULL) + _rpmperlI = rpmperlNew(NULL, 0); + return _rpmperlI; +} + rpmRC rpmperlRun(rpmperl perl, const char * str, const char ** resultp) { rpmRC rc = RPMRC_FAIL; @@ -105,6 +122,8 @@ if (_rpmperl_debug) fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, perl, str); + if (perl == NULL) perl = rpmperlI(); + if (str != NULL) { #if defined(WITH_PERLEMBED) STRLEN n_a; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmperl.h ============================================================================ $ cvs diff -u -r2.2 -r2.3 rpmperl.h --- rpm/rpmio/rpmperl.h 8 Apr 2009 19:55:57 -0000 2.2 +++ rpm/rpmio/rpmperl.h 15 Apr 2009 18:41:30 -0000 2.3 @@ -13,12 +13,10 @@ /*...@unchecked@*/ extern int _rpmperl_debug; -#if defined(_RPMPERL_INTERNAL) -#if defined(WITH_PERLEMBED) -#include <EXTERN.h> -#include <perl.h> -#endif +/*...@unchecked@*/ /*...@relnull@*/ +extern rpmperl _rpmperlI; +#if defined(_RPMPERL_INTERNAL) struct rpmperl_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ const char * fn; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmpython.c ============================================================================ $ cvs diff -u -r2.7 -r2.8 rpmpython.c --- rpm/rpmio/rpmpython.c 13 Apr 2009 18:07:31 -0000 2.7 +++ rpm/rpmio/rpmpython.c 15 Apr 2009 18:41:30 -0000 2.8 @@ -4,6 +4,7 @@ #include "rpmpython.h" #if defined(WITH_PYTHONEMBED) +#include <Python.h> #include <cStringIO.h> #endif @@ -12,6 +13,9 @@ /*...@unchecked@*/ int _rpmpython_debug = 0; +/*...@unchecked@*/ /*...@relnull@*/ +rpmpython _rpmpythonI = NULL; + static void rpmpythonFini(void * _python) /*...@globals fileSystem @*/ /*...@modifies *_python, fileSystem @*/ @@ -72,6 +76,15 @@ return rpmpythonLink(python); } +static rpmpython rpmpythonI(void) + /*...@globals _rpmpythonI @*/ + /*...@modifies _rpmpythonI @*/ +{ + if (_rpmpythonI == NULL) + _rpmpythonI = rpmpythonNew(NULL, 0); + return _rpmpythonI; +} + rpmRC rpmpythonRunFile(rpmpython python, const char * fn, const char ** resultp) { rpmRC rc = RPMRC_FAIL; @@ -80,6 +93,8 @@ if (_rpmpython_debug) fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, python, fn); + if (python == NULL) python = rpmpythonI(); + if (fn != NULL) { #if defined(WITH_PYTHONEMBED) const char * pyfn = ((fn == NULL || !strcmp(fn, "-")) ? "<stdin>" : fn); @@ -103,6 +118,8 @@ if (_rpmpython_debug) fprintf(stderr, "==> %s(%p,%s,%p)\n", __FUNCTION__, python, str, resultp); + if (python == NULL) python = rpmpythonI(); + if (str != NULL) { #if defined(WITH_PYTHONEMBED) PyCompilerFlags cf = { .cf_flags = 0 }; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmpython.h ============================================================================ $ cvs diff -u -r2.3 -r2.4 rpmpython.h --- rpm/rpmio/rpmpython.h 12 Apr 2009 02:24:40 -0000 2.3 +++ rpm/rpmio/rpmpython.h 15 Apr 2009 18:41:30 -0000 2.4 @@ -13,17 +13,15 @@ /*...@unchecked@*/ extern int _rpmpython_debug; -#if defined(_RPMPYTHON_INTERNAL) -#if defined(WITH_PYTHONEMBED) -#include <Python.h> -#include <cStringIO.h> -#endif +/*...@unchecked@*/ /*...@relnull@*/ +extern rpmpython _rpmpythonI; +#if defined(_RPMPYTHON_INTERNAL) struct rpmpython_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ const char * fn; int flags; - void * I; + void * I; /* (unused) */ }; #endif /* _RPMPYTHON_INTERNAL */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmruby.c ============================================================================ $ cvs diff -u -r2.6 -r2.7 rpmruby.c --- rpm/rpmio/rpmruby.c 13 Apr 2009 18:07:31 -0000 2.6 +++ rpm/rpmio/rpmruby.c 15 Apr 2009 18:41:30 -0000 2.7 @@ -22,6 +22,9 @@ /*...@unchecked@*/ int _rpmruby_debug = 0; +/*...@unchecked@*/ /*...@relnull@*/ +rpmruby _rpmrubyI = NULL; + static void rpmrubyFini(void * _ruby) /*...@globals fileSystem @*/ /*...@modifies *_ruby, fileSystem @*/ @@ -81,6 +84,15 @@ return rpmrubyLink(ruby); } +static rpmruby rpmrubyI(void) + /*...@globals _rpmrubyI @*/ + /*...@modifies _rpmrubyI @*/ +{ + if (_rpmrubyI == NULL) + _rpmrubyI = rpmrubyNew(NULL, 0); + return _rpmrubyI; +} + rpmRC rpmrubyRunFile(rpmruby ruby, const char * fn, const char ** resultp) { rpmRC rc = RPMRC_FAIL; @@ -88,6 +100,8 @@ if (_rpmruby_debug) fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, ruby, fn); + if (ruby == NULL) ruby = rpmrubyI(); + if (fn != NULL) { #if defined(WITH_RUBYEMBED) rb_load_file(fn); @@ -107,6 +121,8 @@ if (_rpmruby_debug) fprintf(stderr, "==> %s(%p,%s,%p)\n", __FUNCTION__, ruby, str, resultp); + if (ruby == NULL) ruby = rpmrubyI(); + if (str != NULL) { #if defined(WITH_RUBYEMBED) ruby->state = rb_eval_string(str); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmruby.h ============================================================================ $ cvs diff -u -r2.1 -r2.2 rpmruby.h --- rpm/rpmio/rpmruby.h 8 Apr 2009 17:31:56 -0000 2.1 +++ rpm/rpmio/rpmruby.h 15 Apr 2009 18:41:30 -0000 2.2 @@ -13,6 +13,9 @@ /*...@unchecked@*/ extern int _rpmruby_debug; +/*...@unchecked@*/ /*...@relnull@*/ +extern rpmruby _rpmrubyI; + #if defined(_RPMRUBY_INTERNAL) struct rpmruby_s { struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmtcl.c ============================================================================ $ cvs diff -u -r2.5 -r2.6 rpmtcl.c --- rpm/rpmio/rpmtcl.c 12 Apr 2009 19:39:59 -0000 2.5 +++ rpm/rpmio/rpmtcl.c 15 Apr 2009 18:41:30 -0000 2.6 @@ -1,6 +1,7 @@ #include "system.h" #ifdef WITH_TCL +#include <tcl.h> #define _RPMTCL_INTERNAL #include "rpmtcl.h" @@ -9,6 +10,9 @@ /*...@unchecked@*/ int _rpmtcl_debug = 0; +/*...@unchecked@*/ /*...@relnull@*/ +rpmtcl _rpmtclI = NULL; + static void rpmtclFini(void * _tcl) /*...@globals fileSystem @*/ /*...@modifies *_tcl, fileSystem @*/ @@ -18,7 +22,7 @@ tcl->fn = _free(tcl->fn); tcl->flags = 0; #if defined(WITH_TCL) - Tcl_DeleteInterp(tcl->I); + Tcl_DeleteInterp((Tcl_Interp *)tcl->I); #endif tcl->I = NULL; (void)rpmiobFree(tcl->iob); @@ -109,16 +113,27 @@ tcl->flags = flags; #if defined(WITH_TCL) - tcl->I = Tcl_CreateInterp(); - tcl->tclout = Tcl_GetStdChannel(TCL_STDOUT); - Tcl_SetChannelOption(tcl->I, tcl->tclout, "-translation", "auto"); - Tcl_StackChannel(tcl->I, &rpmtclIO, tcl, TCL_WRITABLE, tcl->tclout); + { Tcl_Interp * tclI = Tcl_CreateInterp(); + tcl->I = tclI; + tcl->tclout = Tcl_GetStdChannel(TCL_STDOUT); + Tcl_SetChannelOption(tclI, tcl->tclout, "-translation", "auto"); + Tcl_StackChannel(tclI, &rpmtclIO, tcl, TCL_WRITABLE, tcl->tclout); + } #endif tcl->iob = rpmiobNew(0); return rpmtclLink(tcl); } +static rpmtcl rpmtclI(void) + /*...@globals _rpmtclI @*/ + /*...@modifies _rpmtclI @*/ +{ + if (_rpmtclI == NULL) + _rpmtclI = rpmtclNew(NULL, 0); + return _rpmtclI; +} + rpmRC rpmtclRunFile(rpmtcl tcl, const char * fn, const char ** resultp) { rpmRC rc = RPMRC_FAIL; @@ -126,8 +141,10 @@ if (_rpmtcl_debug) fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, tcl, fn); + if (tcl == NULL) tcl = rpmtclI(); + #if defined(WITH_TCL) - if (fn != NULL && Tcl_EvalFile(tcl->I, fn) == TCL_OK) { + if (fn != NULL && Tcl_EvalFile((Tcl_Interp *)tcl->I, fn) == TCL_OK) { rc = RPMRC_OK; if (resultp) *resultp = rpmiobStr(tcl->iob); @@ -143,8 +160,10 @@ if (_rpmtcl_debug) fprintf(stderr, "==> %s(%p,%s)\n", __FUNCTION__, tcl, str); + if (tcl == NULL) tcl = rpmtclI(); + #if defined(WITH_TCL) - if (str != NULL && Tcl_Eval(tcl->I, str) == TCL_OK) { + if (str != NULL && Tcl_Eval((Tcl_Interp *)tcl->I, str) == TCL_OK) { rc = RPMRC_OK; if (resultp) *resultp = rpmiobStr(tcl->iob); @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmtcl.h ============================================================================ $ cvs diff -u -r2.4 -r2.5 rpmtcl.h --- rpm/rpmio/rpmtcl.h 12 Apr 2009 19:39:59 -0000 2.4 +++ rpm/rpmio/rpmtcl.h 15 Apr 2009 18:41:30 -0000 2.5 @@ -13,6 +13,9 @@ /*...@unchecked@*/ extern int _rpmtcl_debug; +/*...@unchecked@*/ /*...@relnull@*/ +extern rpmtcl _rpmtclI; + #if defined(_RPMTCL_INTERNAL) #include <tcl.h> @@ -20,8 +23,8 @@ struct rpmioItem_s _item; /*!< usage mutex and pool identifier. */ const char * fn; int flags; - Tcl_Interp * I; - void * tclout; + void * I; /* Tcl_Interp */ + void * tclout; /* Tcl_Channel */ rpmiob iob; }; #endif /* _RPMTCL_INTERNAL */ @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org