diff options
author | Pali Rohár <pali@kernel.org> | 2024-02-18 14:50:54 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2024-02-18 15:55:48 +0100 |
commit | 370be0ded3a0aaa0fff48c9e2e467ed477bc5745 (patch) | |
tree | a321d83acc823eb75122fff4f7a1cd84d1c8c737 | |
parent | 668b22f9427bc81743e4980a962840c8e2dccd0e (diff) | |
download | pciutils-370be0ded3a0aaa0fff48c9e2e467ed477bc5745.tar.gz |
pcilmr: Fix compilation for windows and djgpp
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | lmr/margin.c | 15 | ||||
-rw-r--r-- | pciutils.h | 3 |
3 files changed, 20 insertions, 4 deletions
@@ -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 <unistd.h> +#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 @@ -24,8 +24,9 @@ /* * On Windows only MinGW 3.0 and higher versions provides <getopt.h> * header file. Older MinGW versions and MSVC do not have it. + * DJGPP does not provide <getopt.h>. */ -#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 <getopt.h> |