RetroArch
btarch.h
Go to the documentation of this file.
1 
22 /*
23  * Copyright (c) 2001, Adam Dunkels.
24  * All rights reserved.
25  *
26  * Redistribution and use in source and binary forms, with or without
27  * modification, are permitted provided that the following conditions
28  * are met:
29  * 1. Redistributions of source code must retain the above copyright
30  * notice, this list of conditions and the following disclaimer.
31  * 2. Redistributions in binary form must reproduce the above copyright
32  * notice, this list of conditions and the following disclaimer in the
33  * documentation and/or other materials provided with the distribution.
34  * 3. The name of the author may not be used to endorse or promote
35  * products derived from this software without specific prior
36  * written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
39  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
40  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
42  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
44  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
46  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
47  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
48  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49  *
50  * This file is part of the lwBT stack.
51  *
52  *
53  */
54 
55 #ifndef __BT_ARCH_H__
56 #define __BT_ARCH_H__
57 
58 #include "bt.h"
59 #include "asm.h"
60 #include "processor.h"
61 
62 #define MEM_ALIGNMENT 4
63 #define MEM_ALIGN(mem) ((void*)(((u32_t)(mem)+MEM_ALIGNMENT-1)&~(u32_t)(MEM_ALIGNMENT-1)))
64 #define MEM_ALIGN_SIZE(size) (((size)+MEM_ALIGNMENT-1)&~(u32_t)(MEM_ALIGNMENT-1))
65 
66 
67 #if BYTE_ORDER == BIG_ENDIAN
68  #ifndef htole16
69  #define htole16 bswap16
70  #endif
71  #ifndef htole32
72  #define htole32 bswap32
73  #endif
74  #ifndef htole64
75  #define htole64 bswap64
76  #endif
77  #ifndef le16toh
78  #define le16toh bswap16
79  #endif
80  #ifndef le32toh
81  #define le32toh bswap32
82  #endif
83  #ifndef le642toh
84  #define le64toh bswap64
85  #endif
86  #ifndef htons
87  #define htons(x) (x)
88  #endif
89  #ifndef htonl
90  #define htonl(x) (x)
91  #endif
92  #ifndef ntohl
93  #define ntohl(x) (x)
94  #endif
95  #ifndef ntohs
96  #define ntohs(x) (x)
97  #endif
98 #else
99  #ifndef htole16
100  #define htole16
101  #endif
102  #ifndef htole32
103  #define htole32
104  #endif
105  #ifndef le16toh
106  #define le16toh
107  #endif
108  #ifndef le32toh
109  #define le32toh
110  #endif
111 #endif
112 
113 #if LIBC_MEMFUNCREPLACE
114 static __inline__ void __memcpy(void *dest,const void *src,s32_t len)
115 {
116  u8_t *dest0 = (u8_t*)dest;
117  u8_t *src0 = (u8_t*)src;
118 
119  while(len--) {
120  *dest0++ = *src0++;
121  }
122 }
123 
124 static __inline__ void __memset(void *dest,s32_t c,s32_t len)
125 {
126  u8_t *dest0 = (u8_t*)dest;
127 
128  while(len--) {
129  *dest0++ = (s8_t)c;
130  }
131 }
132 
133 #define MEMCPY __memcpy
134 #define MEMSET __memset
135 #else
136 #define MEMCPY memcpy
137 #define MEMSET memset
138 #endif
139 
140 #if LOGGING == 1
141 #include <stdio.h>
142 #define LOG(fmt, ...) fprintf(stderr, "[BTLOG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
143 #else
144 #define LOG(fmt, ...)
145 #endif /* LOGGING == 1 */
146 
147 #if ERRORING == 1
148 #include <stdio.h>
149 #define ERROR(fmt,...) fprintf(stderr, "[BTERR] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
150 #else
151 #define ERROR(fmt, ...)
152 #endif /* ERRORING == 1 */
153 
156 #endif /* __UIP_ARCH_H__ */
s8 s8_t
Definition: cc.h:44
GLenum GLsizei len
Definition: glext.h:7389
const GLubyte * c
Definition: glext.h:9812
GLenum src
Definition: glext.h:6980
u8 u8_t
Definition: cc.h:43
s32 s32_t
Definition: cc.h:48