From 370be0ded3a0aaa0fff48c9e2e467ed477bc5745 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sun, 18 Feb 2024 14:50:54 +0100 Subject: pcilmr: Fix compilation for windows and djgpp --- Makefile | 6 +++--- lmr/margin.c | 15 +++++++++++++++ pciutils.h | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f76b4cd..3e02eea 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ LMRINC=lmr/lmr.h $(UTILINC) export -all: lib/$(PCIIMPLIB) lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lspci.8 setpci.8 pcilib.7 pci.ids.5 update-pciids update-pciids.8 $(PCI_IDS) pcilmr pcilmr.8 +all: lib/$(PCIIMPLIB) lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lspci.8 setpci.8 pcilib.7 pci.ids.5 update-pciids update-pciids.8 $(PCI_IDS) pcilmr$(EXEEXT) pcilmr.8 lib/$(PCIIMPLIB): $(PCIINC) force $(MAKE) -C lib all @@ -119,7 +119,7 @@ example.o: example.c $(PCIINC) $(LMROBJS) pcilmr.o: override CFLAGS+=-I . $(LMROBJS): %.o: %.c $(LMRINC) -pcilmr: pcilmr.o $(LMROBJS) $(COMMON) lib/$(PCIIMPLIB) +pcilmr$(EXEEXT): pcilmr.o $(LMROBJS) $(COMMON) lib/$(PCIIMPLIB) pcilmr.o: pcilmr.c $(LMRINC) %$(EXEEXT): %.o @@ -153,7 +153,7 @@ TAGS: clean: rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"` - rm -f update-pciids lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lib/config.* *.[578] pci.ids.gz lib/*.pc lib/*.so lib/*.so.* lib/*.dll lib/*.def lib/dllrsrc.rc *-rsrc.rc tags pcilmr + rm -f update-pciids lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lib/config.* *.[578] pci.ids.gz lib/*.pc lib/*.so lib/*.so.* lib/*.dll lib/*.def lib/dllrsrc.rc *-rsrc.rc tags pcilmr$(EXEEXT) rm -rf maint/dist distclean: clean diff --git a/lmr/margin.c b/lmr/margin.c index dfa5612..a8c6571 100644 --- a/lmr/margin.c +++ b/lmr/margin.c @@ -14,6 +14,10 @@ #include "lmr.h" +#ifdef PCI_OS_DJGPP +#include +#endif + /* Macro helpers for Margining command parsing */ typedef u16 margin_cmd; @@ -81,6 +85,16 @@ typedef u16 margin_cmd; static int msleep(long msec) { +#if defined(PCI_OS_WINDOWS) + Sleep(msec); + return 0; +#elif defined(PCI_OS_DJGPP) + if (msec * 1000 < 11264) + usleep(11264); + else + usleep(msec * 1000); + return 0; +#else struct timespec ts; int res; @@ -99,6 +113,7 @@ msleep(long msec) } while (res && errno == EINTR); return res; +#endif } static margin_cmd diff --git a/pciutils.h b/pciutils.h index 53e0ee1..020c02a 100644 --- a/pciutils.h +++ b/pciutils.h @@ -24,8 +24,9 @@ /* * On Windows only MinGW 3.0 and higher versions provides * header file. Older MinGW versions and MSVC do not have it. + * DJGPP does not provide . */ -#if defined(PCI_OS_WINDOWS) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 3) +#if defined(PCI_OS_DJGPP) || (defined(PCI_OS_WINDOWS) && !(defined(__MINGW32_MAJOR_VERSION) && __MINGW32_MAJOR_VERSION >= 3)) #include "compat/getopt.h" #else #include -- cgit 1.2.3-korg