zsh-workers
 help / color / mirror / code / Atom feed
From: "Andrej Borsenkow" <Andrej.Borsenkow@mow.siemens.ru>
To: "Peter Stephenson" <pws@csr.com>,
	"Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: RE: PATCH: RE: termcap moodule problem on Cygwin
Date: Mon, 5 Feb 2001 18:31:46 +0300	[thread overview]
Message-ID: <003901c08f88$bff3e410$21c9ca95@mow.siemens.ru> (raw)
In-Reply-To: <Tc0a8890c517189b68a@mailsweeper01.cambridgesiliconradio.com>

[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]

>
>
> > Yes, test was broken, sorry. Try this patch (on top of previous).
>
> That's fine, both libraries are now dynamically linked on both versions of
> Solaris, which is what was happening before the patch.
>

O.K., hopefully the last version. Now it really works for Cygwin, both shared
and static libs. I tested it with:

- Unix, pseudo-shared (see below) static curses
- Cygwin, static termcap
- Cygwin, shared ncurses

So, remaining case is Unix with real shared library and possibly Unix with
bad-behaving static library.

Solaris 2.6 and my system both provide pseudo-shared implementation - static
symbols are linked into every shared object, but references to them are
resolved at runtime and point to the single copy of static symbol. It has one
possible drawback - if shared object that owns this static symbol is unloaded,
references are no more valid. So far, my system seems to correctly keep
reference count. It depends on coimpiler options (I can force local binding).
So I added test for this case as well - dunno if it really helps.

-andrej

[-- Attachment #2: zsh.termcap.diff --]
[-- Type: application/octet-stream, Size: 10217 bytes --]

Index: aczsh.m4
===================================================================
RCS file: /cvsroot/zsh/zsh/aczsh.m4,v
retrieving revision 1.6
diff -u -r1.6 aczsh.m4
--- aczsh.m4	2000/10/11 12:26:13	1.6
+++ aczsh.m4	2001/02/05 15:24:13
@@ -111,32 +111,59 @@
 
 
 dnl
-dnl zsh_SYS_DYNAMIC_BROKEN
-dnl   Check whether static/shared library linking is broken.
+dnl zsh_SHARED_FUNCTION
 dnl
+dnl This is just a frontend to zsh_SHARED_SYMBOL
+dnl
+dnl Usage: zsh_SHARED_FUNCTION(name[,rettype[,paramtype]])
+dnl
+
+AC_DEFUN(zsh_SHARED_FUNCTION,
+[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ ],[$3])[)], $1)])
+
+dnl
+dnl zsh_SHARED_VARIABLE
+dnl
+dnl This is just a frontend to zsh_SHARED_SYMBOL
+dnl
+dnl Usage: zsh_SHARED_VARIABLE(name[,type])
+dnl
+
+AC_DEFUN(zsh_SHARED_VARIABLE,
+[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])])
+
+dnl
+dnl zsh_SHARED_SYMBOL
+dnl   Check whether symbol is available in static or shared library
+dnl
 dnl   On some systems, static modifiable library symbols (such as environ)
 dnl   may appear only in statically linked libraries.  If this is the case,
 dnl   then two shared libraries that reference the same symbol, each linked
 dnl   with the static library, could be given distinct copies of the symbol.
-dnl   If this is the case then dynamic linking is FUBAR.
+dnl
+dnl Usage: zsh_SHARED_SYMBOL(name,declaration,address)
+dnl Sets zsh_cv_shared_$1 cache variable to yes/no
 dnl
 
