From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3313 invoked from network); 5 Feb 2001 15:32:03 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 5 Feb 2001 15:32:03 -0000 Received: (qmail 1441 invoked by alias); 5 Feb 2001 15:31:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13431 Received: (qmail 1429 invoked from network); 5 Feb 2001 15:31:50 -0000 X-Envelope-Sender-Is: Andrej.Borsenkow@mow.siemens.ru (at relayer david.siemens.de) From: "Andrej Borsenkow" To: "Peter Stephenson" , "Zsh hackers list" Subject: RE: PATCH: RE: termcap moodule problem on Cygwin Date: Mon, 5 Feb 2001 18:31:46 +0300 Message-ID: <003901c08f88$bff3e410$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_003A_01C08FA1.E5411C10" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 In-Reply-To: This is a multi-part message in MIME format. ------=_NextPart_000_003A_01C08FA1.E5411C10 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 7bit > > > > 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 ------=_NextPart_000_003A_01C08FA1.E5411C10 Content-Type: application/octet-stream; name="zsh.termcap.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="zsh.termcap.diff" Index: aczsh.m4=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/aczsh.m4,v=0A= retrieving revision 1.6=0A= diff -u -r1.6 aczsh.m4=0A= --- aczsh.m4 2000/10/11 12:26:13 1.6=0A= +++ aczsh.m4 2001/02/05 15:24:13=0A= @@ -111,32 +111,59 @@=0A= =0A= =0A= dnl=0A= -dnl zsh_SYS_DYNAMIC_BROKEN=0A= -dnl Check whether static/shared library linking is broken.=0A= +dnl zsh_SHARED_FUNCTION=0A= dnl=0A= +dnl This is just a frontend to zsh_SHARED_SYMBOL=0A= +dnl=0A= +dnl Usage: zsh_SHARED_FUNCTION(name[,rettype[,paramtype]])=0A= +dnl=0A= +=0A= +AC_DEFUN(zsh_SHARED_FUNCTION,=0A= +[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ = ],[$3])[)], $1)])=0A= +=0A= +dnl=0A= +dnl zsh_SHARED_VARIABLE=0A= +dnl=0A= +dnl This is just a frontend to zsh_SHARED_SYMBOL=0A= +dnl=0A= +dnl Usage: zsh_SHARED_VARIABLE(name[,type])=0A= +dnl=0A= +=0A= +AC_DEFUN(zsh_SHARED_VARIABLE,=0A= +[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])])=0A= +=0A= +dnl=0A= +dnl zsh_SHARED_SYMBOL=0A= +dnl Check whether symbol is available in static or shared library=0A= +dnl=0A= dnl On some systems, static modifiable library symbols (such as = environ)=0A= dnl may appear only in statically linked libraries. If this is the = case,=0A= dnl then two shared libraries that reference the same symbol, each = linked=0A= dnl with the static library, could be given distinct copies of the = symbol.=0A= -dnl If this is the case then dynamic linking is FUBAR.=0A= +dnl=0A= +dnl Usage: zsh_SHARED_SYMBOL(name,declaration,address)=0A= +dnl Sets zsh_cv_shared_$1 cache variable to yes/no=0A= dnl=0A= =0A= -AC_DEFUN(zsh_SYS_DYNAMIC_BROKEN,=0A= -[AC_CACHE_CHECK([if static/shared library linking is broken],=0A= -zsh_cv_sys_dynamic_broken,=0A= +AC_DEFUN(zsh_SHARED_SYMBOL,=0A= +[AC_CACHE_CHECK([if $1 is available in shared libraries],=0A= +zsh_cv_shared_$1,=0A= [if test "$zsh_cv_func_dlsym_needs_underscore" =3D yes; then=0A= us=3D_=0A= else=0A= us=3D=0A= fi=0A= echo '=0A= - extern char **environ;=0A= - void *symlist1[[]] =3D {=0A= - (void *)&environ,=0A= - (void *)0=0A= - };=0A= +void *zsh_getaddr1()=0A= +{=0A= +#ifdef __CYGWIN__=0A= + __attribute__((__dllimport__)) =0A= +#endif=0A= + extern $2;=0A= + return $3;=0A= +};=0A= ' > conftest1.c=0A= -sed 's/symlist1/symlist2/' < conftest1.c > conftest2.c=0A= +sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c=0A= if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&=0A= $DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 = 2>&5 &&=0A= $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 &&=0A= @@ -172,25 +199,33 @@=0A= main()=0A= {=0A= void *handle1, *handle2;=0A= - void **symlist1, **symlist2;=0A= + void *(*zsh_getaddr1)(), *(*zsh_getaddr2)();=0A= + void *sym1, *sym2;=0A= handle1 =3D dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);=0A= if(!handle1) exit(1);=0A= handle2 =3D dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);=0A= if(!handle2) exit(1);=0A= - symlist1 =3D (void **) dlsym(handle1, "${us}symlist1");=0A= - symlist2 =3D (void **) dlsym(handle2, "${us}symlist2");=0A= - if(!symlist1 || !symlist2) exit(1);=0A= - for(; *symlist1; symlist1++, symlist2++)=0A= - if(*symlist1 !=3D *symlist2)=0A= - exit(1);=0A= + zsh_getaddr1 =3D (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");=0A= + zsh_getaddr2 =3D (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2");=0A= + sym1 =3D zsh_getaddr1();=0A= + sym2 =3D zsh_getaddr2();=0A= + if(!sym1 || !sym2) exit(1);=0A= + if(sym1 !=3D sym2) exit(1);=0A= + dlclose(handle1);=0A= + handle1 =3D dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);=0A= + if(!handle1) exit(1);=0A= + zsh_getaddr1 =3D (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");=0A= + sym1 =3D zsh_getaddr1();=0A= + if(!sym1) exit(1);=0A= + if(sym1 !=3D sym2) exit(1);=0A= exit(0);=0A= }=0A= -], [zsh_cv_sys_dynamic_broken=3Dno],=0A= -[zsh_cv_sys_dynamic_broken=3Dyes],=0A= -[zsh_cv_sys_dynamic_broken=3Dyes]=0A= +], [zsh_cv_shared_$1=3Dyes],=0A= +[zsh_cv_shared_$1=3Dno],=0A= +[zsh_cv_shared_$1=3Dno]=0A= )=0A= else=0A= - zsh_cv_sys_dynamic_broken=3Dyes=0A= + zsh_cv_shared_$1=3Dno=0A= fi=0A= ])=0A= ])=0A= Index: configure.in=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/configure.in,v=0A= retrieving revision 1.39=0A= diff -u -r1.39 configure.in=0A= --- configure.in 2001/01/19 14:47:44 1.39=0A= +++ configure.in 2001/02/05 15:24:14=0A= @@ -493,7 +493,9 @@=0A= dnl On some systems, modules need to be linked against libc explicitly,=0A= dnl in case they require objects that exist only in the static version=0A= dnl and might not be compiled into the zsh executable.=0A= -AC_CHECK_LIB(c, printf)=0A= +dnl On ReliantUNIX -lc better be the last library, else funny things=0A= +dnl may happen.=0A= +AC_CHECK_LIB(c, printf, [LIBS=3D"$LIBS -lc"])=0A= =0A= AC_CHECK_LIB(m, pow)=0A= =0A= @@ -557,37 +559,6 @@=0A= AC_DEFINE(MUST_DEFINE_OSPEED)=0A= fi=0A= =0A= -dnl Check if tgetent accepts NULL (and will allocate its own termcap = buffer)=0A= -dnl Some termcaps reportedly accept a zero buffer, but then dump core=0A= -dnl in tgetstr().=0A= -dnl Under Cygwin test program crashes but exit code is still 0. So,=0A= -dnl we test for a file that porgram should create=0A= -AC_CACHE_CHECK(if tgetent accepts NULL,=0A= -zsh_cv_func_tgetent_accepts_null,=0A= -[AC_TRY_RUN([=0A= -main()=0A= -{=0A= - int i =3D tgetent((char*)0,"vt100");=0A= - if (i > 0) {=0A= - char tbuf[1024], *u;=0A= - u =3D tbuf;=0A= - tgetstr("cl", &u);=0A= - creat("conftest.tgetent", 0640);=0A= - }=0A= - exit(!i || i =3D=3D -1);=0A= -}=0A= -],=0A= - if test -f conftest.tgetent; then=0A= - zsh_cv_func_tgetent_accepts_null=3Dyes=0A= - else=0A= - zsh_cv_func_tgetent_accepts_null=3Dno=0A= - fi,=0A= - zsh_cv_func_tgetent_accepts_null=3Dno,=0A= - zsh_cv_func_tgetent_accepts_null=3Dno)])=0A= -if test $zsh_cv_func_tgetent_accepts_null =3D yes; then=0A= - AC_DEFINE(TGETENT_ACCEPTS_NULL)=0A= -fi=0A= -=0A= dnl --------------=0A= dnl CHECK TYPEDEFS=0A= dnl --------------=0A= @@ -845,9 +816,40 @@=0A= putenv getenv \=0A= brk sbrk \=0A= pathconf sysconf \=0A= - tigetflag tigetnum tigetstr)=0A= + tgetent tigetflag tigetnum tigetstr)=0A= AC_FUNC_STRCOLL=0A= =0A= +dnl Check if tgetent accepts NULL (and will allocate its own termcap = buffer)=0A= +dnl Some termcaps reportedly accept a zero buffer, but then dump core=0A= +dnl in tgetstr().=0A= +dnl Under Cygwin test program crashes but exit code is still 0. So,=0A= +dnl we test for a file that porgram should create=0A= +AC_CACHE_CHECK(if tgetent accepts NULL,=0A= +zsh_cv_func_tgetent_accepts_null,=0A= +[AC_TRY_RUN([=0A= +main()=0A= +{=0A= + int i =3D tgetent((char*)0,"vt100");=0A= + if (i > 0) {=0A= + char tbuf[1024], *u;=0A= + u =3D tbuf;=0A= + tgetstr("cl", &u);=0A= + creat("conftest.tgetent", 0640);=0A= + }=0A= + exit(!i || i =3D=3D -1);=0A= +}=0A= +],=0A= + if test -f conftest.tgetent; then=0A= + zsh_cv_func_tgetent_accepts_null=3Dyes=0A= + else=0A= + zsh_cv_func_tgetent_accepts_null=3Dno=0A= + fi,=0A= + zsh_cv_func_tgetent_accepts_null=3Dno,=0A= + zsh_cv_func_tgetent_accepts_null=3Dno)])=0A= +if test $zsh_cv_func_tgetent_accepts_null =3D yes; then=0A= + AC_DEFINE(TGETENT_ACCEPTS_NULL)=0A= +fi=0A= +=0A= AC_FUNC_MMAP=0A= if test x$ac_cv_func_mmap_fixed_mapped =3D xyes; then=0A= AC_CHECK_FUNCS(munmap msync)=0A= @@ -1471,7 +1473,10 @@=0A= zsh_cv_sys_dynamic_execsyms=3D"${zsh_cv_sys_dynamic_execsyms=3Dno}"=0A= zsh_cv_sys_dynamic_strip_exe=3D"${zsh_cv_sys_dynamic_strip_exe=3Dyes}"=0A= zsh_cv_sys_dynamic_strip_lib=3D"${zsh_cv_sys_dynamic_strip_lib=3Dyes}"=0A= - zsh_cv_sys_dynamic_broken=3D"${zsh_cv_sys_dynamic_broken=3Dno}"=0A= + #=0A= + # THAT SUCKS! and must be changed=0A= + #=0A= + zsh_cv_shared_environ=3D"${zsh_cv_shared_environ=3Dyes}"=0A= LINKMODS=3DLINKMODS=0A= MOD_EXPORT=3D"__attribute__((__dllexport__))"=0A= MOD_IMPORT_VARIABLE=3D"__attribute__((__dllimport__))"=0A= @@ -1616,8 +1621,15 @@=0A= fi=0A= =0A= if test "x$dynamic" =3D xyes; then=0A= - zsh_SYS_DYNAMIC_BROKEN=0A= - test "$zsh_cv_sys_dynamic_broken" =3D no || dynamic=3Dno=0A= + zsh_SHARED_VARIABLE([environ], [char **])=0A= + test "$zsh_cv_shared_environ" =3D yes || dynamic=3Dno=0A= +dnl test "$zsh_cv_sys_dynamic_broken" =3D no || dynamic=3Dno=0A= + if test "$ac_cv_func_tgetent" =3D yes; then=0A= + zsh_SHARED_FUNCTION([tgetent])=0A= + fi=0A= + if test "$ac_cv_func_tigetstr" =3D yes; then=0A= + zsh_SHARED_FUNCTION([tigetstr])=0A= + fi=0A= fi=0A= =0A= if test "x$dynamic" =3D xyes; then=0A= Index: Src/Modules/termcap.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.c,v=0A= retrieving revision 1.1=0A= diff -u -r1.1 termcap.c=0A= --- Src/Modules/termcap.c 2000/12/03 20:53:25 1.1=0A= +++ Src/Modules/termcap.c 2001/02/05 15:24:16=0A= @@ -33,7 +33,7 @@=0A= /* echotc: output a termcap */=0A= =0A= /**/=0A= -int=0A= +static int=0A= bin_echotc(char *name, char **argv, char *ops, int func)=0A= {=0A= char *s, buf[2048], *t, *u;=0A= Index: Src/Modules/termcap.mdd=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Src/Modules/termcap.mdd,v=0A= retrieving revision 1.1=0A= diff -u -r1.1 termcap.mdd=0A= --- Src/Modules/termcap.mdd 2000/12/03 20:53:25 1.1=0A= +++ Src/Modules/termcap.mdd 2001/02/05 15:24:16=0A= @@ -1,5 +1,15 @@=0A= name=3Dzsh/termcap=0A= -link=3Deither=0A= +=0A= +link=3D'if test "x$ac_cv_func_tgetent" =3D xyes; then=0A= + if test "x$zsh_cv_shared_tgetent" =3D xyes; then=0A= + echo either=0A= + else=0A= + echo static=0A= + fi=0A= + else=0A= + echo no;=0A= + fi=0A= +'=0A= load=3Dyes=0A= =0A= autobins=3D"echotc"=0A= Index: Src/Modules/terminfo.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v=0A= retrieving revision 1.4=0A= diff -u -r1.4 terminfo.c=0A= --- Src/Modules/terminfo.c 2000/12/06 01:16:15 1.4=0A= +++ Src/Modules/terminfo.c 2001/02/05 15:24:16=0A= @@ -36,7 +36,7 @@=0A= /* echoti: output a terminfo capability */=0A= =0A= /**/=0A= -int=0A= +static int=0A= bin_echoti(char *name, char **argv, char *ops, int func)=0A= {=0A= char *s, *t;=0A= Index: Src/Modules/terminfo.mdd=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.mdd,v=0A= retrieving revision 1.3=0A= diff -u -r1.3 terminfo.mdd=0A= --- Src/Modules/terminfo.mdd 2000/12/05 11:00:09 1.3=0A= +++ Src/Modules/terminfo.mdd 2001/02/05 15:24:16=0A= @@ -1,5 +1,15 @@=0A= name=3Dzsh/terminfo=0A= -link=3D'if test "x$ac_cv_func_tigetstr" =3D xyes; then echo either; = else echo no; fi'=0A= +=0A= +link=3D'if test "x$ac_cv_func_tigetstr" =3D xyes; then=0A= + if test "x$zsh_cv_shared_tigetstr" =3D xyes; then=0A= + echo either=0A= + else=0A= + echo static=0A= + fi=0A= + else=0A= + echo no;=0A= + fi=0A= +'=0A= load=3Dyes=0A= =0A= autobins=3D"echoti"=0A= ------=_NextPart_000_003A_01C08FA1.E5411C10--