Make the git viewer use the global libtlsf.a
[maemo-rb.git] / lib / rbcodec / rbcodecplatform-unix.h
blob5e65be3ae419db94203f5dab15cec1f6be37a954
1 #ifndef RBCODECPLATFORM_H_INCLUDED
2 #define RBCODECPLATFORM_H_INCLUDED
4 /* assert */
5 #include <assert.h>
7 /* O_RDONLY, O_WRONLY, O_CREAT, O_APPEND */
8 #include <fcntl.h>
10 /* isdigit, islower, isprint, isspace, toupper */
11 #include <ctype.h>
13 /* memchr, memcmp, memcpy, memmove, memset, strcat, strchr, strcmp, strcpy,
14 * strlen, strncmp, strrchr */
15 #include <string.h>
17 /* strcasecmp */
18 #include <strings.h>
20 /* abs, atoi, labs, rand */
21 #include <stdlib.h>
23 /* swap16, swap32 */
24 #include <byteswap.h>
25 #ifndef swap16
26 #define swap16(x) bswap_16(x)
27 #endif
28 #ifndef swap32
29 #define swap32(x) bswap_32(x)
30 #endif
32 /* hto{be,le}{16,32}, {be,le}toh{16,32}, ROCKBOX_{BIG,LITTLE}_ENDIAN */
33 #include <endian.h>
34 #ifndef betoh16
35 #define betoh16 be16toh
36 #endif
37 #ifndef betoh32
38 #define betoh32 be32toh
39 #endif
40 #ifndef letoh16
41 #define letoh16 le16toh
42 #endif
43 #ifndef letoh32
44 #define letoh32 le32toh
45 #endif
46 #if BYTE_ORDER == LITTLE_ENDIAN
47 #define ROCKBOX_LITTLE_ENDIAN 1
48 #else
49 #define ROCKBOX_BIG_ENDIAN 1
50 #endif
52 /* filesize */
53 #include <sys/stat.h>
54 off_t filesize(int fd);
56 static inline off_t filesize(int fd) {
57 struct stat st;
58 fstat(fd, &st);
59 return st.st_size;
63 /* snprintf */
64 #include <stdio.h>
66 /* debugf, logf */
68 #ifdef DEBUG
69 #define debugf(...) fprintf(stderr, __VA_ARGS__)
70 #ifndef logf
71 #define logf(...) do { fprintf(stderr, __VA_ARGS__); \
72 putc('\n', stderr); \
73 } while (0)
74 #endif
75 #endif
78 static inline bool tdspeed_alloc_buffers(int32_t **buffers,
79 const int *buf_s, int nbuf)
81 int i;
82 for (i = 0; i < nbuf; i++)
84 buffers[i] = malloc(buf_s[i]);
85 if (!buffers[i])
86 return false;
88 return true;
91 static inline void tdspeed_free_buffers(int32_t **buffers, int nbuf)
93 int i;
94 for (i = 0; i < nbuf; i++)
96 free(buffers[i]);
100 #endif