Skip to content

Commit f046867

Browse files
committed
Added some const modifiers.
1 parent e6b83e8 commit f046867

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

avrcontext.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99

1010
#ifdef __AVR__
1111

12-
/*
13-
It is highly unlikely to understand the following code without:
14-
a) basic understanding of AVR assembly language;
15-
b) reading about avr-gcc's ABI beforehand (https://gcc.gnu.org/wiki/avr-gcc).
16-
*/
17-
1812
/* AVR machine context definition. Please keep the corresponding routines/macros synchronised with this definition. */
1913
typedef struct avr_context_t_ {
2014
uint8_t sreg;
@@ -35,6 +29,28 @@ typedef struct avr_context_t_ {
3529
} sp;
3630
} avr_context_t;
3731

32+
#ifdef __cplusplus
33+
extern "C" {
34+
#endif /*__cplusplus */
35+
36+
extern void avr_getcontext(avr_context_t *cp);
37+
extern void avr_setcontext(const avr_context_t *cp);
38+
extern void avr_swapcontext(avr_context_t *oucp, const avr_context_t *cp);
39+
extern void avr_makecontext(avr_context_t *cp,
40+
void *stackp, const size_t stack_size,
41+
const avr_context_t *successor_cp,
42+
void (*funcp)(void *), void *funcargp);
43+
44+
#ifdef __cplusplus
45+
}
46+
#endif /*__cplusplus */
47+
48+
/*
49+
It is highly unlikely to understand the following code without:
50+
a) basic understanding of AVR assembly language;
51+
b) reading about avr-gcc's ABI beforehand (https://gcc.gnu.org/wiki/avr-gcc).
52+
*/
53+
3854
/* Some utility macros, most of them define offsets to simplify working on the
3955
machine context structure from within assembly code. */
4056
#define AVR_CONTEXT_ASMCONST(name, value)\
@@ -290,22 +306,6 @@ please make sure that you understand how they work.
290306
"lds ZL, " #global_context_pointer "\n" \
291307
"lds ZH, " #global_context_pointer " + 1\n")
292308

293-
#ifdef __cplusplus
294-
extern "C" {
295-
#endif /*__cplusplus */
296-
297-
extern void avr_getcontext(avr_context_t *cp);
298-
extern void avr_setcontext(avr_context_t *cp);
299-
extern void avr_swapcontext(avr_context_t *oucp, avr_context_t *cp);
300-
extern void avr_makecontext(avr_context_t *cp,
301-
void *stackp, size_t stack_size,
302-
avr_context_t *successor_cp,
303-
void (*funcp)(void *), void *funcargp);
304-
305-
#ifdef __cplusplus
306-
}
307-
#endif /*__cplusplus */
308-
309309
#endif /* __AVR__ */
310310

311311
#endif /* AVRCONTEXT_H */

avrcontext_impl.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void avr_getcontext(avr_context_t *cp)
2020
asm volatile ("ret\n");
2121
}
2222

23-
void avr_setcontext(avr_context_t *cp) __attribute__ ((naked));
24-
void avr_setcontext(avr_context_t *cp)
23+
void avr_setcontext(const avr_context_t *cp) __attribute__ ((naked));
24+
void avr_setcontext(const avr_context_t *cp)
2525
{
2626
(void)cp; /* to avoid compiler warnings */
2727
AVR_RESTORE_CONTEXT(
@@ -31,8 +31,8 @@ void avr_setcontext(avr_context_t *cp)
3131
}
3232

3333

34-
void avr_swapcontext(avr_context_t *oucp, avr_context_t *ucp) __attribute__ ((naked));
35-
void avr_swapcontext(avr_context_t *oucp, avr_context_t *ucp)
34+
void avr_swapcontext(avr_context_t *oucp, const avr_context_t *ucp) __attribute__ ((naked));
35+
void avr_swapcontext(avr_context_t *oucp, const avr_context_t *ucp)
3636
{
3737
(void)oucp; /* to avoid compiler warnings */
3838
(void)ucp;
@@ -49,17 +49,17 @@ void avr_swapcontext(avr_context_t *oucp, avr_context_t *ucp)
4949
#ifdef __cplusplus
5050
extern "C" {
5151
#endif /*__cplusplus **/
52-
static void avr_makecontext_callfunc(avr_context_t *successor, void (*func)(void *), void *funcarg);
52+
static void avr_makecontext_callfunc(const avr_context_t *successor, void (*func)(void *), void *funcarg);
5353
#ifdef __cplusplus
5454
}
5555
#endif /*__cplusplus */
56-
static void avr_makecontext_callfunc(avr_context_t *successor, void (*func)(void *), void *funcarg)
56+
static void avr_makecontext_callfunc(const avr_context_t *successor, void (*func)(void *), void *funcarg)
5757
{
5858
func(funcarg);
5959
avr_setcontext(successor);
6060
}
6161

62-
void avr_makecontext(avr_context_t *cp, void *stackp, size_t stack_size, avr_context_t *successor_cp, void (*funcp)(void *), void *funcargp)
62+
void avr_makecontext(avr_context_t *cp, void *stackp, const size_t stack_size, const avr_context_t *successor_cp, void (*funcp)(void *), void *funcargp)
6363
{
6464
uint16_t addr;
6565
uint8_t *p = (uint8_t *)&addr;

0 commit comments

Comments
 (0)