From 634547b304da80543d015cbbd4a7537c5f45055e Mon Sep 17 00:00:00 2001 From: Richard Cornwell Date: Thu, 30 Jan 2020 21:52:45 -0500 Subject: [PATCH] SCP: Updated SCP to current. --- makefile | 123 ++++++++++++++++++++++++++++------------------------ scp.h | 2 +- sim_card.c | 8 ++-- sim_defs.h | 16 ++++--- sim_ether.c | 62 +++++++++++++++----------- sim_ether.h | 1 - 6 files changed, 118 insertions(+), 94 deletions(-) diff --git a/makefile b/makefile index 48e17fb..d3e7f16 100644 --- a/makefile +++ b/makefile @@ -32,6 +32,10 @@ # installed, gmake should be invoked with LPATH=/usr/lib:/usr/local/lib # defined (adjusted as needed depending on where they may be installed). # +# In the unlikely event that someone wants to build network capable +# simulators without networking support, invoking GNU make with +# NONETWORK=1 will do the trick. +# # The default build will build compiler optimized binaries. # If debugging is desired, then GNU make can be invoked with # DEBUG=1 on the command line. @@ -66,12 +70,6 @@ # Internal ROM support can be disabled if GNU make is invoked with # DONT_USE_ROMS=1 on the command line. # -# The use of pthreads for various things can be disabled if GNU make is -# invoked with NOPTHREADS=1 on the command line. -# -# Asynchronous I/O support can be disabled if GNU make is invoked with -# NOASYNCH=1 on the command line. -# # For linting (or other code analyzers) make may be invoked similar to: # # make GCC=cppcheck CC_OUTSPEC= LDFLAGS= CFLAGS_G="--enable=all --template=gcc" CC_STD=--std=c99 @@ -143,6 +141,10 @@ else BESM6_BUILD = true endif endif +# someone may want to explicitly build simulators without network support +ifneq ($(NONETWORK),) + NETWORK_USEFUL = +endif find_exe = $(abspath $(strip $(firstword $(foreach dir,$(strip $(subst :, ,${PATH})),$(wildcard $(dir)/$(1)))))) find_lib = $(abspath $(strip $(firstword $(foreach dir,$(strip ${LIBPATH}),$(wildcard $(dir)/lib$(1).${LIBEXT}))))) find_include = $(abspath $(strip $(firstword $(foreach dir,$(strip ${INCPATH}),$(wildcard $(dir)/$(1).h))))) @@ -253,10 +255,7 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) LTO_EXCLUDE_VERSIONS = PCAPLIB = pcap ifeq (agcc,$(findstring agcc,${GCC})) # Android target build? - OS_CCDEFS = -D_GNU_SOURCE - ifeq (,$(NOASYNCH)) - OS_CCDEFS += -DSIM_ASYNCH_IO - endif + OS_CCDEFS = -D_GNU_SOURCE -DSIM_ASYNCH_IO OS_LDFLAGS = -lm else # Non-Android (or Native Android) Builds ifeq (,$(INCLUDES)$(LIBRARIES)) @@ -463,38 +462,25 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) OS_LDFLAGS += -lrt $(info using librt: $(call find_lib,rt)) endif - ifneq (,$(NOPTHREADS)) - OS_CCDEFS += -DDONT_USE_READER_THREAD - else - ifneq (,$(call find_include,pthread)) + ifneq (,$(call find_include,pthread)) + ifneq (,$(call find_lib,pthread)) + OS_CCDEFS += -DUSE_READER_THREAD -DSIM_ASYNCH_IO + OS_LDFLAGS += -lpthread + $(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread)) + else + LIBEXTSAVE := ${LIBEXT} + LIBEXT = a ifneq (,$(call find_lib,pthread)) - OS_CCDEFS += -DUSE_READER_THREAD - ifeq (,$(NOASYNCH)) - OS_CCDEFS += -DSIM_ASYNCH_IO - endif + OS_CCDEFS += -DUSE_READER_THREAD -DSIM_ASYNCH_IO OS_LDFLAGS += -lpthread $(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread)) else - LIBEXTSAVE := ${LIBEXT} - LIBEXT = a - ifneq (,$(call find_lib,pthread)) - OS_CCDEFS += -DUSE_READER_THREAD - ifeq (,$(NOASYNCH)) - OS_CCDEFS += -DSIM_ASYNCH_IO - endif - OS_LDFLAGS += -lpthread - $(info using libpthread: $(call find_lib,pthread) $(call find_include,pthread)) - else - ifneq (,$(findstring Haiku,$(OSTYPE))) - OS_CCDEFS += -DUSE_READER_THREAD - ifeq (,$(NOASYNCH)) - OS_CCDEFS += -DSIM_ASYNCH_IO - endif - $(info using libpthread: $(call find_include,pthread)) - endif + ifneq (,$(findstring Haiku,$(OSTYPE))) + OS_CCDEFS += -DUSE_READER_THREAD -DSIM_ASYNCH_IO + $(info using libpthread: $(call find_include,pthread)) endif - LIBEXT = $(LIBEXTSAVE) endif + LIBEXT = $(LIBEXTSAVE) endif endif # Find PCRE RegEx library. @@ -656,14 +642,12 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) endif else ifneq (,$(and $(findstring Linux,$(OSTYPE)),$(call find_exe,apt-get))) - $(info *** Info *** Install the development components of libSDL or libSDL2) - $(info *** Info *** packaged for your operating system distribution for) - $(info *** Info *** your Linux system:) + $(info *** Info *** Install the development components of libSDL2 packaged for) + $(info *** Info *** your operating system distribution for your Linux) + $(info *** Info *** system:) $(info *** Info *** $$ sudo apt-get install libsdl2-dev libpng-dev) - $(info *** Info *** or) - $(info *** Info *** $$ sudo apt-get install libsdl-dev) else - $(info *** Info *** Install the development components of libSDL packaged by your) + $(info *** Info *** Install the development components of libSDL2 packaged by your) $(info *** Info *** operating system distribution and rebuild your simulator to) $(info *** Info *** enable this extra functionality.) endif @@ -957,17 +941,11 @@ else $(info include paths are: ${INCPATH}) # Give preference to any MinGW provided threading (if available) ifneq (,$(call find_include,pthread)) - PTHREADS_CCDEFS = -DUSE_READER_THREAD - ifeq (,$(NOASYNCH)) - PTHREADS_CCDEFS += -DSIM_ASYNCH_IO - endif + PTHREADS_CCDEFS = -DUSE_READER_THREAD -DSIM_ASYNCH_IO PTHREADS_LDFLAGS = -lpthread else ifeq (pthreads,$(shell if exist ..\windows-build\pthreads\Pre-built.2\include\pthread.h echo pthreads)) - PTHREADS_CCDEFS = -DUSE_READER_THREAD -DPTW32_STATIC_LIB -D_POSIX_C_SOURCE -I../windows-build/pthreads/Pre-built.2/include - ifeq (,$(NOASYNCH)) - PTHREADS_CCDEFS += -DSIM_ASYNCH_IO - endif + PTHREADS_CCDEFS = -DUSE_READER_THREAD -DPTW32_STATIC_LIB -D_POSIX_C_SOURCE -I../windows-build/pthreads/Pre-built.2/include -DSIM_ASYNCH_IO PTHREADS_LDFLAGS = -lpthreadGC2 -L..\windows-build\pthreads\Pre-built.2\lib endif endif @@ -1158,11 +1136,15 @@ else ifneq (3,$(GCC_MAJOR_VERSION)) ifeq (,$(GCC_OPTIMIZERS_CMD)) GCC_OPTIMIZERS_CMD = ${GCC} --help=optimizers + GCC_COMMON_CMD = ${GCC} --help=common endif endif ifneq (,$(GCC_OPTIMIZERS_CMD)) GCC_OPTIMIZERS = $(shell $(GCC_OPTIMIZERS_CMD)) endif + ifneq (,$(GCC_COMMON_CMD)) + GCC_OPTIMIZERS += $(shell $(GCC_COMMON_CMD)) + endif ifneq (,$(findstring $(GCC_VERSION),$(LTO_EXCLUDE_VERSIONS))) NO_LTO = 1 endif @@ -1184,6 +1166,9 @@ else ifneq (,$(findstring -fstrict-overflow,$(GCC_OPTIMIZERS))) CFLAGS_O += -fno-strict-overflow endif + ifneq (,$(findstring -fcommon,$(GCC_OPTIMIZERS))$(findstring -fno-common,$(GCC_OPTIMIZERS))) + CFLAGS_O += -fcommon + endif ifeq (,$(NO_LTO)) ifneq (,$(findstring -flto,$(GCC_OPTIMIZERS))) CFLAGS_O += -flto -fwhole-program @@ -1906,10 +1891,36 @@ BESM6 = ${BESM6D}/besm6_cpu.c ${BESM6D}/besm6_sys.c ${BESM6D}/besm6_mmu.c \ ${BESM6D}/besm6_punch.c ${BESM6D}/besm6_punchcard.c ifneq (,$(BESM6_BUILD)) + BESM6_OPT = -I ${BESM6D} -DUSE_INT64 $(BESM6_PANEL_OPT) ifneq (,$(and ${SDLX_CONFIG},${VIDEO_LDFLAGS}, $(or $(and $(call find_include,SDL2/SDL_ttf),$(call find_lib,SDL2_ttf)), $(and $(call find_include,SDL/SDL_ttf),$(call find_lib,SDL_ttf))))) FONTPATH += /usr/share/fonts /Library/Fonts /usr/lib/jvm /System/Library/Frameworks/JavaVM.framework/Versions C:/Windows/Fonts FONTPATH := $(dir $(foreach dir,$(strip $(FONTPATH)),$(wildcard $(dir)/.))) FONTNAME += DejaVuSans.ttf LucidaSansRegular.ttf FreeSans.ttf AppleGothic.ttf tahoma.ttf +#cmake-insert:set(BESM6_FONT) +#cmake-insert:foreach (fdir IN ITEMS +#cmake-insert: "/usr/share/fonts" "/Library/Fonts" "/usr/lib/jvm" +#cmake-insert: "/System/Library/Frameworks/JavaVM.framework/Versions" +#cmake-insert: "$ENV{WINDIR}/Fonts") +#cmake-insert: foreach (font IN ITEMS +#cmake-insert: "DejaVuSans.ttf" "LucidaSansRegular.ttf" "FreeSans.ttf" "AppleGothic.ttf" "tahoma.ttf") +#cmake-insert: if (EXISTS ${fdir}) +#cmake-insert: file(GLOB_RECURSE found_font ${fdir}/${font}) +#cmake-insert: if (found_font) +#cmake-insert: get_filename_component(fontfile ${found_font} ABSOLUTE) +#cmake-insert: list(APPEND BESM6_FONT ${fontfile}) +#cmake-insert: endif () +#cmake-insert: endif () +#cmake-insert: endforeach() +#cmake-insert:endforeach() +#cmake-insert: +#cmake-insert:if (NOT BESM6_FONT) +#cmake-insert: message("No font file available, BESM-6 video panel disabled") +#cmake-insert: set(BESM6_PANEL_OPT) +#cmake-insert:endif () +#cmake-insert: +#cmake-insert:if (BESM6_FONT AND WITH_VIDEO) +#cmake-insert: list(GET BESM6_FONT 0 BESM6_FONT) +#cmake-insert:endif () $(info font paths are: $(FONTPATH)) $(info font names are: $(FONTNAME)) find_fontfile = $(strip $(firstword $(foreach dir,$(strip $(FONTPATH)),$(wildcard $(dir)/$(1))$(wildcard $(dir)/*/$(1))$(wildcard $(dir)/*/*/$(1))$(wildcard $(dir)/*/*/*/$(1))))) @@ -1959,13 +1970,11 @@ ifneq (,$(BESM6_BUILD)) else ifneq (,$(and $(findstring sdl2,${VIDEO_LDFLAGS}),$(call find_include,SDL2/SDL_ttf),$(call find_lib,SDL2_ttf))) $(info using libSDL2_ttf: $(call find_lib,SDL2_ttf) $(call find_include,SDL2/SDL_ttf)) $(info ***) - BESM6_OPT = -I ${BESM6D} -DFONTFILE=${FONTFILE} -DUSE_INT64 ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL2_ttf + BESM6_PANEL_OPT = -DFONTFILE=${FONTFILE} ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL2_ttf else ifneq (,$(and $(call find_include,SDL/SDL_ttf),$(call find_lib,SDL_ttf))) $(info using libSDL_ttf: $(call find_lib,SDL_ttf) $(call find_include,SDL/SDL_ttf)) $(info ***) - BESM6_OPT = -I ${BESM6D} -DFONTFILE=${FONTFILE} -DUSE_INT64 ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL_ttf - else - BESM6_OPT = -I ${BESM6D} -DUSE_INT64 + BESM6_PANEL_OPT = -DFONTFILE=${FONTFILE} ${VIDEO_CCDEFS} ${VIDEO_LDFLAGS} -lSDL_ttf endif endif @@ -2004,7 +2013,7 @@ PDP6 = ${PDP6D}/kx10_cpu.c ${PDP6D}/kx10_sys.c ${PDP6D}/kx10_cty.c \ ${PDP6D}/kx10_lp.c ${PDP6D}/kx10_pt.c ${PDP6D}/kx10_cr.c \ ${PDP6D}/kx10_cp.c ${PDP6D}/pdp6_dct.c ${PDP6D}/pdp6_dtc.c \ ${PDP6D}/pdp6_mtc.c ${PDP6D}/pdp6_dsk.c ${PDP6D}/pdp6_dcs.c \ - ${PDP6D}/kx10_dpy.c ${DISPLAYL} $(DISPLAY340) + ${PDP6D}/kx10_dpy.c ${DISPLAYL} ${DISPLAY340} PDP6_OPT = -DPDP6=1 -DUSE_INT64 -I ${PDP6D} -DUSE_SIM_CARD ${DISPLAY_OPT} ${PDP6_DISPLAY_OPT} KA10D = ${SIMHD}/PDP10 @@ -2023,7 +2032,7 @@ KA10 = ${KA10D}/kx10_cpu.c ${KA10D}/kx10_sys.c ${KA10D}/kx10_df.c \ $(KA10D)/ka10_pmp.c ${KA10D}/ka10_dkb.c ${KA10D}/pdp6_dct.c \ ${KA10D}/pdp6_dtc.c ${KA10D}/pdp6_mtc.c ${KA10D}/pdp6_dsk.c \ ${KA10D}/pdp6_dcs.c ${KA10D}/ka10_dpk.c ${KA10D}/kx10_dpy.c \ - ${PDP10D}/ka10_ai.c ${KA10D}/ka10_iii.c ${DISPLAYL} $(DISPLAY340) + ${PDP10D}/ka10_ai.c ${KA10D}/ka10_iii.c ${DISPLAYL} ${DISPLAY340} KA10_OPT = -DKA=1 -DUSE_INT64 -I ${KA10D} -DUSE_SIM_CARD ${NETWORK_OPT} ${DISPLAY_OPT} ${KA10_DISPLAY_OPT} ifneq (${PANDA_LIGHTS},) # ONLY for Panda display. @@ -2042,7 +2051,7 @@ KI10 = ${KI10D}/kx10_cpu.c ${KI10D}/kx10_sys.c ${KI10D}/kx10_df.c \ ${KI10D}/kx10_rh.c ${KI10D}/kx10_rp.c ${KI10D}/kx10_rc.c \ ${KI10D}/kx10_dt.c ${KI10D}/kx10_dk.c ${KI10D}/kx10_cr.c \ ${KI10D}/kx10_cp.c ${KI10D}/kx10_tu.c ${KI10D}/kx10_rs.c \ - ${KI10D}/kx10_imp.c ${KI10D}/kx10_dpy.c ${DISPLAYL} $(DISPLAY340) + ${KI10D}/kx10_imp.c ${KI10D}/kx10_dpy.c ${DISPLAYL} ${DISPLAY340} KI10_OPT = -DKI=1 -DUSE_INT64 -I ${KI10D} -DUSE_SIM_CARD ${NETWORK_OPT} ${DISPLAY_OPT} ${KI10_DISPLAY_OPT} ifneq (${PANDA_LIGHTS},) # ONLY for Panda display. diff --git a/scp.h b/scp.h index ae7b5b2..409c3a1 100644 --- a/scp.h +++ b/scp.h @@ -417,7 +417,7 @@ extern t_stat parse_sym (CONST char *cptr, t_addr addr, UNIT *uptr, t_value *val /* The per-simulator init routine is a weak global that defaults to NULL The other per-simulator pointers can be overrriden by the init routine */ -WEAK extern void (*sim_vm_init) (void); +extern void (*sim_vm_init) (void); extern char *(*sim_vm_read) (char *ptr, int32 size, FILE *stream); extern void (*sim_vm_post) (t_bool from_scp); extern CTAB *sim_vm_cmd; diff --git a/sim_card.c b/sim_card.c index e6618c0..fc75797 100644 --- a/sim_card.c +++ b/sim_card.c @@ -931,9 +931,9 @@ _sim_read_deck(UNIT * uptr, int eof) if (data->hopper_cards >= data->hopper_size) { data->hopper_size += DECK_SIZE; data->images = (uint16 (*)[1][80])realloc(data->images, - data->hopper_size * sizeof(*(data->images))); + (size_t)data->hopper_size * sizeof(*(data->images))); memset(&data->images[data->hopper_cards], 0, - (data->hopper_size - data->hopper_cards) * + (size_t)(data->hopper_size - data->hopper_cards) * sizeof(*(data->images))); } @@ -961,9 +961,9 @@ _sim_read_deck(UNIT * uptr, int eof) if (data->hopper_cards >= data->hopper_size) { data->hopper_size += DECK_SIZE; data->images = (uint16 (*)[1][80])realloc(data->images, - data->hopper_size * sizeof(*(data->images))); + (size_t)data->hopper_size * sizeof(*(data->images))); memset(&data->images[data->hopper_cards], 0, - (data->hopper_size - data->hopper_cards) * + (size_t)(data->hopper_size - data->hopper_cards) * sizeof(*(data->images))); } diff --git a/sim_defs.h b/sim_defs.h index a90eb2d..a60fad3 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -322,12 +322,16 @@ typedef uint32 t_addr; #define WEAK __attribute__((weak)) #elif defined(_MSC_VER) #define WEAK __declspec(selectany) -#else -#define WEAK extern -#endif -#else -#define WEAK -#endif +#else /* !defined(__GNUC__) && !defined(_MSC_VER) */ +#define WEAK +#endif /* __GNUC__ */ +#else /* !defined(__cplusplus) */ +#if defined(__GNUC__) +#define WEAK __attribute__((common)) +#else /* !defined(__GNUC__) */ +#define WEAK +#endif /* defined(__GNUC__) */ +#endif /* defined(__cplusplus) */ /* System independent definitions */ diff --git a/sim_ether.c b/sim_ether.c index fd02d25..2d304d6 100644 --- a/sim_ether.c +++ b/sim_ether.c @@ -379,6 +379,7 @@ /* Internal routines - forward declarations */ static int _eth_get_system_id (char *buf, size_t buf_size); +static int _eth_devices (int max, ETH_LIST* dev); /* get ethernet devices on host */ /*============================================================================*/ /* OS-independant ethernet routines */ @@ -657,10 +658,10 @@ void eth_packet_trace_detail(ETH_DEV* dev, const uint8 *msg, int len, const char eth_packet_trace_ex(dev, msg, len, txt, 1 , dev->dbit); } -const char* eth_getname(int number, char* name, char *desc) +static const char* _eth_getname(int number, char* name, char *desc) { ETH_LIST list[ETH_MAX_DEVICE]; - int count = eth_devices(ETH_MAX_DEVICE, list); + int count = _eth_devices(ETH_MAX_DEVICE, list); if ((number < 0) || (count <= number)) return NULL; @@ -677,7 +678,7 @@ const char* eth_getname(int number, char* name, char *desc) const char* eth_getname_bydesc(const char* desc, char* name, char *ndesc) { ETH_LIST list[ETH_MAX_DEVICE]; - int count = eth_devices(ETH_MAX_DEVICE, list); + int count = _eth_devices(ETH_MAX_DEVICE, list); int i; size_t j=strlen(desc); @@ -703,7 +704,7 @@ const char* eth_getname_bydesc(const char* desc, char* name, char *ndesc) char* eth_getname_byname(const char* name, char* temp, char *desc) { ETH_LIST list[ETH_MAX_DEVICE]; - int count = eth_devices(ETH_MAX_DEVICE, list); + int count = _eth_devices(ETH_MAX_DEVICE, list); size_t n; int i, found; @@ -723,7 +724,7 @@ char* eth_getname_byname(const char* name, char* temp, char *desc) char* eth_getdesc_byname(char* name, char* temp) { ETH_LIST list[ETH_MAX_DEVICE]; - int count = eth_devices(ETH_MAX_DEVICE, list); + int count = _eth_devices(ETH_MAX_DEVICE, list); size_t n; int i, found; @@ -777,7 +778,7 @@ t_stat eth_show (FILE* st, UNIT* uptr, int32 val, CONST void* desc) ETH_LIST list[ETH_MAX_DEVICE]; int number; - number = eth_devices(ETH_MAX_DEVICE, list); + number = _eth_devices(ETH_MAX_DEVICE, list); fprintf(st, "ETH devices:\n"); if (number == -1) fprintf(st, " network support not available in simulator\n"); @@ -956,7 +957,7 @@ t_stat eth_filter (ETH_DEV* dev, int addr_count, ETH_MAC* const addresses, t_stat eth_filter_hash (ETH_DEV* dev, int addr_count, ETH_MAC* const addresses, ETH_BOOL all_multicast, ETH_BOOL promiscuous, ETH_MULTIHASH* const hash) {return SCPE_NOFNC;} -int eth_devices (int max, ETH_LIST* dev) +int _eth_devices (int max, ETH_LIST* dev) {return -1;} const char *eth_version (void) {return NULL;} @@ -1062,22 +1063,28 @@ static HINSTANCE hLib = NULL; /* handle to DLL */ static void *hLib = 0; /* handle to Library */ #endif static int lib_loaded = 0; /* 0=not loaded, 1=loaded, 2=library load failed, 3=Func load failed */ + +#define __STR_QUOTE(tok) #tok +#define __STR(tok) __STR_QUOTE(tok) static const char* lib_name = #if defined(_WIN32) || defined(__CYGWIN__) "wpcap.dll"; #elif defined(__APPLE__) "/usr/lib/libpcap.A.dylib"; #else -#define __STR_QUOTE(tok) #tok -#define __STR(tok) __STR_QUOTE(tok) "libpcap." __STR(HAVE_DLOPEN); #endif -static const char* no_pcap = + +static char no_pcap[PCAP_ERRBUF_SIZE] = #if defined(_WIN32) || defined(__CYGWIN__) - "wpcap load failure"; + "wpcap.dll failed to load, install Npcap or WinPcap 4.x to use pcap networking"; +#elif defined(__APPLE__) + "/usr/lib/libpcap.A.dylib failed to load, install libpcap to use pcap networking"; #else - "libpcap load failure"; + "libpcap." __STR(HAVE_DLOPEN) " failed to load, install libpcap to use pcap networking"; #endif +#undef __STR +#undef __STR_QUOTE /* define pointers to pcap functions needed */ static void (*p_pcap_close) (pcap_t *); @@ -1147,12 +1154,6 @@ int load_pcap(void) { #endif if (hLib == 0) { /* failed to load DLL */ - sim_printf ("Eth: Failed to load %s\n", lib_name); -#ifdef _WIN32 - sim_printf ("Eth: You must install Npcap or WinPcap 4.x to use networking\n"); -#else - sim_printf ("Eth: You must install libpcap to use networking\n"); -#endif lib_loaded = 2; break; } else { @@ -1212,10 +1213,19 @@ int pcap_compile(pcap_t* a, struct bpf_program* b, const char* c, int d, bpf_u_i } const char *pcap_lib_version(void) { + static char buf[256]; + if ((load_pcap() != 0) && (p_pcap_lib_version != NULL)) { return p_pcap_lib_version(); } else { - return NULL; + sprintf (buf, "%s not installed", +#if defined(_WIN32) + "npcap or winpcap" +#else + "libpcap" +#endif + ); + return buf; } } @@ -1241,6 +1251,7 @@ int pcap_findalldevs(pcap_if_t** a, char* b) { } else { *a = 0; strcpy(b, no_pcap); + no_pcap[0] = '\0'; return -1; } } @@ -1643,7 +1654,7 @@ static int _eth_get_system_id (char *buf, size_t buf_size) if ((status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Cryptography", 0, KEY_QUERY_VALUE|KEY_WOW64_64KEY, ®hnd)) != ERROR_SUCCESS) return -1; reglen = buf_size; - if ((status = RegQueryValueExA (reghnd, "MachineGuid", NULL, ®type, buf, ®len)) != ERROR_SUCCESS) { + if ((status = RegQueryValueExA (reghnd, "MachineGuid", NULL, ®type, (LPBYTE)buf, ®len)) != ERROR_SUCCESS) { RegCloseKey (reghnd); return -1; } @@ -2278,7 +2289,7 @@ if ((strlen(name) == 4) && isdigit(name[3]) ) { num = atoi(&name[3]); - savname = eth_getname(num, temp, desc); + savname = _eth_getname(num, temp, desc); if (savname == NULL) /* didn't translate */ return SCPE_OPENERR; } @@ -3934,7 +3945,7 @@ return SCPE_OK; returned by pcap_findalldevs. */ -int eth_host_devices(int used, int max, ETH_LIST* list) +static int eth_host_devices(int used, int max, ETH_LIST* list) { pcap_t* conn = NULL; int i, j, datalink = 0; @@ -4037,7 +4048,7 @@ if (used < max) { return used; } -int eth_devices(int max, ETH_LIST* list) +static int _eth_devices(int max, ETH_LIST* list) { int i = 0; char errbuf[PCAP_ERRBUF_SIZE] = ""; @@ -4049,7 +4060,8 @@ memset(list, 0, max*sizeof(*list)); errbuf[0] = '\0'; /* retrieve the device list */ if (pcap_findalldevs(&alldevs, errbuf) == -1) { - sim_printf ("Eth: error in pcap_findalldevs: %s\n", errbuf); + if (errbuf[0]) + sim_printf ("Eth: %s\n", errbuf); } else { /* copy device list into the passed structure */ @@ -4241,7 +4253,7 @@ int bpf_compile_skip_count = 0; memset (ð_tst, 0, sizeof(eth_tst)); -eth_device_count = eth_devices(ETH_MAX_DEVICE, eth_list); +eth_device_count = _eth_devices(ETH_MAX_DEVICE, eth_list); eth_opened = 0; for (eth_num=0; eth_num