Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d9 / 3335128452599d0c929387a3553f7bb1ae0bbb
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 1F600431FDD\r
6         for <notmuch@notmuchmail.org>; Thu, 23 Oct 2014 21:40:36 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id UnOZiGwkTIwR for <notmuch@notmuchmail.org>;\r
16         Thu, 23 Oct 2014 21:40:28 -0700 (PDT)\r
17 Received: from mail-la0-f48.google.com (mail-la0-f48.google.com\r
18         [209.85.215.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 5F3DB431FDC\r
21         for <notmuch@notmuchmail.org>; Thu, 23 Oct 2014 21:40:28 -0700 (PDT)\r
22 Received: by mail-la0-f48.google.com with SMTP id gi9so1966483lab.21\r
23         for <notmuch@notmuchmail.org>; Thu, 23 Oct 2014 21:40:25 -0700 (PDT)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=1e100.net; s=20130820;\r
26         h=x-gm-message-state:mime-version:in-reply-to:references:date\r
27         :message-id:subject:from:to:cc:content-type;\r
28         bh=BQi7AgBJzl1M8yMutnXjYAo46AeFFQdOPzxbhPuq1F0=;\r
29         b=NmDEHvd1y52ANM/FsSu5jU3WzmNWktvPShuTUY7NSFprTwmOTLfIl8tJ2a2IqDXg5v\r
30         kcRZ1Cpx91Frs/2oXChdYmp/EVWPzZy8Y9GuBA0oZmsV5x2rXfpNU49ygFsW3gPIEOaF\r
31         lEYdKaXuLQ55kMHCO0oQNZ3A08la/SleSEm0TvSEmk31F7SoCO/HVRDndrUioPMatlCZ\r
32         xuP07mUKIz61NyMtTaNpqI8o++GJnfICNVqED3CqojDuHiBCozxDS9B/N5N6/q/Igk/e\r
33         rb4yDGYDbtN/s4zG47pDgQBw42yabM4Qo+gVuylwikEyNq0EsS9uzs0nP5QmQ2QzHOVn\r
34         jCHg==\r
35 X-Gm-Message-State:\r
36  ALoCoQnJKFx4G4udFAZq9Ld8gli2h35wXO3mDfvpC9G7OOj+u+ycR9nXMc+uydlnb40MxoVtZ44m\r
37 MIME-Version: 1.0\r
38 X-Received: by 10.152.7.7 with SMTP id f7mr1666883laa.57.1414125625506; Thu,\r
39         23 Oct 2014 21:40:25 -0700 (PDT)\r
40 Received: by 10.25.145.7 with HTTP; Thu, 23 Oct 2014 21:40:25 -0700 (PDT)\r
41 Received: by 10.25.145.7 with HTTP; Thu, 23 Oct 2014 21:40:25 -0700 (PDT)\r
42 In-Reply-To: <1414067441-29054-4-git-send-email-aclements@csail.mit.edu>\r
43 References: <1414067441-29054-1-git-send-email-aclements@csail.mit.edu>\r
44         <1414067441-29054-4-git-send-email-aclements@csail.mit.edu>\r
45 Date: Fri, 24 Oct 2014 07:40:25 +0300\r
46 Message-ID:\r
47  <CAB+hUn_d3Wp2bie3E6n1gtb9J_NypAv5rHmr3ObAqWsOX-hzFw@mail.gmail.com>\r
48 Subject: Re: [PATCH v3 3/9] lib: Introduce macros for bit operations\r
49 From: Jani Nikula <jani@nikula.org>\r
50 To: Austin Clements <aclements@csail.mit.edu>\r
51 Content-Type: multipart/alternative; boundary=001a11c2870a939325050623c78e\r
52 Cc: Notmuch Mail <notmuch@notmuchmail.org>\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Fri, 24 Oct 2014 04:40:36 -0000\r
66 \r
67 --001a11c2870a939325050623c78e\r
68 Content-Type: text/plain; charset=UTF-8\r
69 \r
70 On Oct 23, 2014 3:31 PM, "Austin Clements" <aclements@csail.mit.edu> wrote:\r
71 >\r
72 > These macros help clarify basic bit-twiddling code and are written to\r
73 > be robust against C undefined behavior of shift operators.\r
74 > ---\r
75 >  lib/message.cc        |  6 +++---\r
76 >  lib/notmuch-private.h | 11 +++++++++++\r
77 >  2 files changed, 14 insertions(+), 3 deletions(-)\r
78 >\r
79 > diff --git a/lib/message.cc b/lib/message.cc\r
80 > index 38bc929..55d2ff6 100644\r
81 > --- a/lib/message.cc\r
82 > +++ b/lib/message.cc\r
83 > @@ -869,7 +869,7 @@ notmuch_bool_t\r
84 >  notmuch_message_get_flag (notmuch_message_t *message,\r
85 >                           notmuch_message_flag_t flag)\r
86 >  {\r
87 > -    return message->flags & (1 << flag);\r
88 > +    return NOTMUCH_TEST_BIT (message->flags, flag);\r
89 >  }\r
90 >\r
91 >  void\r
92 > @@ -877,9 +877,9 @@ notmuch_message_set_flag (notmuch_message_t *message,\r
93 >                           notmuch_message_flag_t flag, notmuch_bool_t\r
94 enable)\r
95 >  {\r
96 >      if (enable)\r
97 > -       message->flags |= (1 << flag);\r
98 > +       NOTMUCH_SET_BIT (&message->flags, flag);\r
99 >      else\r
100 > -       message->flags &= ~(1 << flag);\r
101 > +       NOTMUCH_CLEAR_BIT (&message->flags, flag);\r
102 >  }\r
103 >\r
104 >  time_t\r
105 > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h\r
106 > index 36cc12b..7250291 100644\r
107 > --- a/lib/notmuch-private.h\r
108 > +++ b/lib/notmuch-private.h\r
109 > @@ -63,6 +63,17 @@ NOTMUCH_BEGIN_DECLS\r
110 >  #define STRNCMP_LITERAL(var, literal) \\r
111 >      strncmp ((var), (literal), sizeof (literal) - 1)\r
112 >\r
113 > +/* Robust bit test/set/reset macros */\r
114 > +#define NOTMUCH_TEST_BIT(val, bit) \\r
115 > +    ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ? 0    \\r
116 > +     : !!((val) & (1ull << bit)))\r
117 > +#define NOTMUCH_SET_BIT(valp, bit) \\r
118 > +    ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ?\r
119 *(valp) \\r
120 > +     : (*(valp) |= (1ull << bit)))\r
121 > +#define NOTMUCH_CLEAR_BIT(valp,  bit) \\r
122 > +    ((bit < 0 || bit >= CHAR_BIT * sizeof (unsigned long long)) ?\r
123 *(valp) \\r
124 > +     : (*(valp) &= ~(1ull << bit)))\r
125 \r
126 bit should be in braces in the above, like valp.\r
127 \r
128 Jani.\r
129 \r
130 > +\r
131 >  #define unused(x) x __attribute__ ((unused))\r
132 >\r
133 >  #ifdef __cplusplus\r
134 > --\r
135 > 2.1.0\r
136 >\r
137 > _______________________________________________\r
138 > notmuch mailing list\r
139 > notmuch@notmuchmail.org\r
140 > http://notmuchmail.org/mailman/listinfo/notmuch\r
141 \r
142 --001a11c2870a939325050623c78e\r
143 Content-Type: text/html; charset=UTF-8\r
144 Content-Transfer-Encoding: quoted-printable\r
145 \r
146 <p dir=3D"ltr"><br>\r
147 On Oct 23, 2014 3:31 PM, &quot;Austin Clements&quot; &lt;<a href=3D"mailto:=\r
148 aclements@csail.mit.edu">aclements@csail.mit.edu</a>&gt; wrote:<br>\r
149 &gt;<br>\r
150 &gt; These macros help clarify basic bit-twiddling code and are written to<=\r
151 br>\r
152 &gt; be robust against C undefined behavior of shift operators.<br>\r
153 &gt; ---<br>\r
154 &gt; =C2=A0lib/message.cc=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 6 +++---<br>\r
155 &gt; =C2=A0lib/notmuch-private.h | 11 +++++++++++<br>\r
156 &gt; =C2=A02 files changed, 14 insertions(+), 3 deletions(-)<br>\r
157 &gt;<br>\r
158 &gt; diff --git a/lib/message.cc b/lib/message.cc<br>\r
159 &gt; index 38bc929..55d2ff6 100644<br>\r
160 &gt; --- a/lib/message.cc<br>\r
161 &gt; +++ b/lib/message.cc<br>\r
162 &gt; @@ -869,7 +869,7 @@ notmuch_bool_t<br>\r
163 &gt; =C2=A0notmuch_message_get_flag (notmuch_message_t *message,<br>\r
164 &gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =\r
165 =C2=A0 =C2=A0 =C2=A0 notmuch_message_flag_t flag)<br>\r
166 &gt; =C2=A0{<br>\r
167 &gt; -=C2=A0 =C2=A0 return message-&gt;flags &amp; (1 &lt;&lt; flag);<br>\r
168 &gt; +=C2=A0 =C2=A0 return NOTMUCH_TEST_BIT (message-&gt;flags, flag);<br>\r
169 &gt; =C2=A0}<br>\r
170 &gt;<br>\r
171 &gt; =C2=A0void<br>\r
172 &gt; @@ -877,9 +877,9 @@ notmuch_message_set_flag (notmuch_message_t *messa=\r
173 ge,<br>\r
174 &gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =\r
175 =C2=A0 =C2=A0 =C2=A0 notmuch_message_flag_t flag, notmuch_bool_t enable)<br=\r
176 >\r
177 &gt; =C2=A0{<br>\r
178 &gt; =C2=A0 =C2=A0 =C2=A0if (enable)<br>\r
179 &gt; -=C2=A0 =C2=A0 =C2=A0 =C2=A0message-&gt;flags |=3D (1 &lt;&lt; flag);<=\r
180 br>\r
181 &gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0NOTMUCH_SET_BIT (&amp;message-&gt;flags, f=\r
182 lag);<br>\r
183 &gt; =C2=A0 =C2=A0 =C2=A0else<br>\r
184 &gt; -=C2=A0 =C2=A0 =C2=A0 =C2=A0message-&gt;flags &amp;=3D ~(1 &lt;&lt; fl=\r
185 ag);<br>\r
186 &gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0NOTMUCH_CLEAR_BIT (&amp;message-&gt;flags,=\r
187  flag);<br>\r
188 &gt; =C2=A0}<br>\r
189 &gt;<br>\r
190 &gt; =C2=A0time_t<br>\r
191 &gt; diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h<br>\r
192 &gt; index 36cc12b..7250291 100644<br>\r
193 &gt; --- a/lib/notmuch-private.h<br>\r
194 &gt; +++ b/lib/notmuch-private.h<br>\r
195 &gt; @@ -63,6 +63,17 @@ NOTMUCH_BEGIN_DECLS<br>\r
196 &gt; =C2=A0#define STRNCMP_LITERAL(var, literal) \<br>\r
197 &gt; =C2=A0 =C2=A0 =C2=A0strncmp ((var), (literal), sizeof (literal) - 1)<b=\r
198 r>\r
199 &gt;<br>\r
200 &gt; +/* Robust bit test/set/reset macros */<br>\r
201 &gt; +#define NOTMUCH_TEST_BIT(val, bit) \<br>\r
202 &gt; +=C2=A0 =C2=A0 ((bit &lt; 0 || bit &gt;=3D CHAR_BIT * sizeof (unsigned=\r
203  long long)) ? 0=C2=A0 =C2=A0 \<br>\r
204 &gt; +=C2=A0 =C2=A0 =C2=A0: !!((val) &amp; (1ull &lt;&lt; bit)))<br>\r
205 &gt; +#define NOTMUCH_SET_BIT(valp, bit) \<br>\r
206 &gt; +=C2=A0 =C2=A0 ((bit &lt; 0 || bit &gt;=3D CHAR_BIT * sizeof (unsigned=\r
207  long long)) ? *(valp) \<br>\r
208 &gt; +=C2=A0 =C2=A0 =C2=A0: (*(valp) |=3D (1ull &lt;&lt; bit)))<br>\r
209 &gt; +#define NOTMUCH_CLEAR_BIT(valp,=C2=A0 bit) \<br>\r
210 &gt; +=C2=A0 =C2=A0 ((bit &lt; 0 || bit &gt;=3D CHAR_BIT * sizeof (unsigned=\r
211  long long)) ? *(valp) \<br>\r
212 &gt; +=C2=A0 =C2=A0 =C2=A0: (*(valp) &amp;=3D ~(1ull &lt;&lt; bit)))</p>\r
213 <p dir=3D"ltr">bit should be in braces in the above, like valp.</p>\r
214 <p dir=3D"ltr">Jani.</p>\r
215 <p dir=3D"ltr">&gt; +<br>\r
216 &gt; =C2=A0#define unused(x) x __attribute__ ((unused))<br>\r
217 &gt;<br>\r
218 &gt; =C2=A0#ifdef __cplusplus<br>\r
219 &gt; --<br>\r
220 &gt; 2.1.0<br>\r
221 &gt;<br>\r
222 &gt; _______________________________________________<br>\r
223 &gt; notmuch mailing list<br>\r
224 &gt; <a href=3D"mailto:notmuch@notmuchmail.org">notmuch@notmuchmail.org</a>=\r
225 <br>\r
226 &gt; <a href=3D"http://notmuchmail.org/mailman/listinfo/notmuch">http://not=\r
227 muchmail.org/mailman/listinfo/notmuch</a><br>\r
228 </p>\r
229 \r
230 --001a11c2870a939325050623c78e--\r