kdbus: Fixup signal subscription
[platform/upstream/glib.git] / glib / gnulib / glib-gnulib.patch
1 These changes are mostly inherited from previous iterations
2 of gnulib-printf-in-glib.
3
4 Here are explanations for some of them:
5 * g-gnulib.h is a minimal replacement for gnulib config.h
6 * gnulib_math.h is a processed copy of gnulib math.in.h
7   We can't keep it named math.h, since we need to include
8   both the system math.h and this header in some places.
9 * gnulib_math.h needs _GL_ATTRIBUTE_CONST, put it directly
10   there instead of getting it from config.h
11   Also, instead of copying _GL_FUNCDECL_RPL and _GL_WARN_ON_USE
12   we simply include headers where these macros are defined.
13 * isnan source files get extra includes, in gnulib these
14   were probably handled by makefiles and/or configure scripts
15 * glib has a test result named HAVE_LONG_LONG instead of HAVE_LONG_LONG_INT,
16   so make the code use that
17 * One of the goals of using this gnulib implementation in glib is
18   to have C99-compliant 3-digit exponent, therefore gnulib
19   ifdefs that *disable* that behaviour are altered to keep it enabled.
20   Another possible location for such a change is where %n use is
21   being enabled or disabled. That, however, is not activated anyway,
22   because this code is made not to use snprintf
23 * glib has G_MAXSIZE instead of SIZE_MAX, so use that
24 * The code is made to use glib alloca header
25 --- glib-82c3e92/glib/gnulib/asnprintf.c        2019-02-09 09:44:55.013866300 +0000
26 +++ glib-82c3e92/glib/gnulib/asnprintf.c        2019-02-09 10:08:46.444859600 +0000
27 @@ -16,6 +16,8 @@
28  
29  #include <config.h>
30  
31 +#include "g-gnulib.h"
32 +
33  /* Specification.  */
34  #include "vasnprintf.h"
35  
36 --- glib-82c3e92/glib/gnulib/isnand.c   2019-02-09 09:44:56.075691800 +0000
37 +++ glib-82c3e92/glib/gnulib/isnand.c   2019-02-09 10:09:35.443191100 +0000
38 @@ -16,4 +16,7 @@
39  
40  /* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
41  
42 +#include <config.h>
43 +#include "gnulib_math.h"
44 +#include "isnand-nolibm.h"
45  #include "isnan.c"
46 --- glib-82c3e92/glib/gnulib/isnand-nolibm.h    2019-02-09 09:44:55.973651800 +0000
47 +++ glib-82c3e92/glib/gnulib/isnand-nolibm.h    2019-02-09 10:09:17.089604000 +0000
48 @@ -16,7 +16,7 @@
49  
50  #if HAVE_ISNAND_IN_LIBC
51  /* Get declaration of isnan macro.  */
52 -# include <math.h>
53 +# include <gnulib_math.h>
54  # if __GNUC__ >= 4
55     /* GCC 4.0 and newer provides three built-ins for isnan.  */
56  #  undef isnand
57 --- glib-82c3e92/glib/gnulib/isnanl.c   2019-02-09 09:44:56.285650400 +0000
58 +++ glib-82c3e92/glib/gnulib/isnanl.c   2019-02-09 10:10:00.060305200 +0000
59 @@ -17,4 +17,7 @@
60  /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
61  
62  #define USE_LONG_DOUBLE
63 +#include <config.h>
64 +#include "gnulib_math.h"
65 +#include "isnanl-nolibm.h"
66  #include "isnan.c"
67 --- glib-82c3e92/glib/gnulib/isnanl-nolibm.h    2019-02-09 09:44:56.181628200 +0000
68 +++ glib-82c3e92/glib/gnulib/isnanl-nolibm.h    2019-02-09 10:09:45.731187400 +0000
69 @@ -16,7 +16,7 @@
70  
71  #if HAVE_ISNANL_IN_LIBC
72  /* Get declaration of isnan macro or (older) isnanl function.  */
73 -# include <math.h>
74 +# include <gnulib_math.h>
75  # if __GNUC__ >= 4
76     /* GCC 4.0 and newer provides three built-ins for isnan.  */
77  #  undef isnanl
78 --- glib-82c3e92/glib/gnulib/printf-args.c      2019-02-09 09:44:57.147081400 +0000
79 +++ glib-82c3e92/glib/gnulib/printf-args.c      2019-02-09 10:10:45.869597700 +0000
80 @@ -24,6 +24,8 @@
81  # include <config.h>
82  #endif
83  
84 +#include "g-gnulib.h"
85 +
86  /* Specification.  */
87  #ifndef PRINTF_FETCHARGS
88  # include "printf-args.h"
89 @@ -65,7 +67,7 @@
90        case TYPE_ULONGINT:
91          ap->a.a_ulongint = va_arg (args, unsigned long int);
92          break;
93 -#if HAVE_LONG_LONG_INT
94 +#if HAVE_LONG_LONG
95        case TYPE_LONGLONGINT:
96          ap->a.a_longlongint = va_arg (args, long long int);
97          break;
98 @@ -135,7 +137,7 @@
99        case TYPE_COUNT_LONGINT_POINTER:
100          ap->a.a_count_longint_pointer = va_arg (args, long int *);
101          break;
102 -#if HAVE_LONG_LONG_INT
103 +#if HAVE_LONG_LONG
104        case TYPE_COUNT_LONGLONGINT_POINTER:
105          ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
106          break;
107 --- glib-82c3e92/glib/gnulib/printf-args.h      2019-02-09 09:44:57.245167700 +0000
108 +++ glib-82c3e92/glib/gnulib/printf-args.h      2019-02-09 10:10:55.543592500 +0000
109 @@ -57,7 +57,7 @@
110    TYPE_UINT,
111    TYPE_LONGINT,
112    TYPE_ULONGINT,
113 -#if HAVE_LONG_LONG_INT
114 +#if HAVE_LONG_LONG
115    TYPE_LONGLONGINT,
116    TYPE_ULONGLONGINT,
117  #endif
118 @@ -76,7 +76,7 @@
119    TYPE_COUNT_SHORT_POINTER,
120    TYPE_COUNT_INT_POINTER,
121    TYPE_COUNT_LONGINT_POINTER
122 -#if HAVE_LONG_LONG_INT
123 +#if HAVE_LONG_LONG
124  , TYPE_COUNT_LONGLONGINT_POINTER
125  #endif
126  #if ENABLE_UNISTDIO
127 @@ -101,7 +101,7 @@
128      unsigned int                a_uint;
129      long int                    a_longint;
130      unsigned long int           a_ulongint;
131 -#if HAVE_LONG_LONG_INT
132 +#if HAVE_LONG_LONG
133      long long int               a_longlongint;
134      unsigned long long int      a_ulonglongint;
135  #endif
136 @@ -121,7 +121,7 @@
137      short *                     a_count_short_pointer;
138      int *                       a_count_int_pointer;
139      long int *                  a_count_longint_pointer;
140 -#if HAVE_LONG_LONG_INT
141 +#if HAVE_LONG_LONG
142      long long int *             a_count_longlongint_pointer;
143  #endif
144  #if ENABLE_UNISTDIO
145 --- glib-82c3e92/glib/gnulib/printf-frexp.c     2019-02-09 09:44:57.355099800 +0000
146 +++ glib-82c3e92/glib/gnulib/printf-frexp.c     2019-02-09 10:11:15.476905600 +0000
147 @@ -26,7 +26,7 @@
148  #endif
149  
150  #include <float.h>
151 -#include <math.h>
152 +#include <gnulib_math.h>
153  #ifdef USE_LONG_DOUBLE
154  # include "fpucw.h"
155  #endif
156 --- glib-82c3e92/glib/gnulib/printf-parse.c     2019-02-09 09:44:57.790835100 +0000
157 +++ glib-82c3e92/glib/gnulib/printf-parse.c     2019-02-09 10:11:32.783744500 +0000
158 @@ -31,6 +31,8 @@
159  # include <config.h>
160  #endif
161  
162 +#include "g-gnulib.h"
163 +
164  /* Specification.  */
165  #ifndef PRINTF_PARSE
166  # include "printf-parse.h"
167 @@ -447,7 +449,7 @@
168                switch (c)
169                  {
170                  case 'd': case 'i':
171 -#if HAVE_LONG_LONG_INT
172 +#if HAVE_LONG_LONG
173                    /* If 'long long' exists and is larger than 'long':  */
174                    if (flags >= 16 || (flags & 4))
175                      type = TYPE_LONGLONGINT;
176 @@ -465,7 +467,7 @@
177                      type = TYPE_INT;
178                    break;
179                  case 'o': case 'u': case 'x': case 'X':
180 -#if HAVE_LONG_LONG_INT
181 +#if HAVE_LONG_LONG
182                    /* If 'long long' exists and is larger than 'long':  */
183                    if (flags >= 16 || (flags & 4))
184                      type = TYPE_ULONGLONGINT;
185 @@ -525,7 +527,7 @@
186                    type = TYPE_POINTER;
187                    break;
188                  case 'n':
189 -#if HAVE_LONG_LONG_INT
190 +#if HAVE_LONG_LONG
191                    /* If 'long long' exists and is larger than 'long':  */
192                    if (flags >= 16 || (flags & 4))
193                      type = TYPE_COUNT_LONGLONGINT_POINTER;
194 --- glib-82c3e92/glib/gnulib/vasnprintf.c       2019-02-09 09:44:58.585342000 +0000
195 +++ glib-82c3e92/glib/gnulib/vasnprintf.c       2019-02-09 10:22:13.196848200 +0000
196 @@ -43,19 +43,21 @@
197       DCHAR_IS_UINT16_T  Set to 1 if DCHAR_T is uint16_t.
198       DCHAR_IS_UINT32_T  Set to 1 if DCHAR_T is uint32_t.  */
199  
200 +#ifndef _WIN32
201  /* Tell glibc's <stdio.h> to provide a prototype for snprintf().
202     This must come before <config.h> because <config.h> may include
203     <features.h>, and once <features.h> has been included, it's too late.  */
204  #ifndef _GNU_SOURCE
205  # define _GNU_SOURCE    1
206  #endif
207 +#endif
208  
209  #ifndef VASNPRINTF
210  # include <config.h>
211  #endif
212 -#ifndef IN_LIBINTL
213 -# include <alloca.h>
214 -#endif
215 +#include "glib/galloca.h"
216 +
217 +#include "g-gnulib.h"
218  
219  /* Specification.  */
220  #ifndef VASNPRINTF
221 @@ -90,29 +92,29 @@
222  #include "verify.h"
223  
224  #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
225 -# include <math.h>
226 +# include <gnulib_math.h>
227  # include "float+.h"
228  #endif
229  
230  #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
231 -# include <math.h>
232 +# include <gnulib_math.h>
233  # include "isnand-nolibm.h"
234  #endif
235  
236  #if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL
237 -# include <math.h>
238 +# include <gnulib_math.h>
239  # include "isnanl-nolibm.h"
240  # include "fpucw.h"
241  #endif
242  
243  #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
244 -# include <math.h>
245 +# include <gnulib_math.h>
246  # include "isnand-nolibm.h"
247  # include "printf-frexp.h"
248  #endif
249  
250  #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
251 -# include <math.h>
252 +# include <gnulib_math.h>
253  # include "isnanl-nolibm.h"
254  # include "printf-frexpl.h"
255  # include "fpucw.h"
256 @@ -1553,7 +1555,7 @@
257    switch (conversion)
258      {
259      case 'd': case 'i': case 'u':
260 -# if HAVE_LONG_LONG_INT
261 +# if HAVE_LONG_LONG
262        if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
263          tmp_length =
264            (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
265 @@ -1583,7 +1585,7 @@
266        break;
267  
268      case 'o':
269 -# if HAVE_LONG_LONG_INT
270 +# if HAVE_LONG_LONG
271        if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
272          tmp_length =
273            (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
274 @@ -1611,7 +1613,7 @@
275        break;
276  
277      case 'x': case 'X':
278 -# if HAVE_LONG_LONG_INT
279 +# if HAVE_LONG_LONG
280        if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
281          tmp_length =
282            (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
283 @@ -1939,7 +1941,7 @@
284                    case TYPE_COUNT_LONGINT_POINTER:
285                      *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
286                      break;
287 -#if HAVE_LONG_LONG_INT
288 +#if HAVE_LONG_LONG
289                    case TYPE_COUNT_LONGLONGINT_POINTER:
290                      *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
291                      break;
292 @@ -4245,7 +4247,7 @@
293                                    static const wchar_t decimal_format[] =
294                                      /* Produce the same number of exponent digits
295                                         as the native printf implementation.  */
296 -#    if defined _WIN32 && ! defined __CYGWIN__
297 +#    if (defined _WIN32 && FALSE) && ! defined __CYGWIN__
298                                      { '%', '+', '.', '3', 'd', '\0' };
299  #    else
300                                      { '%', '+', '.', '2', 'd', '\0' };
301 @@ -4259,7 +4261,7 @@
302                                    static const char decimal_format[] =
303                                      /* Produce the same number of exponent digits
304                                         as the native printf implementation.  */
305 -#    if defined _WIN32 && ! defined __CYGWIN__
306 +#    if (defined _WIN32 && FALSE) && ! defined __CYGWIN__
307                                      "%+.3d";
308  #    else
309                                      "%+.2d";
310 @@ -4438,7 +4440,7 @@
311                                            static const wchar_t decimal_format[] =
312                                              /* Produce the same number of exponent digits
313                                                 as the native printf implementation.  */
314 -#    if defined _WIN32 && ! defined __CYGWIN__
315 +#    if (defined _WIN32 && FALSE) && ! defined __CYGWIN__
316                                              { '%', '+', '.', '3', 'd', '\0' };
317  #    else
318                                              { '%', '+', '.', '2', 'd', '\0' };
319 @@ -4452,7 +4454,7 @@
320                                            static const char decimal_format[] =
321                                              /* Produce the same number of exponent digits
322                                                 as the native printf implementation.  */
323 -#    if defined _WIN32 && ! defined __CYGWIN__
324 +#    if (defined _WIN32 && FALSE) && ! defined __CYGWIN__
325                                              "%+.3d";
326  #    else
327                                              "%+.2d";
328 @@ -4510,7 +4512,7 @@
329                                  *p++ = '+';
330                                  /* Produce the same number of exponent digits as
331                                     the native printf implementation.  */
332 -#   if defined _WIN32 && ! defined __CYGWIN__
333 +#   if (defined _WIN32 && FALSE) && ! defined __CYGWIN__
334                                  *p++ = '0';
335  #   endif
336                                  *p++ = '0';
337 @@ -4835,10 +4837,10 @@
338  
339                  switch (type)
340                    {
341 -#if HAVE_LONG_LONG_INT
342 +#if HAVE_LONG_LONG
343                    case TYPE_LONGLONGINT:
344                    case TYPE_ULONGLONGINT:
345 -# if defined _WIN32 && ! defined __CYGWIN__
346 +# if (defined _WIN32 && FALSE) && ! defined __CYGWIN__
347                      *fbp++ = 'I';
348                      *fbp++ = '6';
349                      *fbp++ = '4';
350 @@ -5063,7 +5065,7 @@
351                            SNPRINTF_BUF (arg);
352                          }
353                          break;
354 -#if HAVE_LONG_LONG_INT
355 +#if HAVE_LONG_LONG
356                        case TYPE_LONGLONGINT:
357                          {
358                            long long int arg = a.arg[dp->arg_index].a.a_longlongint;
359 --- glib-82c3e92/glib/gnulib/xsize.h    2019-02-09 09:44:59.231076600 +0000
360 +++ glib-82c3e92/glib/gnulib/xsize.h    2019-02-09 10:21:28.789553900 +0000
361 @@ -18,10 +18,12 @@
362  #ifndef _XSIZE_H
363  #define _XSIZE_H
364  
365 +#include <glib.h>
366 +
367  /* Get size_t.  */
368  #include <stddef.h>
369  
370 -/* Get SIZE_MAX.  */
371 +/* Get G_MAXSIZE.  */
372  #include <limits.h>
373  #if HAVE_STDINT_H
374  # include <stdint.h>
375 @@ -42,8 +44,8 @@
376     returns a piece of memory that is way too small, and the program then
377     crashes while attempting to fill the memory.
378     To avoid this, the functions and macros in this file check for overflow.
379 -   The convention is that SIZE_MAX represents overflow.
380 -   malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
381 +   The convention is that G_MAXSIZE represents overflow.
382 +   malloc (G_MAXSIZE) is not guaranteed to fail -- think of a malloc
383     implementation that uses mmap --, it's recommended to use size_overflow_p()
384     or size_in_bounds_p() before invoking malloc().
385     The example thus becomes:
386 @@ -53,7 +55,7 @@
387  
388  /* Convert an arbitrary value >= 0 to type size_t.  */
389  #define xcast_size_t(N) \
390 -  ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
391 +  ((N) <= G_MAXSIZE ? (size_t) (N) : G_MAXSIZE)
392  
393  /* Sum of two sizes, with overflow check.  */
394  XSIZE_INLINE size_t
395 @@ -63,7 +65,7 @@
396  xsum (size_t size1, size_t size2)
397  {
398    size_t sum = size1 + size2;
399 -  return (sum >= size1 ? sum : SIZE_MAX);
400 +  return (sum >= size1 ? sum : G_MAXSIZE);
401  }
402  
403  /* Sum of three sizes, with overflow check.  */
404 @@ -94,23 +96,23 @@
405  xmax (size_t size1, size_t size2)
406  {
407    /* No explicit check is needed here, because for any n:
408 -     max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX.  */
409 +     max (G_MAXSIZE, n) == G_MAXSIZE and max (n, G_MAXSIZE) == G_MAXSIZE.  */
410    return (size1 >= size2 ? size1 : size2);
411  }
412  
413  /* Multiplication of a count with an element size, with overflow check.
414     The count must be >= 0 and the element size must be > 0.
415     This is a macro, not a function, so that it works correctly even
416 -   when N is of a wider type and N > SIZE_MAX.  */
417 +   when N is of a wider type and N > G_MAXSIZE.  */
418  #define xtimes(N, ELSIZE) \
419 -  ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
420 +  ((N) <= G_MAXSIZE / (ELSIZE) ? (size_t) (N) * (ELSIZE) : G_MAXSIZE)
421  
422  /* Check for overflow.  */
423  #define size_overflow_p(SIZE) \
424 -  ((SIZE) == SIZE_MAX)
425 +  ((SIZE) == G_MAXSIZE)
426  /* Check against overflow.  */
427  #define size_in_bounds_p(SIZE) \
428 -  ((SIZE) != SIZE_MAX)
429 +  ((SIZE) != G_MAXSIZE)
430  
431  _GL_INLINE_HEADER_END
432  
433 --- a/glib/gnulib/gnulib_math.h.in
434 +++ b/glib/gnulib/gnulib_math.h.in
435 @@ -25,6 +25,13 @@
436  /* The include_next requires a split double-inclusion guard.  */
437  #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
438  
439 +/* The __const__ attribute was added in gcc 2.95.  */
440 +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
441 +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
442 +#else
443 +# define _GL_ATTRIBUTE_CONST /* empty */
444 +#endif
445 +
446  #ifndef _@GUARD_PREFIX@_MATH_H
447  #define _@GUARD_PREFIX@_MATH_H
448  
449 @@ -41,9 +48,9 @@ _GL_INLINE_HEADER_BEGIN
450  # define _GL_MATH_INLINE _GL_INLINE
451  #endif
452  
453 -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
454 +#include "c++defs.h"
455  
456 -/* The definition of _GL_ARG_NONNULL is copied here.  */
457 +#include "arg-nonnull.h"
458  
459  /* The definition of _GL_WARN_ON_USE is copied here.  */
460