summary refs log tree commit diff
path: root/gnu/packages/patches/picprog-non-intel-support.patch
blob: 8908207011c1e582d57eac35307619973412cb1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
https://sources.debian.org/data/main/p/picprog/1.9.1-3/debian/patches/20_iopl.patch

Description: Avoid some functions in some architectures
 Upstream uses iopl() function and other architecture-dependent
 codes. This patch adds building switches to avoid them in
 some architectures.
Author: Koichi Akabe <vbkaisetsu@gmail.com>
Last-Update: 2011-11-30

--- picprog-1.9.1.orig/picport.cc
+++ picprog-1.9.1/picport.cc
@@ -38,7 +38,12 @@
 #include <ctime>
 
 #include <sys/ioctl.h>
-#include <sys/io.h>
+
+#if defined(__i386__) || defined(__x86_64__)
+  #include <sys/io.h>
+  #define HAVE_IOPL
+#endif
+
 #include <fcntl.h>
 #include <sys/time.h>
 #include <unistd.h>
@@ -160,8 +165,12 @@
     // Not root.  Cannot use realtime scheduling.
     use_nanosleep = 0;
   }
+#ifdef HAVE_IOPL
   if (iopl (3))
     disable_interrupts = 0;
+#else
+  disable_interrupts = 0;
+#endif
 
 #ifdef CPU_SETSIZE
   // When computing the delay loops, we do not want the cpu's to change.
@@ -403,13 +412,17 @@
 {
   struct timeval tv1, tv2;
   gettimeofday (&tv1, 0);
+#if defined(__i386__) or defined(__x86_64__)
   if (tsc_1000ns > 1 && disable_interrupts)
     asm volatile("pushf; cli");
+#endif
   set_clock_data (1, b); // set data, clock up
   delay (cable_delay);
   set_clock_data (0, b); // clock down
+#if defined(__i386__) or defined(__x86_64__)
   if (tsc_1000ns > 1 && disable_interrupts)
     asm volatile("popf");
+#endif
   gettimeofday (&tv2, 0);
 
   // We may have spent a long time in an interrupt or in another task
@@ -428,13 +441,17 @@
 {
   struct timeval tv1, tv2;
   gettimeofday (&tv1, 0);
+#if defined(__i386__) or defined(__x86_64__)
   if (tsc_1000ns > 1 && disable_interrupts)
     asm volatile("pushf; cli");
+#endif
   set_clock_data (1, 1); // clock up
   delay (cable_delay);
   set_clock_data (0, 1); // set data up, clock down
+#if defined(__i386__) or defined(__x86_64__)
   if (tsc_1000ns > 1 && disable_interrupts)
     asm volatile("popf");
+#endif
   gettimeofday (&tv2, 0);
 
   // We may have spent a long time in an interrupt or in another task