Mercurial > mplayer.hg
annotate osdep/priority.c @ 29310:c35891e664af
replace "g" asm constraint by "erm" since "g" allows 64bit immediates while
the operator (cmp) using the "g"-constrained operand doesn't support 64bit
immediates.
Original thread:
date: Tue, Jun 2, 2009 at 11:31 AM
subject: [PATCH] Fix MPlayer to compile on Darwin/x86_86
author | gpoirier |
---|---|
date | Sun, 07 Jun 2009 14:42:43 +0000 |
parents | 01b2dcc76143 |
children | 32725ca88fed |
rev | line source |
---|---|
28485
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
1 /* |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
2 * implementation of '-priority' for OS/2 and Win32 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
3 * |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
4 * Copyright (c) 2009 by KO Myung-Hun (komh@chollian.net) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
5 * |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
6 * This file is part of MPlayer. |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
7 * |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
8 * MPlayer is free software; you can redistribute it and/or modify |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
11 * (at your option) any later version. |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
12 * |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
13 * MPlayer is distributed in the hope that it will be useful, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
17 * |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License along |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
21 */ |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
22 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
23 #ifdef __OS2__ |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
24 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
25 #define INCL_DOS |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
26 #include <os2.h> |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
27 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
28 #define REALTIME_PRIORITY_CLASS MAKESHORT(0, PRTYC_TIMECRITICAL) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
29 #define HIGH_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM, PRTYC_REGULAR) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
30 #define ABOVE_NORMAL_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM / 2, PRTYC_REGULAR) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
31 #define NORMAL_PRIORITY_CLASS MAKESHORT(0, PRTYC_REGULAR) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
32 #define BELOW_NORMAL_PRIORITY_CLASS MAKESHORT(PRTYD_MAXIMUM, PRTYC_IDLETIME) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
33 #define IDLE_PRIORITY_CLASS MAKESHORT(0, PRTYC_IDLETIME) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
34 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
35 #else |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
36 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
37 #include <windows.h> |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
38 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
39 #endif /* __OS2__ */ |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
40 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
41 #include <string.h> |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
42 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
43 #include "mp_msg.h" |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
44 #include "help_mp.h" |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
45 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
46 #include "priority.h" |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
47 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
48 char *proc_priority = NULL; |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
49 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
50 void set_priority(void) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
51 { |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
52 struct { |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
53 char* name; |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
54 int prio; |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
55 } priority_presets_defs[] = { |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
56 { "realtime", REALTIME_PRIORITY_CLASS}, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
57 { "high", HIGH_PRIORITY_CLASS}, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
58 #ifdef ABOVE_NORMAL_PRIORITY_CLASS |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
59 { "abovenormal", ABOVE_NORMAL_PRIORITY_CLASS}, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
60 #endif |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
61 { "normal", NORMAL_PRIORITY_CLASS}, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
62 #ifdef BELOW_NORMAL_PRIORITY_CLASS |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
63 { "belownormal", BELOW_NORMAL_PRIORITY_CLASS}, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
64 #endif |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
65 { "idle", IDLE_PRIORITY_CLASS}, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
66 { NULL, NORMAL_PRIORITY_CLASS} /* default */ |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
67 }; |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
68 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
69 if (proc_priority) { |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
70 int i; |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
71 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
72 for (i = 0; priority_presets_defs[i].name; i++) { |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
73 if (strcasecmp(priority_presets_defs[i].name, proc_priority) == 0) |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
74 break; |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
75 } |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
76 mp_msg(MSGT_CPLAYER, MSGL_STATUS, MSGTR_SettingProcessPriority, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
77 priority_presets_defs[i].name); |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
78 |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
79 #ifdef __OS2__ |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
80 DosSetPriority(PRTYS_PROCESS, |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
81 HIBYTE(priority_presets_defs[i].prio), |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
82 LOBYTE(priority_presets_defs[i].prio), |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
83 0); |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
84 #else |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
85 SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio); |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
86 #endif |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
87 } |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
88 } |
3f597aacbb69
Add priority support for OS/2 and factorize the Windows priority support.
diego
parents:
diff
changeset
|
89 |