-AC_DEFUN(zsh_SYS_DYNAMIC_BROKEN,
-[AC_CACHE_CHECK([if static/shared library linking is broken],
-zsh_cv_sys_dynamic_broken,
+AC_DEFUN(zsh_SHARED_SYMBOL,
+[AC_CACHE_CHECK([if $1 is available in shared libraries],
+zsh_cv_shared_$1,
 [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
     us=_
 else
     us=
 fi
 echo '
-	extern char **environ;
-	void *symlist1[[]] = {
-		(void *)&environ,
-		(void *)0
-	};
+void *zsh_getaddr1()
+{
+#ifdef __CYGWIN__
+	__attribute__((__dllimport__))	
+#endif
+	extern $2;
+	return $3;
+};
 ' > conftest1.c
-sed 's/symlist1/symlist2/' < conftest1.c > conftest2.c
+sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c
 if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
 $DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5 &&
 $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 &&
@@ -172,25 +199,33 @@
 main()
 {
     void *handle1, *handle2;
-    void **symlist1, **symlist2;
+    void *(*zsh_getaddr1)(), *(*zsh_getaddr2)();
+    void *sym1, *sym2;
     handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
     if(!handle1) exit(1);
     handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
     if(!handle2) exit(1);
-    symlist1 = (void **) dlsym(handle1, "${us}symlist1");
-    symlist2 = (void **) dlsym(handle2, "${us}symlist2");
-    if(!symlist1 || !symlist2) exit(1);
-    for(; *symlist1; symlist1++, symlist2++)
-	if(*symlist1 != *symlist2)
-	    exit(1);
+    zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
+    zsh_getaddr2 = (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2");
+    sym1 = zsh_getaddr1();
+    sym2 = zsh_getaddr2();
+    if(!sym1 || !sym2) exit(1);
+    if(sym1 != sym2) exit(1);
+    dlclose(handle1);
+    handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+    if(!handle1) exit(1);
+    zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
+    sym1 = zsh_getaddr1();
+    if(!sym1) exit(1);
+    if(sym1 != sym2) exit(1);
     exit(0);
 }
-], [zsh_cv_sys_dynamic_broken=no],
-[zsh_cv_sys_dynamic_broken=yes],
-[zsh_cv_sys_dynamic_broken=yes]
+], [zsh_cv_shared_$1=yes],
+[zsh_cv_shared_$1=no],
+[zsh_cv_shared_$1=no]
 )
 else
-    zsh_cv_sys_dynamic_broken=yes
+    zsh_cv_shared_$1=no
 fi
 ])
 ])
Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.39
diff -u -r1.39 configure.in
--- configure.in	2001/01/19 14:47:44	1.39
+++ configure.in	2001/02/05 15:24:14
@@ -493,7 +493,9 @@
 dnl On some systems, modules need to be linked against libc explicitly,
 dnl in case they require objects that exist only in the static version
 dnl and might not be compiled into the zsh executable.
-AC_CHECK_LIB(c, printf)
+dnl On ReliantUNIX -lc better be the last library, else funny things
+dnl may happen.
+AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc"])
 
 AC_CHECK_LIB(m, pow)
 
@@ -557,37 +559,6 @@
   AC_DEFINE(MUST_DEFINE_OSPEED)
 fi
 
-dnl  Check if tgetent accepts NULL (and will allocate its own termcap buffer)
-dnl  Some termcaps reportedly accept a zero buffer, but then dump core
-dnl  in tgetstr().
-dnl  Under Cygwin test program crashes but exit code is still 0. So,
-dnl  we test for a file that porgram should create
-AC_CACHE_CHECK(if tgetent accepts NULL,
-zsh_cv_func_tgetent_accepts_null,
-[AC_TRY_RUN([
-main()
-{
-    int i = tgetent((char*)0,"vt100");
-    if (i > 0) {
-	char tbuf[1024], *u;
-    	u = tbuf;
-    	tgetstr("cl", &u);
-	creat("conftest.tgetent", 0640);
-    }
-    exit(!i || i == -1);
-}
-],
-  if test -f conftest.tgetent; then
-    zsh_cv_func_tgetent_accepts_null=yes
-  else
-    zsh_cv_func_tgetent_accepts_null=no
-  fi,
-  zsh_cv_func_tgetent_accepts_null=no,
-  zsh_cv_func_tgetent_accepts_null=no)])
-if test $zsh_cv_func_tgetent_accepts_null = yes; then
-  AC_DEFINE(TGETENT_ACCEPTS_NULL)
-fi
-
 dnl --------------
 dnl CHECK TYPEDEFS
 dnl --------------
@@ -845,9 +816,40 @@
 	       putenv getenv \
 	       brk sbrk \
 	       pathconf sysconf \
-	       tigetflag tigetnum tigetstr)
+	       tgetent tigetflag tigetnum tigetstr)
 AC_FUNC_STRCOLL
 
+dnl  Check if tgetent accepts NULL (and will allocate its own termcap buffer)
+dnl  Some termcaps reportedly accept a zero buffer, but then dump core
+dnl  in tgetstr().
+dnl  Under Cygwin test program crashes but exit code is still 0. So,
+dnl  we test for a file that porgram should create
+AC_CACHE_CHECK(if tgetent accepts NULL,
+zsh_cv_func_tgetent_accepts_null,
+[AC_TRY_RUN([
+main()
+{
+    int i = tgetent((char*)0,"vt100");
+    if (i > 0) {
+	char tbuf[1024], *u;
+    	u = tbuf;
+    	tgetstr("cl", &u);
+	creat("conftest.tgetent", 0640);
+    }
+    exit(!i || i == -1);
+}
+],
+  if test -f conftest.tgetent; then
+    zsh_cv_func_tgetent_accepts_null=yes
+  else
+    zsh_cv_func_tgetent_accepts_null=no
+  fi,
+  zsh_cv_func_tgetent_accepts_null=no,
+  zsh_cv_func_tgetent_accepts_null=no)])
+if test $zsh_cv_func_tgetent_accepts_null = yes; then
+  AC_DEFINE(TGETENT_ACCEPTS_NULL)
+fi
+
 AC_FUNC_MMAP
 if test x$ac_cv_func_mmap_fixed_mapped = xyes; then
   AC_CHECK_FUNCS(munmap msync)
