]> mj.ucw.cz Git - pciutils.git/commitdiff
pcilmr: Fix compilation for windows and djgpp
authorPali Rohár <pali@kernel.org>
Sun, 18 Feb 2024 13:50:54 +0000 (14:50 +0100)
committerMartin Mares <mj@ucw.cz>
Sun, 18 Feb 2024 14:55:48 +0000 (15:55 +0100)
Makefile
lmr/margin.c
pciutils.h

index f76b4cd74e216daf1a905d4e52b5b177aea78e5e..3e02eea60b337ec6924cc6cc7ee8b355346b4ddb 100644 (file)
--- 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
index dfa5612f6e8b022db978dce38e46b2e719b3385b..a8c65712a52c26cf8487269d176704deeb75cdfc 100644 (file)
 
 #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
index 53e0ee1b1c4db34ef06aedc13ca05b75e65bb925..020c02a1c668f92a6c7dd4761f5e61b0637680b4 100644 (file)
@@ -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>