184 #ifdef MBG_TGT_NO_TGT 185 #include <mbg_no_tgt.h> 209 #if defined( MBG_PRI_64_PREFIX_L ) 210 #define MBG_PRI_64_PREFIX "l" 211 #elif defined( MBG_PRI_64_PREFIX_LL ) 212 #define MBG_PRI_64_PREFIX "ll" 220 #if defined( _NI_mswin_ ) 221 #define MBG_TGT_WIN32 223 #error Unsupported CVI target platform. 226 #elif defined( _WIN32_WINNT ) 230 #define MBG_TGT_WIN32 232 #if ( _WIN32_WINNT >= 0x0500 ) 234 #if !defined( MBG_TGT_WIN32_NON_PNP ) 236 #define MBG_TGT_WIN32_PNP 240 #elif defined( WINVER ) 244 #define MBG_TGT_WIN32 246 #if ( WINVER >= 0x0500 ) 251 #elif defined( __WIN32__ ) 254 #define MBG_TGT_WIN32 256 #elif defined( _WIN32 ) 259 #define MBG_TGT_WIN32 261 #elif defined( RC_INVOKED ) 264 #define MBG_TGT_WIN32 266 #elif defined( __WINDOWS_386__ ) 269 #define MBG_TGT_WIN32 271 #elif defined( __NETWARE_386__ ) 274 #define MBG_TGT_NETWARE 276 #elif defined( __OS2__ ) 280 #define MBG_TGT_USE_IOCTL 1 282 #elif defined( __linux ) 285 #define MBG_TGT_LINUX 286 #define _GNU_SOURCE 1 288 #if defined( __KERNEL__ ) 289 #define MBG_TGT_KERNEL 292 #elif defined( __FreeBSD__ ) 295 #define MBG_TGT_FREEBSD 297 #elif defined( __NetBSD__ ) 300 #define MBG_TGT_NETBSD 302 #elif defined( __OpenBSD__ ) 305 #define MBG_TGT_OPENBSD 307 #elif defined( __sun ) // Oracle Solaris or other SunOS derived operating system 316 #define MBG_TGT_SUNOS 318 #elif defined( __QNX__ ) 323 #if defined( __QNXNTO__ ) 325 #define MBG_TGT_QNX_NTO 328 #elif defined( __MSDOS__ ) || defined( __DOS__ ) 333 #if defined( __WATCOMC__ ) && defined( __386__ ) 335 #define MBG_TGT_DOS_PM // protected mode DOS 343 #if defined( MBG_TGT_FREEBSD ) \ 344 || defined( MBG_TGT_NETBSD ) \ 345 || defined( MBG_TGT_OPENBSD ) 348 #if defined( _KERNEL ) 349 #define MBG_TGT_KERNEL 354 #if defined( MBG_TGT_LINUX ) \ 355 || defined( MBG_TGT_BSD ) \ 356 || defined( MBG_TGT_QNX_NTO ) \ 357 || defined( MBG_TGT_SUNOS ) 359 #define MBG_TGT_POSIX 364 #if defined( MBG_TGT_WIN32 ) 366 #if !defined( _CRT_SECURE_NO_WARNINGS ) 367 #define _CRT_SECURE_NO_WARNINGS 1 372 #define MBG_TGT_HAS_DEV_FN 1 373 #define MBG_TGT_HAS_DEV_FN_BASE 0 374 #define MBG_TGT_USE_IOCTL 1 381 #define FUNC_UNKNOWN "func_???" 383 #if defined( __GNUC__ ) || defined( __clang__ ) 385 #if defined( __clang__ ) 386 #define _CLANG_VERSION ( __clang_major__ * 10000 \ 387 + __clang_minor__ * 100 \ 388 + __clang_patchlevel__ ) 389 #endif // defined( __clang__ ) 391 #define _GCC_VERSION ( __GNUC__ * 10000 \ 392 + __GNUC_MINOR__ * 100 \ 393 + __GNUC_PATCHLEVEL__ ) 395 #if defined( __MINGW32__ ) 396 #define MBG_TGT_MINGW 399 #if defined( __MINGW64__ ) 400 #define MBG_TGT_MINGW 403 #if defined( MBG_TGT_MINGW ) && defined( __MINGW_EXTENSION ) 407 #if !defined( MBG_TGT_HAS_ABS64 ) 408 #define MBG_TGT_HAS_ABS64 1 412 #if defined( __i386__ ) 414 #define MBG_ARCH_I386 417 #elif defined( __x86_64__ ) 419 #define MBG_ARCH_X86_64 422 #elif defined( __ia64__ ) 424 #define MBG_ARCH_IA64 426 #define _NO_USE_PACK_INTF 428 #elif defined( __sparc__ ) 430 #define MBG_ARCH_SPARC 432 #define _NO_USE_PACK_INTF 434 #elif defined( __arm__ ) 440 #if defined( MBG_TGT_LINUX ) 442 #if defined( MBG_TGT_KERNEL ) 444 #include <linux/types.h> 445 #include <linux/version.h> 447 #if ( LINUX_VERSION_CODE <= KERNEL_VERSION( 2, 6, 4 ) ) || \ 448 ( LINUX_VERSION_CODE >= KERNEL_VERSION( 2, 6, 4 ) ) // must be true for 2.6.32-5-sparc64 449 #define _ULONG_DEFINED 1 450 #define _USHORT_DEFINED 1 451 #define _UINT_DEFINED 1 455 #if ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 6, 19 ) ) 460 #if !defined( KERNEL_HAS_BOOL ) 466 #if !defined( KERNEL_HAS_TRUE_FALSE ) 480 #if ( LINUX_VERSION_CODE < KERNEL_VERSION( 2, 6, 24 ) ) 481 typedef unsigned long uintptr_t;
482 #define uintptr_t uintptr_t 490 #if !defined( MBG_PRI_64_PREFIX ) 494 #define MBG_PRI_64_PREFIX "ll" 500 #include <inttypes.h> 503 #if defined( __u_char_defined ) 504 #define _ULONG_DEFINED 1 505 #define _USHORT_DEFINED 1 506 #define _UINT_DEFINED 1 511 #define MBG_TGT_HAS_DEV_FN 1 512 #define MBG_TGT_HAS_DEV_FN_BASE 1 513 #define MBG_TGT_USE_IOCTL 1 515 #elif defined( MBG_TGT_BSD ) 517 #if defined( MBG_TGT_KERNEL ) 518 #include <sys/types.h> 521 #include <inttypes.h> 525 #define MBG_TGT_HAS_DEV_FN 1 526 #define MBG_TGT_HAS_DEV_FN_BASE 1 527 #define MBG_TGT_USE_IOCTL 1 529 #if defined( MBG_TGT_FREEBSD ) && defined( MBG_TGT_KERNEL ) 530 #if !defined( MBG_PRI_64_PREFIX ) 536 #define MBG_PRI_64_PREFIX "l" 540 #elif defined( MBG_TGT_QNX_NTO ) // QNX 6.x (Neutrino) 544 #include <inttypes.h> 550 #include <inttypes.h> 555 #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1 557 #define MBG_TGT_HAS_WCHAR_T 1 560 #if defined( __clang__ ) 561 #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) // works with clang 3.4.1 562 #elif ( _GCC_VERSION > 40500 ) // gcc 4.5.0 and newer 563 #define _DEPRECATED_BY( _s ) __attribute__((deprecated("use \"" _s "\" instead"))) 564 #elif ( _GCC_VERSION > 30100 ) // gcc 3.1 and newer 565 #define _DEPRECATED_BY( _s ) __attribute__((deprecated)) 570 #if ( _GCC_VERSION > 30100 ) // gcc 3.1 and newer 571 #define __mbg_inline __inline__ __attribute__((always_inline)) 574 #define __mbg_inline __inline__ 577 #elif defined( _MSC_VER ) 594 #if ( _MSC_VER >= 1910 ) 595 #error >= 1910: MSVC++ 15.0 (Visual Studio 2017), or later 596 #elif ( _MSC_VER >= 1900 ) 597 #error 1900: MSVC++ 14.0 (Visual Studio 2015) 598 #elif ( _MSC_VER >= 1800 ) 599 #error 1800: MSVC++ 12.0 (Visual Studio 2013) 600 #elif ( _MSC_VER >= 1700 ) 601 #error 1700: MSVC++ 11.0 (Visual Studio 2012) 602 #elif ( _MSC_VER >= 1600 ) 603 #error 1600: MSVC++ 10.0 (Visual Studio 2010) 604 #elif ( _MSC_VER >= 1500 ) 605 #error 1500: MSVC++ 9.0 (Visual Studio 2008) 606 #elif ( _MSC_VER >= 1400 ) 607 #error STRINGIFY( _MSC_VER ) MSVC++ 8.0 (Visual Studio 2005, Windows Server 2003 SP1 DDK - AMD64) 608 #elif ( _MSC_VER >= 1310 ) 609 #error 1310: MSVC++ 7.1 (Visual Studio .NET 2003, Windows Server 2003 DDK) 610 #elif ( _MSC_VER >= 1300 ) 611 #error 1300: MSVC++ 7.0 (Visual Studio .NET 2002, Windows XP SP1 DDK / DDK 2600) 612 #elif ( _MSC_VER >= 1200 ) 613 #error 1200: MSVC++ 6.0 614 #elif ( _MSC_VER >= 1100 ) 615 #error 1100: MSVC++ 5.0 617 #error <1100: Older than MSVC 4 630 #if ( _MSC_VER < 1900 ) 631 #if !defined( HAVE_STRUCT_TIMESPEC ) 632 #define MBG_TGT_MISSING_STRUCT_TIMESPEC 1 636 #if ( _MSC_VER >= 1600 ) // TODO Eventually even 1600 doesn't support this. 638 #include <inttypes.h> 639 #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1 641 #if !defined( PRId64 ) 642 #define MBG_PRI_64_PREFIX "I64" 645 #define MBG_TGT_HAS_INT_8_16_32 1 646 #define MBG_PRI_64_PREFIX "I64" 649 #if !defined( __cplusplus ) 651 #define MBG_TGT_MISSING_BOOL_TYPE 1 654 #define MBG_TGT_HAS_WCHAR_T 1 656 #define __mbg_inline __forceinline 662 #if ( _MSC_VER >= 1300 ) 663 #define __func__ __FUNCTION__ 665 #define __func__ FUNC_UNKNOWN 675 #if ( ( _MSC_VER >= 1500 ) || \ 676 ( ( _MSC_VER >= 1400 ) && !defined( _DDK_BUILD_ ) ) ) 677 #define _DEPRECATED_BY( _s ) __declspec(deprecated("deprecated, use \"" _s "\"")) 681 #if ( _MSC_VER >= 1310 ) 685 #if !defined( MBG_TGT_HAS_ABS64 ) 686 #define MBG_TGT_HAS_ABS64 1 690 #if !defined ( HAVE_SSIZE_T ) 693 #if ( _MSC_VER >= 1500 ) 696 typedef SSIZE_T ssize_t;
704 #define HAVE_SSIZE_T 1 706 #endif // !defined ( HAVE_SSIZE_T ) 708 #if ( _MSC_VER <= 1500 ) 711 #define MBG_TGT_MISSING_LLDIV_T 1 714 #if ( _MSC_VER <= 1400 ) 715 #define MBG_TGT_MISSING_STRTOLL 1 716 #elif ( _MSC_VER <= 1600 ) 719 #define strtoll _strtoi64 722 #elif defined( _CVI_ ) 734 #include <inttypes.h> 735 #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1 737 #define USE_LONG_FOR_INT32 1 741 #define MBG_TGT_MISSING_BOOL_TYPE 1 743 #define MBG_TGT_HAS_WCHAR_T 0 748 #elif defined( __BORLANDC__ ) // or __CODEGEARC__ in newer versions 771 #if ( __BORLANDC__ >= 0x630 ) 774 #include <inttypes.h> 776 #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1 777 #elif ( __BORLANDC__ >= 0x570 ) 780 #include <inttypes.h> 781 #define MBG_TGT_HAS_EXACT_SIZE_TYPES 1 782 #if !defined( __cplusplus ) 783 #define MBG_TGT_MISSING_BOOL_TYPE 1 785 #elif ( __BORLANDC__ >= 0x0550 ) 786 #define MBG_TGT_HAS_INT_8_16_32 1 787 #define MBG_PRI_64_PREFIX "I64" 788 #if !defined( __cplusplus ) 789 #define MBG_TGT_MISSING_BOOL_TYPE 1 791 #define __func__ FUNC_UNKNOWN 792 #else // e.g. BC 3.1 or earlier 793 #if ( __BORLANDC__ <= 0x410 ) 794 #define MBG_TGT_MISSING_64_BIT_TYPES 1 795 #define MBG_TGT_MISSING_BOOL_TYPE 1 796 #define USE_LONG_FOR_INT32 1 797 #define MBG_TGT_MISSING_STRUCT_TIMESPEC 1 798 #define __func__ __FILE__ ":" STRINGIFY(__LINE__) 804 #if ( __BORLANDC__ <= 0x0550 ) 806 #define MBG_TGT_MISSING_STRTOLL 1 807 #define MBG_TGT_MISSING_LLDIV_T 1 810 #define MBG_TGT_HAS_WCHAR_T defined( MBG_TGT_WIN32 ) 812 #define MBG_TGT_MISSING_STRUCT_TIMESPEC 1 814 #if defined( __cplusplus ) 815 #define __mbg_inline inline // standard C++ syntax 816 #elif ( __BORLANDC__ > 0x410 ) // BC3.1 defines 0x410 ! 817 #define __mbg_inline __inline // newer BC versions support this for C 819 #define __mbg_inline // up to BC3.1 not supported for C 822 #if !defined ( HAVE_SSIZE_T ) 824 #define HAVE_SSIZE_T 1 827 #elif defined( __WATCOMC__ ) 835 #if defined( MBG_TGT_QNX ) // QNX 4.x 837 #include <sys/types.h> 839 #define MBG_TGT_MISSING_64_BIT_TYPES 1 841 #elif ( __WATCOMC__ > 1230 ) // Open Watcom C 1.3 and above 844 #include <inttypes.h> 846 #elif !defined( __WATCOM_INT64__ ) // Watcom C 11 848 #define MBG_TGT_MISSING_64_BIT_TYPES 1 852 #define MBG_TGT_HAS_WCHAR_T defined( MBG_TGT_WIN32 ) 854 #define __mbg_inline _inline 859 #if !defined( MBG_TGT_USE_IOCTL ) 860 #define MBG_TGT_USE_IOCTL 0 870 #if defined( MBG_PRI_64_PREFIX ) 871 #define PRIi64 MBG_PRI_64_PREFIX "i" 872 #define PRId64 MBG_PRI_64_PREFIX "d" 873 #define PRIo64 MBG_PRI_64_PREFIX "o" 874 #define PRIu64 MBG_PRI_64_PREFIX "u" 875 #define PRIx64 MBG_PRI_64_PREFIX "x" 876 #define PRIX64 MBG_PRI_64_PREFIX "X" 879 #if !defined( __GNUC__ ) && !defined( __attribute__ ) 880 #define __attribute__( _x ) 883 #if !defined( _DEPRECATED_BY ) 884 #define _DEPRECATED_BY( _s ) // empty definition 888 #if defined( MBG_TGT_WIN32 ) 890 #if defined( _AMD64_ ) 893 #define MBG_TGT_WIN32_PNP_X64 894 #define WIN32_FLAVOR "x64" 895 #elif defined( _IA64_ ) 896 #define MBG_TGT_WIN32_PNP_IA64 897 #define WIN32_FLAVOR "ia64" 901 #define MBG_TGT_KERNEL 905 #if defined( DBG ) && DBG 914 #if !defined( WIN32_LEAN_AND_MEAN ) 915 #define WIN32_LEAN_AND_MEAN 1 918 #include <winsock2.h> 920 #include <ws2tcpip.h> 924 #define MBG_INVALID_HANDLE INVALID_HANDLE_VALUE 926 #if defined( MBG_TGT_CVI ) 929 #define MBG_INVALID_PORT_HANDLE -1 939 typedef DWORD DWORD_PTR;
943 #if ( _MSC_VER < 1500 ) 945 typedef int socklen_t;
948 #define _MBG_API WINAPI 952 #if !defined( MBG_TGT_MINGW ) // not required for MinGW 953 #if defined( MBG_LIB_EXPORT ) 954 #define _MBG_API_ATTR __declspec( dllexport ) 956 #define _MBG_API_ATTR __declspec( dllimport ) 960 #elif defined( MBG_TGT_POSIX ) 962 #if !defined( MBG_TGT_KERNEL ) 969 #define MBG_INVALID_HANDLE -1 976 #define MBG_INVALID_HANDLE -1 984 #if defined( MBG_TGT_WIN32 ) && !defined( MBG_TGT_MINGW ) 985 #if !defined( MBG_TGT_KERNEL ) // we don't need this in kernel space 990 #elif defined( MBG_TGT_POSIX ) 1000 #if defined( MBG_TGT_WIN32 ) 1001 #define MBG_INVALID_SOCK_FD INVALID_SOCKET // usually evaluates to (SOCKET)(~0) since SOCKET is unsigned 1002 #elif defined( MBG_TGT_POSIX ) 1003 #define MBG_INVALID_SOCK_FD -1 1011 #if defined( MBG_TGT_WIN32 ) 1012 #define MBG_SOCKET_ERR_RETVAL SOCKET_ERROR // usually evaluates to -1 1013 #elif defined( MBG_TGT_POSIX ) 1014 #define MBG_SOCKET_ERR_RETVAL -1 1019 #if !defined( _MBG_API ) 1023 #if !defined( _MBG_API_ATTR ) 1024 #define _MBG_API_ATTR 1027 #if !defined( _NO_MBG_API ) 1031 #if !defined( _NO_MBG_API_ATTR ) 1032 #define _NO_MBG_API_ATTR 1035 #if !defined( MBG_INVALID_PORT_HANDLE ) 1036 #define MBG_INVALID_PORT_HANDLE MBG_INVALID_HANDLE 1039 #if !defined( MBG_TGT_HAS_DEV_FN ) 1040 #define MBG_TGT_HAS_DEV_FN 0 1043 #if !defined( MBG_TGT_HAS_DEV_FN_BASE ) 1044 #define MBG_TGT_HAS_DEV_FN_BASE 0 1047 #if defined( MBG_TGT_MISSING_STRUCT_TIMESPEC ) 1057 #endif // defined( MBG_TGT_MISSING_STRUCT_TIMESPEC ) 1062 #if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199409L ) 1063 #define MBG_TGT_C94 1 1065 #define MBG_TGT_C94 0 1069 #if defined( __STDC_VERSION__ ) && ( __STDC_VERSION__ >= 199901L ) 1070 #define MBG_TGT_C99 1 1072 #define MBG_TGT_C99 0 1076 #if !defined( MBG_TGT_HAS_WCHAR_T ) 1077 #define MBG_TGT_HAS_WCHAR_T ( MBG_TGT_C94 || defined( WCHAR_MAX ) ) 1080 #if !MBG_TGT_HAS_WCHAR_T 1084 #if !defined( _WCHAR_T ) \ 1085 && !defined( _WCHAR_T_DEFINED_ ) 1087 #define wchar_t char 1110 #endif // !defined( MBG_TGT_NO_TGT ) 1112 #endif // !defined( _MBG_TGT_H )
int MBG_SOCK_FD
A socket file descriptor type.