2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: pgmspace.h,v 1.1.2.4 2007-11-21 21:54:38 zer0 Exp $
23 * This file is used for compatibility between host and avr : with
24 * this we can emulate pgmspace on a host.
27 #ifndef _AVERSIVE_PGMSPACE_H_
28 #define _AVERSIVE_PGMSPACE_H_
32 #include <avr/pgmspace.h>
44 typedef void prog_void;
45 typedef char prog_char;
46 typedef unsigned char prog_uchar;
47 typedef int8_t prog_int8_t;
48 typedef uint8_t prog_uint8_t;
49 typedef int16_t prog_int16_t;
50 typedef uint16_t prog_uint16_t;
51 typedef int32_t prog_int32_t;
52 typedef uint32_t prog_uint32_t;
53 typedef int64_t prog_int64_t;
56 static inline int memcmp_P(const void *s1,
57 const prog_void *s2, unsigned n)
59 return memcmp(s1, s2, n);
62 static inline void *memcpy_P(void *s1,
63 const prog_void *s2, unsigned n)
65 return memcpy(s1, s2, n);
68 static inline char *strcat_P(char *s1, const prog_char *s2)
70 return strcat(s1, s2);
73 static inline char *strcpy_P(char *s1, const prog_char *s2)
75 return strcpy(s1, s2);
78 static inline char *strncpy_P(char *s1, const prog_char *s2,
81 return strncpy(s1, s2, n);
84 static inline int strcmp_P(const char *s1, const prog_char *s2)
86 return strcmp(s1, s2);
89 static inline int strncmp_P(const char *s1, const prog_char *s2,
92 return strncmp(s1, s2, n);
95 static inline unsigned strlen_P(const prog_char *s)
100 static inline int vfprintf_P(FILE *stream,
101 const prog_char *s, va_list ap)
103 return vfprintf(stream, s, ap);
106 static inline int vsprintf_P(char *buf, const prog_char *s,
109 return vsprintf(buf, s, ap);
112 #define PGM_P const char *
115 #define printf_P(args...) printf(args)
116 #define sprintf_P(buf, args...) sprintf(buf, args)
117 #define snprintf_P(buf, n, args...) snprintf(buf, n, args)
119 static inline uint32_t pgm_read_dword(const prog_void *x)
121 return *(uint32_t *)x;
124 static inline uint16_t pgm_read_word(const prog_void *x)
126 return *(uint16_t *)x;
129 static inline uint8_t pgm_read_byte(const prog_void *x)
131 return *(uint8_t *)x;
134 #define PGMS_FMT "%s"
136 #endif /* HOST_VERSION */
137 #endif /* _AVERSIVE_PGMSPACE_H_ */