2019-07-06 Juan M. Guerrero * inc/poll.h: New. POSIX requires (AFAIK) this file in a base-dir. 2018-09-01 Juan M. Guerrero * util/sysdep.h [__CYGWIN__]: Macros to replace non-standard functions like stricmp and strnicmp. 2018-08-22 Juan M. Guerrero * bin/djgpp.mak: For gcc 5.N.N and higher versions add `-fgnu89-inline' to the CFLAGS to ensure that always traditional GNU extern inline semantics are used even if ISO C99 semantics have been specified. ISO C99 semantics is always the default for gcc 5.N.N and higher versions. Install target and prefix variable added. * src/makefile.all: For gcc 5.N.N and higher versions add `-fgnu89-inline' to the CFLAGS to ensure that always traditional GNU extern inline semantics are used even if ISO C99 semantics have been specified. ISO C99 semantics is always the default for gcc 5.N.N and higher versions. Install target and prefix variable added. * src/misc.c: stack_limit not used by DJGPP. * src/pcarp.c [TEST_PROG]: Unused variables: num_okay and num_fail. * src/pcsed.c (_eth_init): Initialize mac_tx_format and mac_transmit to some sane default in case that no packet driver has been installed. * src/sock_ini.c: Use FALSE instead of 0. * src/tests/fsext.c (main): Avoid ordered comparison of pointer with integer zero. * src/tests/ttime2.c (main): Initialize lastsec before using it. * src/tests/makefile.all: For gcc 5.N.N and higher versions add `-fgnu89-inline' to the CFLAGS to ensure that always traditional GNU extern inline semantics are used even if ISO C99 semantics have been specified. ISO C99 semantics is always the default for gcc 5.N.N and higher versions. For DJGPP do not build neither swap.$(EXE) nor timeit_test.$(EXE). diff -aprNU3 watt.orig/bin/djgpp.mak watt/bin/djgpp.mak --- watt.orig/bin/djgpp.mak 2018-08-14 22:33:04 +0000 +++ watt/bin/djgpp.mak 2018-08-22 21:19:34 +0000 @@ -37,6 +37,8 @@ DPMI_STUB = 0 MAKE_MAP = 0 +prefix = /dev/env/DJDIR/net/watt + INC_DIR = ../inc ifeq ($(DYNAMIC),1) @@ -52,6 +54,13 @@ endif CC = gcc CFLAGS += -Wall -W -Wno-sign-compare -g -O2 -I$(INC_DIR) #-s # strip symbols from .exe +ifeq ($(filter 2 3 4,$(word 3, $(shell true | $(CC) -E -dD -x c - | grep 'define\ *__GNUC__'))),) +# We have gcc >= 5.x and we must ensure that always traditional +# GNU extern inline semantics are used (aka -fgnu89-inline) even +# if ISO C99 semantics have been specified. +CFLAGS += -fgnu89-inline +endif + ifeq ($(USE_EXCEPT),1) CFLAGS += -DUSE_EXCEPT EXTRAS += d:/prog/mw/except/lib/libexc.a @@ -110,3 +119,7 @@ $(PROGS): $(WATTLIB) clean: rm -f *.o $(PROGS) +install: ping.exe tcpinfo.exe + -mkdir -p "$(prefix)/bin" + cp -f ./ping.exe ./tcpinfo.exe "$(prefix)/bin" + @echo Install to $(prefix) done diff -aprNU3 watt.orig/inc/poll.h watt/inc/poll.h --- watt.orig/inc/poll.h 1970-01-01 00:00:00 +0000 +++ watt/inc/poll.h 2019-07-06 10:21:22 +0000 @@ -0,0 +1,12 @@ +/*!\file poll.h + * + */ +/* + * POSIX requires (AFAIK) this file in a base-dir + */ +#ifndef __POLL_H +#define __POLL_H + +#include + +#endif diff -aprNU3 watt.orig/src/makefile.all watt/src/makefile.all --- watt.orig/src/makefile.all 2018-05-23 15:49:40 +0000 +++ watt/src/makefile.all 2018-08-24 21:49:16 +0000 @@ -170,6 +170,8 @@ PKT_STUB = pkt_stub.h @ifdef DJGPP +prefix = /dev/env/DJDIR/net/watt + ifeq ($(OS),Windows_NT) ifneq ($(DJ_PREFIX),) # @@ -193,10 +195,19 @@ else BIN_PREFIX = endif -CFLAGS = -O2 -g -I. -I../inc -W -Wall -Wno-strict-aliasing -DWATT32_BUILD \ +CFLAGS = -O3 -g -I. -I../inc -W -Wall -Wno-strict-aliasing -DWATT32_BUILD \ # -fno-strength-reduce -ffast-math \ # -ffunction-sections -fomit-frame-pointer -gcoff +ifeq ($(filter 2 3 4,$(word 3, $(shell true | $(CC) -E -dD -x c - | grep 'define\ *__GNUC__'))),) + # We have gcc >= 5.x and we must ensure that always traditional + # GNU extern inline semantics are used (aka -fgnu89-inline) even + # if ISO C99 semantics have been specified. + CFLAGS += -fgnu89-inline +endif + +CFLAGS += -march=i386 -mtune=i586 + CC = $(BIN_PREFIX)gcc AS = $(BIN_PREFIX)as AR = $(BIN_PREFIX)ar rs @@ -227,6 +238,13 @@ clean: rm -f $(TARGET) $(OBJDIR)/*.o $(OBJDIR)/*.iS $(PKT_STUB) $(OBJDIR)/cflags.h @echo Cleaning done +install: all + -mkdir -p "$(prefix)/inc" + -mkdir -p "$(prefix)/lib" + cp -fr ../inc "$(prefix)" + cp -fr ../lib "$(prefix)" + @echo Install to $(prefix) done + -include $(OBJDIR)/watt32.dep diff -aprNU3 watt.orig/src/misc.c watt/src/misc.c --- watt.orig/src/misc.c 2018-05-23 13:34:30 +0000 +++ watt/src/misc.c 2018-08-19 13:25:30 +0000 @@ -1268,7 +1268,9 @@ DWORD get_ss_limit (void) #else THREAD_LOCAL static UINT_PTR stack_bottom = 0; +# ifndef __DJGPP__ THREAD_LOCAL static UINT_PTR stack_limit = 0; +# endif #endif /* More 'gcc -O0' hackery. @@ -2025,7 +2027,7 @@ void foo_70 (void) { puts ("I'm foo_70() int main (void) { #if defined(__MSDOS__) - BYTE strat; + BYTE strat = 0; printf ("DOS memory allocation strategy: "); if (!get_mem_strat(&strat)) diff -aprNU3 watt.orig/src/pcarp.c watt/src/pcarp.c --- watt.orig/src/pcarp.c 2015-06-28 18:18:32 +0000 +++ watt/src/pcarp.c 2018-08-19 13:45:08 +0000 @@ -2164,8 +2164,10 @@ DWORD _route_destin (DWORD ip) #include "pcdns.h" #include "pcbuf.h" +#ifndef __DJGPP__ static int num_okay = 0; static int num_fail = 0; +#endif #define TEST(func, args, expect) do { \ HIGH_TEXT(); \ diff -aprNU3 watt.orig/src/pcsed.c watt/src/pcsed.c --- watt.orig/src/pcsed.c 2016-10-04 10:14:10 +0000 +++ watt/src/pcsed.c 2018-08-19 11:35:40 +0000 @@ -669,7 +669,15 @@ int W32_CALL _eth_init (void) rc = pkt_eth_init (&_eth_addr); if (rc) + { + if (rc == WERR_NO_DRIVER) + { + /* Initialize to some sane default. */ + mac_tx_format = null_mac_format; + mac_transmit = null_mac_xmit; + } return (rc); /* error message already printed */ + } /* Save our MAC-address incase we change it. Change back at exit. */ diff -aprNU3 watt.orig/src/sock_ini.c watt/src/sock_ini.c --- watt.orig/src/sock_ini.c 2017-02-16 17:51:04 +0000 +++ watt/src/sock_ini.c 2018-08-19 11:35:40 +0000 @@ -136,10 +136,10 @@ BOOL _watt_no_config = FALSE; /**< run w WattUserConfigFunc _watt_user_config_fn = NULL; -BOOL survive_eth = 0; /**< GvB 2002-09, allows us to survive without a - * (working) packet driver at all - in cases where life - * still has a meaning without TCP/IP. - */ +BOOL survive_eth = FALSE; /**< GvB 2002-09, allows us to survive without a + * (working) packet driver at all - in cases where life + * still has a meaning without TCP/IP. + */ #if defined(USE_DHCP) BOOL survive_bootp = TRUE; /**< Survive a failed BOOTP attempt */ diff -aprNU3 watt.orig/src/tests/fsext.c watt/src/tests/fsext.c --- watt.orig/src/tests/fsext.c 2007-01-22 23:35:16 +0000 +++ watt/src/tests/fsext.c 2018-08-19 11:35:40 +0000 @@ -15,7 +15,9 @@ int main (void) { struct sockaddr_in sin; +#if 0 struct linger linger; +#endif int s, on = 1; FILE *fil; @@ -59,7 +61,7 @@ int main (void) perror ("fprintf"); break; } - if (fgets(msg,sizeof(msg),fil) < 0) + if (fgets(msg,sizeof(msg),fil) == NULL) { perror ("fgets"); break; diff -aprNU3 watt.orig/src/tests/makefile.all watt/src/tests/makefile.all --- watt.orig/src/tests/makefile.all 2017-07-05 21:28:36 +0000 +++ watt/src/tests/makefile.all 2018-08-19 14:14:28 +0000 @@ -53,10 +53,8 @@ PROGRAMS = bind.$(EXE) \ punycode.$(EXE) \ select.$(EXE) \ socktest.$(EXE) \ - swap.$(EXE) \ syslog.$(EXE) \ tftp.$(EXE) \ - timeit_test.$(EXE) \ ttime.$(EXE) \ udp_srv.$(EXE) \ udp_test.$(EXE) \ @@ -70,6 +68,10 @@ endif PROGRAMS += oldstuff.$(EXE) ttime2.$(EXE) @endif +@ifndef DJGPP + PROGRAMS += swap.$(EXE) timeit_test.$(EXE) +@endif + BIN_PREFIX = @ifdef DJGPP @@ -102,7 +104,14 @@ VPATH = .. @ifdef IS_GCC CC = $(BIN_PREFIX)gcc CFLAGS = -O2 -g -W -Wall -Wno-strict-aliasing - LDFLAGS = -Wl,--print-map,--sort-common +# LDFLAGS = -Wl,--print-map,--sort-common + + ifeq ($(filter 2 3 4,$(word 3, $(shell true | $(CC) -E -dD -x c - | grep 'define\ *__GNUC__'))),) + # We have gcc >= 5.x and we must ensure that always traditional + # GNU extern inline semantics are used (aka -fgnu89-inline) even + # if ISO C99 semantics have been specified. + CFLAGS += -fgnu89-inline + endif define COMP_AND_LINK $(CC) $(CFLAGS) $(LDFLAGS) -o $(1) $(2) $(WATT_LIB) > $(1:.exe=.map) diff -aprNU3 watt.orig/src/tests/ttime2.c watt/src/tests/ttime2.c --- watt.orig/src/tests/ttime2.c 2016-01-02 19:15:34 +0000 +++ watt/src/tests/ttime2.c 2018-08-19 11:35:40 +0000 @@ -28,7 +28,7 @@ int main (void) { union REGS regs; long tick, lasttick = 0, key = 0; - int dx, sec, lastsec; + int dx, sec, lastsec = 0; printf ("Press Esc to quit...\n"); do diff -aprNU3 watt.orig/util/dj-errno.mak watt/util/dj-errno.mak --- watt.orig/util/dj-errno.mak 2017-07-07 13:26:44 +0000 +++ watt/util/dj-errno.mak 2018-08-19 11:35:40 +0000 @@ -57,7 +57,7 @@ else # DJ_ROOT = $(subst /bin/i586-pc-msdosdjgpp-,,$(DJ_PREFIX)) -DJ_ERR_CFLAGS = -m32 -s -DWATT32_DJGPP_MINGW -D__DJGPP__=2 -D__DJGPP_MINOR__=5 +DJ_ERR_CFLAGS = -m32 -s -DWATT32_DJGPP_MINGW -D__DJGPP__=2 -D__DJGPP_MINOR__=6 # # Force including djgpp's and NOT MinGW's diff -aprNU3 watt.orig/util/makefile watt/util/makefile --- watt.orig/util/makefile 2016-01-01 13:34:04 +0000 +++ watt/util/makefile 2018-09-01 16:58:54 +0000 @@ -26,7 +26,7 @@ SLANG_ROOT_LINUX ?= SLANG_LIB_LINUX ?= -lslang CC = gcc -CFLAGS = -Wall -g # -s +CFLAGS = -save-temps -Wall -g # -s all: mkmake.exe mkdep.exe mklang.exe mkimp.exe dxegen.exe bin2c.exe diff -aprNU3 watt.orig/util/sysdep.h watt/util/sysdep.h --- watt.orig/util/sysdep.h 2015-06-28 11:15:38 +0000 +++ watt/util/sysdep.h 2018-09-01 16:46:32 +0000 @@ -84,4 +84,49 @@ #define SLASH '/' #endif +#ifdef __CYGWIN__ +# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) +# define __gnuc_extension__ __extension__ +# else +# define __gnuc_extension__ +# endif + +/* Do not use non-standard functions!!! */ +#undef stricmp +#define stricmp(S1, S2) \ + (__gnuc_extension__ \ + ({ \ + int result; \ + while (tolower(*(S1)) == tolower(*(S2))) \ + { \ + if ((result = *(S1)) == 0) break; \ + (S1)++; \ + (S2)++; \ + } \ + result = tolower(*(S1)) - tolower(*(S2)); \ + }) \ + ) + +#undef strnicmp +#define strnicmp(S1, S2, N) \ + (__gnuc_extension__ \ + ({ \ + int result = 0; \ + if ((N)) \ + { \ + do { \ + if (tolower(*(S1)) == tolower(*(S2))) \ + { \ + result = tolower(*(S1)) - tolower(*--(S2)); \ + break; \ + } \ + else if (*(S1)++ == 0) \ + break; \ + while (--(N)); \ + } \ + result; \ + }) \ + ) +#endif /* __CYGWIN__ */ + #endif /* _w32_SYSDEP_H */ 2019-12-18 Juan M. Guerrero * src/misc.c [__DJGPP__]: Provide an implementation for __readfsdword. * src/cpumodel.h [__NO_INLINE__, __DJGPP__]: If __NO_INLINE__ is defined no functions are provided at all, thus disable this exclusion for DJGPP. diff -aprNU5 watt.orig/src/cpumodel.h watt/src/cpumodel.h --- watt.orig/src/cpumodel.h 2016-12-12 12:30:26 +0000 +++ watt/src/cpumodel.h 2019-12-26 09:40:44 +0000 @@ -150,11 +150,15 @@ extern CONST char DATA_DECL x86_vendor_ #pragma alias (_w32_SelWriteable,"_w32_SelWriteable") #pragma alias (_w32_SelReadable, "_w32_SelReadable") #endif -#if defined(__GNUC__) && defined(__i386__) && !defined(__NO_INLINE__) +/* + * If __NO_INLINE__ is defined no functions are provided at all, thus disable + * this exlusion at least for DJGPP or the build will fail for -O0! + */ +#if defined(__GNUC__) && defined(__i386__) && (!defined(__NO_INLINE__) || defined(__DJGPP__)) /* * Call this only if x86_have_cpuid == TRUE. */ W32_GCC_INLINE void get_cpuid (DWORD val, DWORD *eax, DWORD *ebx, DWORD *ecx, diff -aprNU5 watt.orig/src/misc.c watt/src/misc.c --- watt.orig/src/misc.c 2019-12-26 09:41:28 +0000 +++ watt/src/misc.c 2019-12-26 09:40:44 +0000 @@ -1284,10 +1284,21 @@ DWORD get_ss_limit (void) { return (void*)__readgsqword (FIELD_OFFSET(NT_TIB,FiberData)); } #elif defined(__i386__) + #if defined(__DJGPP__) + /* DJGPP neither includes nor provides __readfsdword. */ + DWORD __readfsdword(DWORD offset) + { + DWORD result; + __asm__ __volatile__ ( + "movl %%fs:%1,%0" + : "=r" (result) ,"=m" ((*(volatile long *) offset)) ); + return result; + } + #endif static void *_w32_GetCurrentFiber (void) { return (void*)__readfsdword (0x10); } #else