Skip to content

Commit 209bf47

Browse files
committed
Add set_sysvar_to_short and fix compiler warnings
As all sysvars are marked as volatile, the compiler complained about discarding the 'volatile' qualifier when passing variables from sysvars.h.
1 parent 609bbd1 commit 209bf47

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

include/mint/sysvars.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ typedef struct _osheader
120120

121121
/* zzzz to-do more */
122122

123-
extern long get_sysvar (volatile void *var) __THROW;
124-
extern void set_sysvar_to_long (void *var, long val) __THROW;
123+
extern long get_sysvar (const volatile void *var) __THROW;
124+
extern void set_sysvar_to_short (volatile void *var, short val) __THROW;
125+
extern void set_sysvar_to_long (volatile void *var, long val) __THROW;
125126

126127

127128
__END_DECLS

mintlib/getcookie.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "libc-symbols.h"
2121

2222
.extern C_SYMBOL_NAME(__has_no_ssystem) | int __has_no_ssystem;
23-
.extern C_SYMBOL_NAME(get_sysvar) | long get_sysvar(void *var);
23+
.extern C_SYMBOL_NAME(get_sysvar) | long get_sysvar(const volatile void *var);
2424

2525
.globl C_SYMBOL_NAME(Getcookie)
2626
C_SYMBOL_NAME(Getcookie):

mintlib/getsysvar.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| this file you indicate that you have read the license and
77
| understand and accept it fully.
88

9-
| long get_sysvar(void *var);
9+
| long get_sysvar(const volatile void *var);
1010
|
1111
| Read an OS variable.
1212
|

mintlib/setsysvar.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,21 @@
77
#include "lib.h"
88

99
void
10-
set_sysvar_to_long (void *var, long val)
10+
set_sysvar_to_short (volatile void *var, short val)
11+
{
12+
if(__has_no_ssystem) {
13+
long save_ssp;
14+
15+
save_ssp = (long) Super((void *) 0L);
16+
*((volatile short *)var) = val;
17+
(void)SuperToUser((void *) save_ssp);
18+
}
19+
else
20+
(void) Ssystem (S_SETWVAL, var, val); /* note: root only! */
21+
}
22+
23+
void
24+
set_sysvar_to_long (volatile void *var, long val)
1125
{
1226
if(__has_no_ssystem) {
1327
long save_ssp;

0 commit comments

Comments
 (0)