@@ -1471,7 +1473,10 @@
   zsh_cv_sys_dynamic_execsyms="${zsh_cv_sys_dynamic_execsyms=no}"
   zsh_cv_sys_dynamic_strip_exe="${zsh_cv_sys_dynamic_strip_exe=yes}"
   zsh_cv_sys_dynamic_strip_lib="${zsh_cv_sys_dynamic_strip_lib=yes}"
-  zsh_cv_sys_dynamic_broken="${zsh_cv_sys_dynamic_broken=no}"
+  #
+  # THAT SUCKS! and must be changed
+  #
+  zsh_cv_shared_environ="${zsh_cv_shared_environ=yes}"
   LINKMODS=LINKMODS
   MOD_EXPORT="__attribute__((__dllexport__))"
   MOD_IMPORT_VARIABLE="__attribute__((__dllimport__))"
@@ -1616,8 +1621,15 @@
 fi
 
 if test "x$dynamic" = xyes; then
-  zsh_SYS_DYNAMIC_BROKEN
-  test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no
+  zsh_SHARED_VARIABLE([environ], [char **])
+  test "$zsh_cv_shared_environ" = yes || dynamic=no
+dnl  test "$zsh_cv_sys_dynamic_broken" = no || dynamic=no
+  if test "$ac_cv_func_tgetent" = yes; then
+    zsh_SHARED_FUNCTION([tgetent])
+  fi
+  if test "$ac_cv_func_tigetstr" = yes; then
+    zsh_SHARED_FUNCTION([tigetstr])
+  fi
 fi
 
 if test "x$dynamic" = xyes; then
Index: Src/Modules/termcap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.c,v
retrieving revision 1.1
diff -u -r1.1 termcap.c
--- Src/Modules/termcap.c	2000/12/03 20:53:25	1.1
+++ Src/Modules/termcap.c	2001/02/05 15:24:16
@@ -33,7 +33,7 @@
 /* echotc: output a termcap */
 
 /**/
-int
+static int
 bin_echotc(char *name, char **argv, char *ops, int func)
 {
     char *s, buf[2048], *t, *u;
Index: Src/Modules/termcap.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.mdd,v
retrieving revision 1.1
diff -u -r1.1 termcap.mdd
--- Src/Modules/termcap.mdd	2000/12/03 20:53:25	1.1
+++ Src/Modules/termcap.mdd	2001/02/05 15:24:16
@@ -1,5 +1,15 @@
 name=zsh/termcap
-link=either
+
+link='if test "x$ac_cv_func_tgetent" = xyes; then
+          if test "x$zsh_cv_shared_tgetent" = xyes; then
+	      echo either
+	  else
+	      echo static
+	  fi
+      else
+          echo no;
+      fi
+'
 load=yes
 
 autobins="echotc"
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.4
diff -u -r1.4 terminfo.c
--- Src/Modules/terminfo.c	2000/12/06 01:16:15	1.4
+++ Src/Modules/terminfo.c	2001/02/05 15:24:16
@@ -36,7 +36,7 @@
 /* echoti: output a terminfo capability */
 
 /**/
-int
+static int
 bin_echoti(char *name, char **argv, char *ops, int func)
 {
     char *s, *t;
Index: Src/Modules/terminfo.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v
retrieving revision 1.3
diff -u -r1.3 terminfo.mdd
--- Src/Modules/terminfo.mdd	2000/12/05 11:00:09	1.3
+++ Src/Modules/terminfo.mdd	2001/02/05 15:24:16
@@ -1,5 +1,15 @@
 name=zsh/terminfo
-link='if test "x$ac_cv_func_tigetstr" = xyes; then echo either; else echo no; fi'
+
+link='if test "x$ac_cv_func_tigetstr" = xyes; then
+          if test "x$zsh_cv_shared_tigetstr" = xyes; then
+	      echo either
+	  else
+	      echo static
+	  fi
+      else
+          echo no;
+      fi
+'
 load=yes
 
 autobins="echoti"

  reply	other threads:[~2001-02-05 15:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-29 14:55 Andrej Borsenkow
2001-01-29 15:10 ` Peter Stephenson
2001-01-30  8:25   ` Andrej Borsenkow
2001-01-30 10:34     ` Peter Stephenson
2001-01-31  8:50       ` Somebody with gcc knowledge here? (Was: termcap moodule problem on Cygwin ) Andrej Borsenkow
2001-01-31 10:37       ` PATCH: RE: termcap moodule problem on Cygwin Andrej Borsenkow
2001-01-31 11:30         ` Peter Stephenson
2001-01-31 12:42           ` Andrej Borsenkow
2001-01-31 13:49             ` Peter Stephenson
2001-02-05 15:31               ` Andrej Borsenkow [this message]
2001-02-13 14:36                 ` Andrej Borsenkow
2001-01-29 16:48 ` Zefram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003901c08f88$bff3e410$21c9ca95@mow.siemens.ru' \
    --to=andrej.borsenkow@mow.siemens.ru \
    --cc=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).