Ilya Zakharevich on Sat, 11 May 2002 00:18:15 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: DYNAMIC_PLOTTING with gnuplot made easy


On Mon, May 06, 2002 at 08:00:46PM -0400, Ilya Zakharevich wrote:
> On Sat, May 04, 2002 at 02:11:08PM -0400, Ilya Zakharevich wrote:
> > On Sat, May 04, 2002 at 05:21:09AM -0400, Ilya Zakharevich wrote:
> > > This patch improves support of DYNAMIC_PLOTTING with gnuplot: now it 
> 
> Testing this on Solaris, I get
> 
>   ***   Can't load Gnuplot drawing engine from '/home/ilya/.cpan/build/Term-Gnuplot-0.5703/blib/arch/auto/Term/Gnuplot/Gnuplot.so': ld.so.1: ./gp-sta: fatal: relocation error: file /home/ilya/.cpan/build/Term-Gnuplot-0.5703/blib/arch/auto/Term/Gnuplot/Gnuplot.so: symbol PL_markstack_ptr: referenced symbol not found.

The reasons are multiple:

  a) On Solaris, RTDL_LAZY is not applicable to data, only to functions;

  b) gp-dyn is statically linked (?!), so the symbols from it are not
     visible from the loaded DLLs.

The following patch contains a workaround for this, as well as a chunk
improving the stability when the builtin-X11 plotting is used in the
same process as the gnuplot plotting.

Due to some interaction (bugs in the PARI signal handling?) when one uses
builtin-X11 plotting together with gnuplot plotting, in some situation
one ends with a process emitting endless "Bug in PARI, please report"
messages.  So do not do it until things clear out.

Ilya

diff -pru pari/src/graph/plotgnuplot.c pari-gnuplot-x/src/graph/plotgnuplot.c
--- pari/src/graph/plotgnuplot.c	Fri May 10 23:41:17 2002
+++ pari-gnuplot-x/src/graph/plotgnuplot.c	Fri May 10 17:14:06 2002
@@ -255,18 +255,27 @@ term_set(char *s)
 
 #ifdef BOTH_GNUPLOT_AND_X11    
   if (is_builtin) {
-      if (!strcmp(s,"builtin"))
-	  return X11_term_set(s);
+      if (!strcmp(s,"builtin")) {
+	  if (!getenv("DISPLAY"))
+	      goto complain;
+	  return X11_term_set(s);	  
+      }
       is_builtin = 0;
-      PARI_get_plot(1);
+      /* The following line may switch on Gnuplot's X11 term first: */
+      /* PARI_get_plot(1); */
   } else if (!strcmp(s,"builtin")) {
-      is_builtin = 1;
-      if (!X11_init) {
-	  if (!getenv("DISPLAY"))
+/*      if (!X11_init) {*/
+	  if (!getenv("DISPLAY")) {
+	    complain:
 	      croak("The builtin-X11 plotting requires DISPLAY environment variable set");
+	  }	  
+	  /* Restore the safe state by switching to a do-little terminal */
+	  if (pari_plot.init && strcmp(pari_plot.name, "dumb"))
+	      term_set("dumb");
+	  is_builtin = 1;
 	  X11_PARI_get_plot(1);
 	  X11_init = 1;
-      }
+/*      }*/
       return X11_term_set(s);
   }
 #endif	/* defined BOTH_GNUPLOT_AND_X11     */ 
diff -pru pari/src/language/init.c pari-gnuplot-x/src/language/init.c
--- pari/src/language/init.c	Thu May  2 14:30:46 2002
+++ pari-gnuplot-x/src/language/init.c	Fri May 10 17:13:51 2002
@@ -65,6 +65,14 @@ pariout_t DFLT_OUTPUT = { 'g', 0, -1, 1,
 extern void  initout(int initerr);
 extern int   term_width(void);
 
+#ifdef BOTH_GNUPLOT_AND_X11
+/* Satisfy DLL dependencies: dummy only */
+#define EXTERM_DLL_DPES *PL_markstack_ptr, PL_stack_max, *PL_Sv, *PL_stack_sp, \
+  *PL_tmps_floor, *PL_tmps_ix, *PL_markstack_max, *PL_stack_base, PL_na, *PL_sv_yes, *PL_sv_no
+extern int EXTERM_DLL_DPES;
+int EXTERM_DLL_DPES;
+#endif	/* defined BOTH_GNUPLOT_AND_X11 */ 
+
 typedef struct cell {
   void *env;
   void *data;