Describes predefine macros for mbed online compiler (armcc)

Committer:
MACRUM
Date:
Thu Mar 16 21:58:09 2017 +0900
Revision:
6:40e873bbc5f7
Add licence header info

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 6:40e873bbc5f7 1 /*
MACRUM 6:40e873bbc5f7 2 * mbed Microcontroller Library
MACRUM 6:40e873bbc5f7 3 * Copyright (c) 2006-2016 ARM Limited
MACRUM 6:40e873bbc5f7 4 *
MACRUM 6:40e873bbc5f7 5 * Licensed under the Apache License, Version 2.0 (the "License");
MACRUM 6:40e873bbc5f7 6 * you may not use this file except in compliance with the License.
MACRUM 6:40e873bbc5f7 7 * You may obtain a copy of the License at
MACRUM 6:40e873bbc5f7 8 *
MACRUM 6:40e873bbc5f7 9 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 6:40e873bbc5f7 10 *
MACRUM 6:40e873bbc5f7 11 * Unless required by applicable law or agreed to in writing, software
MACRUM 6:40e873bbc5f7 12 * distributed under the License is distributed on an "AS IS" BASIS,
MACRUM 6:40e873bbc5f7 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 6:40e873bbc5f7 14 * See the License for the specific language governing permissions and
MACRUM 6:40e873bbc5f7 15 * limitations under the License.
MACRUM 6:40e873bbc5f7 16 *
MACRUM 6:40e873bbc5f7 17 */
MACRUM 6:40e873bbc5f7 18
MACRUM 6:40e873bbc5f7 19 #ifndef RETARGET_H
MACRUM 6:40e873bbc5f7 20 #define RETARGET_H
MACRUM 6:40e873bbc5f7 21
MACRUM 6:40e873bbc5f7 22 #include <stdint.h>
MACRUM 6:40e873bbc5f7 23 #include <stddef.h>
MACRUM 6:40e873bbc5f7 24
MACRUM 6:40e873bbc5f7 25 /* We can get the following standard types from sys/types for gcc, but we
MACRUM 6:40e873bbc5f7 26 * need to define the types ourselves for the other compilers that normally
MACRUM 6:40e873bbc5f7 27 * target embedded systems */
MACRUM 6:40e873bbc5f7 28 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
MACRUM 6:40e873bbc5f7 29 typedef int ssize_t; ///< Signed size type, usually encodes negative errors
MACRUM 6:40e873bbc5f7 30 typedef long off_t; ///< Offset in a data stream
MACRUM 6:40e873bbc5f7 31 typedef int mode_t; ///< Mode for opening files
MACRUM 6:40e873bbc5f7 32
MACRUM 6:40e873bbc5f7 33 #define O_RDONLY 0
MACRUM 6:40e873bbc5f7 34 #define O_WRONLY 1
MACRUM 6:40e873bbc5f7 35 #define O_RDWR 2
MACRUM 6:40e873bbc5f7 36 #define O_CREAT 0x0200
MACRUM 6:40e873bbc5f7 37 #define O_TRUNC 0x0400
MACRUM 6:40e873bbc5f7 38 #define O_APPEND 0x0008
MACRUM 6:40e873bbc5f7 39
MACRUM 6:40e873bbc5f7 40 #define NAME_MAX 255 ///< Maximum size of a name in a file path
MACRUM 6:40e873bbc5f7 41
MACRUM 6:40e873bbc5f7 42 #else
MACRUM 6:40e873bbc5f7 43 #include <sys/fcntl.h>
MACRUM 6:40e873bbc5f7 44 #include <sys/types.h>
MACRUM 6:40e873bbc5f7 45 #include <sys/syslimits.h>
MACRUM 6:40e873bbc5f7 46 #endif
MACRUM 6:40e873bbc5f7 47
MACRUM 6:40e873bbc5f7 48
MACRUM 6:40e873bbc5f7 49 /* DIR declarations must also be here */
MACRUM 6:40e873bbc5f7 50 #if __cplusplus
MACRUM 6:40e873bbc5f7 51 namespace mbed { class Dir; }
MACRUM 6:40e873bbc5f7 52 typedef mbed::Dir DIR;
MACRUM 6:40e873bbc5f7 53
MACRUM 6:40e873bbc5f7 54 extern "C" {
MACRUM 6:40e873bbc5f7 55 DIR *opendir(const char*);
MACRUM 6:40e873bbc5f7 56 struct dirent *readdir(DIR *);
MACRUM 6:40e873bbc5f7 57 int closedir(DIR*);
MACRUM 6:40e873bbc5f7 58 void rewinddir(DIR*);
MACRUM 6:40e873bbc5f7 59 long telldir(DIR*);
MACRUM 6:40e873bbc5f7 60 void seekdir(DIR*, long);
MACRUM 6:40e873bbc5f7 61 int mkdir(const char *name, mode_t n);
MACRUM 6:40e873bbc5f7 62 };
MACRUM 6:40e873bbc5f7 63 #endif
MACRUM 6:40e873bbc5f7 64
MACRUM 6:40e873bbc5f7 65
MACRUM 6:40e873bbc5f7 66 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
MACRUM 6:40e873bbc5f7 67 /* The intent of this section is to unify the errno error values to match
MACRUM 6:40e873bbc5f7 68 * the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is
MACRUM 6:40e873bbc5f7 69 * necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some
MACRUM 6:40e873bbc5f7 70 * symbol definitions used by the POSIX filesystem API to return errno codes.
MACRUM 6:40e873bbc5f7 71 * Note also that ARMCC errno.h defines some symbol values differently from
MACRUM 6:40e873bbc5f7 72 * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against
MACRUM 6:40e873bbc5f7 73 * this and future changes by changing the symbol definition as shown below. */
MACRUM 6:40e873bbc5f7 74 #ifdef ENOENT
MACRUM 6:40e873bbc5f7 75 #undef ENOENT
MACRUM 6:40e873bbc5f7 76 #endif
MACRUM 6:40e873bbc5f7 77 #define ENOENT 2 /* No such file or directory. */
MACRUM 6:40e873bbc5f7 78
MACRUM 6:40e873bbc5f7 79 #ifdef EIO
MACRUM 6:40e873bbc5f7 80 #undef EIO
MACRUM 6:40e873bbc5f7 81 #endif
MACRUM 6:40e873bbc5f7 82 #define EIO 5 /* I/O error */
MACRUM 6:40e873bbc5f7 83
MACRUM 6:40e873bbc5f7 84 #ifdef ENXIO
MACRUM 6:40e873bbc5f7 85 #undef ENXIO
MACRUM 6:40e873bbc5f7 86 #endif
MACRUM 6:40e873bbc5f7 87 #define ENXIO 6 /* No such device or address */
MACRUM 6:40e873bbc5f7 88
MACRUM 6:40e873bbc5f7 89 #ifdef ENOEXEC
MACRUM 6:40e873bbc5f7 90 #undef ENOEXEC
MACRUM 6:40e873bbc5f7 91 #endif
MACRUM 6:40e873bbc5f7 92 #define ENOEXEC 8 /* Exec format error */
MACRUM 6:40e873bbc5f7 93
MACRUM 6:40e873bbc5f7 94 #ifdef EBADF
MACRUM 6:40e873bbc5f7 95 #undef EBADF
MACRUM 6:40e873bbc5f7 96 #endif
MACRUM 6:40e873bbc5f7 97 #define EBADF 9 /* Bad file number */
MACRUM 6:40e873bbc5f7 98
MACRUM 6:40e873bbc5f7 99 #ifdef ENOMEM
MACRUM 6:40e873bbc5f7 100 #undef ENOMEM
MACRUM 6:40e873bbc5f7 101 #endif
MACRUM 6:40e873bbc5f7 102 #define ENOMEM 12 /* Not enough space */
MACRUM 6:40e873bbc5f7 103
MACRUM 6:40e873bbc5f7 104 #ifdef EACCES
MACRUM 6:40e873bbc5f7 105 #undef EACCES
MACRUM 6:40e873bbc5f7 106 #endif
MACRUM 6:40e873bbc5f7 107 #define EACCES 13 /* Permission denied */
MACRUM 6:40e873bbc5f7 108
MACRUM 6:40e873bbc5f7 109 #ifdef EFAULT
MACRUM 6:40e873bbc5f7 110 #undef EFAULT
MACRUM 6:40e873bbc5f7 111 #endif
MACRUM 6:40e873bbc5f7 112 #define EFAULT 14 /* Bad address */
MACRUM 6:40e873bbc5f7 113
MACRUM 6:40e873bbc5f7 114 #ifdef EEXIST
MACRUM 6:40e873bbc5f7 115 #undef EEXIST
MACRUM 6:40e873bbc5f7 116 #endif
MACRUM 6:40e873bbc5f7 117 #define EEXIST 17 /* File exists */
MACRUM 6:40e873bbc5f7 118
MACRUM 6:40e873bbc5f7 119 #ifdef EINVAL
MACRUM 6:40e873bbc5f7 120 #undef EINVAL
MACRUM 6:40e873bbc5f7 121 #endif
MACRUM 6:40e873bbc5f7 122 #define EINVAL 22 /* Invalid argument */
MACRUM 6:40e873bbc5f7 123
MACRUM 6:40e873bbc5f7 124 #ifdef ENFILE
MACRUM 6:40e873bbc5f7 125 #undef ENFILE
MACRUM 6:40e873bbc5f7 126 #endif
MACRUM 6:40e873bbc5f7 127 #define ENFILE 23 /* Too many open files in system */
MACRUM 6:40e873bbc5f7 128
MACRUM 6:40e873bbc5f7 129 #ifdef EMFILE
MACRUM 6:40e873bbc5f7 130 #undef EMFILE
MACRUM 6:40e873bbc5f7 131 #endif
MACRUM 6:40e873bbc5f7 132 #define EMFILE 24 /* File descriptor value too large */
MACRUM 6:40e873bbc5f7 133
MACRUM 6:40e873bbc5f7 134 #ifdef ENOSYS
MACRUM 6:40e873bbc5f7 135 #undef ENOSYS
MACRUM 6:40e873bbc5f7 136 #endif
MACRUM 6:40e873bbc5f7 137 #define ENOSYS 38 /* Function not implemented */
MACRUM 6:40e873bbc5f7 138
MACRUM 6:40e873bbc5f7 139 /* Missing stat.h defines.
MACRUM 6:40e873bbc5f7 140 * The following are sys/stat.h definitions not currently present in the ARMCC
MACRUM 6:40e873bbc5f7 141 * errno.h. Note, ARMCC errno.h defines some symbol values differing from
MACRUM 6:40e873bbc5f7 142 * GCC_ARM/IAR/standard POSIX definitions. Guard against this and future
MACRUM 6:40e873bbc5f7 143 * changes by changing the symbol definition for filesystem use. */
MACRUM 6:40e873bbc5f7 144 #define _IFDIR 0040000 /* directory */
MACRUM 6:40e873bbc5f7 145 #define _IFREG 0100000 /* regular */
MACRUM 6:40e873bbc5f7 146
MACRUM 6:40e873bbc5f7 147 #define S_IFDIR _IFDIR
MACRUM 6:40e873bbc5f7 148 #define S_IFREG _IFREG
MACRUM 6:40e873bbc5f7 149
MACRUM 6:40e873bbc5f7 150 #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
MACRUM 6:40e873bbc5f7 151 #define S_IRUSR 0000400 /* read permission, owner */
MACRUM 6:40e873bbc5f7 152 #define S_IWUSR 0000200 /* write permission, owner */
MACRUM 6:40e873bbc5f7 153 #define S_IXUSR 0000100/* execute/search permission, owner */
MACRUM 6:40e873bbc5f7 154 #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
MACRUM 6:40e873bbc5f7 155 #define S_IRGRP 0000040 /* read permission, group */
MACRUM 6:40e873bbc5f7 156 #define S_IWGRP 0000020 /* write permission, grougroup */
MACRUM 6:40e873bbc5f7 157 #define S_IXGRP 0000010/* execute/search permission, group */
MACRUM 6:40e873bbc5f7 158 #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
MACRUM 6:40e873bbc5f7 159 #define S_IROTH 0000004 /* read permission, other */
MACRUM 6:40e873bbc5f7 160 #define S_IWOTH 0000002 /* write permission, other */
MACRUM 6:40e873bbc5f7 161 #define S_IXOTH 0000001/* execute/search permission, other */
MACRUM 6:40e873bbc5f7 162
MACRUM 6:40e873bbc5f7 163 #endif /* defined(__ARMCC_VERSION) || defined(__ICCARM__) */
MACRUM 6:40e873bbc5f7 164
MACRUM 6:40e873bbc5f7 165
MACRUM 6:40e873bbc5f7 166 /* The following are dirent.h definitions are declared here to garuntee
MACRUM 6:40e873bbc5f7 167 * consistency where structure may be different with different toolchains */
MACRUM 6:40e873bbc5f7 168 struct dirent {
MACRUM 6:40e873bbc5f7 169 char d_name[NAME_MAX+1];
MACRUM 6:40e873bbc5f7 170 uint8_t d_type;
MACRUM 6:40e873bbc5f7 171 };
MACRUM 6:40e873bbc5f7 172
MACRUM 6:40e873bbc5f7 173 enum {
MACRUM 6:40e873bbc5f7 174 DT_UNKNOWN, // The file type could not be determined.
MACRUM 6:40e873bbc5f7 175 DT_FIFO, // This is a named pipe (FIFO).
MACRUM 6:40e873bbc5f7 176 DT_CHR, // This is a character device.
MACRUM 6:40e873bbc5f7 177 DT_DIR, // This is a directory.
MACRUM 6:40e873bbc5f7 178 DT_BLK, // This is a block device.
MACRUM 6:40e873bbc5f7 179 DT_REG, // This is a regular file.
MACRUM 6:40e873bbc5f7 180 DT_LNK, // This is a symbolic link.
MACRUM 6:40e873bbc5f7 181 DT_SOCK, // This is a UNIX domain socket.
MACRUM 6:40e873bbc5f7 182 };
MACRUM 6:40e873bbc5f7 183
MACRUM 6:40e873bbc5f7 184
MACRUM 6:40e873bbc5f7 185 #endif /* RETARGET_H */