diff --git a/BasiliskII/src/Windows/cd_defs.h b/BasiliskII/src/Windows/cd_defs.h index 8aaa595b..f58069e5 100755 --- a/BasiliskII/src/Windows/cd_defs.h +++ b/BasiliskII/src/Windows/cd_defs.h @@ -23,6 +23,8 @@ #define MAXIMUM_NUMBER_TRACKS 100 #define MAXIMUM_CDROM_SIZE 804 +#pragma pack(push, 1) + typedef struct _TRACK_DATA { UCHAR Reserved; UCHAR Control : 4; @@ -30,14 +32,14 @@ typedef struct _TRACK_DATA { UCHAR TrackNumber; UCHAR Reserved1; UCHAR Address[4]; -} ATTRIBUTE_PACKED TRACK_DATA, *PTRACK_DATA; +} TRACK_DATA, *PTRACK_DATA; typedef struct _CDROM_TOC { UCHAR Length[2]; UCHAR FirstTrack; UCHAR LastTrack; TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS]; -} ATTRIBUTE_PACKED CDROM_TOC, *PCDROM_TOC; +} CDROM_TOC, *PCDROM_TOC; // #include "ntddcdrm.h" #define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM @@ -61,7 +63,7 @@ typedef struct _CDROM_TOC { typedef struct _VOLUME_CONTROL { UCHAR PortVolume[4]; -} ATTRIBUTE_PACKED VOLUME_CONTROL, *PVOLUME_CONTROL; +} VOLUME_CONTROL, *PVOLUME_CONTROL; typedef struct _CDROM_PLAY_AUDIO_MSF { UCHAR StartingM; @@ -70,13 +72,13 @@ typedef struct _CDROM_PLAY_AUDIO_MSF { UCHAR EndingM; UCHAR EndingS; UCHAR EndingF; -} ATTRIBUTE_PACKED CDROM_PLAY_AUDIO_MSF, *PCDROM_PLAY_AUDIO_MSF; +} CDROM_PLAY_AUDIO_MSF, *PCDROM_PLAY_AUDIO_MSF; typedef struct _CDROM_SEEK_AUDIO_MSF { UCHAR M; UCHAR S; UCHAR F; -} ATTRIBUTE_PACKED CDROM_SEEK_AUDIO_MSF, *PCDROM_SEEK_AUDIO_MSF; +} CDROM_SEEK_AUDIO_MSF, *PCDROM_SEEK_AUDIO_MSF; // @@ -87,7 +89,7 @@ typedef struct _SUB_Q_HEADER { UCHAR Reserved; UCHAR AudioStatus; UCHAR DataLength[2]; -} ATTRIBUTE_PACKED SUB_Q_HEADER, *PSUB_Q_HEADER; +} SUB_Q_HEADER, *PSUB_Q_HEADER; typedef struct _SUB_Q_CURRENT_POSITION { SUB_Q_HEADER Header; @@ -98,7 +100,7 @@ typedef struct _SUB_Q_CURRENT_POSITION { UCHAR IndexNumber; UCHAR AbsoluteAddress[4]; UCHAR TrackRelativeAddress[4]; -} ATTRIBUTE_PACKED SUB_Q_CURRENT_POSITION, *PSUB_Q_CURRENT_POSITION; +} SUB_Q_CURRENT_POSITION, *PSUB_Q_CURRENT_POSITION; typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER { SUB_Q_HEADER Header; @@ -107,7 +109,7 @@ typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER { UCHAR Reserved1 : 7; UCHAR Mcval : 1; UCHAR MediaCatalog[15]; -} ATTRIBUTE_PACKED SUB_Q_MEDIA_CATALOG_NUMBER, *PSUB_Q_MEDIA_CATALOG_NUMBER; +} SUB_Q_MEDIA_CATALOG_NUMBER, *PSUB_Q_MEDIA_CATALOG_NUMBER; typedef struct _SUB_Q_TRACK_ISRC { SUB_Q_HEADER Header; @@ -118,7 +120,7 @@ typedef struct _SUB_Q_TRACK_ISRC { UCHAR Reserved2 : 7; UCHAR Tcval : 1; UCHAR TrackIsrc[15]; -} ATTRIBUTE_PACKED SUB_Q_TRACK_ISRC, *PSUB_Q_TRACK_ISRC; +} SUB_Q_TRACK_ISRC, *PSUB_Q_TRACK_ISRC; typedef union _SUB_Q_CHANNEL_DATA { SUB_Q_CURRENT_POSITION CurrentPosition; @@ -136,16 +138,16 @@ typedef struct __RAW_READ_INFO { LARGE_INTEGER DiskOffset; ULONG SectorCount; TRACK_MODE_TYPE TrackMode; -} ATTRIBUTE_PACKED RAW_READ_INFO, *PRAW_READ_INFO; +} RAW_READ_INFO, *PRAW_READ_INFO; typedef struct _CDROM_SUB_Q_DATA_FORMAT { UCHAR Format; UCHAR Track; -} ATTRIBUTE_PACKED CDROM_SUB_Q_DATA_FORMAT, *PCDROM_SUB_Q_DATA_FORMAT; +} CDROM_SUB_Q_DATA_FORMAT, *PCDROM_SUB_Q_DATA_FORMAT; #define IOCTL_CDROM_SUB_Q_CHANNEL 0x00 #define IOCTL_CDROM_CURRENT_POSITION 0x01 #define IOCTL_CDROM_MEDIA_CATALOG 0x02 #define IOCTL_CDROM_TRACK_ISRC 0x03 -#pragma pack() +#pragma pack(pop) diff --git a/BasiliskII/src/Windows/clip_windows.cpp b/BasiliskII/src/Windows/clip_windows.cpp index 1e6f982b..c4ee65bc 100755 --- a/BasiliskII/src/Windows/clip_windows.cpp +++ b/BasiliskII/src/Windows/clip_windows.cpp @@ -21,8 +21,6 @@ #include "sysdeps.h" #include -#define WIN32_LEAN_AND_MEAN -#include #include "macos_util.h" #include "clip.h" @@ -236,7 +234,7 @@ static void do_getscrap(void **handle, uint32 type, int32 offset) // Convert text from ISO-Latin1 to Mac charset uint8 *p = Mac2HostAddr(scrap_area); - for (int i = 0; i < length; i++) { + for (uint32 i = 0; i < length; i++) { uint8 c = data[i]; if (c < 0x80) { if (c == 0) @@ -262,7 +260,7 @@ static void do_getscrap(void **handle, uint32 type, int32 offset) 0x2f, 0x3c, 0, 0, 0, 0, // move.l #outbuf,-(sp) 0xa9, 0xfe, // PutScrap() 0x58, 0x8f, // addq.l #4,sp - M68K_RTS >> 8, M68K_RTS + uint8(M68K_RTS >> 8), uint8(M68K_RTS) }; uint32 proc_area = Host2MacAddr(proc); WriteMacInt32(proc_area + 6, out_length); diff --git a/BasiliskII/src/Windows/prefs_windows.cpp b/BasiliskII/src/Windows/prefs_windows.cpp index ef3eac10..c7789fbc 100755 --- a/BasiliskII/src/Windows/prefs_windows.cpp +++ b/BasiliskII/src/Windows/prefs_windows.cpp @@ -20,9 +20,6 @@ #include "sysdeps.h" -#define WIN32_LEAN_AND_MEAN -#include - #include #include diff --git a/BasiliskII/src/Windows/router/router_types.h b/BasiliskII/src/Windows/router/router_types.h index 1185dccb..9dcc8e63 100755 --- a/BasiliskII/src/Windows/router/router_types.h +++ b/BasiliskII/src/Windows/router/router_types.h @@ -23,7 +23,7 @@ #ifndef _ROUTER_TYPES_H_ #define _ROUTER_TYPES_H_ -#pragma pack(1) +#pragma pack(push, 1) // --------------------------- MAC --------------------------- @@ -31,7 +31,7 @@ typedef struct { uint8 dest[6]; uint8 src[6]; uint16 type; -} ATTRIBUTE_PACKED mac_t; +} mac_t; enum { mac_type_llc_ipx_limit = 0x05DC, // <= mac_type_llc_ipx_limit -->> 802.3 MAC frame @@ -54,7 +54,7 @@ typedef struct { uint8 srcp[4]; // size for ip uint8 dsth[6]; // size for ethernet uint8 dstp[4]; // size for ip -} ATTRIBUTE_PACKED arp_t; +} arp_t; enum { arp_request = 1, @@ -79,7 +79,7 @@ typedef struct { uint32 src; uint32 dest; // ip options, size = 4 * header_len - 20 -} ATTRIBUTE_PACKED ip_t; +} ip_t; // Protocol STD numbers enum { @@ -95,7 +95,7 @@ typedef struct { uint8 code; uint16 checksum; // data -} ATTRIBUTE_PACKED icmp_t; +} icmp_t; enum { icmp_Echo_reply = 0, @@ -140,7 +140,7 @@ typedef struct { uint16 urgent_ptr; // options + padding: size = dataoffset*4-20 // data -} ATTRIBUTE_PACKED tcp_t; +} tcp_t; enum { tcp_flags_URG = 0x20, // The urgent pointer field is significant in this segment. @@ -173,15 +173,15 @@ typedef struct { uint16 msg_len; uint16 checksum; // data -} ATTRIBUTE_PACKED udp_t; +} udp_t; typedef struct { uint16 src_lo, src_hi; uint16 dest_lo, dest_hi; uint16 proto; uint16 msg_len; -} ATTRIBUTE_PACKED pseudo_ip_t; +} pseudo_ip_t; -#pragma pack() +#pragma pack(pop) #endif // _ROUTER_TYPES_H_ diff --git a/BasiliskII/src/Windows/serial_windows.cpp b/BasiliskII/src/Windows/serial_windows.cpp index 4f4639fe..4a1300b2 100755 --- a/BasiliskII/src/Windows/serial_windows.cpp +++ b/BasiliskII/src/Windows/serial_windows.cpp @@ -166,8 +166,8 @@ public: private: bool configure(uint16 config); void set_handshake(uint32 s, bool with_dtr); - static WINAPI unsigned int input_func(void *arg); - static WINAPI unsigned int output_func(void *arg); + static unsigned int WINAPI input_func(void *arg); + static unsigned int WINAPI output_func(void *arg); static int acknowledge_error(HANDLE h, bool is_read); bool set_timeouts(int bauds, int parity_bits, int stop_bits); diff --git a/BasiliskII/src/Windows/sys_windows.cpp b/BasiliskII/src/Windows/sys_windows.cpp index 4a50d658..9e3ed385 100755 --- a/BasiliskII/src/Windows/sys_windows.cpp +++ b/BasiliskII/src/Windows/sys_windows.cpp @@ -20,8 +20,6 @@ #include "sysdeps.h" -#define WIN32_LEAN_AND_MEAN -#include #include #include @@ -497,11 +495,11 @@ void *Sys_open(const char *path_name, bool read_only) } } - if (fh->is_floppy && first_floppy == NULL) - first_floppy = fh; - - if (fh) + if (fh) { + if (fh->is_floppy && first_floppy == NULL) + first_floppy = fh; sys_add_file_handle(fh); + } return fh; } @@ -793,7 +791,7 @@ bool SysCDReadTOC(void *arg, uint8 *toc) NULL, 0, toc, min((int)sizeof(CDROM_TOC), 804), &dummy, - NULL); + NULL) != FALSE; } @@ -819,7 +817,7 @@ bool SysCDGetPosition(void *arg, uint8 *pos) &q_format, sizeof(CDROM_SUB_Q_DATA_FORMAT), &q_data, sizeof(SUB_Q_CHANNEL_DATA), &dwBytesReturned, - NULL); + NULL) != FALSE; if (ok) memcpy(pos, &q_data.CurrentPosition, sizeof(SUB_Q_CURRENT_POSITION)); @@ -851,7 +849,7 @@ bool SysCDPlay(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, uint8 end &msf, sizeof(CDROM_PLAY_AUDIO_MSF), NULL, 0, &dwBytesReturned, - NULL); + NULL) != FALSE; } @@ -871,7 +869,7 @@ bool SysCDPause(void *arg) NULL, 0, NULL, 0, &dwBytesReturned, - NULL); + NULL) != FALSE; } @@ -890,7 +888,7 @@ bool SysCDResume(void *arg) IOCTL_CDROM_RESUME_AUDIO, NULL, 0, NULL, 0, - &dwBytesReturned, NULL); + &dwBytesReturned, NULL) != FALSE; } @@ -910,7 +908,7 @@ bool SysCDStop(void *arg, uint8 lead_out_m, uint8 lead_out_s, uint8 lead_out_f) NULL, 0, NULL, 0, &dwBytesReturned, - NULL); + NULL) != FALSE; } @@ -935,7 +933,7 @@ bool SysCDScan(void *arg, uint8 start_m, uint8 start_s, uint8 start_f, bool reve &msf, sizeof(CDROM_SEEK_AUDIO_MSF), NULL, 0, &dwBytesReturned, - NULL); + NULL) != FALSE; } diff --git a/BasiliskII/src/Windows/sysdeps.h b/BasiliskII/src/Windows/sysdeps.h index b64a19fa..8f6fa72b 100755 --- a/BasiliskII/src/Windows/sysdeps.h +++ b/BasiliskII/src/Windows/sysdeps.h @@ -21,7 +21,7 @@ #ifndef SYSDEPS_H #define SYSDEPS_H -#ifndef __STDC__ +#if !defined _MSC_VER && !defined __STDC__ #error "Your compiler is not ANSI. Get a real one." #endif @@ -41,9 +41,9 @@ #include #include #include -#ifdef __WIN32__ +#define WIN32_LEAN_AND_MEAN #include -#endif +#include #include @@ -78,6 +78,10 @@ /* ExtFS is supported */ #define SUPPORTS_EXTFS 1 +/* POSIX data types missing from Microsoft's CRT */ +#ifdef _MSC_VER +typedef ptrdiff_t ssize_t; +#endif /* Data types */ typedef unsigned char uint8; @@ -123,13 +127,21 @@ typedef int64 intptr; #error "Unsupported size of pointer" #endif -#ifdef __WIN32__ +#ifdef _WIN32 typedef int64 loff_t; #endif #ifndef HAVE_CADDR_T typedef char * caddr_t; #endif +#ifdef _MSC_VER +#ifdef _M_IX86 +#define __i386__ +#elif defined _M_AMD64 +#define __x86_64__ +#endif +#endif + /* Time data type for Time Manager emulation */ typedef int64 tm_time_t; @@ -207,31 +219,42 @@ static inline int spin_trylock(spinlock_t *lock) } #endif -/* Intel x86 */ #define X86_PPRO_OPT +#define HAVE_OPTIMIZED_BYTESWAP_32 +#define HAVE_OPTIMIZED_BYTESWAP_16 + +#ifdef _MSC_VER +static inline uae_u32 do_get_mem_long(uae_u32 *a) {return _byteswap_ulong(*a);} +static inline uae_u32 do_get_mem_word(uae_u16 *a) {return _byteswap_ushort(*a);} +static inline void do_put_mem_long(uae_u32 *a, uae_u32 v) {*a = _byteswap_ulong(v);} +static inline void do_put_mem_word(uae_u16 *a, uae_u32 v) {*a = _byteswap_ushort(v);} +static inline uae_u32 do_byteswap_32_g(uae_u32 v) {return _byteswap_ulong(v);} +static inline uae_u32 do_byteswap_16_g(uae_u32 v) {return _byteswap_ushort(v);} +#else +/* Intel x86 */ static inline uae_u32 do_get_mem_long(uae_u32 *a) {uint32 retval; __asm__ ("bswap %0" : "=r" (retval) : "0" (*a) : "cc"); return retval;} #ifdef X86_PPRO_OPT static inline uae_u32 do_get_mem_word(uae_u16 *a) {uint32 retval; __asm__ ("movzwl %w1,%k0\n\tshll $16,%k0\n\tbswapl %k0\n" : "=&r" (retval) : "m" (*a) : "cc"); return retval;} #else static inline uae_u32 do_get_mem_word(uae_u16 *a) {uint32 retval; __asm__ ("xorl %k0,%k0\n\tmovw %w1,%w0\n\trolw $8,%w0" : "=&r" (retval) : "m" (*a) : "cc"); return retval;} #endif -#define HAVE_GET_WORD_UNSWAPPED -#define do_get_mem_word_unswapped(a) ((uae_u32)*((uae_u16 *)(a))) static inline void do_put_mem_long(uae_u32 *a, uae_u32 v) {__asm__ ("bswap %0" : "=r" (v) : "0" (v) : "cc"); *a = v;} #ifdef X86_PPRO_OPT static inline void do_put_mem_word(uae_u16 *a, uae_u32 v) {__asm__ ("bswapl %0" : "=&r" (v) : "0" (v << 16) : "cc"); *a = v;} #else static inline void do_put_mem_word(uae_u16 *a, uae_u32 v) {__asm__ ("rolw $8,%0" : "=r" (v) : "0" (v) : "cc"); *a = v;} #endif -#define HAVE_OPTIMIZED_BYTESWAP_32 /* bswap doesn't affect condition codes */ static inline uae_u32 do_byteswap_32_g(uae_u32 v) {__asm__ ("bswap %0" : "=r" (v) : "0" (v)); return v;} -#define HAVE_OPTIMIZED_BYTESWAP_16 #ifdef X86_PPRO_OPT static inline uae_u32 do_byteswap_16_g(uae_u32 v) {__asm__ ("bswapl %0" : "=&r" (v) : "0" (v << 16) : "cc"); return v;} #else static inline uae_u32 do_byteswap_16_g(uae_u32 v) {__asm__ ("rolw $8,%0" : "=r" (v) : "0" (v) : "cc"); return v;} #endif +#endif + +#define HAVE_GET_WORD_UNSWAPPED +#define do_get_mem_word_unswapped(a) ((uae_u32)*((uae_u16 *)(a))) #ifndef HAVE_OPTIMIZED_BYTESWAP_32 static inline uae_u32 do_byteswap_32_g(uae_u32 v) @@ -294,8 +317,6 @@ static inline uae_u32 do_byteswap_16_g(uae_u32 v) #define ENUMNAME(name) name #define write_log printf -#define ATTRIBUTE_PACKED __attribute__((packed)) - #if defined(X86_ASSEMBLY) || defined(X86_64_ASSEMBLY) #define ASM_SYM(a) __asm__(a) #else @@ -307,4 +328,8 @@ static inline uae_u32 do_byteswap_16_g(uae_u32 v) #endif #define REGPARAM2 +#ifdef _MSC_VER +#define ATTRIBUTE_PACKED +#endif + #endif diff --git a/BasiliskII/src/Windows/timer_windows.cpp b/BasiliskII/src/Windows/timer_windows.cpp index 5399fdfc..d0aed8ac 100755 --- a/BasiliskII/src/Windows/timer_windows.cpp +++ b/BasiliskII/src/Windows/timer_windows.cpp @@ -20,9 +20,6 @@ #include "sysdeps.h" -#define WIN32_LEAN_AND_MEAN -#include - #include "main.h" #include "macos_util.h" #include "timer.h" @@ -169,9 +166,9 @@ int32 timer_host2mac_time(tm_time_t hosttime) else { uint64 t = TICKS2USECS(hosttime); if (t > 0x7fffffff) - return t / 1000; // Time in milliseconds + return int32(t / 1000); // Time in milliseconds else - return -t; // Time in negative microseconds + return -int32(t); // Time in negative microseconds } } diff --git a/BasiliskII/src/Windows/user_strings_windows.cpp b/BasiliskII/src/Windows/user_strings_windows.cpp index 0b9de060..3ca501be 100755 --- a/BasiliskII/src/Windows/user_strings_windows.cpp +++ b/BasiliskII/src/Windows/user_strings_windows.cpp @@ -21,9 +21,6 @@ #include "sysdeps.h" #include "user_strings.h" -#define WIN32_LEAN_AND_MEAN -#include - // Platform-specific string definitions user_string_def platform_strings[] = { diff --git a/BasiliskII/src/Windows/util_windows.cpp b/BasiliskII/src/Windows/util_windows.cpp index 10e586d2..130b8b8c 100755 --- a/BasiliskII/src/Windows/util_windows.cpp +++ b/BasiliskII/src/Windows/util_windows.cpp @@ -23,6 +23,8 @@ #include "sysdeps.h" #include "util_windows.h" #include "main.h" +#include +#include #include using std::list; @@ -35,10 +37,10 @@ BOOL exists( const char *path ) HFILE h; bool ret = false; - h = _lopen( path, OF_READ ); - if(h != HFILE_ERROR) { + h = _open( path, _O_RDONLY | _O_BINARY ); + if(h != -1) { ret = true; - _lclose(h); + _close(h); } return(ret); } diff --git a/BasiliskII/src/Windows/xpram_windows.cpp b/BasiliskII/src/Windows/xpram_windows.cpp index f69c0d0e..c47a9cb7 100755 --- a/BasiliskII/src/Windows/xpram_windows.cpp +++ b/BasiliskII/src/Windows/xpram_windows.cpp @@ -20,9 +20,6 @@ #include "sysdeps.h" -#define WIN32_LEAN_AND_MEAN -#include - #include using std::string;