~ubuntu-branches/ubuntu/breezy/avr-libc/breezy

« back to all changes in this revision

Viewing changes to include/pgmspace.h

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2002-04-15 14:53:38 UTC
  • Revision ID: james.westby@ubuntu.com-20020415145338-c8hi0tn5bx74w7o3
Tags: upstream-20020203
ImportĀ upstreamĀ versionĀ 20020203

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   pgmspace.h
 
3
 
 
4
   Contributors:
 
5
     Created by Marek Michalkiewicz <marekm@linux.org.pl>
 
6
 
 
7
   THIS SOFTWARE IS NOT COPYRIGHTED
 
8
 
 
9
   This source code is offered for use in the public domain.  You may
 
10
   use, modify or distribute it freely.
 
11
 
 
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.
 
16
 */
 
17
 
 
18
/*
 
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).
 
23
 */
 
24
 
 
25
#ifndef __PGMSPACE_H_
 
26
#define __PGMSPACE_H_ 1
 
27
 
 
28
#define __need_size_t
 
29
#include <stddef.h>
 
30
 
 
31
/* #include <io.h> */
 
32
 
 
33
#ifndef __ATTR_CONST__
 
34
#define __ATTR_CONST__ __attribute__((__const__))
 
35
#endif
 
36
 
 
37
#ifndef __ATTR_PROGMEM__
 
38
#define __ATTR_PROGMEM__ __attribute__((__progmem__))
 
39
#endif
 
40
 
 
41
#ifndef __ATTR_PURE__
 
42
#define __ATTR_PURE__ __attribute__((__pure__))
 
43
#endif
 
44
 
 
45
#define PROGMEM __ATTR_PROGMEM__
 
46
 
 
47
#ifdef __cplusplus
 
48
extern "C" {
 
49
#endif
 
50
 
 
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;
 
57
 
 
58
#define PSTR(s) ({static char __c[] PROGMEM = (s); __c;})
 
59
 
 
60
/* _LPM(), _ELPM() */
 
61
#include <ina90.h>
 
62
 
 
63
static inline unsigned char __lpm_inline(unsigned short __addr) __ATTR_CONST__;
 
64
static inline unsigned char __lpm_inline(unsigned short __addr)
 
65
{
 
66
        return _LPM(__addr);
 
67
}
 
68
 
 
69
#ifdef RAMPZ  /* >64K program memory (ATmega103) */
 
70
/*
 
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).
 
75
 */
 
76
 
 
77
static inline unsigned char __elpm_inline(unsigned long __addr) __ATTR_CONST__;
 
78
static inline unsigned char __elpm_inline(unsigned long __addr)
 
79
{
 
80
        return _ELPM(__addr);
 
81
}
 
82
#endif
 
83
 
 
84
#if 0
 
85
#define PRG_RDB(addr) __lpm_inline((unsigned short)(addr))
 
86
#else
 
87
#define PRG_RDB(addr) _LPM((unsigned short)(addr))
 
88
#endif
 
89
 
 
90
#ifndef PGM_P
 
91
#define PGM_P const prog_char *
 
92
#endif
 
93
 
 
94
#ifndef PGM_VOID_P
 
95
#define PGM_VOID_P const prog_void *
 
96
#endif
 
97
 
 
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);
 
107
 
 
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);
 
115
#endif
 
116
 
 
117
#ifdef __cplusplus
 
118
}
 
119
#endif
 
120
 
 
121
#endif /* __PGMSPACE_H_ */
 
122