Several fixes for compiling Bochs successfully in Cygwin64

This commit is contained in:
Volker Ruppert 2013-11-01 18:19:52 +00:00
parent 5b9d937cc1
commit f8ea396a2c
13 changed files with 55 additions and 43 deletions

View File

@ -70,10 +70,11 @@ IMPLEMENT_GUI_PLUGIN_CODE(rfb)
#define LOG_THIS theGui->
#ifdef WIN32
#if defined(WIN32) && !defined(__CYGWIN__)
#include <winsock.h>
#include <process.h>
#define BX_RFB_WIN32
#else
@ -183,7 +184,7 @@ static SOCKET sGlobal;
static Bit32u clientEncodingsCount = 0;
static Bit32u *clientEncodings = NULL;
#ifdef WIN32
#ifdef BX_RFB_WIN32
bool StopWinsock();
#endif
void rfbStartThread();
@ -202,7 +203,7 @@ void rfbSetStatusText(int element, const char *text, bx_bool active, bx_bool w =
static Bit32u convertStringToRfbKey(const char *string);
void rfbKeyPressed(Bit32u key, int press_release);
void rfbMouseMove(int x, int y, int bmask);
#if BX_SHOW_IPS && defined(WIN32)
#if BX_SHOW_IPS && defined(BX_RFB_WIN32)
DWORD WINAPI rfbShowIPSthread(LPVOID);
#endif
@ -301,7 +302,7 @@ void bx_rfb_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
desktop_resizable = 0;
rfbStartThread();
#ifdef WIN32
#ifdef BX_RFB_WIN32
Sleep(1000);
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
#endif
@ -317,7 +318,7 @@ void bx_rfb_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
if (timeout > 0) {
while ((!client_connected) && (timeout--)) {
fprintf(stderr, "Bochs RFB server waiting for client: %2d\r", timeout+1);
#ifdef WIN32
#ifdef BX_RFB_WIN32
Sleep(1000);
#else
sleep(1);
@ -330,7 +331,7 @@ void bx_rfb_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
}
}
#if BX_SHOW_IPS && defined(WIN32)
#if BX_SHOW_IPS && defined(BX_RFB_WIN32)
if (!rfbHideIPS) {
DWORD threadID;
CreateThread(NULL, 0, rfbShowIPSthread, NULL, 0, &threadID);
@ -766,7 +767,7 @@ void bx_rfb_gui_c::exit(void)
{
unsigned int i;
keep_alive = 0;
#ifdef WIN32
#ifdef BX_RFB_WIN32
StopWinsock();
#endif
free(rfbScreen);
@ -867,7 +868,7 @@ void bx_rfb_gui_c::show_ips(Bit32u ips_count)
// RFB specific functions
#ifdef WIN32
#ifdef BX_RFB_WIN32
bool InitWinsock()
{
WSADATA wsaData;
@ -891,7 +892,7 @@ void CDECL rfbServerThreadInit(void *indata)
int port_ok = 0;
int one=1;
#ifdef WIN32
#ifdef BX_RFB_WIN32
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
if(!InitWinsock()) {
BX_PANIC(("could not initialize winsock."));
@ -946,7 +947,7 @@ void CDECL rfbServerThreadInit(void *indata)
}
end_of_thread:
#ifdef WIN32
#ifdef BX_RFB_WIN32
StopWinsock();
#endif
return;
@ -954,7 +955,7 @@ end_of_thread:
void rfbStartThread()
{
#ifdef WIN32
#ifdef BX_RFB_WIN32
_beginthread(rfbServerThreadInit, 0, NULL);
#else
pthread_t thread;
@ -1833,7 +1834,7 @@ void rfbMouseMove(int x, int y, int bmask)
}
}
#if BX_SHOW_IPS && defined(WIN32)
#if BX_SHOW_IPS && defined(BX_RFB_WIN32)
VOID CALLBACK IPSTimerProc(HWND hWnd, UINT nMsg, UINT_PTR nIDEvent, DWORD dwTime)
{
if (keep_alive) {

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002-2012 The Bochs Project
// Copyright (C) 2002-2013 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -98,7 +98,7 @@ static int ms_lastx=0, ms_lasty=0;
static int ms_savedx=0, ms_savedy=0;
static BOOL mouseCaptureMode, mouseCaptureNew, mouseToggleReq;
static BOOL win32MouseModeAbsXY = 0;
static UINT_PTR workerThread = 0;
static HANDLE workerThread = 0;
static DWORD workerThreadID = 0;
static int mouse_buttons = 3;
static bx_bool win32_nokeyrepeat = 0;
@ -197,7 +197,7 @@ sharedThreadInfo stInfo;
LRESULT CALLBACK mainWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK simWndProc (HWND, UINT, WPARAM, LPARAM);
VOID CDECL UIThread(PVOID);
DWORD WINAPI UIThread(PVOID);
void SetStatusText(unsigned Num, const char *Text, bx_bool active, bx_bool w=0);
void terminateEmul(int);
void create_vga_font(void);
@ -701,7 +701,7 @@ void bx_win32_gui_c::specific_init(int argc, char **argv, unsigned headerbar_y)
}
if (stInfo.hInstance)
workerThread = _beginthread (UIThread, 0, NULL);
workerThread = CreateThread(NULL, 0, UIThread, NULL, 0, &workerThreadID);
else
terminateEmul(EXIT_GMH_FAILURE);
@ -795,7 +795,7 @@ void resize_main_window()
}
// This thread controls the GUI window.
VOID CDECL UIThread(PVOID pvoid)
DWORD WINAPI UIThread(LPVOID)
{
MSG msg;
HDC hdc;
@ -943,7 +943,7 @@ VOID CDECL UIThread(PVOID pvoid)
stInfo.kill = EXIT_GUI_SHUTDOWN;
_endthread();
return 0;
}
void SetStatusText(unsigned Num, const char *Text, bx_bool active, bx_bool w)

View File

@ -36,7 +36,7 @@
#include <sys/socket.h>
#include <sys/wait.h>
#include <stdint.h>
#ifndef WIN32
#if !defined(WIN32) || defined(__CYGWIN__)
#include <arpa/inet.h> /* ntohs, htons */
#else
#include <winsock.h>

View File

@ -43,7 +43,7 @@
#define BX_ETH_VNET_LOGGING 1
#define BX_ETH_VNET_PCAP_LOGGING 0
#ifndef WIN32
#if !defined(WIN32) || defined(__CYGWIN__)
#include <arpa/inet.h> /* ntohs, htons */
#else
#include <winsock.h>

View File

@ -2,7 +2,7 @@
// $Id$
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2011 The Bochs Project
// Copyright (C) 2001-2013 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -42,7 +42,9 @@
#if BX_NETWORKING && BX_NETMOD_WIN32
#ifndef __CYGWIN__
#include <winsock.h>
#endif
// windows.h included by bochs.h
#define LOG_THIS netdev->

View File

@ -35,7 +35,7 @@
#include "netmod.h"
#ifndef WIN32
#if !defined(WIN32) || defined(__CYGWIN__)
#include <arpa/inet.h> /* ntohs, htons */
#else
#include <winsock.h>

View File

@ -30,7 +30,7 @@
// is used to know when we are exporting symbols and when we are importing.
#define BX_PLUGGABLE
#ifndef WIN32
#if !defined(WIN32) || defined(__CYGWIN__)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
@ -39,6 +39,7 @@
typedef int SOCKET;
#else
#include <winsock.h>
#define BX_SER_WIN32
#endif
#include "iodev.h"
@ -201,7 +202,7 @@ bx_serial_c::~bx_serial_c(void)
fclose(BX_SER_THIS s[i].output);
break;
case BX_SER_MODE_TERM:
#if defined(SERIAL_ENABLE) && !defined(WIN32)
#if defined(SERIAL_ENABLE) && !defined(BX_SER_WIN32)
if (s[i].tty_id >= 0) {
tcsetattr(s[i].tty_id, TCSAFLUSH, &s[i].term_orig);
}
@ -218,7 +219,7 @@ bx_serial_c::~bx_serial_c(void)
break;
case BX_SER_MODE_PIPE_CLIENT:
case BX_SER_MODE_PIPE_SERVER:
#ifdef WIN32
#ifdef BX_SER_WIN32
if (BX_SER_THIS s[i].pipe)
CloseHandle(BX_SER_THIS s[i].pipe);
#endif
@ -369,7 +370,7 @@ bx_serial_c::init(void)
BX_SER_THIS s[i].io_mode = BX_SER_MODE_FILE;
}
} else if (mode == BX_SER_MODE_TERM) {
#if defined(SERIAL_ENABLE) && !defined(WIN32)
#if defined(SERIAL_ENABLE) && !defined(BX_SER_WIN32)
if (strlen(dev) > 0) {
BX_SER_THIS s[i].tty_id = open(dev, O_RDWR|O_NONBLOCK,600);
if (BX_SER_THIS s[i].tty_id < 0) {
@ -428,7 +429,7 @@ bx_serial_c::init(void)
SOCKET socket;
bx_bool server = (mode == BX_SER_MODE_SOCKET_SERVER);
#if defined(WIN32)
#ifdef BX_SER_WIN32
static bx_bool winsock_init = false;
if (!winsock_init) {
WORD wVersionRequested;
@ -499,7 +500,7 @@ bx_serial_c::init(void)
(mode == BX_SER_MODE_PIPE_SERVER)) {
if (strlen(dev) > 0) {
bx_bool server = (mode == BX_SER_MODE_PIPE_SERVER);
#ifdef WIN32
#ifdef BX_SER_WIN32
HANDLE pipe;
BX_SER_THIS s[i].io_mode = mode;
@ -1424,7 +1425,7 @@ void bx_serial_c::tx_timer(void)
case BX_SER_MODE_SOCKET_CLIENT:
case BX_SER_MODE_SOCKET_SERVER:
if (BX_SER_THIS s[port].socket_id >= 0) {
#ifdef WIN32
#ifdef BX_SER_WIN32
BX_INFO(("attempting to write win32 : %c", BX_SER_THIS s[port].tsrbuffer));
::send(BX_SER_THIS s[port].socket_id,
(const char*) & BX_SER_THIS s[port].tsrbuffer, 1, 0);
@ -1436,7 +1437,7 @@ void bx_serial_c::tx_timer(void)
break;
case BX_SER_MODE_PIPE_CLIENT:
case BX_SER_MODE_PIPE_SERVER:
#ifdef WIN32
#ifdef BX_SER_WIN32
if (BX_SER_THIS s[port].pipe) {
DWORD written;
WriteFile(BX_SER_THIS s[port].pipe, (bx_ptr_t)& BX_SER_THIS s[port].tsrbuffer, 1, &written, NULL);
@ -1528,7 +1529,7 @@ void bx_serial_c::rx_timer(void)
if (socketid >= 0) FD_SET(socketid, &fds);
if ((socketid >= 0) && (select(socketid+1, &fds, NULL, NULL, &tval) == 1)) {
ssize_t bytes = (ssize_t)
#ifdef WIN32
#ifdef BX_SER_WIN32
::recv(socketid, (char*) &chbuf, 1, 0);
#else
read(socketid, &chbuf, 1);
@ -1603,7 +1604,7 @@ void bx_serial_c::rx_timer(void)
break;
case BX_SER_MODE_PIPE_CLIENT:
case BX_SER_MODE_PIPE_SERVER:
#ifdef WIN32
#ifdef BX_SER_WIN32
DWORD avail = 0;
if (BX_SER_THIS s[port].pipe &&
PeekNamedPipe(BX_SER_THIS s[port].pipe, NULL, 0, NULL, &avail, NULL) &&

View File

@ -33,11 +33,11 @@
# define BX_SER_THIS this->
#endif
#if defined(WIN32)
#ifdef BX_SER_WIN32
#define SERIAL_ENABLE
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__APPLE__) || defined(__sun__)
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__APPLE__) || defined(__sun__) || defined(__CYGWIN__)
#define SERIAL_ENABLE
extern "C" {
#include <termios.h>
@ -116,14 +116,14 @@ typedef struct {
int tty_id;
SOCKET socket_id;
FILE *output;
#ifdef WIN32
#ifdef BX_SER_WIN32
HANDLE pipe;
#endif
#if USE_RAW_SERIAL
serial_raw* raw;
#endif
#if defined(SERIAL_ENABLE) && !defined(WIN32)
#if defined(SERIAL_ENABLE) && !defined(BX_SER_WIN32)
struct termios term_orig, term_new;
#endif

View File

@ -21,7 +21,7 @@
/* Commits a redolog file to a 'flat' or 'growing' mode base image. */
/* Converts growing mode image to flat and vice versa */
#ifdef WIN32
#if defined(WIN32) && !defined(__CYGWIN__)
# include <conio.h>
#endif
#include <sys/types.h>
@ -109,7 +109,7 @@ const char *main_menu_prompt =
void myexit(int code)
{
#ifdef WIN32
#if defined(WIN32) && !defined(__CYGWIN__)
printf("\nPress any key to continue\n");
getch();
#endif

View File

@ -58,7 +58,7 @@
#include "config.h"
#include "bxcompat.h"
#ifdef WIN32
#if defined(WIN32) && !defined(__CYGWIN__)
# include <conio.h>
# include <winioctl.h>
#endif
@ -171,7 +171,7 @@ int bx_mkstemp(char *tpl)
void myexit(int code)
{
#ifdef WIN32
#if defined(WIN32) && !defined(__CYGWIN__)
printf("\nPress any key to continue\n");
getch();
#endif

View File

@ -21,7 +21,9 @@
/* Create empty hard disk or floppy disk images for bochs. */
#ifdef WIN32
#ifndef __CYGWIN__
# include <conio.h>
#endif
# include <windows.h>
# include <winioctl.h>
#ifdef _MSC_VER
@ -80,7 +82,7 @@ int hdmode_n_choices = 3;
void myexit(int code)
{
#ifdef WIN32
#if defined(WIN32) && !defined(__CYGWIN__)
printf("\nPress any key to continue\n");
getch();
#endif

View File

@ -18,7 +18,11 @@
#include <windows.h>
#include <stdio.h>
#ifdef __CYGWIN__
#include <wchar.h>
#else
#include <conio.h>
#endif
#include <stdlib.h>
#if defined(_MSC_VER)
@ -48,8 +52,10 @@ PCHAR (*PacketGetVersion)() = NULL;
void myexit (int code)
{
#ifndef __CYGWIN__
printf ("\nPress any key to continue\n");
getch();
#endif
exit(code);
}
@ -59,7 +65,7 @@ int CDECL main(int argc, char **argv)
HINSTANCE hPacket;
DWORD dwVersion, dwMajorVersion;
char AdapterInfo[NIC_BUFFER_SIZE] = { '\0','\0' };
unsigned long AdapterLength = NIC_BUFFER_SIZE;
ULONG AdapterLength = NIC_BUFFER_SIZE;
LPWSTR wstrName;
LPSTR strName, strDesc;
int nAdapterCount;

View File

@ -71,6 +71,7 @@ extern "C" {
# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
#endif
#if defined(_MSC_VER)
// win32 has snprintf though with different name.
#define snprintf _snprintf
#define vsnprintf _vsnprintf
@ -79,7 +80,6 @@ extern "C" {
#define BX_HAVE_SNPRINTF 1
#define BX_HAVE_VSNPRINTF 1
#if defined(_MSC_VER)
#define access _access
#define fdopen _fdopen
#define mktemp _mktemp