• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2011 Red Hat, Inc
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16  *
17  * Author: Matthias Clasen
18  */
19 
20 
21 /* This file collects documentation for macros, typedefs and
22  * the like, which have no good home in any of the 'real' source
23  * files.
24  */
25 
26 /* Basic types {{{1 */
27 
28 /**
29  * SECTION:types
30  * @title: Basic Types
31  * @short_description: standard GLib types, defined for ease-of-use
32  *     and portability
33  *
34  * GLib defines a number of commonly used types, which can be divided
35  * into several groups:
36  * - New types which are not part of standard C (but are defined in
37  *   various C standard library header files) — #gboolean, #gssize.
38  * - Integer types which are guaranteed to be the same size across
39  *   all platforms — #gint8, #guint8, #gint16, #guint16, #gint32,
40  *   #guint32, #gint64, #guint64.
41  * - Types which are easier to use than their standard C counterparts -
42  *   #gpointer, #gconstpointer, #guchar, #guint, #gushort, #gulong.
43  * - Types which correspond exactly to standard C types, but are
44  *   included for completeness — #gchar, #gint, #gshort, #glong,
45  *   #gfloat, #gdouble.
46  * - Types which correspond exactly to standard C99 types, but are available
47  *   to use even if your compiler does not support C99 — #gsize, #goffset,
48  *   #gintptr, #guintptr.
49  *
50  * GLib also defines macros for the limits of some of the standard
51  * integer and floating point types, as well as macros for suitable
52  * printf() formats for these types.
53  *
54  * Note that depending on the platform and build configuration, the format
55  * macros might not be compatible with the system provided printf() function,
56  * because GLib might use a different printf() implementation internally.
57  * The format macros will always work with GLib API (like g_print()), and with
58  * any C99 compatible printf() implementation.
59  */
60 
61 /**
62  * gboolean:
63  *
64  * A standard boolean type.
65  * Variables of this type should only contain the value
66  * %TRUE or %FALSE.
67  *
68  * Never directly compare the contents of a #gboolean variable with the values
69  * %TRUE or %FALSE. Use `if (condition)` to check a #gboolean is "true", instead
70  * of `if (condition == TRUE)`. Likewise use `if (!condition)` to check a
71  * #gboolean is "false".
72  *
73  * There is no validation when assigning to a #gboolean variable and so it could
74  * contain any value represented by a #gint. This is why the use of `if
75  * (condition)` is recommended. All non-zero values in C evaluate to "true".
76  */
77 
78 /**
79  * gpointer:
80  *
81  * An untyped pointer.
82  * #gpointer looks better and is easier to use than void*.
83  */
84 
85 /**
86  * gconstpointer:
87  *
88  * An untyped pointer to constant data.
89  * The data pointed to should not be changed.
90  *
91  * This is typically used in function prototypes to indicate
92  * that the data pointed to will not be altered by the function.
93  */
94 
95 /**
96  * gchar:
97  *
98  * Corresponds to the standard C char type.
99  */
100 
101 /**
102  * guchar:
103  *
104  * Corresponds to the standard C unsigned char type.
105  */
106 
107 /**
108  * gint:
109  *
110  * Corresponds to the standard C int type.
111  * Values of this type can range from #G_MININT to #G_MAXINT.
112  */
113 
114 /**
115  * G_MININT:
116  *
117  * The minimum value which can be held in a #gint.
118  */
119 
120 /**
121  * G_MAXINT:
122  *
123  * The maximum value which can be held in a #gint.
124  */
125 
126 /**
127  * guint:
128  *
129  * Corresponds to the standard C unsigned int type.
130  * Values of this type can range from 0 to #G_MAXUINT.
131  */
132 
133 /**
134  * G_MAXUINT:
135  *
136  * The maximum value which can be held in a #guint.
137  */
138 
139 /**
140  * gshort:
141  *
142  * Corresponds to the standard C short type.
143  * Values of this type can range from #G_MINSHORT to #G_MAXSHORT.
144  */
145 
146 /**
147  * G_MINSHORT:
148  *
149  * The minimum value which can be held in a #gshort.
150  */
151 
152 /**
153  * G_MAXSHORT:
154  *
155  * The maximum value which can be held in a #gshort.
156  */
157 
158 /**
159  * gushort:
160  *
161  * Corresponds to the standard C unsigned short type.
162  * Values of this type can range from 0 to #G_MAXUSHORT.
163  */
164 
165 /**
166  * G_MAXUSHORT:
167  *
168  * The maximum value which can be held in a #gushort.
169  */
170 
171 /**
172  * glong:
173  *
174  * Corresponds to the standard C long type.
175  * Values of this type can range from #G_MINLONG to #G_MAXLONG.
176  */
177 
178 /**
179  * G_MINLONG:
180  *
181  * The minimum value which can be held in a #glong.
182  */
183 
184 /**
185  * G_MAXLONG:
186  *
187  * The maximum value which can be held in a #glong.
188  */
189 
190 /**
191  * gulong:
192  *
193  * Corresponds to the standard C unsigned long type.
194  * Values of this type can range from 0 to #G_MAXULONG.
195  */
196 
197 /**
198  * G_MAXULONG:
199  *
200  * The maximum value which can be held in a #gulong.
201  */
202 
203 /**
204  * gint8:
205  *
206  * A signed integer guaranteed to be 8 bits on all platforms.
207  * Values of this type can range from #G_MININT8 (= -128) to
208  * #G_MAXINT8 (= 127).
209  */
210 
211 /**
212  * G_MAXINT8:
213  *
214  * The maximum value which can be held in a #gint8.
215  *
216  * Since: 2.4
217  */
218 
219 /**
220  * guint8:
221  *
222  * An unsigned integer guaranteed to be 8 bits on all platforms.
223  * Values of this type can range from 0 to #G_MAXUINT8 (= 255).
224  */
225 
226 /**
227  * G_MAXUINT8:
228  *
229  * The maximum value which can be held in a #guint8.
230  *
231  * Since: 2.4
232  */
233 
234 /**
235  * gint16:
236  *
237  * A signed integer guaranteed to be 16 bits on all platforms.
238  * Values of this type can range from #G_MININT16 (= -32,768) to
239  * #G_MAXINT16 (= 32,767).
240  *
241  * To print or scan values of this type, use
242  * %G_GINT16_MODIFIER and/or %G_GINT16_FORMAT.
243  */
244 
245 /**
246  * G_MAXINT16:
247  *
248  * The maximum value which can be held in a #gint16.
249  *
250  * Since: 2.4
251  */
252 
253 /**
254  * G_GINT16_MODIFIER:
255  *
256  * The platform dependent length modifier for conversion specifiers
257  * for scanning and printing values of type #gint16 or #guint16. It
258  * is a string literal, but doesn't include the percent-sign, such
259  * that you can add precision and length modifiers between percent-sign
260  * and conversion specifier and append a conversion specifier.
261  *
262  * The following example prints "0x7b";
263  * |[<!-- language="C" -->
264  * gint16 value = 123;
265  * g_print ("%#" G_GINT16_MODIFIER "x", value);
266  * ]|
267  *
268  * Since: 2.4
269  */
270 
271 /**
272  * G_GINT16_FORMAT:
273  *
274  * This is the platform dependent conversion specifier for scanning and
275  * printing values of type #gint16. It is a string literal, but doesn't
276  * include the percent-sign, such that you can add precision and length
277  * modifiers between percent-sign and conversion specifier.
278  *
279  * |[<!-- language="C" -->
280  * gint16 in;
281  * gint32 out;
282  * sscanf ("42", "%" G_GINT16_FORMAT, &in)
283  * out = in * 1000;
284  * g_print ("%" G_GINT32_FORMAT, out);
285  * ]|
286  */
287 
288 /**
289  * guint16:
290  *
291  * An unsigned integer guaranteed to be 16 bits on all platforms.
292  * Values of this type can range from 0 to #G_MAXUINT16 (= 65,535).
293  *
294  * To print or scan values of this type, use
295  * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT.
296  */
297 
298 /**
299  * G_MAXUINT16:
300  *
301  * The maximum value which can be held in a #guint16.
302  *
303  * Since: 2.4
304  */
305 
306 /**
307  * G_GUINT16_FORMAT:
308  *
309  * This is the platform dependent conversion specifier for scanning
310  * and printing values of type #guint16. See also #G_GINT16_FORMAT
311  */
312 
313 /**
314  * gint32:
315  *
316  * A signed integer guaranteed to be 32 bits on all platforms.
317  * Values of this type can range from #G_MININT32 (= -2,147,483,648)
318  * to #G_MAXINT32 (= 2,147,483,647).
319  *
320  * To print or scan values of this type, use
321  * %G_GINT32_MODIFIER and/or %G_GINT32_FORMAT.
322  */
323 
324 /**
325  * G_MAXINT32:
326  *
327  * The maximum value which can be held in a #gint32.
328  *
329  * Since: 2.4
330  */
331 
332 /**
333  * G_GINT32_MODIFIER:
334  *
335  * The platform dependent length modifier for conversion specifiers
336  * for scanning and printing values of type #gint32 or #guint32. It
337  * is a string literal. See also #G_GINT16_MODIFIER.
338  *
339  * Since: 2.4
340  */
341 
342 /**
343  * G_GINT32_FORMAT:
344  *
345  * This is the platform dependent conversion specifier for scanning
346  * and printing values of type #gint32. See also #G_GINT16_FORMAT.
347  */
348 
349 /**
350  * guint32:
351  *
352  * An unsigned integer guaranteed to be 32 bits on all platforms.
353  * Values of this type can range from 0 to #G_MAXUINT32 (= 4,294,967,295).
354  *
355  * To print or scan values of this type, use
356  * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT.
357  */
358 
359 /**
360  * G_MAXUINT32:
361  *
362  * The maximum value which can be held in a #guint32.
363  *
364  * Since: 2.4
365  */
366 
367 /**
368  * G_GUINT32_FORMAT:
369  *
370  * This is the platform dependent conversion specifier for scanning
371  * and printing values of type #guint32. See also #G_GINT16_FORMAT.
372  */
373 
374 /**
375  * gint64:
376  *
377  * A signed integer guaranteed to be 64 bits on all platforms.
378  * Values of this type can range from #G_MININT64
379  * (= -9,223,372,036,854,775,808) to #G_MAXINT64
380  * (= 9,223,372,036,854,775,807).
381  *
382  * To print or scan values of this type, use
383  * %G_GINT64_MODIFIER and/or %G_GINT64_FORMAT.
384  */
385 
386 /**
387  * G_MAXINT64:
388  *
389  * The maximum value which can be held in a #gint64.
390  */
391 
392 /**
393  * G_GINT64_MODIFIER:
394  *
395  * The platform dependent length modifier for conversion specifiers
396  * for scanning and printing values of type #gint64 or #guint64.
397  * It is a string literal.
398  *
399  * Some platforms do not support printing 64-bit integers, even
400  * though the types are supported. On such platforms %G_GINT64_MODIFIER
401  * is not defined.
402  *
403  * Since: 2.4
404  */
405 
406 /**
407  * G_GINT64_FORMAT:
408  *
409  * This is the platform dependent conversion specifier for scanning
410  * and printing values of type #gint64. See also #G_GINT16_FORMAT.
411  *
412  * Some platforms do not support scanning and printing 64-bit integers,
413  * even though the types are supported. On such platforms %G_GINT64_FORMAT
414  * is not defined. Note that scanf() may not support 64-bit integers, even
415  * if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
416  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
417  * instead.
418  */
419 
420 /**
421  * guint64:
422  *
423  * An unsigned integer guaranteed to be 64-bits on all platforms.
424  * Values of this type can range from 0 to #G_MAXUINT64
425  * (= 18,446,744,073,709,551,615).
426  *
427  * To print or scan values of this type, use
428  * %G_GINT64_MODIFIER and/or %G_GUINT64_FORMAT.
429  */
430 
431 /**
432  * G_MAXUINT64:
433  *
434  * The maximum value which can be held in a #guint64.
435  */
436 
437 /**
438  * G_GUINT64_FORMAT:
439  *
440  * This is the platform dependent conversion specifier for scanning
441  * and printing values of type #guint64. See also #G_GINT16_FORMAT.
442  *
443  * Some platforms do not support scanning and printing 64-bit integers,
444  * even though the types are supported. On such platforms %G_GUINT64_FORMAT
445  * is not defined.  Note that scanf() may not support 64-bit integers, even
446  * if %G_GINT64_FORMAT is defined. Due to its weak error handling, scanf()
447  * is not recommended for parsing anyway; consider using g_ascii_strtoull()
448  * instead.
449  */
450 
451 /**
452  * G_GINT64_CONSTANT:
453  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
454  *
455  * This macro is used to insert 64-bit integer literals
456  * into the source code.
457  */
458 
459 /**
460  * G_GUINT64_CONSTANT:
461  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7U
462  *
463  * This macro is used to insert 64-bit unsigned integer
464  * literals into the source code.
465  *
466  * Since: 2.10
467  */
468 
469 /**
470  * gfloat:
471  *
472  * Corresponds to the standard C float type.
473  * Values of this type can range from -#G_MAXFLOAT to #G_MAXFLOAT.
474  */
475 
476 /**
477  * G_MINFLOAT:
478  *
479  * The minimum positive value which can be held in a #gfloat.
480  *
481  * If you are interested in the smallest value which can be held
482  * in a #gfloat, use -%G_MAXFLOAT.
483  */
484 
485 /**
486  * G_MAXFLOAT:
487  *
488  * The maximum value which can be held in a #gfloat.
489  */
490 
491 /**
492  * gdouble:
493  *
494  * Corresponds to the standard C double type.
495  * Values of this type can range from -#G_MAXDOUBLE to #G_MAXDOUBLE.
496  */
497 
498 /**
499  * G_MINDOUBLE:
500  *
501  * The minimum positive value which can be held in a #gdouble.
502  *
503  * If you are interested in the smallest value which can be held
504  * in a #gdouble, use -%G_MAXDOUBLE.
505  */
506 
507 /**
508  * G_MAXDOUBLE:
509  *
510  * The maximum value which can be held in a #gdouble.
511  */
512 
513 /**
514  * gsize:
515  *
516  * An unsigned integer type of the result of the sizeof operator,
517  * corresponding to the size_t type defined in C99.
518  * This type is wide enough to hold the numeric value of a pointer,
519  * so it is usually 32 bit wide on a 32-bit platform and 64 bit wide
520  * on a 64-bit platform. Values of this type can range from 0 to
521  * #G_MAXSIZE.
522  *
523  * To print or scan values of this type, use
524  * %G_GSIZE_MODIFIER and/or %G_GSIZE_FORMAT.
525  */
526 
527 /**
528  * G_MAXSIZE:
529  *
530  * The maximum value which can be held in a #gsize.
531  *
532  * Since: 2.4
533  */
534 
535 /**
536  * G_GSIZE_MODIFIER:
537  *
538  * The platform dependent length modifier for conversion specifiers
539  * for scanning and printing values of type #gsize. It
540  * is a string literal.
541  *
542  * Since: 2.6
543  */
544 
545 /**
546  * G_GSIZE_FORMAT:
547  *
548  * This is the platform dependent conversion specifier for scanning
549  * and printing values of type #gsize. See also #G_GINT16_FORMAT.
550  *
551  * Since: 2.6
552  */
553 
554 /**
555  * gssize:
556  *
557  * A signed variant of #gsize, corresponding to the
558  * ssize_t defined on most platforms.
559  * Values of this type can range from #G_MINSSIZE
560  * to #G_MAXSSIZE.
561  *
562  * To print or scan values of this type, use
563  * %G_GSSIZE_MODIFIER and/or %G_GSSIZE_FORMAT.
564  */
565 
566 /**
567  * G_MINSSIZE:
568  *
569  * The minimum value which can be held in a #gssize.
570  *
571  * Since: 2.14
572  */
573 
574 /**
575  * G_MAXSSIZE:
576  *
577  * The maximum value which can be held in a #gssize.
578  *
579  * Since: 2.14
580  */
581 
582 /**
583  * G_GSSIZE_FORMAT:
584  *
585  * This is the platform dependent conversion specifier for scanning
586  * and printing values of type #gssize. See also #G_GINT16_FORMAT.
587  *
588  * Since: 2.6
589  */
590 
591 /**
592  * G_GSSIZE_MODIFIER:
593  *
594  * The platform dependent length modifier for conversion specifiers
595  * for scanning and printing values of type #gssize. It
596  * is a string literal.
597  *
598  * Since: 2.6
599  */
600 
601 /**
602  * goffset:
603  *
604  * A signed integer type that is used for file offsets,
605  * corresponding to the POSIX type `off_t` as if compiling with
606  * `_FILE_OFFSET_BITS` set to 64. #goffset is always 64 bits wide, even on
607  * 32-bit architectures.
608  * Values of this type can range from #G_MINOFFSET to
609  * #G_MAXOFFSET.
610  *
611  * To print or scan values of this type, use
612  * %G_GOFFSET_MODIFIER and/or %G_GOFFSET_FORMAT.
613  *
614  * Since: 2.14
615  */
616 
617 /**
618  * G_MINOFFSET:
619  *
620  * The minimum value which can be held in a #goffset.
621  */
622 
623 /**
624  * G_MAXOFFSET:
625  *
626  * The maximum value which can be held in a #goffset.
627  */
628 
629 /**
630  * G_GOFFSET_MODIFIER:
631  *
632  * The platform dependent length modifier for conversion specifiers
633  * for scanning and printing values of type #goffset. It is a string
634  * literal. See also #G_GINT64_MODIFIER.
635  *
636  * Since: 2.20
637  */
638 
639 /**
640  * G_GOFFSET_FORMAT:
641  *
642  * This is the platform dependent conversion specifier for scanning
643  * and printing values of type #goffset. See also #G_GINT64_FORMAT.
644  *
645  * Since: 2.20
646  */
647 
648 /**
649  * G_GOFFSET_CONSTANT:
650  * @val: a literal integer value, e.g. 0x1d636b02300a7aa7
651  *
652  * This macro is used to insert #goffset 64-bit integer literals
653  * into the source code.
654  *
655  * See also #G_GINT64_CONSTANT.
656  *
657  * Since: 2.20
658  */
659 
660 /**
661  * gintptr:
662  *
663  * Corresponds to the C99 type intptr_t,
664  * a signed integer type that can hold any pointer.
665  *
666  * To print or scan values of this type, use
667  * %G_GINTPTR_MODIFIER and/or %G_GINTPTR_FORMAT.
668  *
669  * Since: 2.18
670  */
671 
672 /**
673  * G_GINTPTR_MODIFIER:
674  *
675  * The platform dependent length modifier for conversion specifiers
676  * for scanning and printing values of type #gintptr or #guintptr.
677  * It is a string literal.
678  *
679  * Since: 2.22
680  */
681 
682 /**
683  * G_GINTPTR_FORMAT:
684  *
685  * This is the platform dependent conversion specifier for scanning
686  * and printing values of type #gintptr.
687  *
688  * Since: 2.22
689  */
690 
691 /**
692  * guintptr:
693  *
694  * Corresponds to the C99 type uintptr_t,
695  * an unsigned integer type that can hold any pointer.
696  *
697  * To print or scan values of this type, use
698  * %G_GINTPTR_MODIFIER and/or %G_GUINTPTR_FORMAT.
699  *
700  * Since: 2.18
701  */
702 
703 /**
704  * G_GUINTPTR_FORMAT:
705  *
706  * This is the platform dependent conversion specifier
707  * for scanning and printing values of type #guintptr.
708  *
709  * Since: 2.22
710  */
711 
712 /* Type conversion {{{1 */
713 
714 /**
715  * SECTION:type_conversion
716  * @title: Type Conversion Macros
717  * @short_description: portably storing integers in pointer variables
718  *
719  * Many times GLib, GTK+, and other libraries allow you to pass "user
720  * data" to a callback, in the form of a void pointer. From time to time
721  * you want to pass an integer instead of a pointer. You could allocate
722  * an integer, with something like:
723  * |[<!-- language="C" -->
724  *   int *ip = g_new (int, 1);
725  *   *ip = 42;
726  * ]|
727  * But this is inconvenient, and it's annoying to have to free the
728  * memory at some later time.
729  *
730  * Pointers are always at least 32 bits in size (on all platforms GLib
731  * intends to support). Thus you can store at least 32-bit integer values
732  * in a pointer value. Naively, you might try this, but it's incorrect:
733  * |[<!-- language="C" -->
734  *   gpointer p;
735  *   int i;
736  *   p = (void*) 42;
737  *   i = (int) p;
738  * ]|
739  * Again, that example was not correct, don't copy it.
740  * The problem is that on some systems you need to do this:
741  * |[<!-- language="C" -->
742  *   gpointer p;
743  *   int i;
744  *   p = (void*) (long) 42;
745  *   i = (int) (long) p;
746  * ]|
747  * The GLib macros GPOINTER_TO_INT(), GINT_TO_POINTER(), etc. take care
748  * to do the right thing on every platform.
749  *
750  * Warning: You may not store pointers in integers. This is not
751  * portable in any way, shape or form. These macros only allow storing
752  * integers in pointers, and only preserve 32 bits of the integer; values
753  * outside the range of a 32-bit integer will be mangled.
754  */
755 
756 /**
757  * GINT_TO_POINTER:
758  * @i: integer to stuff into a pointer
759  *
760  * Stuffs an integer into a pointer type.
761  *
762  * Remember, you may not store pointers in integers. This is not portable
763  * in any way, shape or form. These macros only allow storing integers in
764  * pointers, and only preserve 32 bits of the integer; values outside the
765  * range of a 32-bit integer will be mangled.
766  */
767 
768 /**
769  * GPOINTER_TO_INT:
770  * @p: pointer containing an integer
771  *
772  * Extracts an integer from a pointer. The integer must have
773  * been stored in the pointer with GINT_TO_POINTER().
774  *
775  * Remember, you may not store pointers in integers. This is not portable
776  * in any way, shape or form. These macros only allow storing integers in
777  * pointers, and only preserve 32 bits of the integer; values outside the
778  * range of a 32-bit integer will be mangled.
779  */
780 
781 /**
782  * GUINT_TO_POINTER:
783  * @u: unsigned integer to stuff into the pointer
784  *
785  * Stuffs an unsigned integer into a pointer type.
786  */
787 
788 /**
789  * GPOINTER_TO_UINT:
790  * @p: pointer to extract an unsigned integer from
791  *
792  * Extracts an unsigned integer from a pointer. The integer must have
793  * been stored in the pointer with GUINT_TO_POINTER().
794  */
795 
796 /**
797  * GSIZE_TO_POINTER:
798  * @s: #gsize to stuff into the pointer
799  *
800  * Stuffs a #gsize into a pointer type.
801  */
802 
803 /**
804  * GPOINTER_TO_SIZE:
805  * @p: pointer to extract a #gsize from
806  *
807  * Extracts a #gsize from a pointer. The #gsize must have
808  * been stored in the pointer with GSIZE_TO_POINTER().
809  */
810 
811 /* Byte order {{{1 */
812 
813 /**
814  * SECTION:byte_order
815  * @title: Byte Order Macros
816  * @short_description: a portable way to convert between different byte orders
817  *
818  * These macros provide a portable way to determine the host byte order
819  * and to convert values between different byte orders.
820  *
821  * The byte order is the order in which bytes are stored to create larger
822  * data types such as the #gint and #glong values.
823  * The host byte order is the byte order used on the current machine.
824  *
825  * Some processors store the most significant bytes (i.e. the bytes that
826  * hold the largest part of the value) first. These are known as big-endian
827  * processors. Other processors (notably the x86 family) store the most
828  * significant byte last. These are known as little-endian processors.
829  *
830  * Finally, to complicate matters, some other processors store the bytes in
831  * a rather curious order known as PDP-endian. For a 4-byte word, the 3rd
832  * most significant byte is stored first, then the 4th, then the 1st and
833  * finally the 2nd.
834  *
835  * Obviously there is a problem when these different processors communicate
836  * with each other, for example over networks or by using binary file formats.
837  * This is where these macros come in. They are typically used to convert
838  * values into a byte order which has been agreed on for use when
839  * communicating between different processors. The Internet uses what is
840  * known as 'network byte order' as the standard byte order (which is in
841  * fact the big-endian byte order).
842  *
843  * Note that the byte order conversion macros may evaluate their arguments
844  * multiple times, thus you should not use them with arguments which have
845  * side-effects.
846  */
847 
848 /**
849  * G_BYTE_ORDER:
850  *
851  * The host byte order.
852  * This can be either #G_LITTLE_ENDIAN or #G_BIG_ENDIAN (support for
853  * #G_PDP_ENDIAN may be added in future.)
854  */
855 
856 /**
857  * G_LITTLE_ENDIAN:
858  *
859  * Specifies one of the possible types of byte order.
860  * See #G_BYTE_ORDER.
861  */
862 
863 /**
864  * G_BIG_ENDIAN:
865  *
866  * Specifies one of the possible types of byte order.
867  * See #G_BYTE_ORDER.
868  */
869 
870 /**
871  * G_PDP_ENDIAN:
872  *
873  * Specifies one of the possible types of byte order
874  * (currently unused). See #G_BYTE_ORDER.
875  */
876 
877 /**
878  * g_htonl:
879  * @val: a 32-bit integer value in host byte order
880  *
881  * Converts a 32-bit integer value from host to network byte order.
882  *
883  * Returns: @val converted to network byte order
884  */
885 
886 /**
887  * g_htons:
888  * @val: a 16-bit integer value in host byte order
889  *
890  * Converts a 16-bit integer value from host to network byte order.
891  *
892  * Returns: @val converted to network byte order
893  */
894 
895 /**
896  * g_ntohl:
897  * @val: a 32-bit integer value in network byte order
898  *
899  * Converts a 32-bit integer value from network to host byte order.
900  *
901  * Returns: @val converted to host byte order.
902  */
903 
904 /**
905  * g_ntohs:
906  * @val: a 16-bit integer value in network byte order
907  *
908  * Converts a 16-bit integer value from network to host byte order.
909  *
910  * Returns: @val converted to host byte order
911  */
912 
913 /**
914  * GINT_FROM_BE:
915  * @val: a #gint value in big-endian byte order
916  *
917  * Converts a #gint value from big-endian to host byte order.
918  *
919  * Returns: @val converted to host byte order
920  */
921 
922 /**
923  * GINT_FROM_LE:
924  * @val: a #gint value in little-endian byte order
925  *
926  * Converts a #gint value from little-endian to host byte order.
927  *
928  * Returns: @val converted to host byte order
929  */
930 
931 /**
932  * GINT_TO_BE:
933  * @val: a #gint value in host byte order
934  *
935  * Converts a #gint value from host byte order to big-endian.
936  *
937  * Returns: @val converted to big-endian byte order
938  */
939 
940 /**
941  * GINT_TO_LE:
942  * @val: a #gint value in host byte order
943  *
944  * Converts a #gint value from host byte order to little-endian.
945  *
946  * Returns: @val converted to little-endian byte order
947  */
948 
949 /**
950  * GUINT_FROM_BE:
951  * @val: a #guint value in big-endian byte order
952  *
953  * Converts a #guint value from big-endian to host byte order.
954  *
955  * Returns: @val converted to host byte order
956  */
957 
958 /**
959  * GUINT_FROM_LE:
960  * @val: a #guint value in little-endian byte order
961  *
962  * Converts a #guint value from little-endian to host byte order.
963  *
964  * Returns: @val converted to host byte order
965  */
966 
967 /**
968  * GUINT_TO_BE:
969  * @val: a #guint value in host byte order
970  *
971  * Converts a #guint value from host byte order to big-endian.
972  *
973  * Returns: @val converted to big-endian byte order
974  */
975 
976 /**
977  * GUINT_TO_LE:
978  * @val: a #guint value in host byte order
979  *
980  * Converts a #guint value from host byte order to little-endian.
981  *
982  * Returns: @val converted to little-endian byte order.
983  */
984 
985 /**
986  * GLONG_FROM_BE:
987  * @val: a #glong value in big-endian byte order
988  *
989  * Converts a #glong value from big-endian to the host byte order.
990  *
991  * Returns: @val converted to host byte order
992  */
993 
994 /**
995  * GLONG_FROM_LE:
996  * @val: a #glong value in little-endian byte order
997  *
998  * Converts a #glong value from little-endian to host byte order.
999  *
1000  * Returns: @val converted to host byte order
1001  */
1002 
1003 /**
1004  * GLONG_TO_BE:
1005  * @val: a #glong value in host byte order
1006  *
1007  * Converts a #glong value from host byte order to big-endian.
1008  *
1009  * Returns: @val converted to big-endian byte order
1010  */
1011 
1012 /**
1013  * GLONG_TO_LE:
1014  * @val: a #glong value in host byte order
1015  *
1016  * Converts a #glong value from host byte order to little-endian.
1017  *
1018  * Returns: @val converted to little-endian
1019  */
1020 
1021 /**
1022  * GULONG_FROM_BE:
1023  * @val: a #gulong value in big-endian byte order
1024  *
1025  * Converts a #gulong value from big-endian to host byte order.
1026  *
1027  * Returns: @val converted to host byte order
1028  */
1029 
1030 /**
1031  * GULONG_FROM_LE:
1032  * @val: a #gulong value in little-endian byte order
1033  *
1034  * Converts a #gulong value from little-endian to host byte order.
1035  *
1036  * Returns: @val converted to host byte order
1037  */
1038 
1039 /**
1040  * GULONG_TO_BE:
1041  * @val: a #gulong value in host byte order
1042  *
1043  * Converts a #gulong value from host byte order to big-endian.
1044  *
1045  * Returns: @val converted to big-endian
1046  */
1047 
1048 /**
1049  * GULONG_TO_LE:
1050  * @val: a #gulong value in host byte order
1051  *
1052  * Converts a #gulong value from host byte order to little-endian.
1053  *
1054  * Returns: @val converted to little-endian
1055  */
1056 
1057 /**
1058  * GSIZE_FROM_BE:
1059  * @val: a #gsize value in big-endian byte order
1060  *
1061  * Converts a #gsize value from big-endian to the host byte order.
1062  *
1063  * Returns: @val converted to host byte order
1064  */
1065 
1066 /**
1067  * GSIZE_FROM_LE:
1068  * @val: a #gsize value in little-endian byte order
1069  *
1070  * Converts a #gsize value from little-endian to host byte order.
1071  *
1072  * Returns: @val converted to host byte order
1073  */
1074 
1075 /**
1076  * GSIZE_TO_BE:
1077  * @val: a #gsize value in host byte order
1078  *
1079  * Converts a #gsize value from host byte order to big-endian.
1080  *
1081  * Returns: @val converted to big-endian byte order
1082  */
1083 
1084 /**
1085  * GSIZE_TO_LE:
1086  * @val: a #gsize value in host byte order
1087  *
1088  * Converts a #gsize value from host byte order to little-endian.
1089  *
1090  * Returns: @val converted to little-endian
1091  */
1092 
1093 /**
1094  * GSSIZE_FROM_BE:
1095  * @val: a #gssize value in big-endian byte order
1096  *
1097  * Converts a #gssize value from big-endian to host byte order.
1098  *
1099  * Returns: @val converted to host byte order
1100  */
1101 
1102 /**
1103  * GSSIZE_FROM_LE:
1104  * @val: a #gssize value in little-endian byte order
1105  *
1106  * Converts a #gssize value from little-endian to host byte order.
1107  *
1108  * Returns: @val converted to host byte order
1109  */
1110 
1111 /**
1112  * GSSIZE_TO_BE:
1113  * @val: a #gssize value in host byte order
1114  *
1115  * Converts a #gssize value from host byte order to big-endian.
1116  *
1117  * Returns: @val converted to big-endian
1118  */
1119 
1120 /**
1121  * GSSIZE_TO_LE:
1122  * @val: a #gssize value in host byte order
1123  *
1124  * Converts a #gssize value from host byte order to little-endian.
1125  *
1126  * Returns: @val converted to little-endian
1127  */
1128 
1129 /**
1130  * GINT16_FROM_BE:
1131  * @val: a #gint16 value in big-endian byte order
1132  *
1133  * Converts a #gint16 value from big-endian to host byte order.
1134  *
1135  * Returns: @val converted to host byte order
1136  */
1137 
1138 /**
1139  * GINT16_FROM_LE:
1140  * @val: a #gint16 value in little-endian byte order
1141  *
1142  * Converts a #gint16 value from little-endian to host byte order.
1143  *
1144  * Returns: @val converted to host byte order
1145  */
1146 
1147 /**
1148  * GINT16_TO_BE:
1149  * @val: a #gint16 value in host byte order
1150  *
1151  * Converts a #gint16 value from host byte order to big-endian.
1152  *
1153  * Returns: @val converted to big-endian
1154  */
1155 
1156 /**
1157  * GINT16_TO_LE:
1158  * @val: a #gint16 value in host byte order
1159  *
1160  * Converts a #gint16 value from host byte order to little-endian.
1161  *
1162  * Returns: @val converted to little-endian
1163  */
1164 
1165 /**
1166  * GUINT16_FROM_BE:
1167  * @val: a #guint16 value in big-endian byte order
1168  *
1169  * Converts a #guint16 value from big-endian to host byte order.
1170  *
1171  * Returns: @val converted to host byte order
1172  */
1173 
1174 /**
1175  * GUINT16_FROM_LE:
1176  * @val: a #guint16 value in little-endian byte order
1177  *
1178  * Converts a #guint16 value from little-endian to host byte order.
1179  *
1180  * Returns: @val converted to host byte order
1181  */
1182 
1183 /**
1184  * GUINT16_TO_BE:
1185  * @val: a #guint16 value in host byte order
1186  *
1187  * Converts a #guint16 value from host byte order to big-endian.
1188  *
1189  * Returns: @val converted to big-endian
1190  */
1191 
1192 /**
1193  * GUINT16_TO_LE:
1194  * @val: a #guint16 value in host byte order
1195  *
1196  * Converts a #guint16 value from host byte order to little-endian.
1197  *
1198  * Returns: @val converted to little-endian
1199  */
1200 
1201 /**
1202  * GINT32_FROM_BE:
1203  * @val: a #gint32 value in big-endian byte order
1204  *
1205  * Converts a #gint32 value from big-endian to host byte order.
1206  *
1207  * Returns: @val converted to host byte order
1208  */
1209 
1210 /**
1211  * GINT32_FROM_LE:
1212  * @val: a #gint32 value in little-endian byte order
1213  *
1214  * Converts a #gint32 value from little-endian to host byte order.
1215  *
1216  * Returns: @val converted to host byte order
1217  */
1218 
1219 /**
1220  * GINT32_TO_BE:
1221  * @val: a #gint32 value in host byte order
1222  *
1223  * Converts a #gint32 value from host byte order to big-endian.
1224  *
1225  * Returns: @val converted to big-endian
1226  */
1227 
1228 /**
1229  * GINT32_TO_LE:
1230  * @val: a #gint32 value in host byte order
1231  *
1232  * Converts a #gint32 value from host byte order to little-endian.
1233  *
1234  * Returns: @val converted to little-endian
1235  */
1236 
1237 /**
1238  * GUINT32_FROM_BE:
1239  * @val: a #guint32 value in big-endian byte order
1240  *
1241  * Converts a #guint32 value from big-endian to host byte order.
1242  *
1243  * Returns: @val converted to host byte order
1244  */
1245 
1246 /**
1247  * GUINT32_FROM_LE:
1248  * @val: a #guint32 value in little-endian byte order
1249  *
1250  * Converts a #guint32 value from little-endian to host byte order.
1251  *
1252  * Returns: @val converted to host byte order
1253  */
1254 
1255 /**
1256  * GUINT32_TO_BE:
1257  * @val: a #guint32 value in host byte order
1258  *
1259  * Converts a #guint32 value from host byte order to big-endian.
1260  *
1261  * Returns: @val converted to big-endian
1262  */
1263 
1264 /**
1265  * GUINT32_TO_LE:
1266  * @val: a #guint32 value in host byte order
1267  *
1268  * Converts a #guint32 value from host byte order to little-endian.
1269  *
1270  * Returns: @val converted to little-endian
1271  */
1272 
1273 /**
1274  * GINT64_FROM_BE:
1275  * @val: a #gint64 value in big-endian byte order
1276  *
1277  * Converts a #gint64 value from big-endian to host byte order.
1278  *
1279  * Returns: @val converted to host byte order
1280  */
1281 
1282 /**
1283  * GINT64_FROM_LE:
1284  * @val: a #gint64 value in little-endian byte order
1285  *
1286  * Converts a #gint64 value from little-endian to host byte order.
1287  *
1288  * Returns: @val converted to host byte order
1289  */
1290 
1291 /**
1292  * GINT64_TO_BE:
1293  * @val: a #gint64 value in host byte order
1294  *
1295  * Converts a #gint64 value from host byte order to big-endian.
1296  *
1297  * Returns: @val converted to big-endian
1298  */
1299 
1300 /**
1301  * GINT64_TO_LE:
1302  * @val: a #gint64 value in host byte order
1303  *
1304  * Converts a #gint64 value from host byte order to little-endian.
1305  *
1306  * Returns: @val converted to little-endian
1307  */
1308 
1309 /**
1310  * GUINT64_FROM_BE:
1311  * @val: a #guint64 value in big-endian byte order
1312  *
1313  * Converts a #guint64 value from big-endian to host byte order.
1314  *
1315  * Returns: @val converted to host byte order
1316  */
1317 
1318 /**
1319  * GUINT64_FROM_LE:
1320  * @val: a #guint64 value in little-endian byte order
1321  *
1322  * Converts a #guint64 value from little-endian to host byte order.
1323  *
1324  * Returns: @val converted to host byte order
1325  */
1326 
1327 /**
1328  * GUINT64_TO_BE:
1329  * @val: a #guint64 value in host byte order
1330  *
1331  * Converts a #guint64 value from host byte order to big-endian.
1332  *
1333  * Returns: @val converted to big-endian
1334  */
1335 
1336 /**
1337  * GUINT64_TO_LE:
1338  * @val: a #guint64 value in host byte order
1339  *
1340  * Converts a #guint64 value from host byte order to little-endian.
1341  *
1342  * Returns: @val converted to little-endian
1343  */
1344 
1345 /**
1346  * GUINT16_SWAP_BE_PDP:
1347  * @val: a #guint16 value in big-endian or pdp-endian byte order
1348  *
1349  * Converts a #guint16 value between big-endian and pdp-endian byte order.
1350  * The conversion is symmetric so it can be used both ways.
1351  *
1352  * Returns: @val converted to the opposite byte order
1353  */
1354 
1355 /**
1356  * GUINT16_SWAP_LE_BE:
1357  * @val: a #guint16 value in little-endian or big-endian byte order
1358  *
1359  * Converts a #guint16 value between little-endian and big-endian byte order.
1360  * The conversion is symmetric so it can be used both ways.
1361  *
1362  * Returns: @val converted to the opposite byte order
1363  */
1364 
1365 /**
1366  * GUINT16_SWAP_LE_PDP:
1367  * @val: a #guint16 value in little-endian or pdp-endian byte order
1368  *
1369  * Converts a #guint16 value between little-endian and pdp-endian byte order.
1370  * The conversion is symmetric so it can be used both ways.
1371  *
1372  * Returns: @val converted to the opposite byte order
1373  */
1374 
1375 /**
1376  * GUINT32_SWAP_BE_PDP:
1377  * @val: a #guint32 value in big-endian or pdp-endian byte order
1378  *
1379  * Converts a #guint32 value between big-endian and pdp-endian byte order.
1380  * The conversion is symmetric so it can be used both ways.
1381  *
1382  * Returns: @val converted to the opposite byte order
1383  */
1384 
1385 /**
1386  * GUINT32_SWAP_LE_BE:
1387  * @val: a #guint32 value in little-endian or big-endian byte order
1388  *
1389  * Converts a #guint32 value between little-endian and big-endian byte order.
1390  * The conversion is symmetric so it can be used both ways.
1391  *
1392  * Returns: @val converted to the opposite byte order
1393  */
1394 
1395 /**
1396  * GUINT32_SWAP_LE_PDP:
1397  * @val: a #guint32 value in little-endian or pdp-endian byte order
1398  *
1399  * Converts a #guint32 value between little-endian and pdp-endian byte order.
1400  * The conversion is symmetric so it can be used both ways.
1401  *
1402  * Returns: @val converted to the opposite byte order
1403  */
1404 
1405 /**
1406  * GUINT64_SWAP_LE_BE:
1407  * @val: a #guint64 value in little-endian or big-endian byte order
1408  *
1409  * Converts a #guint64 value between little-endian and big-endian byte order.
1410  * The conversion is symmetric so it can be used both ways.
1411  *
1412  * Returns: @val converted to the opposite byte order
1413  */
1414 
1415 /* Bounds-checked integer arithmetic {{{1 */
1416 /**
1417  * SECTION:checkedmath
1418  * @title: Bounds-checking integer arithmetic
1419  * @short_description: a set of helpers for performing checked integer arithmetic
1420  *
1421  * GLib offers a set of macros for doing additions and multiplications
1422  * of unsigned integers, with checks for overflows.
1423  *
1424  * The helpers all have three arguments.  A pointer to the destination
1425  * is always the first argument and the operands to the operation are
1426  * the other two.
1427  *
1428  * Following standard GLib convention, the helpers return %TRUE in case
1429  * of success (ie: no overflow).
1430  *
1431  * The helpers may be macros, normal functions or inlines.  They may be
1432  * implemented with inline assembly or compiler intrinsics where
1433  * available.
1434  *
1435  * Since: 2.48
1436  */
1437 
1438 /**
1439  * g_uint_checked_add
1440  * @dest: a pointer to the #guint destination
1441  * @a: the #guint left operand
1442  * @b: the #guint right operand
1443  *
1444  * Performs a checked addition of @a and @b, storing the result in
1445  * @dest.
1446  *
1447  * If the operation is successful, %TRUE is returned.  If the operation
1448  * overflows then the state of @dest is undefined and %FALSE is
1449  * returned.
1450  *
1451  * Returns: %TRUE if there was no overflow
1452  * Since: 2.48
1453  */
1454 
1455 /**
1456  * g_uint_checked_mul
1457  * @dest: a pointer to the #guint destination
1458  * @a: the #guint left operand
1459  * @b: the #guint right operand
1460  *
1461  * Performs a checked multiplication of @a and @b, storing the result in
1462  * @dest.
1463  *
1464  * If the operation is successful, %TRUE is returned.  If the operation
1465  * overflows then the state of @dest is undefined and %FALSE is
1466  * returned.
1467  *
1468  * Returns: %TRUE if there was no overflow
1469  * Since: 2.48
1470  */
1471 
1472 /**
1473  * g_uint64_checked_add
1474  * @dest: a pointer to the #guint64 destination
1475  * @a: the #guint64 left operand
1476  * @b: the #guint64 right operand
1477  *
1478  * Performs a checked addition of @a and @b, storing the result in
1479  * @dest.
1480  *
1481  * If the operation is successful, %TRUE is returned.  If the operation
1482  * overflows then the state of @dest is undefined and %FALSE is
1483  * returned.
1484  *
1485  * Returns: %TRUE if there was no overflow
1486  * Since: 2.48
1487  */
1488 
1489 /**
1490  * g_uint64_checked_mul
1491  * @dest: a pointer to the #guint64 destination
1492  * @a: the #guint64 left operand
1493  * @b: the #guint64 right operand
1494  *
1495  * Performs a checked multiplication of @a and @b, storing the result in
1496  * @dest.
1497  *
1498  * If the operation is successful, %TRUE is returned.  If the operation
1499  * overflows then the state of @dest is undefined and %FALSE is
1500  * returned.
1501  *
1502  * Returns: %TRUE if there was no overflow
1503  * Since: 2.48
1504  */
1505 
1506 /**
1507  * g_size_checked_add
1508  * @dest: a pointer to the #gsize destination
1509  * @a: the #gsize left operand
1510  * @b: the #gsize right operand
1511  *
1512  * Performs a checked addition of @a and @b, storing the result in
1513  * @dest.
1514  *
1515  * If the operation is successful, %TRUE is returned.  If the operation
1516  * overflows then the state of @dest is undefined and %FALSE is
1517  * returned.
1518  *
1519  * Returns: %TRUE if there was no overflow
1520  * Since: 2.48
1521  */
1522 
1523 /**
1524  * g_size_checked_mul
1525  * @dest: a pointer to the #gsize destination
1526  * @a: the #gsize left operand
1527  * @b: the #gsize right operand
1528  *
1529  * Performs a checked multiplication of @a and @b, storing the result in
1530  * @dest.
1531  *
1532  * If the operation is successful, %TRUE is returned.  If the operation
1533  * overflows then the state of @dest is undefined and %FALSE is
1534  * returned.
1535  *
1536  * Returns: %TRUE if there was no overflow
1537  * Since: 2.48
1538  */
1539 /* Numerical Definitions {{{1 */
1540 
1541 /**
1542  * SECTION:numerical
1543  * @title: Numerical Definitions
1544  * @short_description: mathematical constants, and floating point decomposition
1545  *
1546  * GLib offers mathematical constants such as #G_PI for the value of pi;
1547  * many platforms have these in the C library, but some don't, the GLib
1548  * versions always exist.
1549  *
1550  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the
1551  * sign, mantissa and exponent of IEEE floats and doubles. These unions are
1552  * defined as appropriate for a given platform. IEEE floats and doubles are
1553  * supported (used for storage) by at least Intel, PPC and Sparc. See
1554  * [IEEE 754-2008](http://en.wikipedia.org/wiki/IEEE_float)
1555  * for more information about IEEE number formats.
1556  */
1557 
1558 /**
1559  * G_IEEE754_FLOAT_BIAS:
1560  *
1561  * The bias by which exponents in single-precision floats are offset.
1562  */
1563 
1564 /**
1565  * G_IEEE754_DOUBLE_BIAS:
1566  *
1567  * The bias by which exponents in double-precision floats are offset.
1568  */
1569 
1570 /**
1571  * GFloatIEEE754:
1572  * @v_float: the double value
1573  *
1574  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1575  * mantissa and exponent of IEEE floats and doubles. These unions are defined
1576  * as appropriate for a given platform. IEEE floats and doubles are supported
1577  * (used for storage) by at least Intel, PPC and Sparc.
1578  */
1579 
1580 /**
1581  * GDoubleIEEE754:
1582  * @v_double: the double value
1583  *
1584  * The #GFloatIEEE754 and #GDoubleIEEE754 unions are used to access the sign,
1585  * mantissa and exponent of IEEE floats and doubles. These unions are defined
1586  * as appropriate for a given platform. IEEE floats and doubles are supported
1587  * (used for storage) by at least Intel, PPC and Sparc.
1588  */
1589 
1590 /**
1591  * G_E:
1592  *
1593  * The base of natural logarithms.
1594  */
1595 
1596 /**
1597  * G_LN2:
1598  *
1599  * The natural logarithm of 2.
1600  */
1601 
1602 /**
1603  * G_LN10:
1604  *
1605  * The natural logarithm of 10.
1606  */
1607 
1608 /**
1609  * G_PI:
1610  *
1611  * The value of pi (ratio of circle's circumference to its diameter).
1612  */
1613 
1614 /**
1615  * G_PI_2:
1616  *
1617  * Pi divided by 2.
1618  */
1619 
1620 /**
1621  * G_PI_4:
1622  *
1623  * Pi divided by 4.
1624  */
1625 
1626 /**
1627  * G_SQRT2:
1628  *
1629  * The square root of two.
1630  */
1631 
1632 /**
1633  * G_LOG_2_BASE_10:
1634  *
1635  * Multiplying the base 2 exponent by this number yields the base 10 exponent.
1636  */
1637 
1638 /* Macros {{{1 */
1639 
1640 /**
1641  * SECTION:macros
1642  * @title: Standard Macros
1643  * @short_description: commonly-used macros
1644  *
1645  * These macros provide a few commonly-used features.
1646  */
1647 
1648 /**
1649  * G_OS_WIN32:
1650  *
1651  * This macro is defined only on Windows. So you can bracket
1652  * Windows-specific code in "\#ifdef G_OS_WIN32".
1653  */
1654 
1655 /**
1656  * G_OS_UNIX:
1657  *
1658  * This macro is defined only on UNIX. So you can bracket
1659  * UNIX-specific code in "\#ifdef G_OS_UNIX".
1660  */
1661 
1662 /**
1663  * G_DIR_SEPARATOR:
1664  *
1665  * The directory separator character.
1666  * This is '/' on UNIX machines and '\' under Windows.
1667  */
1668 
1669 /**
1670  * G_DIR_SEPARATOR_S:
1671  *
1672  * The directory separator as a string.
1673  * This is "/" on UNIX machines and "\" under Windows.
1674  */
1675 
1676 /**
1677  * G_IS_DIR_SEPARATOR:
1678  * @c: a character
1679  *
1680  * Checks whether a character is a directory
1681  * separator. It returns %TRUE for '/' on UNIX
1682  * machines and for '\' or '/' under Windows.
1683  *
1684  * Since: 2.6
1685  */
1686 
1687 /**
1688  * G_SEARCHPATH_SEPARATOR:
1689  *
1690  * The search path separator character.
1691  * This is ':' on UNIX machines and ';' under Windows.
1692  */
1693 
1694 /**
1695  * G_SEARCHPATH_SEPARATOR_S:
1696  *
1697  * The search path separator as a string.
1698  * This is ":" on UNIX machines and ";" under Windows.
1699  */
1700 
1701 /**
1702  * TRUE:
1703  *
1704  * Defines the %TRUE value for the #gboolean type.
1705  */
1706 
1707 /**
1708  * FALSE:
1709  *
1710  * Defines the %FALSE value for the #gboolean type.
1711  */
1712 
1713 /**
1714  * NULL:
1715  *
1716  * Defines the standard %NULL pointer.
1717  */
1718 
1719 /**
1720  * MIN:
1721  * @a: a numeric value
1722  * @b: a numeric value
1723  *
1724  * Calculates the minimum of @a and @b.
1725  *
1726  * Returns: the minimum of @a and @b.
1727  */
1728 
1729 /**
1730  * MAX:
1731  * @a: a numeric value
1732  * @b: a numeric value
1733  *
1734  * Calculates the maximum of @a and @b.
1735  *
1736  * Returns: the maximum of @a and @b.
1737  */
1738 
1739 /**
1740  * ABS:
1741  * @a: a numeric value
1742  *
1743  * Calculates the absolute value of @a.
1744  * The absolute value is simply the number with any negative sign taken away.
1745  *
1746  * For example,
1747  * - ABS(-10) is 10.
1748  * - ABS(10) is also 10.
1749  *
1750  * Returns: the absolute value of @a.
1751  */
1752 
1753 /**
1754  * CLAMP:
1755  * @x: the value to clamp
1756  * @low: the minimum value allowed
1757  * @high: the maximum value allowed
1758  *
1759  * Ensures that @x is between the limits set by @low and @high. If @low is
1760  * greater than @high the result is undefined.
1761  *
1762  * For example,
1763  * - CLAMP(5, 10, 15) is 10.
1764  * - CLAMP(15, 5, 10) is 10.
1765  * - CLAMP(20, 15, 25) is 20.
1766  *
1767  * Returns: the value of @x clamped to the range between @low and @high
1768  */
1769 
1770 /**
1771  * G_APPROX_VALUE:
1772  * @a: a numeric value
1773  * @b: a numeric value
1774  * @epsilon: a numeric value that expresses the tolerance between @a and @b
1775  *
1776  * Evaluates to a truth value if the absolute difference between @a and @b is
1777  * smaller than @epsilon, and to a false value otherwise.
1778  *
1779  * For example,
1780  * - `G_APPROX_VALUE (5, 6, 2)` evaluates to true
1781  * - `G_APPROX_VALUE (3.14, 3.15, 0.001)` evaluates to false
1782  * - `G_APPROX_VALUE (n, 0.f, FLT_EPSILON)` evaluates to true if `n` is within
1783  *   the single precision floating point epsilon from zero
1784  *
1785  * Returns: %TRUE if the two values are within the desired range
1786  *
1787  * Since: 2.58
1788  */
1789 
1790 /**
1791  * G_STRUCT_MEMBER:
1792  * @member_type: the type of the struct field
1793  * @struct_p: a pointer to a struct
1794  * @struct_offset: the offset of the field from the start of the struct,
1795  *     in bytes
1796  *
1797  * Returns a member of a structure at a given offset, using the given type.
1798  *
1799  * Returns: the struct member
1800  */
1801 
1802 /**
1803  * G_STRUCT_MEMBER_P:
1804  * @struct_p: a pointer to a struct
1805  * @struct_offset: the offset from the start of the struct, in bytes
1806  *
1807  * Returns an untyped pointer to a given offset of a struct.
1808  *
1809  * Returns: an untyped pointer to @struct_p plus @struct_offset bytes
1810  */
1811 
1812 /**
1813  * G_STRUCT_OFFSET:
1814  * @struct_type: a structure type, e.g. #GtkWidget
1815  * @member: a field in the structure, e.g. @window
1816  *
1817  * Returns the offset, in bytes, of a member of a struct.
1818  *
1819  * Returns: the offset of @member from the start of @struct_type
1820  */
1821 
1822 /**
1823  * G_N_ELEMENTS:
1824  * @arr: the array
1825  *
1826  * Determines the number of elements in an array. The array must be
1827  * declared so the compiler knows its size at compile-time; this
1828  * macro will not work on an array allocated on the heap, only static
1829  * arrays or arrays on the stack.
1830  */
1831 
1832 /* Miscellaneous Macros {{{1 */
1833 
1834 /**
1835  * SECTION:macros_misc
1836  * @title: Miscellaneous Macros
1837  * @short_description: specialized macros which are not used often
1838  *
1839  * These macros provide more specialized features which are not
1840  * needed so often by application programmers.
1841  */
1842 
1843 /**
1844  * G_STMT_START:
1845  *
1846  * Used within multi-statement macros so that they can be used in places
1847  * where only one statement is expected by the compiler.
1848  */
1849 
1850 /**
1851  * G_STMT_END:
1852  *
1853  * Used within multi-statement macros so that they can be used in places
1854  * where only one statement is expected by the compiler.
1855  */
1856 
1857 /**
1858  * G_BEGIN_DECLS:
1859  *
1860  * Used (along with #G_END_DECLS) to bracket header files. If the
1861  * compiler in use is a C++ compiler, adds extern "C"
1862  * around the header.
1863  */
1864 
1865 /**
1866  * G_END_DECLS:
1867  *
1868  * Used (along with #G_BEGIN_DECLS) to bracket header files. If the
1869  * compiler in use is a C++ compiler, adds extern "C"
1870  * around the header.
1871  */
1872 
1873 /**
1874  * G_VA_COPY:
1875  * @ap1: the va_list variable to place a copy of @ap2 in
1876  * @ap2: a va_list
1877  *
1878  * Portable way to copy va_list variables.
1879  *
1880  * In order to use this function, you must include string.h yourself,
1881  * because this macro may use memmove() and GLib does not include
1882  * string.h for you.
1883  */
1884 
1885 /**
1886  * G_STRINGIFY:
1887  * @macro_or_string: a macro or a string
1888  *
1889  * Accepts a macro or a string and converts it into a string after
1890  * preprocessor argument expansion. For example, the following code:
1891  *
1892  * |[<!-- language="C" -->
1893  * #define AGE 27
1894  * const gchar *greeting = G_STRINGIFY (AGE) " today!";
1895  * ]|
1896  *
1897  * is transformed by the preprocessor into (code equivalent to):
1898  *
1899  * |[<!-- language="C" -->
1900  * const gchar *greeting = "27 today!";
1901  * ]|
1902  */
1903 
1904 /**
1905  * G_PASTE:
1906  * @identifier1: an identifier
1907  * @identifier2: an identifier
1908  *
1909  * Yields a new preprocessor pasted identifier
1910  * @identifier1identifier2 from its expanded
1911  * arguments @identifier1 and @identifier2. For example,
1912  * the following code:
1913  * |[<!-- language="C" -->
1914  * #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
1915  * const gchar *name = GET (traveller, name);
1916  * const gchar *quest = GET (traveller, quest);
1917  * GdkColor *favourite = GET (traveller, favourite_colour);
1918  * ]|
1919  *
1920  * is transformed by the preprocessor into:
1921  * |[<!-- language="C" -->
1922  * const gchar *name = traveller_get_name (traveller);
1923  * const gchar *quest = traveller_get_quest (traveller);
1924  * GdkColor *favourite = traveller_get_favourite_colour (traveller);
1925  * ]|
1926  *
1927  * Since: 2.20
1928  */
1929 
1930 /**
1931  * G_STATIC_ASSERT:
1932  * @expr: a constant expression
1933  *
1934  * The G_STATIC_ASSERT() macro lets the programmer check
1935  * a condition at compile time, the condition needs to
1936  * be compile time computable. The macro can be used in
1937  * any place where a typedef is valid.
1938  *
1939  * A typedef is generally allowed in exactly the same places that
1940  * a variable declaration is allowed. For this reason, you should
1941  * not use G_STATIC_ASSERT() in the middle of blocks of code.
1942  *
1943  * The macro should only be used once per source code line.
1944  *
1945  * Since: 2.20
1946  */
1947 
1948 /**
1949  * G_STATIC_ASSERT_EXPR:
1950  * @expr: a constant expression
1951  *
1952  * The G_STATIC_ASSERT_EXPR() macro lets the programmer check
1953  * a condition at compile time. The condition needs to be
1954  * compile time computable.
1955  *
1956  * Unlike G_STATIC_ASSERT(), this macro evaluates to an expression
1957  * and, as such, can be used in the middle of other expressions.
1958  * Its value should be ignored. This can be accomplished by placing
1959  * it as the first argument of a comma expression.
1960  *
1961  * |[<!-- language="C" -->
1962  * #define ADD_ONE_TO_INT(x) \
1963  *   (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
1964  * ]|
1965  *
1966  * Since: 2.30
1967  */
1968 
1969 /**
1970  * G_GNUC_EXTENSION:
1971  *
1972  * Expands to __extension__ when gcc is used as the compiler. This simply
1973  * tells gcc not to warn about the following non-standard code when compiling
1974  * with the `-pedantic` option.
1975  */
1976 
1977 /**
1978  * G_GNUC_CHECK_VERSION:
1979  * @major: major version to check against
1980  * @minor: minor version to check against
1981  *
1982  * Expands to a check for a compiler with __GNUC__ defined and a version
1983  * greater than or equal to the major and minor numbers provided. For example,
1984  * the following would only match on compilers such as GCC 4.8 or newer.
1985  *
1986  * |[<!-- language="C" -->
1987  * #if G_GNUC_CHECK_VERSION(4, 8)
1988  * #endif
1989  * ]|
1990  *
1991  * Since: 2.42
1992  */
1993 
1994 /**
1995  * G_GNUC_BEGIN_IGNORE_DEPRECATIONS:
1996  *
1997  * Tells gcc (if it is a new enough version) to temporarily stop emitting
1998  * warnings when functions marked with %G_GNUC_DEPRECATED or
1999  * %G_GNUC_DEPRECATED_FOR are called. This is useful for when you have
2000  * one deprecated function calling another one, or when you still have
2001  * regression tests for deprecated functions.
2002  *
2003  * Use %G_GNUC_END_IGNORE_DEPRECATIONS to begin warning again. (If you
2004  * are not compiling with `-Wdeprecated-declarations` then neither macro
2005  * has any effect.)
2006  *
2007  * This macro can be used either inside or outside of a function body,
2008  * but must appear on a line by itself. Both this macro and the corresponding
2009  * %G_GNUC_END_IGNORE_DEPRECATIONS are considered statements, so they
2010  * should not be used around branching or loop conditions; for instance,
2011  * this use is invalid:
2012  *
2013  * |[<!-- language="C" -->
2014  *   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
2015  *   if (check == some_deprecated_function ())
2016  *   G_GNUC_END_IGNORE_DEPRECATIONS
2017  *     {
2018  *       do_something ();
2019  *     }
2020  * ]|
2021  *
2022  * and you should move the deprecated section outside the condition
2023  *
2024  * |[<!-- language="C" -->
2025  *
2026  *   // Solution A
2027  *   some_data_t *res;
2028  *
2029  *   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
2030  *   res = some_deprecated_function ();
2031  *   G_GNUC_END_IGNORE_DEPRECATIONS
2032  *
2033  *   if (check == res)
2034  *     {
2035  *       do_something ();
2036  *     }
2037  *
2038  *   // Solution B
2039  *   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
2040  *   if (check == some_deprecated_function ())
2041  *     {
2042  *       do_something ();
2043  *     }
2044  *   G_GNUC_END_IGNORE_DEPRECATIONS
2045  * ]|
2046  *
2047  * |[<!-- language="C" --
2048  * static void
2049  * test_deprecated_function (void)
2050  * {
2051  *   G_GNUC_BEGIN_IGNORE_DEPRECATIONS
2052  *   g_assert_cmpint (my_mistake (), ==, 42);
2053  *   G_GNUC_END_IGNORE_DEPRECATIONS
2054  * }
2055  * ]|
2056  *
2057  * Since: 2.32
2058  */
2059 
2060 /**
2061  * G_GNUC_END_IGNORE_DEPRECATIONS:
2062  *
2063  * Undoes the effect of %G_GNUC_BEGIN_IGNORE_DEPRECATIONS, telling
2064  * gcc to begin outputting warnings again (assuming those warnings
2065  * had been enabled to begin with).
2066  *
2067  * This macro can be used either inside or outside of a function body,
2068  * but must appear on a line by itself.
2069  *
2070  * Since: 2.32
2071  */
2072 
2073 /**
2074  * G_DEPRECATED:
2075  *
2076  * This macro is similar to %G_GNUC_DEPRECATED, and can be used to mark
2077  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED, it is
2078  * meant to be portable across different compilers and must be placed
2079  * before the function declaration.
2080  *
2081  * |[<!-- language="C" --
2082  * G_DEPRECATED
2083  * int my_mistake (void);
2084  * ]|
2085  *
2086  * Since: 2.32
2087  */
2088 
2089 /**
2090  * G_DEPRECATED_FOR:
2091  * @f: the name of the function that this function was deprecated for
2092  *
2093  * This macro is similar to %G_GNUC_DEPRECATED_FOR, and can be used to mark
2094  * functions declarations as deprecated. Unlike %G_GNUC_DEPRECATED_FOR, it
2095  * is meant to be portable across different compilers and must be placed
2096  * before the function declaration.
2097  *
2098  * |[<!-- language="C" --
2099  * G_DEPRECATED_FOR(my_replacement)
2100  * int my_mistake (void);
2101  * ]|
2102  *
2103  * Since: 2.32
2104  */
2105 
2106 /**
2107  * G_UNAVAILABLE:
2108  * @maj: the major version that introduced the symbol
2109  * @min: the minor version that introduced the symbol
2110  *
2111  * This macro can be used to mark a function declaration as unavailable.
2112  * It must be placed before the function declaration. Use of a function
2113  * that has been annotated with this macros will produce a compiler warning.
2114  *
2115  * Since: 2.32
2116  */
2117 
2118 /**
2119  * GLIB_DISABLE_DEPRECATION_WARNINGS:
2120  *
2121  * A macro that should be defined before including the glib.h header.
2122  * If it is defined, no compiler warnings will be produced for uses
2123  * of deprecated GLib APIs.
2124  */
2125 
2126 /**
2127  * G_GNUC_INTERNAL:
2128  *
2129  * This attribute can be used for marking library functions as being used
2130  * internally to the library only, which may allow the compiler to handle
2131  * function calls more efficiently. Note that static functions do not need
2132  * to be marked as internal in this way. See the GNU C documentation for
2133  * details.
2134  *
2135  * When using a compiler that supports the GNU C hidden visibility attribute,
2136  * this macro expands to __attribute__((visibility("hidden"))).
2137  * When using the Sun Studio compiler, it expands to __hidden.
2138  *
2139  * Note that for portability, the attribute should be placed before the
2140  * function declaration. While GCC allows the macro after the declaration,
2141  * Sun Studio does not.
2142  *
2143  * |[<!-- language="C" -->
2144  * G_GNUC_INTERNAL
2145  * void _g_log_fallback_handler (const gchar    *log_domain,
2146  *                               GLogLevelFlags  log_level,
2147  *                               const gchar    *message,
2148  *                               gpointer        unused_data);
2149  * ]|
2150  *
2151  * Since: 2.6
2152  */
2153 
2154 /**
2155  * G_LIKELY:
2156  * @expr: the expression
2157  *
2158  * Hints the compiler that the expression is likely to evaluate to
2159  * a true value. The compiler may use this information for optimizations.
2160  *
2161  * |[<!-- language="C" -->
2162  * if (G_LIKELY (random () != 1))
2163  *   g_print ("not one");
2164  * ]|
2165  *
2166  * Returns: the value of @expr
2167  *
2168  * Since: 2.2
2169  */
2170 
2171 /**
2172  * G_UNLIKELY:
2173  * @expr: the expression
2174  *
2175  * Hints the compiler that the expression is unlikely to evaluate to
2176  * a true value. The compiler may use this information for optimizations.
2177  *
2178  * |[<!-- language="C" -->
2179  * if (G_UNLIKELY (random () == 1))
2180  *   g_print ("a random one");
2181  * ]|
2182  *
2183  * Returns: the value of @expr
2184  *
2185  * Since: 2.2
2186  */
2187 
2188 /**
2189  * G_STRLOC:
2190  *
2191  * Expands to a string identifying the current code position.
2192  */
2193 
2194 /**
2195  * G_STRFUNC:
2196  *
2197  * Expands to a string identifying the current function.
2198  *
2199  * Since: 2.4
2200  */
2201 
2202 /**
2203  * G_HAVE_GNUC_VISIBILITY:
2204  *
2205  * Defined to 1 if gcc-style visibility handling is supported.
2206  */
2207 
2208 /* g_auto(), g_autoptr() and helpers {{{1 */
2209 
2210 /**
2211  * g_auto:
2212  * @TypeName: a supported variable type
2213  *
2214  * Helper to declare a variable with automatic cleanup.
2215  *
2216  * The variable is cleaned up in a way appropriate to its type when the
2217  * variable goes out of scope.  The type must support this.
2218  * The way to clean up the type must have been defined using one of the macros
2219  * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC() or G_DEFINE_AUTO_CLEANUP_FREE_FUNC().
2220  *
2221  * This feature is only supported on GCC and clang.  This macro is not
2222  * defined on other compilers and should not be used in programs that
2223  * are intended to be portable to those compilers.
2224  *
2225  * This is meant to be used with stack-allocated structures and
2226  * non-pointer types.  For the (more commonly used) pointer version, see
2227  * g_autoptr().
2228  *
2229  * This macro can be used to avoid having to do explicit cleanups of
2230  * local variables when exiting functions.  It often vastly simplifies
2231  * handling of error conditions, removing the need for various tricks
2232  * such as `goto out` or repeating of cleanup code.  It is also helpful
2233  * for non-error cases.
2234  *
2235  * Consider the following example:
2236  *
2237  * |[
2238  * GVariant *
2239  * my_func(void)
2240  * {
2241  *   g_auto(GQueue) queue = G_QUEUE_INIT;
2242  *   g_auto(GVariantBuilder) builder;
2243  *   g_auto(GStrv) strv;
2244  *
2245  *   g_variant_builder_init (&builder, G_VARIANT_TYPE_VARDICT);
2246  *   strv = g_strsplit("a:b:c", ":", -1);
2247  *
2248  *   ...
2249  *
2250  *   if (error_condition)
2251  *     return NULL;
2252  *
2253  *   ...
2254  *
2255  *   return g_variant_builder_end (&builder);
2256  * }
2257  * ]|
2258  *
2259  * You must initialize the variable in some way — either by use of an
2260  * initialiser or by ensuring that an `_init` function will be called on
2261  * it unconditionally before it goes out of scope.
2262  *
2263  * Since: 2.44
2264  */
2265 
2266 /**
2267  * g_autoptr:
2268  * @TypeName: a supported variable type
2269  *
2270  * Helper to declare a pointer variable with automatic cleanup.
2271  *
2272  * The variable is cleaned up in a way appropriate to its type when the
2273  * variable goes out of scope.  The type must support this.
2274  * The way to clean up the type must have been defined using the macro
2275  * G_DEFINE_AUTOPTR_CLEANUP_FUNC().
2276  *
2277  * This feature is only supported on GCC and clang.  This macro is not
2278  * defined on other compilers and should not be used in programs that
2279  * are intended to be portable to those compilers.
2280  *
2281  * This is meant to be used to declare pointers to types with cleanup
2282  * functions.  The type of the variable is a pointer to @TypeName.  You
2283  * must not add your own `*`.
2284  *
2285  * This macro can be used to avoid having to do explicit cleanups of
2286  * local variables when exiting functions.  It often vastly simplifies
2287  * handling of error conditions, removing the need for various tricks
2288  * such as `goto out` or repeating of cleanup code.  It is also helpful
2289  * for non-error cases.
2290  *
2291  * Consider the following example:
2292  *
2293  * |[
2294  * gboolean
2295  * check_exists(GVariant *dict)
2296  * {
2297  *   g_autoptr(GVariant) dirname, basename = NULL;
2298  *   g_autofree gchar *path = NULL;
2299  *
2300  *   dirname = g_variant_lookup_value (dict, "dirname", G_VARIANT_TYPE_STRING);
2301  *
2302  *   if (dirname == NULL)
2303  *     return FALSE;
2304  *
2305  *   basename = g_variant_lookup_value (dict, "basename", G_VARIANT_TYPE_STRING);
2306  *
2307  *   if (basename == NULL)
2308  *     return FALSE;
2309  *
2310  *   path = g_build_filename (g_variant_get_string (dirname, NULL),
2311  *                            g_variant_get_string (basename, NULL),
2312  *                            NULL);
2313  *
2314  *   return g_access (path, R_OK) == 0;
2315  * }
2316  * ]|
2317  *
2318  * You must initialise the variable in some way — either by use of an
2319  * initialiser or by ensuring that it is assigned to unconditionally
2320  * before it goes out of scope.
2321  *
2322  * See also g_auto(), g_autofree() and g_steal_pointer().
2323  *
2324  * Since: 2.44
2325  */
2326 
2327 /**
2328  * g_autofree:
2329  *
2330  * Macro to add an attribute to pointer variable to ensure automatic
2331  * cleanup using g_free().
2332  *
2333  * This macro differs from g_autoptr() in that it is an attribute supplied
2334  * before the type name, rather than wrapping the type definition.  Instead
2335  * of using a type-specific lookup, this macro always calls g_free() directly.
2336  *
2337  * This means it's useful for any type that is returned from
2338  * g_malloc().
2339  *
2340  * Otherwise, this macro has similar constraints as g_autoptr(): only
2341  * supported on GCC and clang, the variable must be initialized, etc.
2342  *
2343  * |[
2344  * gboolean
2345  * operate_on_malloc_buf (void)
2346  * {
2347  *   g_autofree guint8* membuf = NULL;
2348  *
2349  *   membuf = g_malloc (8192);
2350  *
2351  *   // Some computation on membuf
2352  *
2353  *   // membuf will be automatically freed here
2354  *   return TRUE;
2355  * }
2356  * ]|
2357  *
2358  * Since: 2.44
2359  */
2360 
2361 /**
2362  * g_autolist:
2363  * @TypeName: a supported variable type
2364  *
2365  * Helper to declare a list variable with automatic deep cleanup.
2366  *
2367  * The list is deeply freed, in a way appropriate to the specified type, when the
2368  * variable goes out of scope.  The type must support this.
2369  *
2370  * This feature is only supported on GCC and clang.  This macro is not
2371  * defined on other compilers and should not be used in programs that
2372  * are intended to be portable to those compilers.
2373  *
2374  * This is meant to be used to declare lists of a type with a cleanup
2375  * function.  The type of the variable is a `GList *`.  You
2376  * must not add your own `*`.
2377  *
2378  * This macro can be used to avoid having to do explicit cleanups of
2379  * local variables when exiting functions.  It often vastly simplifies
2380  * handling of error conditions, removing the need for various tricks
2381  * such as `goto out` or repeating of cleanup code.  It is also helpful
2382  * for non-error cases.
2383  *
2384  * See also g_autoslist(), g_autoptr() and g_steal_pointer().
2385  *
2386  * Since: 2.56
2387  */
2388 
2389 /**
2390  * g_autoslist:
2391  * @TypeName: a supported variable type
2392  *
2393  * Helper to declare a singly linked list variable with automatic deep cleanup.
2394  *
2395  * The list is deeply freed, in a way appropriate to the specified type, when the
2396  * variable goes out of scope.  The type must support this.
2397  *
2398  * This feature is only supported on GCC and clang.  This macro is not
2399  * defined on other compilers and should not be used in programs that
2400  * are intended to be portable to those compilers.
2401  *
2402  * This is meant to be used to declare lists of a type with a cleanup
2403  * function.  The type of the variable is a `GSList *`.  You
2404  * must not add your own `*`.
2405  *
2406  * This macro can be used to avoid having to do explicit cleanups of
2407  * local variables when exiting functions.  It often vastly simplifies
2408  * handling of error conditions, removing the need for various tricks
2409  * such as `goto out` or repeating of cleanup code.  It is also helpful
2410  * for non-error cases.
2411  *
2412  * See also g_autolist(), g_autoptr() and g_steal_pointer().
2413  *
2414  * Since: 2.56
2415  */
2416 
2417 /**
2418  * g_autoqueue:
2419  * @TypeName: a supported variable type
2420  *
2421  * Helper to declare a double-ended queue variable with automatic deep cleanup.
2422  *
2423  * The queue is deeply freed, in a way appropriate to the specified type, when the
2424  * variable goes out of scope.  The type must support this.
2425  *
2426  * This feature is only supported on GCC and clang.  This macro is not
2427  * defined on other compilers and should not be used in programs that
2428  * are intended to be portable to those compilers.
2429  *
2430  * This is meant to be used to declare queues of a type with a cleanup
2431  * function.  The type of the variable is a `GQueue *`.  You
2432  * must not add your own `*`.
2433  *
2434  * This macro can be used to avoid having to do explicit cleanups of
2435  * local variables when exiting functions.  It often vastly simplifies
2436  * handling of error conditions, removing the need for various tricks
2437  * such as `goto out` or repeating of cleanup code.  It is also helpful
2438  * for non-error cases.
2439  *
2440  * See also g_autolist(), g_autoptr() and g_steal_pointer().
2441  *
2442  * Since: 2.62
2443  */
2444 
2445 
2446 /**
2447  * G_DEFINE_AUTOPTR_CLEANUP_FUNC:
2448  * @TypeName: a type name to define a g_autoptr() cleanup function for
2449  * @func: the cleanup function
2450  *
2451  * Defines the appropriate cleanup function for a pointer type.
2452  *
2453  * The function will not be called if the variable to be cleaned up
2454  * contains %NULL.
2455  *
2456  * This will typically be the `_free()` or `_unref()` function for the given
2457  * type.
2458  *
2459  * With this definition, it will be possible to use g_autoptr() with
2460  * @TypeName.
2461  *
2462  * |[
2463  * G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref)
2464  * ]|
2465  *
2466  * This macro should be used unconditionally; it is a no-op on compilers
2467  * where cleanup is not supported.
2468  *
2469  * Since: 2.44
2470  */
2471 
2472 /**
2473  * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC:
2474  * @TypeName: a type name to define a g_auto() cleanup function for
2475  * @func: the clear function
2476  *
2477  * Defines the appropriate cleanup function for a type.
2478  *
2479  * This will typically be the `_clear()` function for the given type.
2480  *
2481  * With this definition, it will be possible to use g_auto() with
2482  * @TypeName.
2483  *
2484  * |[
2485  * G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear)
2486  * ]|
2487  *
2488  * This macro should be used unconditionally; it is a no-op on compilers
2489  * where cleanup is not supported.
2490  *
2491  * Since: 2.44
2492  */
2493 
2494 /**
2495  * G_DEFINE_AUTO_CLEANUP_FREE_FUNC:
2496  * @TypeName: a type name to define a g_auto() cleanup function for
2497  * @func: the free function
2498  * @none: the "none" value for the type
2499  *
2500  * Defines the appropriate cleanup function for a type.
2501  *
2502  * With this definition, it will be possible to use g_auto() with
2503  * @TypeName.
2504  *
2505  * This function will be rarely used.  It is used with pointer-based
2506  * typedefs and non-pointer types where the value of the variable
2507  * represents a resource that must be freed.  Two examples are #GStrv
2508  * and file descriptors.
2509  *
2510  * @none specifies the "none" value for the type in question.  It is
2511  * probably something like %NULL or `-1`.  If the variable is found to
2512  * contain this value then the free function will not be called.
2513  *
2514  * |[
2515  * G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
2516  * ]|
2517  *
2518  * This macro should be used unconditionally; it is a no-op on compilers
2519  * where cleanup is not supported.
2520  *
2521  * Since: 2.44
2522  */
2523 
2524 /* Warnings and Assertions {{{1 */
2525 
2526 /**
2527  * SECTION:warnings
2528  * @title: Warnings and Assertions
2529  * @short_description: warnings and assertions to use in runtime code
2530  *
2531  * GLib defines several warning functions and assertions which can be used to
2532  * warn of programmer errors when calling functions, and print error messages
2533  * from command line programs.
2534  *
2535  * The g_return_if_fail(), g_return_val_if_fail(), g_return_if_reached() and
2536  * g_return_val_if_reached() macros are intended as pre-condition assertions, to
2537  * be used at the top of a public function to check that the function’s
2538  * arguments are acceptable. Any failure of such a pre-condition assertion is
2539  * considered a programming error on the part of the caller of the public API,
2540  * and the program is considered to be in an undefined state afterwards. They
2541  * are similar to the libc assert() function, but provide more context on
2542  * failures.
2543  *
2544  * For example:
2545  * |[<!-- language="C" -->
2546  * gboolean
2547  * g_dtls_connection_shutdown (GDtlsConnection  *conn,
2548  *                             gboolean          shutdown_read,
2549  *                             gboolean          shutdown_write,
2550  *                             GCancellable     *cancellable,
2551  *                             GError          **error)
2552  * {
2553  *   // local variable declarations
2554  *
2555  *   g_return_val_if_fail (G_IS_DTLS_CONNECTION (conn), FALSE);
2556  *   g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
2557  *   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
2558  *
2559  *   // function body
2560  *
2561  *   return return_val;
2562  * }
2563  * ]|
2564  *
2565  * g_print(), g_printerr() and g_set_print_handler() are intended to be used for
2566  * output from command line applications, since they output to standard output
2567  * and standard error by default — whereas functions like g_message() and
2568  * g_log() may be redirected to special purpose message windows, files, or the
2569  * system journal.
2570  */
2571 
2572 /* Windows Compatibility Functions {{{1 */
2573 
2574 /**
2575  * SECTION:windows
2576  * @title: Windows Compatibility Functions
2577  * @short_description: UNIX emulation on Windows
2578  *
2579  * These functions provide some level of UNIX emulation on the
2580  * Windows platform. If your application really needs the POSIX
2581  * APIs, we suggest you try the Cygwin project.
2582  */
2583 
2584 /**
2585  * MAXPATHLEN:
2586  *
2587  * Provided for UNIX emulation on Windows; equivalent to UNIX
2588  * macro %MAXPATHLEN, which is the maximum length of a filename
2589  * (including full path).
2590  */
2591 
2592 /**
2593  * G_WIN32_DLLMAIN_FOR_DLL_NAME:
2594  * @static: empty or "static"
2595  * @dll_name: the name of the (pointer to the) char array where
2596  *     the DLL name will be stored. If this is used, you must also
2597  *     include `windows.h`. If you need a more complex DLL entry
2598  *     point function, you cannot use this
2599  *
2600  * On Windows, this macro defines a DllMain() function that stores
2601  * the actual DLL name that the code being compiled will be included in.
2602  *
2603  * On non-Windows platforms, expands to nothing.
2604  */
2605 
2606 /**
2607  * G_WIN32_HAVE_WIDECHAR_API:
2608  *
2609  * On Windows, this macro defines an expression which evaluates to
2610  * %TRUE if the code is running on a version of Windows where the wide
2611  * character versions of the Win32 API functions, and the wide character
2612  * versions of the C library functions work. (They are always present in
2613  * the DLLs, but don't work on Windows 9x and Me.)
2614  *
2615  * On non-Windows platforms, it is not defined.
2616  *
2617  * Since: 2.6
2618  */
2619 
2620 
2621 /**
2622  * G_WIN32_IS_NT_BASED:
2623  *
2624  * On Windows, this macro defines an expression which evaluates to
2625  * %TRUE if the code is running on an NT-based Windows operating system.
2626  *
2627  * On non-Windows platforms, it is not defined.
2628  *
2629  * Since: 2.6
2630  */
2631 
2632  /* Epilogue {{{1 */
2633 /* vim: set foldmethod=marker: */
2634