change PAD_ScanPads()s behaviour. the return value now contains a bitmask of the...
[libogc.git] / lwbt / btarch.h
blob7697f32b22b600fb0b3cf082739db504c8df24c9
1 /**
2 * \defgroup uiparch Architecture specific uIP functions
3 * @{
5 * The functions in the architecture specific module implement the IP
6 * check sum and 32-bit additions.
8 * The IP checksum calculation is the most computationally expensive
9 * operation in the TCP/IP stack and it therefore pays off to
10 * implement this in efficient assembler. The purpose of the uip-arch
11 * module is to let the checksum functions to be implemented in
12 * architecture specific assembler.
16 /**
17 * \file
18 * Declarations of architecture specific functions.
19 * \author Adam Dunkels <adam@dunkels.com>
23 * Copyright (c) 2001, Adam Dunkels.
24 * All rights reserved.
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.
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.
50 * This file is part of the lwBT stack.
55 #ifndef __BT_ARCH_H__
56 #define __BT_ARCH_H__
58 #include "bt.h"
59 #include "asm.h"
60 #include "processor.h"
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))
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
113 #if LIBC_MEMFUNCREPLACE
114 static __inline__ void __memcpy(void *dest,const void *src,s32_t len)
116 u8_t *dest0 = (u8_t*)dest;
117 u8_t *src0 = (u8_t*)src;
119 while(len--) {
120 *dest0++ = *src0++;
124 static __inline__ void __memset(void *dest,s32_t c,s32_t len)
126 u8_t *dest0 = (u8_t*)dest;
128 while(len--) {
129 *dest0++ = (s8_t)c;
133 #define MEMCPY __memcpy
134 #define MEMSET __memset
135 #else
136 #define MEMCPY memcpy
137 #define MEMSET memset
138 #endif
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 */
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 */
154 /** @} */
156 #endif /* __UIP_ARCH_H__ */