summaryrefslogtreecommitdiff
path: root/emulators/hercules/patches/patch-ag
blob: 52562cb2625760227933355d9101c83223ed33ef (plain)
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
$NetBSD: patch-ag,v 1.1 2001/02/26 14:49:35 agc Exp $

Fix for coredump on exit on NetBSD from Wolfgang Solfrank

--- cpu.c	2001/02/26 14:35:56	1.1
+++ cpu.c	2001/02/26 14:40:26
@@ -741,19 +741,22 @@
 
 void *cpu_thread (REGS *regs)
 {
-#define CPU_PRIORITY    15              /* CPU thread priority       */
 
 #ifndef WIN32
-    /* Set CPU thread priority */
-    if (setpriority(PRIO_PROCESS, 0, CPU_PRIORITY))
-        logmsg ("HHC621I CPU thread set priority failed: %s\n",
-                strerror(errno));
+    struct sched_param sp;
+    int p;
+
+    if (pthread_getschedparam(pthread_self(), &p, &sp)
+	|| (sp.sched_priority = sched_get_priority_min(p),
+	    pthread_setschedparam(pthread_self(), p, &sp)))
+	logmsg ("HHC621I CPU thread set priority failed: %s\n",
+		strerror(errno));
 
     /* Display thread started message on control panel */
     logmsg ("HHC620I CPU%4.4X thread started: tid=%8.8lX, pid=%d, "
             "priority=%d\n",
             regs->cpuad, thread_id(), getpid(),
-            getpriority(PRIO_PROCESS,0));
+            sp.sched_priority);
 #endif
 
     logmsg ("HHC630I CPU%4.4X Architecture Mode %s\n",regs->cpuad,