zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: PATCH: separate watch/log functionality out into a module
Date: Thu, 11 Nov 2021 20:06:39 +0900	[thread overview]
Message-ID: <F80A0CEA-3C20-491E-B15B-1ECC544ABE8F@kba.biglobe.ne.jp> (raw)
In-Reply-To: <41833-1635545739.955327@NiDy.UqMC.wWcd>


> 2021/10/30 7:15, Oliver Kiddle <opk@zsh.org> wrote:
> 
> This patch extracts the functionality out into a zsh/watch module.

With this patch (either with or without the one in worker/49544⁩),
build fails on Cygwin as follows:

gcc -c ...(snip)...  -o watch..o watch.c
In file included from ../../Src/zsh.mdh:16,
                 from watch.mdh:15,
                 from watch.c:30:
../../Src/zsh.h:2097:34: error: initializer element is not constant
 2097 |     { name, flags, (void *) var, (void *) gsu, \
      |                                  ^
watch.c:643:5: note: in expansion of macro ‘PARAMDEF’
  643 |     PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL, &watch, &colonarr_gsu),
      |     ^~~~~~~~

(and the same error for &vararray_gsu)

On Cygwin, params.o (in which colonarr_gsu is defined) is not included in
the main zsh.exe but in libzsh.dll (I don't know why).
This means &colonarr_gsu is not a build-time constant and can't be used
for the initialization of the static variable partab[].
A simple workaround is to set the .gsu in the setup_() function.
This takes virtually no time to execute and I think we don't need to use
#ifdef __CYGWIN__.




diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c
index 5ce604c63..1c2766dda 100644
--- a/Src/Modules/watch.c
+++ b/Src/Modules/watch.c
@@ -640,8 +640,8 @@ static struct builtin bintab[] = {
 };
 
 static struct paramdef partab[] = {
-    PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL, &watch, &colonarr_gsu),
-    PARAMDEF("watch", PM_ARRAY|PM_SPECIAL, &watch, &vararray_gsu),
+    PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL, &watch, NULL),
+    PARAMDEF("watch", PM_ARRAY|PM_SPECIAL, &watch, NULL),
 };
 
 static struct features module_features = {
@@ -656,6 +656,10 @@ static struct features module_features = {
 int
 setup_(UNUSED(Module m))
 {
+    /* On Cygwin, colonarr_gsu exists in libzsh.dll and we can't
+     * use &colonarr_gsu in the initialization of bintab[] above */
+    partab[0].gsu = (void *)&colonarr_gsu;
+    partab[1].gsu = (void *)&vararray_gsu;
     return 0;
 }
 




  parent reply	other threads:[~2021-11-11 11:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29 22:15 Oliver Kiddle
2021-11-01  0:06 ` Oliver Kiddle
2021-11-01  3:11   ` Bart Schaefer
2021-11-06  0:17     ` Oliver Kiddle
2021-11-06 20:53       ` Bart Schaefer
2021-11-28 20:56         ` Oliver Kiddle
2021-11-29  4:31           ` Bart Schaefer
2021-11-09 10:27       ` Jun. T
2021-11-09 21:09         ` Daniel Shahaf
2021-11-11 11:06 ` Jun T [this message]
2021-11-11 17:08   ` Oliver Kiddle
2021-11-12  9:19     ` Jun T

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=F80A0CEA-3C20-491E-B15B-1ECC544ABE8F@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /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).