37 #ifndef GCONFIG_NO_GCONFIG_DEFS
38 #include <gconfig_defs.h>
43 #if !defined(G_WINDOWS) && !defined(G_UNIX)
50 #if defined(G_WINDOWS) && defined(G_UNIX)
51 #error invalid compilation switches - define G_WINDOWS or G_UNIX but not both
53 #if GCONFIG_WINXP && !defined(G_WINDOWS)
54 #error invalid compilation switches - GCONFIG_WINXP requires G_WINDOWS
59 #if defined(__MINGW32__) && !defined(G_MINGW)
63 #if defined(G_MINGW) && !defined(G_WINDOWS)
64 #error invalid compilation switches - G_MINGW requires G_WINDOWS
66 #if defined(__NetBSD__)
68 #define G_UNIX_NETBSD 1
70 #if defined(__OpenBSD__)
72 #define G_UNIX_OPENBSD 1
74 #if defined(__FreeBSD__)
76 #define G_UNIX_FREEBSD 1
78 #if defined(__APPLE__)
82 #if defined(linux) || defined(__linux__)
83 #define G_UNIX_LINUX 1
85 #if !defined(GCONFIG_WINXP)
86 #define GCONFIG_WINXP 0
91 #if defined(__cplusplus)
92 #if defined(_MSC_VER) && defined(__has_include)
93 #if __has_include(<version>)
97 #if __cplusplus >= 202000L
102 #if !defined(GCONFIG_HAVE_CXX_ALIGNMENT)
103 #define GCONFIG_HAVE_CXX_ALIGNMENT 1
105 #if !defined(GCONFIG_HAVE_CXX_STD_MAKE_UNIQUE)
106 #if defined(_MSC_VER)
107 #define GCONFIG_HAVE_CXX_STD_MAKE_UNIQUE 1
109 #if __cplusplus >= 201400L
110 #define GCONFIG_HAVE_CXX_STD_MAKE_UNIQUE 1
112 #define GCONFIG_HAVE_CXX_STD_MAKE_UNIQUE 0
116 #if !defined(GCONFIG_HAVE_CXX_STRING_VIEW)
117 #if defined(_MSC_VER) && defined(__cplusplus)
119 #if defined(__cpp_lib_string_view)
120 #define GCONFIG_HAVE_CXX_STRING_VIEW 1
122 #define GCONFIG_HAVE_CXX_STRING_VIEW 0
125 #if __cplusplus >= 201700L
126 #define GCONFIG_HAVE_CXX_STRING_VIEW 1
128 #define GCONFIG_HAVE_CXX_STRING_VIEW 0
132 #if !defined(GCONFIG_HAVE_CXX_OPTIONAL)
133 #if defined(_MSC_VER) && defined(__cplusplus) && _MSVC_LANG >= 201700L
134 #define GCONFIG_HAVE_CXX_OPTIONAL 1
136 #if __cplusplus >= 201700L
137 #define GCONFIG_HAVE_CXX_OPTIONAL 1
139 #define GCONFIG_HAVE_CXX_OPTIONAL 0
143 #if !defined(GCONFIG_HAVE_SYS_UTSNAME_H)
145 #define GCONFIG_HAVE_SYS_UTSNAME_H 1
147 #define GCONFIG_HAVE_SYS_UTSNAME_H 0
150 #if !defined(GCONFIG_HAVE_SYS_SELECT_H)
152 #define GCONFIG_HAVE_SYS_SELECT_H 1
154 #define GCONFIG_HAVE_SYS_SELECT_H 0
157 #if !defined(GCONFIG_HAVE_SYS_SOCKET_H)
159 #define GCONFIG_HAVE_SYS_SOCKET_H 1
161 #define GCONFIG_HAVE_SYS_SOCKET_H 0
164 #if !defined(GCONFIG_HAVE_SYS_MMAN_H)
166 #define GCONFIG_HAVE_SYS_MMAN_H 1
168 #define GCONFIG_HAVE_SYS_MMAN_H 0
171 #if !defined(GCONFIG_HAVE_NETINET_IN_H)
173 #define GCONFIG_HAVE_NETINET_IN_H 1
175 #define GCONFIG_HAVE_NETINET_IN_H 0
178 #if !defined(GCONFIG_HAVE_NETDB_H)
180 #define GCONFIG_HAVE_NETDB_H 1
182 #define GCONFIG_HAVE_NETDB_H 0
185 #if !defined(GCONFIG_HAVE_ARPA_INET_H)
187 #define GCONFIG_HAVE_ARPA_INET_H 1
189 #define GCONFIG_HAVE_ARPA_INET_H 0
192 #if !defined(GCONFIG_HAVE_LONG_LONG)
193 #define GCONFIG_HAVE_LONG_LONG 1
195 #if !defined(GCONFIG_HAVE_LONG_LONG_LONG)
197 #define GCONFIG_HAVE_LONG_LONG_LONG 0
199 #if !defined(GCONFIG_HAVE_STDINT_H)
200 #define GCONFIG_HAVE_STDINT_H 1
202 #if !defined(GCONFIG_HAVE_INTTYPES_H)
203 #define GCONFIG_HAVE_INTTYPES_H 1
205 #if !defined(GCONFIG_HAVE_INT64)
206 #define GCONFIG_HAVE_INT64 1
208 #if !defined(GCONFIG_HAVE_INT32)
209 #define GCONFIG_HAVE_INT32 1
211 #if !defined(GCONFIG_HAVE_INT16)
212 #define GCONFIG_HAVE_INT16 1
214 #if !defined(GCONFIG_HAVE_DIRENT_H)
215 #define GCONFIG_HAVE_DIRENT_H 1
217 #if !defined(GCONFIG_HAVE_READLINK)
219 #define GCONFIG_HAVE_READLINK 1
221 #define GCONFIG_HAVE_READLINK 0
224 #if !defined(GCONFIG_HAVE_ERRNO_T)
226 #define GCONFIG_HAVE_ERRNO_T 1
228 #define GCONFIG_HAVE_ERRNO_T 0
231 #if !defined(GCONFIG_HAVE_GETENV_S)
232 #if ( defined(G_WINDOWS) && !defined(G_MINGW) ) || defined(getenv_s)
233 #define GCONFIG_HAVE_GETENV_S 1
235 #define GCONFIG_HAVE_GETENV_S 0
240 #ifdef GCONFIG_HAVE_WGETENV_S
241 #undef GCONFIG_HAVE_WGETENV_S
243 #define GCONFIG_HAVE_WGETENV_S 0
245 #if !defined(GCONFIG_HAVE_WGETENV_S)
246 #if defined(G_WINDOWS)
247 #define GCONFIG_HAVE_WGETENV_S 1
249 #define GCONFIG_HAVE_WGETENV_S 0
253 #if !defined(GCONFIG_HAVE_PUTENV_S)
254 #if ( defined(G_WINDOWS) && !defined(G_MINGW) ) || defined(putenv_s)
255 #define GCONFIG_HAVE_PUTENV_S 1
257 #define GCONFIG_HAVE_PUTENV_S 0
261 #ifdef GCONFIG_HAVE_WPUTENV_S
262 #undef GCONFIG_HAVE_WPUTENV_S
264 #define GCONFIG_HAVE_WPUTENV_S 0
266 #if !defined(GCONFIG_HAVE_WPUTENV_S)
267 #if defined(G_WINDOWS)
268 #define GCONFIG_HAVE_WPUTENV_S 1
270 #define GCONFIG_HAVE_WPUTENV_S 0
274 #if !defined(GCONFIG_HAVE_PUTENV)
275 #define GCONFIG_HAVE_PUTENV 1
278 #ifdef GCONFIG_HAVE_WCSERROR_S
279 #undef GCONFIG_HAVE_WCSERROR_S
281 #define GCONFIG_HAVE_WCSERROR_S 0
283 #if !defined(GCONFIG_HAVE_WCSERROR_S)
284 #if defined(G_WINDOWS)
285 #define GCONFIG_HAVE_WCSERROR_S 1
287 #define GCONFIG_HAVE_WCSERROR_S 0
291 #if !defined(GCONFIG_HAVE_GETPWNAM)
292 #define GCONFIG_HAVE_GETPWNAM 1
294 #if !defined(GCONFIG_HAVE_GETPWNAM_R)
295 #define GCONFIG_HAVE_GETPWNAM_R 1
297 #if !defined(GCONFIG_HAVE_GETGRNAM)
298 #define GCONFIG_HAVE_GETGRNAM 1
300 #if !defined(GCONFIG_HAVE_GETGRNAM_R)
301 #define GCONFIG_HAVE_GETGRNAM_R 1
303 #if !defined(GCONFIG_HAVE_GMTIME_R)
304 #if defined(G_WINDOWS) && !defined(gmtime_r)
305 #define GCONFIG_HAVE_GMTIME_R 0
307 #define GCONFIG_HAVE_GMTIME_R 1
310 #if !defined(GCONFIG_HAVE_GMTIME_S)
311 #if defined(G_WINDOWS) || defined(gmtime_s)
312 #define GCONFIG_HAVE_GMTIME_S 1
314 #define GCONFIG_HAVE_GMTIME_S 0
317 #if !defined(GCONFIG_HAVE_IPV6)
318 #define GCONFIG_HAVE_IPV6 1
320 #if !defined(GCONFIG_HAVE_EXECVPE)
322 #define GCONFIG_HAVE_EXECVPE 1
324 #define GCONFIG_HAVE_EXECVPE 0
327 #if !defined(GCONFIG_HAVE_RTNETLINK)
329 #define GCONFIG_HAVE_RTNETLINK 1
331 #define GCONFIG_HAVE_RTNETLINK 0
334 #if !defined(GCONFIG_HAVE_NETROUTE)
336 #define GCONFIG_HAVE_NETROUTE 1
338 #define GCONFIG_HAVE_NETROUTE 0
341 #if !defined(GCONFIG_HAVE_LOCALTIME_R)
342 #if defined(G_WINDOWS) && !defined(localtime_r)
343 #define GCONFIG_HAVE_LOCALTIME_R 0
345 #define GCONFIG_HAVE_LOCALTIME_R 1
348 #if !defined(GCONFIG_HAVE_LOCALTIME_S)
349 #if defined(G_WINDOWS) || defined(localtime_s)
350 #define GCONFIG_HAVE_LOCALTIME_S 1
352 #define GCONFIG_HAVE_LOCALTIME_S 0
355 #if !defined(GCONFIG_HAVE_MEMORY_H)
356 #define GCONFIG_HAVE_MEMORY_H 1
358 #if !defined(GCONFIG_HAVE_SETPGRP_BSD)
359 #if defined(G_UNIX_LINUX) || defined(G_UNIX_MAC)
360 #define GCONFIG_HAVE_SETPGRP_BSD 0
362 #define GCONFIG_HAVE_SETPGRP_BSD 1
365 #if !defined(GCONFIG_HAVE_SETGROUPS)
367 #define GCONFIG_HAVE_SETGROUPS 1
369 #define GCONFIG_HAVE_SETGROUPS 0
372 #if !defined(GCONFIG_HAVE_STATBUF_TIMESPEC)
373 #if defined(G_UNIX_MAC)
374 #define GCONFIG_HAVE_STATBUF_TIMESPEC 1
376 #define GCONFIG_HAVE_STATBUF_TIMESPEC 0
379 #if !defined(GCONFIG_HAVE_STATBUF_NSEC)
380 #define GCONFIG_HAVE_STATBUF_NSEC 0
382 #if !defined(GCONFIG_HAVE_SIN6_LEN)
383 #define GCONFIG_HAVE_SIN6_LEN 0
385 #if !defined(GCONFIG_HAVE_SOCKLEN_T)
386 #define GCONFIG_HAVE_SOCKLEN_T 1
388 #if !defined(GCONFIG_HAVE_STDLIB_H)
389 #define GCONFIG_HAVE_STDLIB_H 1
391 #if !defined(GCONFIG_HAVE_STRNCPY_S)
392 #if ( defined(G_WINDOWS) && !defined(G_MINGW) ) || defined(strncpy_s)
393 #define GCONFIG_HAVE_STRNCPY_S 1
395 #define GCONFIG_HAVE_STRNCPY_S 0
398 #if !defined(GCONFIG_HAVE_STRINGS_H)
399 #define GCONFIG_HAVE_STRINGS_H 1
401 #if !defined(GCONFIG_HAVE_STRING_H)
402 #define GCONFIG_HAVE_STRING_H 1
404 #if !defined(GCONFIG_HAVE_NDIR_H)
405 #define GCONFIG_HAVE_NDIR_H 0
407 #if !defined(GCONFIG_HAVE_SYS_DIR_H)
408 #define GCONFIG_HAVE_SYS_DIR_H 0
410 #if !defined(GCONFIG_HAVE_SYS_NDIR_H)
411 #define GCONFIG_HAVE_SYS_NDIR_H 0
413 #if !defined(GCONFIG_HAVE_SYS_STAT_H)
414 #define GCONFIG_HAVE_SYS_STAT_H 1
416 #if !defined(GCONFIG_HAVE_SYS_WAIT_H)
418 #define GCONFIG_HAVE_SYS_WAIT_H 1
420 #define GCONFIG_HAVE_SYS_WAIT_H 0
423 #if !defined(GCONFIG_HAVE_SYS_TIME_H)
424 #define GCONFIG_HAVE_SYS_TIME_H 1
426 #if !defined(GCONFIG_HAVE_SYS_TYPES_H)
427 #define GCONFIG_HAVE_SYS_TYPES_H 1
429 #if !defined(GCONFIG_HAVE_UNISTD_H)
431 #define GCONFIG_HAVE_UNISTD_H 1
433 #define GCONFIG_HAVE_UNISTD_H 0
436 #if !defined(GCONFIG_HAVE_ERRNO_H)
437 #define GCONFIG_HAVE_ERRNO_H 1
439 #if !defined(GCONFIG_HAVE_NET_IF_H)
441 #define GCONFIG_HAVE_NET_IF_H 1
443 #define GCONFIG_HAVE_NET_IF_H 0
446 #if !defined(GCONFIG_HAVE_WINDOWS_IPHLPAPI_H)
448 #define GCONFIG_HAVE_WINDOWS_IPHLPAPI_H 0
450 #define GCONFIG_HAVE_WINDOWS_IPHLPAPI_H 1
453 #if !defined(GCONFIG_HAVE_GAI_STRERROR)
454 #define GCONFIG_HAVE_GAI_STRERROR 1
456 #if !defined(GCONFIG_HAVE_GAI_IDN)
457 #define GCONFIG_HAVE_GAI_IDN 0
459 #if !defined(GCONFIG_HAVE_INET_NTOP)
460 #define GCONFIG_HAVE_INET_NTOP 1
462 #if !defined(GCONFIG_HAVE_IFNAMETOINDEX)
464 #define GCONFIG_HAVE_IFNAMETOINDEX 1
466 #define GCONFIG_HAVE_IFNAMETOINDEX 0
469 #if !defined(GCONFIG_HAVE_IFNAMETOLUID)
470 #if defined(G_WINDOWS) && !defined(G_MINGW)
471 #define GCONFIG_HAVE_IFNAMETOLUID 1
473 #define GCONFIG_HAVE_IFNAMETOLUID 0
476 #if !defined(GCONFIG_HAVE_IFINDEX)
478 #define GCONFIG_HAVE_IFINDEX 1
480 #define GCONFIG_HAVE_IFINDEX 0
483 #if !defined(GCONFIG_HAVE_INET_PTON)
484 #define GCONFIG_HAVE_INET_PTON 1
486 #if !defined(GCONFIG_HAVE_UID_T)
488 #define GCONFIG_HAVE_UID_T 1
490 #define GCONFIG_HAVE_UID_T 0
493 #if !defined(GCONFIG_HAVE_GID_T)
494 #define GCONFIG_HAVE_GID_T GCONFIG_HAVE_UID_T
496 #if !defined(GCONFIG_HAVE_UINTPTR_T)
497 #define GCONFIG_HAVE_UINTPTR_T 0
499 #if !defined(GCONFIG_HAVE_SSIZE_T)
500 #if defined(G_UNIX) || defined(G_MINGW)
501 #define GCONFIG_HAVE_SSIZE_T 1
503 #define GCONFIG_HAVE_SSIZE_T 0
506 #if !defined(GCONFIG_HAVE_PID_T)
507 #if defined(G_UNIX) || defined(G_MINGW)
508 #define GCONFIG_HAVE_PID_T 1
510 #define GCONFIG_HAVE_PID_T 0
513 #if !defined(GCONFIG_HAVE_GET_WINDOW_LONG_PTR)
515 #define GCONFIG_HAVE_GET_WINDOW_LONG_PTR 1
517 #define GCONFIG_HAVE_GET_WINDOW_LONG_PTR 0
520 #if !defined(GCONFIG_HAVE_MREMAP)
522 #define GCONFIG_HAVE_MREMAP 1
524 #define GCONFIG_HAVE_MREMAP 0
527 #if !defined(GCONFIG_HAVE_TIMERFD)
529 #define GCONFIG_HAVE_TIMERFD 1
531 #define GCONFIG_HAVE_TIMERFD 0
534 #if !defined(GCONFIG_HAVE_PAM)
536 #define GCONFIG_HAVE_PAM 1
538 #define GCONFIG_HAVE_PAM 0
541 #if !defined(GCONFIG_HAVE_PAM_IN_SECURITY)
543 #define GCONFIG_HAVE_PAM_IN_SECURITY 1
545 #define GCONFIG_HAVE_PAM_IN_SECURITY 0
548 #if !defined(GCONFIG_HAVE_PAM_IN_INCLUDE)
549 #define GCONFIG_HAVE_PAM_IN_INCLUDE 0
551 #if !defined(GCONFIG_HAVE_PAM_IN_PAM)
552 #define GCONFIG_HAVE_PAM_IN_PAM 0
554 #if !defined(GCONFIG_PAM_CONST)
555 #if defined(G_UNIX_LINUX) || defined(G_UNIX_BSD)
556 #define GCONFIG_PAM_CONST 1
558 #define GCONFIG_PAM_CONST 0
561 #if !defined(GCONFIG_HAVE_GET_NATIVE_SYSTEM_INFO)
563 #define GCONFIG_HAVE_GET_NATIVE_SYSTEM_INFO 1
565 #define GCONFIG_HAVE_GET_NATIVE_SYSTEM_INFO 0
568 #if !defined(GCONFIG_HAVE_LIBJPEG)
569 #define GCONFIG_HAVE_LIBJPEG 0
571 #if !defined(GCONFIG_HAVE_LIBPNG)
572 #define GCONFIG_HAVE_LIBPNG 0
574 #if !defined(GCONFIG_HAVE_LIBAV)
575 #define GCONFIG_HAVE_LIBAV 0
577 #if !defined(GCONFIG_HAVE_CURSES)
578 #define GCONFIG_HAVE_CURSES 0
580 #if !defined(GCONFIG_HAVE_LIBEXIV)
581 #define GCONFIG_HAVE_LIBEXIV 0
583 #if !defined(GCONFIG_HAVE_V4L)
585 #define GCONFIG_HAVE_V4L 1
587 #define GCONFIG_HAVE_V4L 0
590 #if !defined(GCONFIG_HAVE_LIBV4L)
591 #define GCONFIG_HAVE_LIBV4L 0
593 #if !defined(GCONFIG_HAVE_GETTEXT)
595 #if defined(ENABLE_NLS) && ENABLE_NLS == 1
596 #define GCONFIG_HAVE_GETTEXT 1
598 #define GCONFIG_HAVE_GETTEXT 0
601 #if !defined(GCONFIG_ENABLE_IPV6)
602 #define GCONFIG_ENABLE_IPV6 GCONFIG_HAVE_IPV6
604 #if !defined(GCONFIG_ENABLE_STD_THREAD)
605 #define GCONFIG_ENABLE_STD_THREAD 1
607 #if !defined(GCONFIG_HAVE_SEM_INIT)
608 #if defined(G_UNIX_LINUX) || defined(G_UNIX_FREEBSD)
609 #define GCONFIG_HAVE_SEM_INIT 1
611 #define GCONFIG_HAVE_SEM_INIT 0
614 #if !defined(GCONFIG_HAVE_X11)
616 #define GCONFIG_HAVE_X11 1
618 #define GCONFIG_HAVE_X11 0
621 #if !defined(GCONFIG_HAVE_WAYLAND)
623 #define GCONFIG_HAVE_WAYLAND 0
625 #define GCONFIG_HAVE_WAYLAND 0
628 #if !defined(GCONFIG_HAVE_MBEDTLS)
629 #define GCONFIG_HAVE_MBEDTLS 1
631 #if !defined(GCONFIG_HAVE_MBEDTLS_NET_H)
632 #define GCONFIG_HAVE_MBEDTLS_NET_H 0
634 #if !defined(GCONFIG_HAVE_OPENSSL)
636 #define GCONFIG_HAVE_OPENSSL 1
638 #define GCONFIG_HAVE_OPENSSL 0
641 #if !defined(GCONFIG_HAVE_OPENSSL_MIN_MAX)
642 #define GCONFIG_HAVE_OPENSSL_MIN_MAX 1
644 #if !defined(GCONFIG_HAVE_OPENSSL_SSLv23_METHOD)
645 #define GCONFIG_HAVE_OPENSSL_SSLv23_METHOD 0
647 #if !defined(GCONFIG_HAVE_OPENSSL_SSLv3_METHOD)
648 #define GCONFIG_HAVE_OPENSSL_SSLv3_METHOD 0
650 #if !defined(GCONFIG_HAVE_OPENSSL_TLSv1_1_METHOD)
651 #define GCONFIG_HAVE_OPENSSL_TLSv1_1_METHOD 1
653 #if !defined(GCONFIG_HAVE_OPENSSL_TLSv1_2_METHOD)
654 #define GCONFIG_HAVE_OPENSSL_TLSv1_2_METHOD 1
656 #if !defined(GCONFIG_HAVE_BOOST)
658 #define GCONFIG_HAVE_BOOST 1
660 #define GCONFIG_HAVE_BOOST 0
663 #if !defined(GCONFIG_HAVE_ALSA)
665 #define GCONFIG_HAVE_ALSA 1
667 #define GCONFIG_HAVE_ALSA 0
670 #if !defined(GCONFIG_HAVE_FMEMOPEN)
671 #if !defined(G_UNIX_OPENBSD)
672 #define GCONFIG_HAVE_FMEMOPEN 1
674 #define GCONFIG_HAVE_FMEMOPEN 0
677 #if !defined(GCONFIG_HAVE_IP_MREQN)
678 #if defined(G_UNIX_LINUX) || defined(G_UNIX_FREEBSD)
679 #define GCONFIG_HAVE_IP_MREQN 1
681 #define GCONFIG_HAVE_IP_MREQN 0
684 #if !defined(GCONFIG_HAVE_EXECVPE)
686 #define GCONFIG_HAVE_EXECVPE 1
688 #define GCONFIG_HAVE_EXECVPE 0
691 #if !defined(GCONFIG_HAVE_WINDOWS_CREATE_WAITABLE_TIMER_EX)
692 #if defined(G_WINDOWS) && !defined(G_MINGW)
693 #define GCONFIG_HAVE_WINDOWS_CREATE_WAITABLE_TIMER_EX 1
695 #define GCONFIG_HAVE_WINDOWS_CREATE_WAITABLE_TIMER_EX 0
698 #if !defined(GCONFIG_HAVE_WINDOWS_CREATE_EVENT_EX)
699 #if defined(G_WINDOWS) && !defined(G_MINGW)
700 #define GCONFIG_HAVE_WINDOWS_CREATE_EVENT_EX 1
702 #define GCONFIG_HAVE_WINDOWS_CREATE_EVENT_EX 0
705 #if !defined(GCONFIG_HAVE_WINDOWS_INIT_COMMON_CONTROLS_EX)
706 #if defined(G_WINDOWS) && !defined(G_MINGW)
707 #define GCONFIG_HAVE_WINDOWS_INIT_COMMON_CONTROLS_EX 1
709 #define GCONFIG_HAVE_WINDOWS_INIT_COMMON_CONTROLS_EX 0
712 #if !defined(GCONFIG_HAVE_WINDOWS_VERSIONHELPERS_H)
713 #if defined(G_WINDOWS)
714 #define GCONFIG_HAVE_WINDOWS_VERSIONHELPERS_H 1
716 #define GCONFIG_HAVE_WINDOWS_VERSIONHELPERS_H 0
719 #if !defined(GCONFIG_HAVE_WINDOWS_STARTUP_INFO_EX)
720 #if defined(G_WINDOWS) && !defined(G_MINGW)
721 #define GCONFIG_HAVE_WINDOWS_STARTUP_INFO_EX 1
723 #define GCONFIG_HAVE_WINDOWS_STARTUP_INFO_EX 0
726 #if !defined(GCONFIG_HAVE_DLOPEN)
728 #define GCONFIG_HAVE_DLOPEN 1
730 #define GCONFIG_HAVE_DLOPEN 0
733 #if !defined(GCONFIG_HAVE_FSOPEN)
734 #if defined(G_UNIX) || defined(G_MINGW)
735 #define GCONFIG_HAVE_FSOPEN 0
737 #define GCONFIG_HAVE_FSOPEN 1
740 #if !defined(GCONFIG_HAVE_FOPEN_S)
741 #if defined(G_WINDOWS)
742 #define GCONFIG_HAVE_FOPEN_S 1
744 #define GCONFIG_HAVE_FOPEN_S 0
747 #if !defined(GCONFIG_HAVE_SOPEN)
748 #if defined(G_UNIX) || defined(G_MINGW)
749 #define GCONFIG_HAVE_SOPEN 0
751 #define GCONFIG_HAVE_SOPEN 1
754 #if !defined(GCONFIG_HAVE_SOPEN_S)
755 #if defined(G_UNIX) || defined(G_MINGW)
756 #define GCONFIG_HAVE_SOPEN_S 0
758 #define GCONFIG_HAVE_SOPEN_S 1
762 #ifdef GCONFIG_HAVE_WSOPEN_S
763 #undef GCONFIG_HAVE_WSOPEN_S
765 #define GCONFIG_HAVE_WSOPEN_S 0
767 #if !defined(GCONFIG_HAVE_WSOPEN_S)
768 #if defined(G_WINDOWS)
769 #define GCONFIG_HAVE_WSOPEN_S 1
771 #define GCONFIG_HAVE_WSOPEN_S 0
775 #if !defined(GCONFIG_HAVE_EXTENDED_OPEN)
776 #if defined(G_UNIX) || defined(G_MINGW)
777 #define GCONFIG_HAVE_EXTENDED_OPEN 0
779 #define GCONFIG_HAVE_EXTENDED_OPEN 1
782 #if !defined(GCONFIG_HAVE_SIGPROCMASK)
784 #define GCONFIG_HAVE_SIGPROCMASK 1
786 #define GCONFIG_HAVE_SIGPROCMASK 0
789 #if !defined(GCONFIG_HAVE_PTHREAD_SIGMASK)
791 #define GCONFIG_HAVE_PTHREAD_SIGMASK 1
793 #define GCONFIG_HAVE_PTHREAD_SIGMASK 0
796 #if !defined(GCONFIG_HAVE_DIRENT_D_TYPE)
797 #if defined(_DIRENT_HAVE_D_TYPE)
798 #define GCONFIG_HAVE_DIRENT_D_TYPE 1
800 #define GCONFIG_HAVE_DIRENT_D_TYPE 0
803 #if !defined(GCONFIG_HAVE_UDS)
805 #define GCONFIG_HAVE_UDS 1
807 #define GCONFIG_HAVE_UDS 0
810 #if !defined(GCONFIG_HAVE_UDS_LEN)
812 #define GCONFIG_HAVE_UDS_LEN 1
814 #define GCONFIG_HAVE_UDS_LEN 0
820 #if defined(G_WINDOWS)
821 #ifndef WIN32_LEAN_AND_MEAN
822 #define WIN32_LEAN_AND_MEAN
824 #include <winsock2.h>
826 #include <ws2tcpip.h>
827 #if GCONFIG_HAVE_WINDOWS_IPHLPAPI_H
828 #include <iphlpapi.h>
830 #if GCONFIG_HAVE_WINDOWS_VERSIONHELPERS_H
831 #include <versionhelpers.h>
850 #if defined(G_WINDOWS)
851 #include <shellapi.h>
855 #if GCONFIG_HAVE_SYS_TYPES_H
856 #include <sys/types.h>
858 #if GCONFIG_HAVE_SYS_STAT_H
859 #include <sys/stat.h>
861 #if GCONFIG_HAVE_INTTYPES_H
865 #include <inttypes.h>
868 #if GCONFIG_HAVE_STDINT_H
875 #if GCONFIG_HAVE_UNISTD_H
878 #if GCONFIG_HAVE_ERRNO_H
885 #if GCONFIG_HAVE_SYS_WAIT_H
886 #include <sys/wait.h>
888 #if GCONFIG_HAVE_SYS_UTSNAME_H
889 #include <sys/utsname.h>
891 #if GCONFIG_HAVE_SYS_SELECT_H
892 #include <sys/select.h>
894 #if GCONFIG_HAVE_SYS_SOCKET_H
895 #include <sys/socket.h>
898 #define MSG_NOSIGNAL 0
900 #if GCONFIG_HAVE_SYS_MMAN_H
901 #include <sys/mman.h>
902 #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
903 #define MAP_ANONYMOUS MAP_ANON
905 #ifndef MREMAP_MAYMOVE
906 #define MREMAP_MAYMOVE 0
909 #if GCONFIG_HAVE_NETINET_IN_H
910 #include <netinet/in.h>
912 #if GCONFIG_HAVE_NETDB_H
915 #if GCONFIG_HAVE_ARPA_INET_H
916 #include <arpa/inet.h>
918 #if GCONFIG_HAVE_NET_IF_H
921 #if GCONFIG_HAVE_PWD_H
924 #if GCONFIG_HAVE_GRP_H
956 #if ! defined(G_WINDOWS)
957 using BOOL =
unsigned char ;
958 using HDC =
unsigned int ;
959 using HWND =
unsigned int ;
960 using HINSTANCE =
unsigned int ;
961 using HANDLE =
unsigned int ;
962 using TCHAR = wchar_t ;
964 using DWORD =
unsigned int ;
975 #if defined(G_WINDOWS)
976 #if GCONFIG_HAVE_INT64
977 using g_int64_t = INT64 ;
978 using g_uint64_t = UINT64 ;
980 #if GCONFIG_HAVE_INT32
981 using g_int32_t = INT32 ;
982 using g_uint32_t = UINT32 ;
984 #if GCONFIG_HAVE_INT16
985 using g_int16_t = INT16 ;
986 using g_uint16_t = UINT16 ;
989 #if GCONFIG_HAVE_INT64
990 using g_int64_t = int64_t ;
991 using g_uint64_t = uint64_t ;
993 #if GCONFIG_HAVE_INT32
994 using g_int32_t = int32_t ;
995 using g_uint32_t = uint32_t ;
997 #if GCONFIG_HAVE_INT16
998 using g_int16_t = int16_t ;
999 using g_uint16_t = uint16_t ;
1002 #if GCONFIG_HAVE_UINTPTR_T
1003 using g_uintptr_t = uintptr_t ;
1005 using g_uintptr_t = std::size_t ;
1007 #if GCONFIG_HAVE_INT64
1008 static_assert(
sizeof(g_int64_t) == 8U ,
"uint64 wrong size" ) ;
1009 static_assert(
sizeof(g_uint64_t) == 8U ,
"int64 wrong size" ) ;
1011 #if GCONFIG_HAVE_INT32
1012 static_assert(
sizeof(g_uint32_t) == 4U ,
"uint32 wrong size" ) ;
1013 static_assert(
sizeof(g_int32_t) == 4U ,
"int32 wrong size" ) ;
1015 #if GCONFIG_HAVE_INT16
1016 static_assert(
sizeof(g_uint16_t) == 2U ,
"uint16 wrong size" ) ;
1017 static_assert(
sizeof(g_int16_t) == 2U ,
"int16 wrong size" ) ;
1019 static_assert(
sizeof(g_uintptr_t) >=
sizeof(
void*) ,
"" ) ;
1023 #if ! GCONFIG_HAVE_UID_T
1026 #if ! GCONFIG_HAVE_GID_T
1029 #if ! GCONFIG_HAVE_SSIZE_T
1030 #if defined(SSIZE_T)
1031 using ssize_t = SSIZE_T ;
1034 using ssize_t = int ;
1037 #if ! GCONFIG_HAVE_PID_T
1038 using pid_t =
unsigned int ;
1040 #if ! GCONFIG_HAVE_SOCKLEN_T
1041 using socklen_t = int ;
1043 #if ! GCONFIG_HAVE_ERRNO_T
1044 using errno_t = int ;
1049 #if __cplusplus >= 201700L
1050 #define GDEF_NORETURN_LHS [[noreturn]]
1051 #define GDEF_UNUSED [[maybe_unused]]
1052 #define GDEF_FALLTHROUGH [[fallthrough]];
1054 #if defined(__GNUC__) || defined(__clang__)
1055 #define GDEF_NORETURN_RHS __attribute__((noreturn))
1056 #define GDEF_UNUSED __attribute__((unused))
1057 #if defined(__GNUC__) && __GNUC__ >= 7
1058 #define GDEF_FALLTHROUGH __attribute__((fallthrough));
1060 #if defined(__clang__) && __clang_major__ >= 10
1061 #define GDEF_FALLTHROUGH __attribute__((fallthrough));
1064 #if defined(_MSC_VER)
1065 #define GDEF_NORETURN_LHS __declspec(noreturn)
1068 #if __cplusplus >= 201700L || _MSVC_LANG >= 201700L
1069 #define GDEF_FSIG_NOEXCEPT noexcept
1071 #define GDEF_FSIG_NOEXCEPT
1073 #ifndef GDEF_NORETURN_LHS
1074 #define GDEF_NORETURN_LHS
1076 #ifndef GDEF_NORETURN_RHS
1077 #define GDEF_NORETURN_RHS
1082 #ifndef GDEF_FALLTHROUGH
1083 #define GDEF_FALLTHROUGH
1086 namespace G {
template <
typename... T>
inline void gdef_ignore( T&& ... ) {} }
1087 #define GDEF_IGNORE_PARAMS(...) G::gdef_ignore(__VA_ARGS__)
1088 #define GDEF_IGNORE_RETURN std::ignore =
1089 #define GDEF_IGNORE_PARAM(name) std::ignore = name
1090 #define GDEF_IGNORE_VARIABLE(name) std::ignore = name
1094 #if defined(_MSC_VER)
1095 #define GDEF_WARNING_DISABLE_START( n ) __pragma(warning(push)) __pragma(warning(disable:n))
1096 #define GDEF_WARNING_DISABLE_END __pragma(warning(pop))
1098 #define GDEF_WARNING_DISABLE_START( n )
1099 #define GDEF_WARNING_DISABLE_END
1104 #if !GCONFIG_HAVE_CXX_STD_MAKE_UNIQUE
1109 template <
typename T,
typename... Args>
1110 std::unique_ptr<T> make_unique( Args&&... args )
1112 return std::unique_ptr<T>(
new T( std::forward<Args>(args)... ) ) ;
1119 #if GCONFIG_ENABLE_STD_THREAD
1127 static constexpr bool using_std_thread = true ;
1128 using thread_type = std::thread ;
1129 using mutex_type = std::mutex ;
1130 using lock_type = std::lock_guard<std::mutex> ;
1131 static bool works() ;
1132 static void yield()
noexcept { std::this_thread::yield() ; }
1142 template <
typename T_fn>
explicit dummy_thread( T_fn fn ) { fn() ; }
1143 template <
typename T_fn,
typename T_arg1> dummy_thread( T_fn fn , T_arg1 arg1 ) { fn(arg1) ; }
1144 template <
typename T_fn,
typename T_arg1,
typename T_arg2> dummy_thread( T_fn fn , T_arg1 arg1 , T_arg2 arg2 ) { fn(arg1,arg2) ; }
1146 bool joinable() const noexcept {
return false ; }
1149 id get_id()
const {
return 0 ; }
1151 class dummy_mutex {} ;
1152 class dummy_lock {
public:
explicit dummy_lock( dummy_mutex & ) {} } ;
1155 static constexpr bool using_std_thread = false ;
1156 using thread_type = G::dummy_thread ;
1157 using mutex_type = G::dummy_mutex ;
1158 using lock_type = G::dummy_lock ;
1159 static bool works() ;
1160 static void yield() noexcept {}
1170 constexpr bool is_windows() noexcept {
return true ; }
1172 constexpr bool is_windows() noexcept {
return false ; }
1175 constexpr bool is_linux() noexcept {
return true ; }
1177 constexpr bool is_linux() noexcept {
return false ; }
1179 #ifdef G_UNIX_FREEBSD
1180 constexpr bool is_free_bsd() noexcept {
return true ; }
1182 constexpr bool is_free_bsd() noexcept {
return false ; }
1184 #ifdef G_UNIX_OPENBSD
1185 constexpr bool is_open_bsd() noexcept {
return true ; }
1187 constexpr bool is_open_bsd() noexcept {
return false ; }
1190 constexpr bool is_bsd() noexcept {
return true ; }
1192 constexpr bool is_bsd() noexcept {
return false ; }
1199 using g_port_t = g_uint16_t ;
1203 #ifndef AI_NUMERICSERV
1204 #define AI_NUMERICSERV 0
1207 #ifndef MSG_NOSIGNAL
1208 #define MSG_NOSIGNAL 0
1211 #ifndef AI_ADDRCONFIG
1212 #define AI_ADDRCONFIG 0
1216 #define INADDR_NONE 0xffffffff
1222 #if GCONFIG_HAVE_IPV6
1223 inline void gdef_address6_init( sockaddr_in6 & s )
1225 #if GCONFIG_HAVE_SIN6_LEN
1226 s.sin6_len =
sizeof(s) ;
1236 #if ! GCONFIG_HAVE_GAI_STRERROR
1237 inline const char * gai_strerror(
int )
1243 namespace GNet {
int inet_pton_imp(
int f ,
const char * p ,
void * result ) ; }
1244 #if ! GCONFIG_HAVE_INET_PTON
1245 inline int inet_pton(
int f ,
const char * p ,
void * result )
1247 return GNet::inet_pton_imp( f , p , result ) ;
1251 namespace GNet {
const char * inet_ntop_imp(
int f ,
void * ap ,
char * buffer , std::size_t n ) ; }
1252 #if ! GCONFIG_HAVE_INET_NTOP
1253 inline const char * inet_ntop(
int f ,
void * ap ,
char * buffer , std::size_t n )
1255 return GNet::inet_ntop_imp( f , ap , buffer , n ) ;
1259 #if GCONFIG_HAVE_PTHREAD_SIGMASK && GCONFIG_ENABLE_STD_THREAD
1261 inline int gdef_pthread_sigmask(
int how ,
const sigset_t * set_p , sigset_t * oldset_p )
noexcept
1263 return pthread_sigmask( how , set_p , oldset_p ) ;
1266 #if GCONFIG_HAVE_SIGPROCMASK
1268 inline int gdef_pthread_sigmask(
int how ,
const sigset_t * set_p , sigset_t * oldset_p )
noexcept
1270 return sigprocmask( how , set_p , oldset_p ) ;
1273 template <
typename... T>
int gdef_pthread_sigmask(T...) noexcept {
return 0 ; }
1277 #if GCONFIG_HAVE_IFNAMETOLUID
1278 #include <iphlpapi.h>
1279 inline unsigned long gdef_if_nametoindex(
const char * p )
1282 if( ConvertInterfaceNameToLuidA( p , &luid ) )
1284 _set_errno( EINVAL ) ;
1287 NET_IFINDEX result = 0 ;
1288 if( ConvertInterfaceLuidToIndex( &luid , &result ) != NO_ERROR )
1290 _set_errno( EINVAL ) ;
1297 #if GCONFIG_HAVE_IFNAMETOINDEX
1298 inline unsigned long gdef_if_nametoindex(
const char * p )
1305 return if_nametoindex( p ) ;
1308 inline unsigned long gdef_if_nametoindex(
const char * )
1311 _set_errno( EINVAL ) ;
1319 #if ! GCONFIG_HAVE_READLINK && !defined(readlink)
1320 inline ssize_t readlink(
const char * ,
char * , std::size_t )
1325 #if ! GCONFIG_HAVE_EXECVPE && !defined(execvpe) && defined(G_UNIX)
1326 inline int execvpe(
const char * ,
char * [] ,
char * [] )
1333 #if GCONFIG_HAVE_GETPWNAM && ! GCONFIG_HAVE_GETPWNAM_R
1335 inline int getpwnam_r(
const char * name ,
struct passwd * pwd ,
1336 char * buf , std::size_t buflen ,
struct passwd ** result )
1338 struct passwd * p = ::getpwnam( name ) ;
1353 #if GCONFIG_HAVE_GETGRNAM && ! GCONFIG_HAVE_GETGRNAM_R
1355 inline int getgrnam_r(
const char * name ,
struct group * grp ,
1356 char * buf , std::size_t buflen ,
struct passwd ** result )
1358 struct group * p = ::getgrnam( name ) ;
1373 #if ! GCONFIG_HAVE_GMTIME_R && !defined(gmtime_r)
1374 inline std::tm * gmtime_r(
const std::time_t * tp , std::tm * tm_p )
1376 #if GCONFIG_HAVE_GMTIME_S || defined(gmtime_s)
1377 errno_t e = gmtime_s( tm_p , tp ) ;
1378 if( e )
return nullptr ;
1381 const struct std::tm * p = std::gmtime( tp ) ;
1382 if( p == 0 )
return nullptr ;
1389 #if ! GCONFIG_HAVE_LOCALTIME_R && !defined(localtime_r)
1390 inline struct std::tm * localtime_r(
const std::time_t * tp ,
struct std::tm * tm_p )
1392 #if GCONFIG_HAVE_LOCALTIME_S || defined(localtime_s)
1393 errno_t e = localtime_s( tm_p , tp ) ;
1394 if( e )
return nullptr ;
1397 const struct std::tm * p = std::localtime( tp ) ;
1398 if( p == 0 )
return nullptr ;
1405 #if ! GCONFIG_HAVE_LOCALTIME_S && !defined(localtime_s)
1406 inline errno_t localtime_s(
struct std::tm * tm_p ,
const std::time_t * tp )
1408 const errno_t e_inval = 22 ;
1409 if( tm_p ==
nullptr )
return e_inval ;
1410 tm_p->tm_sec = tm_p->tm_min = tm_p->tm_hour = tm_p->tm_mday = tm_p->tm_mon =
1411 tm_p->tm_year = tm_p->tm_wday = tm_p->tm_yday = tm_p->tm_isdst = -1 ;
1412 if( tp ==
nullptr || *tp < 0 )
return e_inval ;
1413 const struct std::tm * p = std::localtime( tp ) ;
1414 if( p ==
nullptr )
return e_inval ;
1420 #if ! GCONFIG_HAVE_GMTIME_S && !defined(gmtime_s)
1421 inline errno_t gmtime_s(
struct std::tm * tm_p ,
const std::time_t * tp )
1423 const errno_t e_inval = 22 ;
1424 if( tm_p ==
nullptr )
return e_inval ;
1425 tm_p->tm_sec = tm_p->tm_min = tm_p->tm_hour = tm_p->tm_mday = tm_p->tm_mon =
1426 tm_p->tm_year = tm_p->tm_wday = tm_p->tm_yday = tm_p->tm_isdst = -1 ;
1427 if( tp ==
nullptr || *tp < 0 )
return e_inval ;
1428 const struct std::tm * p = std::gmtime( tp ) ;
1429 if( p ==
nullptr )
return e_inval ;
1435 #if GCONFIG_HAVE_SETGROUPS
1438 inline int setgroups( std::size_t ,
const gid_t * )
1444 #if ! GCONFIG_HAVE_GET_WINDOW_LONG_PTR && defined(G_WINDOWS)
1445 static_assert(
sizeof(
void*) == 4U ,
"" ) ;
1446 const int GWLP_HINSTANCE = GWL_HINSTANCE ;
1447 const int GWLP_WNDPROC = GWL_WNDPROC ;
1448 const int DWLP_USER = DWL_USER ;
1449 inline LONG_PTR GetWindowLongPtr( HWND h ,
int id )
1451 return static_cast<LONG_PTR
>(::GetWindowLong(h,
id)) ;
1453 inline LONG_PTR SetWindowLongPtr( HWND h ,
int id , LONG_PTR value )
1455 return static_cast<LONG_PTR
>(::SetWindowLong(h,
id,
static_cast<LONG
>(value))) ;
1459 #if ! GCONFIG_HAVE_WINDOWS_VERSIONHELPERS_H && defined(G_WINDOWS)
1460 inline bool IsWindowsVistaOrGreater()
1462 WORD major = HIBYTE( _WIN32_WINNT_VISTA ) ;
1463 WORD minor = LOBYTE( _WIN32_WINNT_VISTA ) ;
1464 OSVERSIONINFOEXW info {} ;
1465 info.dwOSVersionInfoSize =
sizeof(info) ;
1466 info.dwMajorVersion = major ;
1467 info.dwMinorVersion = minor ;
1468 return !! VerifyVersionInfoW( &info , VER_MAJORVERSION | VER_MINORVERSION ,
1469 VerSetConditionMask( VerSetConditionMask(0,VER_MAJORVERSION,VER_GREATER_EQUAL) ,
1470 VER_MINORVERSION , VER_GREATER_EQUAL ) ) ;
1474 #if ! GCONFIG_HAVE_MREMAP && defined(G_UNIX)
1475 inline void * mremap(
void * , std::size_t , std::size_t ,
int )
1478 return (
void*)(-1) ;
1482 #if GCONFIG_HAVE_SETPGRP_BSD && defined(G_UNIX)
1483 inline int setpgrp()
1485 return ::setpgrp( 0 , 0 ) ;
1489 #if ! GCONFIG_HAVE_CXX_ALIGNMENT
1493 inline void * align(
size_t align ,
size_t size ,
void * & ptr_inout ,
size_t & space )
noexcept
1495 const auto ptr =
reinterpret_cast<uintptr_t
>( ptr_inout ) ;
1496 const auto aligned = ( ptr - 1U + align ) & -align ;
1497 const auto diff = aligned - ptr ;
1498 if( (size + diff) > space )
1505 ptr_inout =
reinterpret_cast<void*
>( aligned ) ;
Helper class for std::thread capabilities.