Merge pull request #670 from dhrdlicka/feature/msvc-compat

Fix MSVC and Windows SDK compatibility
This commit is contained in:
OBattler
2020-04-04 13:17:50 +02:00
committed by GitHub
20 changed files with 68 additions and 37 deletions

View File

@@ -321,7 +321,7 @@ struct _cpustate_ {
#define CPU_STATUS_MASK 0xffff0000
#endif
#ifdef __MSC__
#ifdef _MSC_VER
# define COMPILE_TIME_ASSERT(expr) /*nada*/
#else
# ifdef EXTREME_DEBUG

View File

@@ -24,7 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include <time.h>
#include <wchar.h>
#include <errno.h>
#define HAVE_STDARG_H

View File

@@ -29,6 +29,7 @@
/* The Win32 API uses _wcsicmp. */
#ifdef _WIN32
# define wcscasecmp _wcsicmp
# define strcasecmp _stricmp
#endif
#if defined(UNIX) && defined(FREEBSD)
@@ -37,11 +38,20 @@
# define fseeko64 fseeko
# define ftello64 ftello
# define off64_t off_t
#elif defined(_MSC_VER)
//# define fopen64 fopen
# define fseeko64 _fseeki64
# define ftello64 _ftelli64
# define off64_t off_t
#endif
/* A hack (GCC-specific?) to allow us to ignore unused parameters. */
#define UNUSED(arg) __attribute__((unused))arg
#ifdef _MSC_VER
# define UNUSED(arg) arg
#else
/* A hack (GCC-specific?) to allow us to ignore unused parameters. */
# define UNUSED(arg) __attribute__((unused))arg
#endif
/* Return the size (in wchar's) of a wchar_t array. */
#define sizeof_w(x) (sizeof((x)) / sizeof(wchar_t))

View File

@@ -13,6 +13,7 @@
# include <windows.h>
#endif
#include <intrin.h>
#include <xmmintrin.h>
#define BLOCK_NUM 8

View File

@@ -13,6 +13,7 @@
# include <windows.h>
#endif
#include <intrin.h>
#include <xmmintrin.h>
#define BLOCK_NUM 8

View File

@@ -79,6 +79,10 @@
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern HINSTANCE hinstance;
extern HWND hwndMain,
hwndRender;
@@ -94,10 +98,6 @@ extern WCHAR wopenfilestring[512];
extern uint8_t filterindex;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef USE_CRASHDUMP
extern void InitCrashDump(void);
#endif

View File

@@ -21,7 +21,6 @@
#else
#include <arpa/inet.h>
#endif
#include <unistd.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdint.h>

View File

@@ -53,12 +53,12 @@ typedef struct gsapi_revision_s {
long revisiondate;
} gsapi_revision_t;
static GSDLLAPI int (*gsapi_revision)(gsapi_revision_t *pr, int len);
static GSDLLAPI int (*gsapi_new_instance)(void **pinstance, void *caller_handle);
static GSDLLAPI void (*gsapi_delete_instance)(void *instance);
static GSDLLAPI int (*gsapi_set_arg_encoding)(void *instance, int encoding);
static GSDLLAPI int (*gsapi_init_with_args)(void *instance, int argc, char **argv);
static GSDLLAPI int (*gsapi_exit)(void *instance);
static int (GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len);
static int (GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle);
static void (GSDLLAPI *gsapi_delete_instance)(void *instance);
static int (GSDLLAPI *gsapi_set_arg_encoding)(void *instance, int encoding);
static int (GSDLLAPI *gsapi_init_with_args)(void *instance, int argc, char **argv);
static int (GSDLLAPI *gsapi_exit)(void *instance);
static dllimp_t ghostscript_imports[] = {
{ "gsapi_revision", &gsapi_revision },
@@ -405,12 +405,12 @@ ps_close(void *p)
}
const lpt_device_t lpt_prt_ps_device = {
name: "Generic PostScript printer",
init: ps_init,
close: ps_close,
write_data: ps_write_data,
write_ctrl: ps_write_ctrl,
read_data: NULL,
read_status: ps_read_status,
read_ctrl: NULL
.name = "Generic PostScript printer",
.init = ps_init,
.close = ps_close,
.write_data = ps_write_data,
.write_ctrl = ps_write_ctrl,
.read_data = NULL,
.read_status = ps_read_status,
.read_ctrl = NULL
};

View File

@@ -25,7 +25,7 @@
uint32_t preconst = 0x6ED9EBA1;
static __inline__ uint32_t rotl32c (uint32_t x, uint32_t n)
static __inline uint32_t rotl32c (uint32_t x, uint32_t n)
{
#if 0
assert (n<32);
@@ -33,7 +33,7 @@ static __inline__ uint32_t rotl32c (uint32_t x, uint32_t n)
return (x<<n) | (x>>(-n&31));
}
static __inline__ uint32_t rotr32c (uint32_t x, uint32_t n)
static __inline uint32_t rotr32c (uint32_t x, uint32_t n)
{
#if 0
assert (n<32);
@@ -45,11 +45,11 @@ static __inline__ uint32_t rotr32c (uint32_t x, uint32_t n)
#define ROTATE_RIGHT rotr32c
static __inline__ unsigned long long rdtsc(void)
static __inline unsigned long long rdtsc(void)
{
#if defined(__i386__) || defined (__x86_64__)
unsigned hi, lo;
#ifdef __MSC__
#ifdef _MSC_VER
__asm {
rdtsc
mov hi, edx ; EDX:EAX is already standard return!!

View File

@@ -336,7 +336,7 @@ static uint8_t ncr53c8xx_reg_readb(ncr53c8xx_t *dev, uint32_t offset);
static void ncr53c8xx_reg_writeb(ncr53c8xx_t *dev, uint32_t offset, uint8_t val);
static __inline__ int32_t
static __inline int32_t
sextract32(uint32_t value, int start, int length)
{
/* Note that this implementation relies on right shift of signed
@@ -346,7 +346,7 @@ sextract32(uint32_t value, int start, int length)
}
static __inline__ int
static __inline int
ncr53c8xx_irq_on_rsl(ncr53c8xx_t *dev)
{
return (dev->sien0 & NCR_SIST0_RSL) && (dev->scid & NCR_SCID_RRE);
@@ -490,7 +490,7 @@ ncr53c8xx_write(ncr53c8xx_t *dev, uint32_t addr, uint8_t *buf, uint32_t len)
}
static __inline__ uint32_t
static __inline uint32_t
read_dword(ncr53c8xx_t *dev, uint32_t addr)
{
uint32_t buf;
@@ -588,7 +588,7 @@ ncr53c8xx_script_dma_interrupt(ncr53c8xx_t *dev, int stat)
}
static __inline__ void
static __inline void
ncr53c8xx_set_phase(ncr53c8xx_t *dev, int phase)
{
dev->sstat1 = (dev->sstat1 & ~PHASE_MASK) | phase;

View File

@@ -641,7 +641,8 @@ void adgold_timer_poll(void *p)
static void adgold_get_buffer(int32_t *buffer, int len, void *p)
{
adgold_t *adgold = (adgold_t *)p;
int16_t adgold_buffer[len*2];
int16_t* adgold_buffer = malloc(sizeof(int16_t) * len * 2);
if (adgold_buffer == NULL) fatal("adgold_buffer = NULL");
int c;
@@ -747,6 +748,8 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p)
adgold->opl.pos = 0;
adgold->pos = 0;
free(adgold_buffer);
}

View File

@@ -3,6 +3,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define HAVE_STDARG_H
#include <86box/86box.h>

View File

@@ -5,6 +5,7 @@
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define HAVE_STDARG_H
#include <86box/86box.h>

View File

@@ -4,6 +4,7 @@
486-50 - 32kHz
Pentium - 45kHz*/
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdarg.h>
#include <stdint.h>

View File

@@ -7223,7 +7223,8 @@ static void voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uin
int x;
// Scratchpad for avoiding feedback streaks
uint8_t fil3[(voodoo->h_disp) * 3];
uint8_t *fil3 = malloc((voodoo->h_disp) * 3);
if (fil3 == NULL) fatal("fil3 = NULL");
/* 16 to 32-bit */
for (x=0; x<column;x++)
@@ -7281,6 +7282,8 @@ static void voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uin
fil[(x)*3+1] = voodoo->thefilterg[fil3[x*3+1]][fil3[ (x+1) *3+1]];
fil[(x)*3+2] = voodoo->thefilter[fil3[x*3+2]][fil3[ (x+1) *3+2]];
}
free(fil3);
}
@@ -7289,7 +7292,8 @@ static void voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uin
int x;
// Scratchpad for blending filter
uint8_t fil3[(voodoo->h_disp) * 3];
uint8_t *fil3 = malloc((voodoo->h_disp) * 3);
if (fil3 == NULL) fatal("fil3 = NULL");
/* 16 to 32-bit */
for (x=0; x<column;x++)
@@ -7346,6 +7350,8 @@ static void voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uin
fil3[(column-1)*3] = voodoo->thefilterb [fil[(column-1)*3]][((src[column] & 31) << 3)];
fil3[(column-1)*3+1] = voodoo->thefilterg [fil[(column-1)*3+1]][(((src[column] >> 5) & 63) << 2)];
fil3[(column-1)*3+2] = voodoo->thefilter [fil[(column-1)*3+2]][(((src[column] >> 11) & 31) << 3)];
free(fil3);
}
void voodoo_callback(void *p)
@@ -7400,7 +7406,8 @@ void voodoo_callback(void *p)
if (voodoo->scrfilter && voodoo->scrfilterEnabled)
{
uint8_t fil[(voodoo->h_disp) * 3]; /* interleaved 24-bit RGB */
uint8_t *fil = malloc((voodoo->h_disp) * 3); /* interleaved 24-bit RGB */
if (fil == NULL) fatal("fil = NULL");
if (voodoo->type == VOODOO_2)
voodoo_filterline_v2(voodoo, fil, voodoo->h_disp, src, voodoo->line);
@@ -7411,6 +7418,8 @@ void voodoo_callback(void *p)
{
p[x] = (voodoo->clutData256[fil[x*3]].b << 0 | voodoo->clutData256[fil[x*3+1]].g << 8 | voodoo->clutData256[fil[x*3+2]].r << 16);
}
free(fil);
}
else
{

View File

@@ -1,4 +1,4 @@
/*
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent

View File

@@ -19,7 +19,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stringapiset.h>
#include <windows.h>
#include <time.h>
#define HAVE_STDARG_H
#include <86box/86box.h>

View File

@@ -18,6 +18,7 @@
*/
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdarg.h>
#include <stdint.h>
@@ -29,6 +30,8 @@
#include <86box/gameport.h>
#include <86box/win.h>
#define DIDEVTYPE_JOYSTICK 4
plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS];
joystick_t joystick_state[MAX_JOYSTICKS];

View File

@@ -21,6 +21,7 @@
#include <hidclass.h>
#include <hidusage.h>
#include <hidsdi.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdarg.h>
#include <stdint.h>

View File

@@ -19,6 +19,7 @@
* Copyright 2019 GH Cao.
*/
#include <xinput.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdarg.h>
#include <stdint.h>