Skip to content

Commit 4b57c58

Browse files
Merge pull request #5528 from c1728p9/simplify_retarget
Use retarget defines where possible
2 parents b6e50f5 + beb0b20 commit 4b57c58

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

platform/mbed_retarget.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ static SingletonPtr<PlatformMutex> _mutex;
6363
# define STDERR_FILENO 2
6464

6565
#else
66-
# include <sys/stat.h>
6766
# include <sys/syslimits.h>
6867
# define PREFIX(x) x
6968
#endif

platform/mbed_retarget.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@
2828
/* We can get the following standard types from sys/types for gcc, but we
2929
* need to define the types ourselves for the other compilers that normally
3030
* target embedded systems */
31-
#if defined(__ARMCC_VERSION) || defined(__ICCARM__)
3231
typedef signed int ssize_t; ///< Signed size type, usually encodes negative errors
3332
typedef signed long off_t; ///< Offset in a data stream
33+
#if defined(__ARMCC_VERSION) || !defined(__GNUC__)
3434
typedef unsigned int mode_t; ///< Mode for opening files
3535
typedef unsigned int dev_t; ///< Device ID type
3636
typedef unsigned long ino_t; ///< File serial number
3737
typedef unsigned int nlink_t; ///< Number of links to a file
3838
typedef unsigned int uid_t; ///< User ID
3939
typedef unsigned int gid_t; ///< Group ID
40+
#endif
4041

4142
#define O_RDONLY 0 ///< Open for reading
4243
#define O_WRONLY 1 ///< Open for writing
@@ -45,19 +46,12 @@ typedef unsigned int gid_t; ///< Group ID
4546
#define O_TRUNC 0x0400 ///< Truncate file to zero length
4647
#define O_EXCL 0x0800 ///< Fail if file exists
4748
#define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write
49+
#define O_BINARY 0x8000 ///< Open file in binary mode
4850

4951
#define NAME_MAX 255 ///< Maximum size of a name in a file path
5052

5153
#include <time.h>
5254

53-
#else
54-
55-
#include <sys/fcntl.h>
56-
#include <sys/types.h>
57-
#include <sys/syslimits.h>
58-
59-
#endif
60-
6155
/** \addtogroup platform */
6256
/** @{*/
6357
/**
@@ -94,7 +88,6 @@ extern "C" {
9488
#endif
9589

9690

97-
#if defined(__ARMCC_VERSION) || defined(__ICCARM__)
9891
/* The intent of this section is to unify the errno error values to match
9992
* the POSIX definitions for the GCC_ARM, ARMCC and IAR compilers. This is
10093
* necessary because the ARMCC/IAR errno.h, or sys/stat.h are missing some
@@ -365,9 +358,7 @@ extern "C" {
365358
#define EOWNERDEAD 130 /* Owner died */
366359
#undef ENOTRECOVERABLE
367360
#define ENOTRECOVERABLE 131 /* State not recoverable */
368-
#endif
369361

370-
#if defined(__ARMCC_VERSION) || defined(__ICCARM__)
371362
/* Missing stat.h defines.
372363
* The following are sys/stat.h definitions not currently present in the ARMCC
373364
* errno.h. Note, ARMCC errno.h defines some symbol values differing from
@@ -424,8 +415,6 @@ struct stat {
424415
time_t st_ctime; ///< Time of last status change
425416
};
426417

427-
#endif /* defined(__ARMCC_VERSION) || defined(__ICCARM__) */
428-
429418

430419
/* The following are dirent.h definitions are declared here to garuntee
431420
* consistency where structure may be different with different toolchains

0 commit comments

Comments
 (0)