Various changes for MingWin32 support.
This commit is contained in:
parent
9ff6934c83
commit
eca2afb982
@ -77,9 +77,10 @@ if test -d /opt/X11R6 ; then
|
||||
fi
|
||||
|
||||
if test "x$ac_cv_header_windows_h" = "xyes" ; then
|
||||
if test -d /usr/mingw/usr ; then
|
||||
EXTRA_DIRS="$EXTRA_DIRS /usr/mingw/usr"
|
||||
fi
|
||||
EXTRA_DIRS="${EXTRA_DIRS} `pwd`/Win32"
|
||||
# elif test `uname -s` = "SunOS" ; then
|
||||
# EXTRA_DIRS="${EXTRA_DIRS} `pwd`/SunOS"
|
||||
fi
|
||||
wi_EXTRA_DIRS(no, ${EXTRA_DIRS})
|
||||
|
||||
|
@ -139,6 +139,11 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined( __MINGW32__ )
|
||||
# define bcopy(from, to, n) memcpy(to, from, n)
|
||||
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
||||
#endif
|
||||
|
||||
/* KAI C++ */
|
||||
#if defined(__KCC)
|
||||
|
||||
|
@ -551,7 +551,7 @@ bool SGBinObject::write_bin( const string& base, const string& name,
|
||||
|
||||
string dir = base + "/" + b.gen_base_path();
|
||||
string command = "mkdir -p " + dir;
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
system( (string("mkdir ") + dir).c_str() );
|
||||
#else
|
||||
system(command.c_str());
|
||||
@ -828,7 +828,7 @@ bool SGBinObject::write_ascii( const string& base, const string& name,
|
||||
|
||||
string dir = base + "/" + b.gen_base_path();
|
||||
string command = "mkdir -p " + dir;
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
system( (string("mkdir ") + dir).c_str() );
|
||||
#else
|
||||
system(command.c_str());
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
@ -51,7 +51,7 @@ bool SGFile::open( const SGProtocolDir d ) {
|
||||
set_dir( d );
|
||||
|
||||
if ( get_dir() == SG_IO_OUT ) {
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
int mode = 00666;
|
||||
#else
|
||||
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
# include <sys/time.h> // select()
|
||||
# include <sys/types.h> // socket(), bind(), select(), accept()
|
||||
# include <sys/socket.h> // socket(), bind(), listen(), accept()
|
||||
@ -48,7 +48,7 @@ SGSocket::SGSocket( const string& host, const string& port,
|
||||
port_str(port),
|
||||
save_len(0)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
if (!wsock_init && !wsastartup()) {
|
||||
SG_LOG( SG_IO, SG_ALERT, "Winsock not available");
|
||||
}
|
||||
@ -75,7 +75,7 @@ SGSocket::~SGSocket() {
|
||||
SGSocket::SocketType SGSocket::make_server_socket () {
|
||||
struct sockaddr_in name;
|
||||
|
||||
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) || defined( sgi ) || defined( _MSC_VER )
|
||||
#if defined( __CYGWIN__ ) || defined( __CYGWIN32__ ) || defined( sgi ) || defined( _MSC_VER ) || defined(__MINGW32__)
|
||||
int length;
|
||||
#else
|
||||
socklen_t length;
|
||||
@ -161,7 +161,7 @@ SGSocket::SocketType SGSocket::make_client_socket () {
|
||||
|
||||
// Wrapper functions
|
||||
size_t SGSocket::readsocket( int fd, void *buf, size_t count ) {
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
return ::recv( fd, (char *)buf, count, 0 );
|
||||
#else
|
||||
return ::read( fd, buf, count );
|
||||
@ -169,14 +169,14 @@ size_t SGSocket::readsocket( int fd, void *buf, size_t count ) {
|
||||
}
|
||||
|
||||
size_t SGSocket::writesocket( int fd, const void *buf, size_t count ) {
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
return ::send( fd, (const char*)buf, count, 0 );
|
||||
#else
|
||||
return ::write( fd, buf, count );
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
int SGSocket::closesocket( int fd ) {
|
||||
return ::close( fd );
|
||||
}
|
||||
@ -504,7 +504,7 @@ bool SGSocket::nonblock() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
u_long arg = 1;
|
||||
if (ioctlsocket( sock, FIONBIO, &arg ) != 0) {
|
||||
int error_code = WSAGetLastError();
|
||||
@ -519,7 +519,7 @@ bool SGSocket::nonblock() {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
|
||||
bool SGSocket::wsock_init = false;
|
||||
|
||||
|
@ -41,8 +41,8 @@
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <winsock.h>
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#define SG_MAX_SOCKET_QUEUE 32
|
||||
@ -53,7 +53,7 @@ SG_USING_STD(string);
|
||||
*/
|
||||
class SGSocket : public SGIOChannel {
|
||||
public:
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
typedef SOCKET SocketType;
|
||||
#else
|
||||
typedef int SocketType;
|
||||
@ -83,11 +83,11 @@ private:
|
||||
// wrapper functions
|
||||
size_t readsocket( int fd, void *buf, size_t count );
|
||||
size_t writesocket( int fd, const void *buf, size_t count );
|
||||
#if !defined(_MSC_VER)
|
||||
#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
int closesocket(int fd);
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
// Ensure winsock has been initialised.
|
||||
static bool wsock_init;
|
||||
static bool wsastartup();
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
# include <time.h>
|
||||
#else
|
||||
# include <sys/time.h>
|
||||
|
@ -193,7 +193,7 @@ static double sidereal_course( time_t cur_time, struct tm *gmt, double lng )
|
||||
void SGTime::update( double lon, double lat, long int warp ) {
|
||||
double gst_precise, gst_course;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
tm * gmt = &m_gmt;
|
||||
#endif
|
||||
|
||||
@ -207,7 +207,7 @@ void SGTime::update( double lon, double lat, long int warp ) {
|
||||
<< " warp = " << warp );
|
||||
|
||||
// get GMT break down for current time
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
|
||||
#else
|
||||
gmt = gmtime(&cur_time);
|
||||
@ -333,13 +333,14 @@ double sgTimeCalcMJD(int mn, double dy, int yr) {
|
||||
// return the current modified Julian date (number of days elapsed
|
||||
// since 1900 jan 0.5), mjd.
|
||||
double sgTimeCurrentMJD( long int warp ) {
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
struct tm m_gmt; // copy of system gmtime(&time_t) structure
|
||||
#else
|
||||
struct tm *gmt;
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
tm * gmt = &m_gmt;
|
||||
#endif
|
||||
|
||||
@ -351,7 +352,7 @@ double sgTimeCurrentMJD( long int warp ) {
|
||||
<< " warp = " << warp );
|
||||
|
||||
// get GMT break down for current time
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
memcpy( gmt, gmtime(&cur_time), sizeof(tm) );
|
||||
#else
|
||||
gmt = gmtime(&cur_time);
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
time_t cur_time;
|
||||
|
||||
// Break down of equivalent GMT time
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
struct tm m_gmt; // copy of system gmtime(&time_t) structure
|
||||
#else
|
||||
struct tm *gmt;
|
||||
@ -166,7 +166,7 @@ public:
|
||||
inline char* get_zonename() const { return zonename; }
|
||||
|
||||
/** @return GMT in a "brokent down" tm structure */
|
||||
#ifdef _MSC_VER
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
inline struct tm* getGmt()const { return (struct tm *)&m_gmt; };
|
||||
#else
|
||||
inline struct tm* getGmt()const { return gmt; };
|
||||
|
Loading…
Reference in New Issue
Block a user