diff --git a/lib/master.pike.in b/lib/master.pike.in index e79b6c7e3900fb278eee24fb9010c407b53ed8da..72567acfcc816354445e84118522c5c478d38641 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -6,7 +6,7 @@ // Pike is distributed under GPL, LGPL and MPL. See the file COPYING // for more information. // -// $Id: master.pike.in,v 1.247 2003/01/09 14:29:27 grubba Exp $ +// $Id: master.pike.in,v 1.248 2003/01/13 14:42:06 grubba Exp $ #pike __REAL_VERSION__ @@ -1874,6 +1874,14 @@ void _main(array(string) orig_argv, array(string) env) return v; }; +#ifdef __AUTO_BIGNUM__ + // Load bignum support... + { + mixed v = resolv("Gmp.bignum"); + if (!v) _error("Failed to load Gmp.bignum.\n"); + } +#endif /* __AUTO_BIGNUM__ */ + switch (postparseaction) { case "features": @@ -2564,11 +2572,12 @@ string describe_program(program p) if(s=get_clean_program_path(p, "object_program(", ")", "")) return s; - if(mixed tmp=(function_object(p) || function_program(p))) + if(mixed tmp=(function_object(p) || function_program(p))) { if(s = function_name(p)) - { - return describe_module(tmp) + s; - } + { + return describe_module(tmp) + s; + } + } if(s=_static_modules.Builtin()->program_defined(p)) return EXPLODE_PATH(s)[-1]; diff --git a/src/bignum.c b/src/bignum.c index 862806ac15ef4771b17834ce56185b19513b6e8c..d11ee13b057ad7cc084291bf0d07194bc4f62bb4 100644 --- a/src/bignum.c +++ b/src/bignum.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: bignum.c,v 1.28 2003/01/11 01:52:55 mast Exp $ +|| $Id: bignum.c,v 1.29 2003/01/13 14:42:06 grubba Exp $ */ #include "global.h" @@ -17,34 +17,13 @@ #define sp Pike_sp -struct svalue auto_bignum_program = { +PMOD_EXPORT struct svalue auto_bignum_program = { T_INT, 0, #ifdef HAVE_UNION_INIT {0}, /* Only to avoid warnings. */ #endif }; -PMOD_EXPORT int gmp_library_loaded=0; -int gmp_library_resolving=0; - -void init_auto_bignum(void) -{ - if(gmp_library_resolving) - Pike_fatal("Recursive GMP resolving!\n"); - - gmp_library_resolving=1; - push_text("Gmp.bignum"); - SAFE_APPLY_MASTER("resolv", 1); - - if(sp[-1].type != T_FUNCTION && sp[-1].type != T_PROGRAM) - Pike_error("Failed to resolv Gmp.mpz!\n"); - - auto_bignum_program=sp[-1]; - sp--; - dmalloc_touch_svalue(sp); - gmp_library_resolving=0; -} - PMOD_EXPORT struct program *get_auto_bignum_program(void) { return program_from_function(&auto_bignum_program); diff --git a/src/main.c b/src/main.c index f3183e94b9fbb21fbbd762eb25027de20066e436..e05b319e403a06effe2fa825da6796fbf40f0f30 100644 --- a/src/main.c +++ b/src/main.c @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: main.c,v 1.165 2003/01/12 16:00:14 mast Exp $ +|| $Id: main.c,v 1.166 2003/01/13 14:42:06 grubba Exp $ */ #include "global.h" -RCSID("$Id: main.c,v 1.165 2003/01/12 16:00:14 mast Exp $"); +RCSID("$Id: main.c,v 1.166 2003/01/13 14:42:06 grubba Exp $"); #include "fdlib.h" #include "backend.h" #include "module.h" @@ -705,10 +705,6 @@ int dbm_main(int argc, char **argv) call_callback(& post_master_callbacks, 0); free_callback_list(& post_master_callbacks); -#ifdef AUTO_BIGNUM - init_auto_bignum(); -#endif - TRACE((stderr, "Call master->_main()...\n")); a=allocate_array_no_init(argc,0); diff --git a/src/modules/Gmp/mpz_glue.c b/src/modules/Gmp/mpz_glue.c index af2f65f24113a97da6a407efd0460a555e0ee62e..b5e4068e7f928fcef6e5a34a58d29dc85d07b68b 100644 --- a/src/modules/Gmp/mpz_glue.c +++ b/src/modules/Gmp/mpz_glue.c @@ -2,11 +2,11 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: mpz_glue.c,v 1.115 2002/10/21 17:06:12 marcus Exp $ +|| $Id: mpz_glue.c,v 1.116 2003/01/13 14:42:07 grubba Exp $ */ #include "global.h" -RCSID("$Id: mpz_glue.c,v 1.115 2002/10/21 17:06:12 marcus Exp $"); +RCSID("$Id: mpz_glue.c,v 1.116 2003/01/13 14:42:07 grubba Exp $"); #include "gmp_machine.h" #include "module.h" @@ -308,12 +308,6 @@ void get_new_mpz(MP_INT *tmp, struct svalue *s) */ static void mpzmod_create(INT32 args) { -#ifdef AUTO_BIGNUM - /* Alert bignum.c that we have been loaded /Hubbe */ - if(THIS_PROGRAM == bignum_program) - gmp_library_loaded=1; -#endif - switch(args) { case 1: @@ -1719,6 +1713,7 @@ PIKE_MODULE_INIT #ifdef AUTO_BIGNUM { int id; + extern struct svalue auto_bignum_program; /* This program autoconverts to integers, Gmp.mpz does not!! * magic? no, just an if statement :) /Hubbe @@ -1741,6 +1736,11 @@ PIKE_MODULE_INIT PROGRAM_NO_EXPLICIT_DESTRUCT | PROGRAM_CONSTANT ; + /* Magic hook in... */ + free_svalue(&auto_bignum_program); + add_ref(auto_bignum_program.u.program = bignum_program); + auto_bignum_program.type = PIKE_T_PROGRAM; + #if 0 /* magic /Hubbe * This seems to break more than it fixes though... /Hubbe @@ -1749,6 +1749,7 @@ PIKE_MODULE_INIT ID_FROM_INT(Pike_compiler->new_program, id)->type=CONSTTYPE(tOr(tFunc(tOr5(tVoid,tStr,tInt,tFlt,tObj),tInt),tFunc(tStr tInt,tInt))); #endif } + #endif #endif