10 #include "daqc_private.h"
16 #define INT32_MAX ( std::numeric_limits< int32_t >::max( ) )
29 void socket_io_non_blocking( nds_socket_type Socket );
30 void socket_io_default( nds_socket_type Socket );
32 void pstrerror_r(
char* StrErrBuf,
size_t StrErrBufLen );
35 template <
typename DEST,
typename SOURCE >
37 check_int_overflow( SOURCE Source )
39 if (
sizeof( DEST ) <
sizeof( SOURCE ) )
41 switch (
sizeof( DEST ) )
44 if ( Source > INT32_MAX )
46 throw std::overflow_error(
47 "Rounding error resulting from integer truncation" );
51 return static_cast< DEST
>( Source );
61 #define DLL_EXPORT __declspec( dllexport )
65 typedef size_t ssize_t;
66 typedef int socklen_t;
71 #define F_OK ( (int)0 )
72 #define W_OK ( (int)2 )
75 close( nds_socket_type s )
77 return closesocket( s );
85 fdopen(
int fd,
const char* mode )
87 return _fdopen( fd, mode );
90 read( nds_socket_type s,
void* buf,
size_t len )
93 s, reinterpret_cast< char* >( buf ), static_cast< int >( len ), 0 );
98 Sleep( seconds * 1000 );
101 usleep(
int microseconds )
103 Sleep( microseconds / 1000 );
105 static inline ssize_t
106 write( nds_socket_type s,
const void* buf,
size_t count )
109 reinterpret_cast< const char* >( buf ),
110 static_cast< int >( count ),
114 static inline errno_t
115 strerror_r(
int errnum,
char* buf,
size_t buflen )
117 return strerror_s( buf, buflen, errnum );
120 #define perror( message ) nds_perror( message )
124 #define close( fd ) closesocket( fd )
125 #define dup( oldfd ) _dup( oldfd )
126 #define fdopen( path, mode ) _fdopen( path, mode )
127 #define read( fd, buf, len ) recv( fd, buf, len, 0 )
128 #define sleep( Seconds ) Sleep( Seconds * 1000 )
129 #define usleep( MicroSeconds ) Sleep( MicroSeconds / 1000 )
130 #define write( fd, buf, count ) send( fd, buf, count, 0 )
131 #define perror( message ) nds_perror( message )
132 #define unlink( filename ) _unlink( filename )
134 #define strerror_r( a, b, c ) strerror_s( b, c, a )
137 #define access( path, mode ) _access( path, mode )
138 #define strdup( str ) _strdup( str )
146 #define strncpy_s( dest, dest_len, src, count ) strncpy( dest, src, count )
148 #define strcpy_s( dest, dest_len, src ) strcpy( dest, src )