diff --git a/bochs/config.cc b/bochs/config.cc index 6fa81c146..f57ab2bf3 100644 --- a/bochs/config.cc +++ b/bochs/config.cc @@ -128,7 +128,7 @@ static Bit64s bx_param_handler(bx_param_c *param, bool set, Bit64s val) val = get_floppy_type_from_image(SIM->get_param_string("path", base)->getptr()); SIM->get_param_enum("type", base)->set(val); } else if (!SIM->get_init_done() && (val != BX_FLOPPY_NONE)) { - device = get_floppy_devtype_from_type(val); + device = get_floppy_devtype_from_type((int)val); SIM->get_param_enum("devtype", base)->set(device); } } @@ -2361,7 +2361,7 @@ int bx_split_option_list(const char *msg, const char *rawopt, char **argv, int m strcpy(tmpstr, ptr); ptr2 = tmpstr; while (isspace(*ptr2)) ptr2++; - i = strlen(ptr2) - 1; + i = (int)strlen(ptr2) - 1; while ((i >= 0) && isspace(ptr2[i])) { ptr2[i] = 0; i--; @@ -3029,7 +3029,7 @@ static int parse_line_formatted(const char *context, int num_params, char *param &tm_time.tm_hour, &tm_time.tm_min, &tm_time.tm_sec, &year); if ((n == 7) && (year >= 1980) && (strstr(months, mon) != NULL)) { tm_time.tm_year = year - 1900; - tm_time.tm_mon = 12 - (strlen(strstr(months, mon)) / 4); + tm_time.tm_mon = 12 - ((int)strlen(strstr(months, mon)) / 4); SIM->get_param_num(BXPN_CLOCK_TIME0)->set(mktime(&tm_time)); } else { PARSE_ERR(("%s: time0 string format malformed.", context)); diff --git a/bochs/config.h.in b/bochs/config.h.in index 73883bd13..4dee8c0a5 100644 --- a/bochs/config.h.in +++ b/bochs/config.h.in @@ -85,6 +85,15 @@ #define BX_SHOW_IPS 0 +#define MSVC_TARGET 0 +#if defined(_MSC_VER) && defined(MSVC_TARGET) +#if defined(_M_X64) && (MSVC_TARGET != 64) +#error Bochs not configured for MSVC WIN64 +#elif !defined(_M_X64) && (MSVC_TARGET != 32) +#error Bochs not configured for MSVC WIN32 +#endif +#endif + #if (BX_SHOW_IPS) && (defined(__MINGW32__) || defined(_MSC_VER)) #define SIGALRM 14 #endif diff --git a/bochs/configure.in b/bochs/configure.in index 4e71e78ee..3595ce45c 100644 --- a/bochs/configure.in +++ b/bochs/configure.in @@ -48,9 +48,11 @@ case "$target" in case "$target" in x86_64*) MSVC_TARGET=64 + AC_DEFINE(MSVC_TARGET, 64) ;; *) MSVC_TARGET=32 + AC_DEFINE(MSVC_TARGET, 32) ;; esac ;; diff --git a/bochs/iodev/network/e1000.cc b/bochs/iodev/network/e1000.cc index f71f31ab4..0e59fd854 100644 --- a/bochs/iodev/network/e1000.cc +++ b/bochs/iodev/network/e1000.cc @@ -1503,7 +1503,7 @@ void bx_e1000_c::rx_frame(const void *buf, unsigned buf_size) if (copy_size > BX_E1000_THIS s.rxbuf_size) { copy_size = BX_E1000_THIS s.rxbuf_size; } - DEV_MEM_WRITE_PHYSICAL_DMA(le64_to_cpu(desc.buffer_addr), copy_size, + DEV_MEM_WRITE_PHYSICAL_DMA(le64_to_cpu(desc.buffer_addr), (unsigned)copy_size, (Bit8u *)buf + desc_offset + vlan_offset); } desc_offset += desc_size; diff --git a/bochs/iodev/pci_ide.cc b/bochs/iodev/pci_ide.cc index ffc097ed7..d4df1d286 100644 --- a/bochs/iodev/pci_ide.cc +++ b/bochs/iodev/pci_ide.cc @@ -267,7 +267,7 @@ void bx_pci_ide_c::timer() } if (BX_PIDE_THIS s.bmdma[channel].cmd_rwcon) { BX_DEBUG(("READ DMA to addr=0x%08x, size=0x%08x", prd.addr, size)); - count = size - (BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx); + count = (int)(size - (BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx)); while (count > 0) { sector_size = count; if (DEV_hd_bmdma_read_sector(channel, BX_PIDE_THIS s.bmdma[channel].buffer_top, §or_size)) { @@ -288,7 +288,7 @@ void bx_pci_ide_c::timer() BX_DEBUG(("WRITE DMA from addr=0x%08x, size=0x%08x", prd.addr, size)); DEV_MEM_READ_PHYSICAL_DMA(prd.addr, size, BX_PIDE_THIS s.bmdma[channel].buffer_top); BX_PIDE_THIS s.bmdma[channel].buffer_top += size; - count = BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx; + count = (int)(BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx); while (count > 511) { if (DEV_hd_bmdma_write_sector(channel, BX_PIDE_THIS s.bmdma[channel].buffer_idx)) { BX_PIDE_THIS s.bmdma[channel].buffer_idx += 512; @@ -309,7 +309,7 @@ void bx_pci_ide_c::timer() DEV_hd_bmdma_complete(channel); } else { // To avoid buffer overflow reset buffer pointers and copy data if necessary - count = BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx; + count = (int)(BX_PIDE_THIS s.bmdma[channel].buffer_top - BX_PIDE_THIS s.bmdma[channel].buffer_idx); if (count > 0) { memmove(BX_PIDE_THIS s.bmdma[channel].buffer, BX_PIDE_THIS s.bmdma[channel].buffer_idx, count); } diff --git a/bochs/iodev/serial.cc b/bochs/iodev/serial.cc index 81bf47772..a2eb5f0a9 100644 --- a/bochs/iodev/serial.cc +++ b/bochs/iodev/serial.cc @@ -1551,7 +1551,7 @@ void bx_serial_c::rx_timer(void) SOCKET socketid = BX_SER_THIS s[port].socket_id; if (socketid >= 0) { FD_SET(socketid, &fds); - if (select(socketid+1, &fds, NULL, NULL, &tval) == 1) { + if (select((int)(socketid+1), &fds, NULL, NULL, &tval) == 1) { ssize_t bytes = (ssize_t) ::recv(socketid, (char*) &chbuf, 1, 0); if (bytes > 0) { diff --git a/bochs/iodev/usb/scsi_device.cc b/bochs/iodev/usb/scsi_device.cc index 96cb75ca0..1c76ce1eb 100644 --- a/bochs/iodev/usb/scsi_device.cc +++ b/bochs/iodev/usb/scsi_device.cc @@ -282,7 +282,7 @@ void scsi_device_t::restore_requests(const char *path) do { ret = fgets(line, sizeof(line)-1, fp); line[sizeof(line) - 1] = '\0'; - int len = strlen(line); + size_t len = strlen(line); if ((len > 0) && (line[len-1] < ' ')) line[len-1] = '\0'; i = 0; @@ -628,8 +628,8 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun, bool as case 0x83: { // Device identification page, mandatory - int max_len = 255 - 8; - int id_len = strlen(DEVICE_NAME); + size_t max_len = 255 - 8; + size_t id_len = strlen(DEVICE_NAME); if (id_len > max_len) id_len = max_len; @@ -643,15 +643,15 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun, bool as outbuf[r->buf_len++] = 0x83; // this page outbuf[r->buf_len++] = 0x00; - outbuf[r->buf_len++] = 3 + id_len; + outbuf[r->buf_len++] = 3 + (Bit8u)id_len; outbuf[r->buf_len++] = 0x2; // ASCII outbuf[r->buf_len++] = 0; // not officially assigned outbuf[r->buf_len++] = 0; // reserved - outbuf[r->buf_len++] = id_len; // length of data following + outbuf[r->buf_len++] = (Bit8u)id_len; // length of data following memcpy(&outbuf[r->buf_len], DEVICE_NAME, id_len); - r->buf_len += id_len; + r->buf_len += (int)id_len; } break; @@ -769,7 +769,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun, bool as p[21] = (16 * 176) & 0xff; p += 22; } - r->buf_len = p - outbuf; + r->buf_len = (int)(p - outbuf); outbuf[0] = r->buf_len - 4; if (r->buf_len > (int)len) r->buf_len = len; diff --git a/bochs/iodev/usb/usb_common.cc b/bochs/iodev/usb/usb_common.cc index 9ba6b7be8..3be2042a2 100644 --- a/bochs/iodev/usb/usb_common.cc +++ b/bochs/iodev/usb/usb_common.cc @@ -611,7 +611,7 @@ int usb_device_c::set_usb_string(Bit8u *buf, const char *str) *q++ = str[i]; *q++ = 0; } - return q - buf; + return (int)(q - buf); } #endif // BX_SUPPORT_PCI && BX_SUPPORT_PCIUSB