5
Created by Marek Michalkiewicz <marekm@linux.org.pl>
7
THIS SOFTWARE IS NOT COPYRIGHTED
9
This source code is offered for use in the public domain. You may
10
use, modify or distribute it freely.
12
This code is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
14
DISCLAIMED. This includes but is not limited to warranties of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
pgmspace.h - this is an attempt to provide some compatibility with
20
header files that come with IAR C, to make porting applications
21
between different compilers easier. No 100% compatibility though
22
(GCC does not have full support for multiple address spaces yet).
26
#define __PGMSPACE_H_ 1
33
#ifndef __ATTR_CONST__
34
#define __ATTR_CONST__ __attribute__((__const__))
37
#ifndef __ATTR_PROGMEM__
38
#define __ATTR_PROGMEM__ __attribute__((__progmem__))
42
#define __ATTR_PURE__ __attribute__((__pure__))
45
#define PROGMEM __ATTR_PROGMEM__
51
typedef void prog_void PROGMEM;
52
typedef char prog_char PROGMEM;
53
typedef unsigned char prog_uchar PROGMEM;
54
typedef int prog_int PROGMEM;
55
typedef long prog_long PROGMEM;
56
typedef long long prog_long_long PROGMEM;
58
#define PSTR(s) ({static char __c[] PROGMEM = (s); __c;})
63
static inline unsigned char __lpm_inline(unsigned short __addr) __ATTR_CONST__;
64
static inline unsigned char __lpm_inline(unsigned short __addr)
69
#ifdef RAMPZ /* >64K program memory (ATmega103) */
71
use this for access to >64K program memory (ATmega103),
72
addr = RAMPZ:r31:r30 (if possible, put your constant tables in the
73
lower 64K and use "lpm" - it is more efficient that way, and you can
74
still use the upper 64K for executable code).
77
static inline unsigned char __elpm_inline(unsigned long __addr) __ATTR_CONST__;
78
static inline unsigned char __elpm_inline(unsigned long __addr)
85
#define PRG_RDB(addr) __lpm_inline((unsigned short)(addr))
87
#define PRG_RDB(addr) _LPM((unsigned short)(addr))
91
#define PGM_P const prog_char *
95
#define PGM_VOID_P const prog_void *
98
extern void *memcpy_P(void *, PGM_VOID_P, size_t);
99
extern char *strcat_P(char *, PGM_P);
100
extern int strcmp_P(const char *, PGM_P) __ATTR_PURE__;
101
extern char *strcpy_P(char *, PGM_P);
102
extern int strcasecmp_P(const char *, PGM_P) __ATTR_PURE__;
103
extern size_t strlen_P(PGM_P) __ATTR_CONST__; /* program memory can't change */
104
extern int strncmp_P(const char *, PGM_P, size_t) __ATTR_PURE__;
105
extern int strncasecmp_P(const char *, PGM_P) __ATTR_PURE__;
106
extern char *strncpy_P(char *, PGM_P, size_t);
108
#if 0 /* not implemented yet */
109
extern int printf_P(PGM_P, ...);
110
extern int puts_P(PGM_P);
111
extern int scanf_P(PGM_P, ...);
112
extern int sprintf_P(char *, PGM_P, ...);
113
extern int sscanf_P(const char *, PGM_P, ...);
114
extern PGM_P strerror_P(int);
121
#endif /* __PGMSPACE_H_ */