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>
43 typedef void prog_void;
44 typedef char prog_char;
45 typedef unsigned char prog_uchar;
46 typedef int8_t prog_int8_t;
47 typedef uint8_t prog_uint8_t;
48 typedef int16_t prog_int16_t;
49 typedef uint16_t prog_uint16_t;
50 typedef int32_t prog_int32_t;
51 typedef uint32_t prog_uint32_t;
52 typedef int64_t prog_int64_t;
55 static inline int memcmp_P(const void *s1,
56 const prog_void *s2, unsigned n)
58 return memcmp(s1, s2, n);
61 static inline void *memcpy_P(void *s1,
62 const prog_void *s2, unsigned n)
64 return memcpy(s1, s2, n);
67 static inline char *strcat_P(char *s1, const prog_char *s2)
69 return strcat(s1, s2);
72 static inline char *strcpy_P(char *s1, const prog_char *s2)
74 return strcpy(s1, s2);
77 static inline char *strncpy_P(char *s1, const prog_char *s2,
80 return strncpy(s1, s2, n);
83 static inline int strcmp_P(const char *s1, const prog_char *s2)
85 return strcmp(s1, s2);
88 static inline int strncmp_P(const char *s1, const prog_char *s2,
91 return strncmp(s1, s2, n);
94 static inline unsigned strlen_P(const prog_char *s)
99 static inline int vfprintf_P(FILE *stream,
100 const prog_char *s, va_list ap)
102 return vfprintf(stream, s, ap);
105 static inline int vsprintf_P(char *buf, const prog_char *s,
108 return vsprintf(buf, s, ap);
111 #define PGM_P const char *
114 #define printf_P(arg...) printf(args)
115 #define sprintf_P(buf, args...) sprintf(buf, args)
116 #define snprintf_P(buf, n, args...) snprintf(buf, n, args)
118 static inline uint32_t pgm_read_dword(const prog_void *x)
120 return *(uint32_t *)x;
123 static inline uint16_t pgm_read_word(const prog_void *x)
125 return *(uint16_t *)x;
128 static inline uint8_t pgm_read_byte(const prog_void *x)
130 return *(uint8_t *)x;
133 #define PGMS_FMT "%s"
135 #endif /* HOST_VERSION */
136 #endif /* _AVERSIVE_PGMSPACE_H_ */