Mbed-os improvement for CHIP project integration:

Increase SPI stack size to 2048 for BlueNrg driver
Improve getting/setting O_NONBLOCK option in fcntl() implementation
Disable override errno erro value in mbed_retarget.h
Disable setting own values of flags for fcntl() function if they are defined
pull/14522/head
ATmobica 2021-04-08 15:41:53 +02:00
parent 0c6753bb82
commit 332ba4c5ae
4 changed files with 301 additions and 146 deletions

View File

@ -55,7 +55,7 @@
#define LL_WITHOUT_HOST_OFFSET 0x2C #define LL_WITHOUT_HOST_OFFSET 0x2C
#define ROLE_OFFSET 0x2D #define ROLE_OFFSET 0x2D
#define SPI_STACK_SIZE 1024 #define SPI_STACK_SIZE 2048
namespace ble { namespace ble {
namespace vendor { namespace vendor {

View File

@ -186,7 +186,7 @@ struct AtomicBaseRaw {
T val; T val;
} ret; } ret;
{ {
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
memcpy(std::addressof(ret.val), const_cast<const T *>(std::addressof(data)), sizeof(T)); memcpy(std::addressof(ret.val), const_cast<const T *>(std::addressof(data)), sizeof(T));
} }
return std::move(ret.val); return std::move(ret.val);
@ -194,19 +194,19 @@ struct AtomicBaseRaw {
T load(memory_order order = memory_order_seq_cst) const noexcept T load(memory_order order = memory_order_seq_cst) const noexcept
{ {
MBED_CHECK_LOAD_ORDER(order); MBED_CHECK_LOAD_ORDER(order);
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
return data; return data;
} }
void store(T desired, memory_order order = memory_order_seq_cst) volatile noexcept void store(T desired, memory_order order = memory_order_seq_cst) volatile noexcept
{ {
MBED_CHECK_STORE_ORDER(order); MBED_CHECK_STORE_ORDER(order);
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
memcpy(const_cast<T *>(std::addressof(data)), std::addressof(desired), sizeof(T)); memcpy(const_cast<T *>(std::addressof(data)), std::addressof(desired), sizeof(T));
} }
void store(T desired, memory_order order = memory_order_seq_cst) noexcept void store(T desired, memory_order order = memory_order_seq_cst) noexcept
{ {
MBED_CHECK_STORE_ORDER(order); MBED_CHECK_STORE_ORDER(order);
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
data = std::move(desired); // MoveAssignable data = std::move(desired); // MoveAssignable
} }
T exchange(T desired, memory_order = memory_order_seq_cst) volatile noexcept T exchange(T desired, memory_order = memory_order_seq_cst) volatile noexcept
@ -217,7 +217,7 @@ struct AtomicBaseRaw {
T val; T val;
} old; } old;
{ {
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
memcpy(std::addressof(old.val), const_cast<const T *>(std::addressof(data)), sizeof(T)); memcpy(std::addressof(old.val), const_cast<const T *>(std::addressof(data)), sizeof(T));
memcpy(const_cast<T *>(std::addressof(data)), std::addressof(desired), sizeof(T)); memcpy(const_cast<T *>(std::addressof(data)), std::addressof(desired), sizeof(T));
} }
@ -225,7 +225,7 @@ struct AtomicBaseRaw {
} }
T exchange(T desired, memory_order = memory_order_seq_cst) noexcept T exchange(T desired, memory_order = memory_order_seq_cst) noexcept
{ {
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
T old = std::move(data); // MoveConstructible T old = std::move(data); // MoveConstructible
data = std::move(desired); // MoveAssignable data = std::move(desired); // MoveAssignable
return old; return old;
@ -233,7 +233,7 @@ struct AtomicBaseRaw {
bool compare_exchange_strong(T &expected, T desired, memory_order success, memory_order failure) volatile noexcept bool compare_exchange_strong(T &expected, T desired, memory_order success, memory_order failure) volatile noexcept
{ {
MBED_CHECK_CAS_ORDER(success, failure); MBED_CHECK_CAS_ORDER(success, failure);
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
if (memcmp(const_cast<const T *>(std::addressof(data)), std::addressof(expected), sizeof(T)) == 0) { if (memcmp(const_cast<const T *>(std::addressof(data)), std::addressof(expected), sizeof(T)) == 0) {
memcpy(const_cast<T *>(std::addressof(data)), std::addressof(desired), sizeof(T)); memcpy(const_cast<T *>(std::addressof(data)), std::addressof(desired), sizeof(T));
return true; return true;
@ -245,7 +245,7 @@ struct AtomicBaseRaw {
bool compare_exchange_strong(T &expected, T desired, memory_order success, memory_order failure) noexcept bool compare_exchange_strong(T &expected, T desired, memory_order success, memory_order failure) noexcept
{ {
MBED_CHECK_CAS_ORDER(success, failure); MBED_CHECK_CAS_ORDER(success, failure);
CriticalSectionLock lock; mbed::CriticalSectionLock lock;
if (memcmp(std::addressof(data), std::addressof(expected), sizeof(T)) == 0) { if (memcmp(std::addressof(data), std::addressof(expected), sizeof(T)) == 0) {
data = std::move(desired); // MoveAssignable data = std::move(desired); // MoveAssignable
return true; return true;

View File

@ -36,6 +36,7 @@
#define __error_t_defined 1 #define __error_t_defined 1
#endif #endif
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#if defined __has_include #if defined __has_include
# if __has_include (<sys/stat.h>) # if __has_include (<sys/stat.h>)
@ -63,17 +64,36 @@ typedef unsigned int gid_t; ///< Group ID
/* Flags for open() and fcntl(GETFL/SETFL) /* Flags for open() and fcntl(GETFL/SETFL)
* At present, fcntl only supports reading and writing O_NONBLOCK * At present, fcntl only supports reading and writing O_NONBLOCK
*/ */
#ifndef O_RDONLY
#define O_RDONLY 0 ///< Open for reading #define O_RDONLY 0 ///< Open for reading
#endif
#ifndef O_WRONLY
#define O_WRONLY 1 ///< Open for writing #define O_WRONLY 1 ///< Open for writing
#endif
#ifndef O_RDWR
#define O_RDWR 2 ///< Open for reading and writing #define O_RDWR 2 ///< Open for reading and writing
#endif
#ifndef O_NONBLOCK
#define O_NONBLOCK 0x0004 ///< Non-blocking mode #define O_NONBLOCK 0x0004 ///< Non-blocking mode
#endif
#ifndef O_APPEND
#define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write #define O_APPEND 0x0008 ///< Set file offset to end of file prior to each write
#endif
#ifndef O_CREAT
#define O_CREAT 0x0200 ///< Create file if it does not exist #define O_CREAT 0x0200 ///< Create file if it does not exist
#endif
#ifndef O_TRUNC
#define O_TRUNC 0x0400 ///< Truncate file to zero length #define O_TRUNC 0x0400 ///< Truncate file to zero length
#endif
#ifndef O_EXCL
#define O_EXCL 0x0800 ///< Fail if file exists #define O_EXCL 0x0800 ///< Fail if file exists
#endif
#ifndef O_BINARY
#define O_BINARY 0x8000 ///< Open file in binary mode #define O_BINARY 0x8000 ///< Open file in binary mode
#endif
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif
#define NAME_MAX 255 ///< Maximum size of a name in a file path #define NAME_MAX 255 ///< Maximum size of a name in a file path
@ -196,268 +216,399 @@ typedef struct DIR_impl DIR;
* the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against * the GCC_ARM/IAR/standard POSIX definitions. The definitions guard against
* this and future changes by changing the symbol definition as shown below. * this and future changes by changing the symbol definition as shown below.
*/ */
#undef EPERM #ifndef EPERM
#define EPERM 1 /* Operation not permitted */ #define EPERM 1 /* Operation not permitted */
#undef ENOENT #endif
#ifndef ENOENT
#define ENOENT 2 /* No such file or directory */ #define ENOENT 2 /* No such file or directory */
#undef ESRCH #endif
#ifndef ESRCH
#define ESRCH 3 /* No such process */ #define ESRCH 3 /* No such process */
#undef EINTR #endif
#ifndef EINTR
#define EINTR 4 /* Interrupted system call */ #define EINTR 4 /* Interrupted system call */
#undef EIO #endif
#ifndef EIO
#define EIO 5 /* I/O error */ #define EIO 5 /* I/O error */
#undef ENXIO #endif
#ifndef ENXIO
#define ENXIO 6 /* No such device or address */ #define ENXIO 6 /* No such device or address */
#undef E2BIG #endif
#ifndef E2BIG
#define E2BIG 7 /* Argument list too long */ #define E2BIG 7 /* Argument list too long */
#undef ENOEXEC #endif
#ifndef ENOEXEC
#define ENOEXEC 8 /* Exec format error */ #define ENOEXEC 8 /* Exec format error */
#undef EBADF #endif
#ifndef EBADF
#define EBADF 9 /* Bad file number */ #define EBADF 9 /* Bad file number */
#undef ECHILD #endif
#ifndef ECHILD
#define ECHILD 10 /* No child processes */ #define ECHILD 10 /* No child processes */
#undef EAGAIN #endif
#ifndef EAGAIN
#define EAGAIN 11 /* Try again */ #define EAGAIN 11 /* Try again */
#undef ENOMEM #endif
#ifndef ENOMEM
#define ENOMEM 12 /* Out of memory */ #define ENOMEM 12 /* Out of memory */
#undef EACCES #endif
#ifndef EACCES
#define EACCES 13 /* Permission denied */ #define EACCES 13 /* Permission denied */
#undef EFAULT #endif
#ifndef EFAULT
#define EFAULT 14 /* Bad address */ #define EFAULT 14 /* Bad address */
#undef ENOTBLK #endif
#ifndef ENOTBLK
#define ENOTBLK 15 /* Block device required */ #define ENOTBLK 15 /* Block device required */
#undef EBUSY #endif
#ifndef EBUSY
#define EBUSY 16 /* Device or resource busy */ #define EBUSY 16 /* Device or resource busy */
#undef EEXIST #endif
#ifndef EEXIST
#define EEXIST 17 /* File exists */ #define EEXIST 17 /* File exists */
#undef EXDEV #endif
#ifndef EXDEV
#define EXDEV 18 /* Cross-device link */ #define EXDEV 18 /* Cross-device link */
#undef ENODEV #endif
#ifndef ENODEV
#define ENODEV 19 /* No such device */ #define ENODEV 19 /* No such device */
#undef ENOTDIR #endif
#ifndef ENOTDIR
#define ENOTDIR 20 /* Not a directory */ #define ENOTDIR 20 /* Not a directory */
#undef EISDIR #endif
#ifndef EISDIR
#define EISDIR 21 /* Is a directory */ #define EISDIR 21 /* Is a directory */
#undef EINVAL #endif
#ifndef EINVAL
#define EINVAL 22 /* Invalid argument */ #define EINVAL 22 /* Invalid argument */
#undef ENFILE #endif
#ifndef ENFILE
#define ENFILE 23 /* File table overflow */ #define ENFILE 23 /* File table overflow */
#undef EMFILE #endif
#ifndef EMFILE
#define EMFILE 24 /* Too many open files */ #define EMFILE 24 /* Too many open files */
#undef ENOTTY #endif
#ifndef ENOTTY
#define ENOTTY 25 /* Not a typewriter */ #define ENOTTY 25 /* Not a typewriter */
#undef ETXTBSY #endif
#ifndef ETXTBSY
#define ETXTBSY 26 /* Text file busy */ #define ETXTBSY 26 /* Text file busy */
#undef EFBIG #endif
#ifndef EFBIG
#define EFBIG 27 /* File too large */ #define EFBIG 27 /* File too large */
#undef ENOSPC #endif
#ifndef ENOSPC
#define ENOSPC 28 /* No space left on device */ #define ENOSPC 28 /* No space left on device */
#undef ESPIPE #endif
#ifndef ESPIPE
#define ESPIPE 29 /* Illegal seek */ #define ESPIPE 29 /* Illegal seek */
#undef EROFS #endif
#ifndef EROFS
#define EROFS 30 /* Read-only file system */ #define EROFS 30 /* Read-only file system */
#undef EMLINK #endif
#ifndef EMLINK
#define EMLINK 31 /* Too many links */ #define EMLINK 31 /* Too many links */
#undef EPIPE #endif
#ifndef EPIPE
#define EPIPE 32 /* Broken pipe */ #define EPIPE 32 /* Broken pipe */
#undef EDOM #endif
#ifndef EDOM
#define EDOM 33 /* Math argument out of domain of func */ #define EDOM 33 /* Math argument out of domain of func */
#undef ERANGE #endif
#ifndef ERANGE
#define ERANGE 34 /* Math result not representable */ #define ERANGE 34 /* Math result not representable */
#undef EDEADLK #endif
#ifndef EDEADLK
#define EDEADLK 35 /* Resource deadlock would occur */ #define EDEADLK 35 /* Resource deadlock would occur */
#undef ENAMETOOLONG #endif
#ifndef ENAMETOOLONG
#define ENAMETOOLONG 36 /* File name too long */ #define ENAMETOOLONG 36 /* File name too long */
#undef ENOLCK #endif
#ifndef ENOLCK
#define ENOLCK 37 /* No record locks available */ #define ENOLCK 37 /* No record locks available */
#undef ENOSYS #endif
#ifndef ENOSYS
#define ENOSYS 38 /* Function not implemented */ #define ENOSYS 38 /* Function not implemented */
#undef ENOTEMPTY #endif
#ifndef ENOTEMPTY
#define ENOTEMPTY 39 /* Directory not empty */ #define ENOTEMPTY 39 /* Directory not empty */
#undef ELOOP #endif
#ifndef ELOOP
#define ELOOP 40 /* Too many symbolic links encountered */ #define ELOOP 40 /* Too many symbolic links encountered */
#undef EWOULDBLOCK #endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN /* Operation would block */ #define EWOULDBLOCK EAGAIN /* Operation would block */
#undef ENOMSG #endif
#ifndef ENOMSG
#define ENOMSG 42 /* No message of desired type */ #define ENOMSG 42 /* No message of desired type */
#undef EIDRM #endif
#ifndef EIDRM
#define EIDRM 43 /* Identifier removed */ #define EIDRM 43 /* Identifier removed */
#undef ECHRNG #endif
#ifndef ECHRNG
#define ECHRNG 44 /* Channel number out of range */ #define ECHRNG 44 /* Channel number out of range */
#undef EL2NSYNC #endif
#ifndef EL2NSYNC
#define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL2NSYNC 45 /* Level 2 not synchronized */
#undef EL3HLT #endif
#ifndef EL3HLT
#define EL3HLT 46 /* Level 3 halted */ #define EL3HLT 46 /* Level 3 halted */
#undef EL3RST #endif
#ifndef EL3RST
#define EL3RST 47 /* Level 3 reset */ #define EL3RST 47 /* Level 3 reset */
#undef ELNRNG #endif
#ifndef ELNRNG
#define ELNRNG 48 /* Link number out of range */ #define ELNRNG 48 /* Link number out of range */
#undef EUNATCH #endif
#ifndef EUNATCH
#define EUNATCH 49 /* Protocol driver not attached */ #define EUNATCH 49 /* Protocol driver not attached */
#undef ENOCSI #endif
#ifndef ENOCSI
#define ENOCSI 50 /* No CSI structure available */ #define ENOCSI 50 /* No CSI structure available */
#undef EL2HLT #endif
#ifndef EL2HLT
#define EL2HLT 51 /* Level 2 halted */ #define EL2HLT 51 /* Level 2 halted */
#undef EBADE #endif
#ifndef EBADE
#define EBADE 52 /* Invalid exchange */ #define EBADE 52 /* Invalid exchange */
#undef EBADR #endif
#ifndef EBADR
#define EBADR 53 /* Invalid request descriptor */ #define EBADR 53 /* Invalid request descriptor */
#undef EXFULL #endif
#ifndef EXFULL
#define EXFULL 54 /* Exchange full */ #define EXFULL 54 /* Exchange full */
#undef ENOANO #endif
#ifndef ENOANO
#define ENOANO 55 /* No anode */ #define ENOANO 55 /* No anode */
#undef EBADRQC #endif
#ifndef EBADRQC
#define EBADRQC 56 /* Invalid request code */ #define EBADRQC 56 /* Invalid request code */
#undef EBADSLT #endif
#ifndef EBADSLT
#define EBADSLT 57 /* Invalid slot */ #define EBADSLT 57 /* Invalid slot */
#undef EDEADLOCK #endif
#ifndef EDEADLOCK
#define EDEADLOCK EDEADLK /* Resource deadlock would occur */ #define EDEADLOCK EDEADLK /* Resource deadlock would occur */
#undef EBFONT #endif
#ifndef EBFONT
#define EBFONT 59 /* Bad font file format */ #define EBFONT 59 /* Bad font file format */
#undef ENOSTR #endif
#ifndef ENOSTR
#define ENOSTR 60 /* Device not a stream */ #define ENOSTR 60 /* Device not a stream */
#undef ENODATA #endif
#ifndef ENODATA
#define ENODATA 61 /* No data available */ #define ENODATA 61 /* No data available */
#undef ETIME #endif
#ifndef ETIME
#define ETIME 62 /* Timer expired */ #define ETIME 62 /* Timer expired */
#undef ENOSR #endif
#ifndef ENOSR
#define ENOSR 63 /* Out of streams resources */ #define ENOSR 63 /* Out of streams resources */
#undef ENONET #endif
#ifndef ENONET
#define ENONET 64 /* Machine is not on the network */ #define ENONET 64 /* Machine is not on the network */
#undef ENOPKG #endif
#ifndef ENOPKG
#define ENOPKG 65 /* Package not installed */ #define ENOPKG 65 /* Package not installed */
#undef EREMOTE #endif
#ifndef EREMOTE
#define EREMOTE 66 /* Object is remote */ #define EREMOTE 66 /* Object is remote */
#undef ENOLINK #endif
#ifndef ENOLINK
#define ENOLINK 67 /* Link has been severed */ #define ENOLINK 67 /* Link has been severed */
#undef EADV #endif
#ifndef EADV
#define EADV 68 /* Advertise error */ #define EADV 68 /* Advertise error */
#undef ESRMNT #endif
#ifndef ESRMNT
#define ESRMNT 69 /* Srmount error */ #define ESRMNT 69 /* Srmount error */
#undef ECOMM #endif
#ifndef ECOMM
#define ECOMM 70 /* Communication error on send */ #define ECOMM 70 /* Communication error on send */
#undef EPROTO #endif
#ifndef EPROTO
#define EPROTO 71 /* Protocol error */ #define EPROTO 71 /* Protocol error */
#undef EMULTIHOP #endif
#ifndef EMULTIHOP
#define EMULTIHOP 72 /* Multihop attempted */ #define EMULTIHOP 72 /* Multihop attempted */
#undef EDOTDOT #endif
#ifndef EDOTDOT
#define EDOTDOT 73 /* RFS specific error */ #define EDOTDOT 73 /* RFS specific error */
#undef EBADMSG #endif
#ifndef EBADMSG
#define EBADMSG 74 /* Not a data message */ #define EBADMSG 74 /* Not a data message */
#undef EOVERFLOW #endif
#ifndef EOVERFLOW
#define EOVERFLOW 75 /* Value too large for defined data type */ #define EOVERFLOW 75 /* Value too large for defined data type */
#undef ENOTUNIQ #endif
#ifndef ENOTUNIQ
#define ENOTUNIQ 76 /* Name not unique on network */ #define ENOTUNIQ 76 /* Name not unique on network */
#undef EBADFD #endif
#ifndef EBADFD
#define EBADFD 77 /* File descriptor in bad state */ #define EBADFD 77 /* File descriptor in bad state */
#undef EREMCHG #endif
#ifndef EREMCHG
#define EREMCHG 78 /* Remote address changed */ #define EREMCHG 78 /* Remote address changed */
#undef ELIBACC #endif
#ifndef ELIBACC
#define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBACC 79 /* Can not access a needed shared library */
#undef ELIBBAD #endif
#ifndef ELIBBAD
#define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */
#undef ELIBSCN #endif
#ifndef ELIBSCN
#define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBSCN 81 /* .lib section in a.out corrupted */
#undef ELIBMAX #endif
#ifndef ELIBMAX
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */
#undef ELIBEXEC #endif
#ifndef ELIBEXEC
#define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */
#undef EILSEQ #endif
#ifndef EILSEQ
#define EILSEQ 84 /* Illegal byte sequence */ #define EILSEQ 84 /* Illegal byte sequence */
#undef ERESTART #endif
#ifndef ERESTART
#define ERESTART 85 /* Interrupted system call should be restarted */ #define ERESTART 85 /* Interrupted system call should be restarted */
#undef ESTRPIPE #endif
#ifndef ESTRPIPE
#define ESTRPIPE 86 /* Streams pipe error */ #define ESTRPIPE 86 /* Streams pipe error */
#undef EUSERS #endif
#ifndef EUSERS
#define EUSERS 87 /* Too many users */ #define EUSERS 87 /* Too many users */
#undef ENOTSOCK #endif
#ifndef ENOTSOCK
#define ENOTSOCK 88 /* Socket operation on non-socket */ #define ENOTSOCK 88 /* Socket operation on non-socket */
#undef EDESTADDRREQ #endif
#ifndef EDESTADDRREQ
#define EDESTADDRREQ 89 /* Destination address required */ #define EDESTADDRREQ 89 /* Destination address required */
#undef EMSGSIZE #endif
#ifndef EMSGSIZE
#define EMSGSIZE 90 /* Message too long */ #define EMSGSIZE 90 /* Message too long */
#undef EPROTOTYPE #endif
#ifndef EPROTOTYPE
#define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */
#undef ENOPROTOOPT #endif
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 92 /* Protocol not available */ #define ENOPROTOOPT 92 /* Protocol not available */
#undef EPROTONOSUPPORT #endif
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT 93 /* Protocol not supported */ #define EPROTONOSUPPORT 93 /* Protocol not supported */
#undef ESOCKTNOSUPPORT #endif
#ifndef ESOCKTNOSUPPORT
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */
#undef EOPNOTSUPP #endif
#ifndef EOPNOTSUPP
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#undef EPFNOSUPPORT #endif
#ifndef EPFNOSUPPORT
#define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EPFNOSUPPORT 96 /* Protocol family not supported */
#undef EAFNOSUPPORT #endif
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */
#undef EADDRINUSE #endif
#ifndef EADDRINUSE
#define EADDRINUSE 98 /* Address already in use */ #define EADDRINUSE 98 /* Address already in use */
#undef EADDRNOTAVAIL #endif
#ifndef EADDRNOTAVAIL
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */
#undef ENETDOWN #endif
#ifndef ENETDOWN
#define ENETDOWN 100 /* Network is down */ #define ENETDOWN 100 /* Network is down */
#undef ENETUNREACH #endif
#ifndef ENETUNREACH
#define ENETUNREACH 101 /* Network is unreachable */ #define ENETUNREACH 101 /* Network is unreachable */
#undef ENETRESET #endif
#ifndef ENETRESET
#define ENETRESET 102 /* Network dropped connection because of reset */ #define ENETRESET 102 /* Network dropped connection because of reset */
#undef ECONNABORTED #endif
#ifndef ECONNABORTED
#define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNABORTED 103 /* Software caused connection abort */
#undef ECONNRESET #endif
#ifndef ECONNRESET
#define ECONNRESET 104 /* Connection reset by peer */ #define ECONNRESET 104 /* Connection reset by peer */
#undef ENOBUFS #endif
#ifndef ENOBUFS
#define ENOBUFS 105 /* No buffer space available */ #define ENOBUFS 105 /* No buffer space available */
#undef EISCONN #endif
#ifndef EISCONN
#define EISCONN 106 /* Transport endpoint is already connected */ #define EISCONN 106 /* Transport endpoint is already connected */
#undef ENOTCONN #endif
#ifndef ENOTCONN
#define ENOTCONN 107 /* Transport endpoint is not connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */
#undef ESHUTDOWN #endif
#ifndef ESHUTDOWN
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
#undef ETOOMANYREFS #endif
#ifndef ETOOMANYREFS
#define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */
#undef ETIMEDOUT #endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 110 /* Connection timed out */ #define ETIMEDOUT 110 /* Connection timed out */
#undef ECONNREFUSED #endif
#ifndef ECONNREFUSED
#define ECONNREFUSED 111 /* Connection refused */ #define ECONNREFUSED 111 /* Connection refused */
#undef EHOSTDOWN #endif
#ifndef EHOSTDOWN
#define EHOSTDOWN 112 /* Host is down */ #define EHOSTDOWN 112 /* Host is down */
#undef EHOSTUNREACH #endif
#ifndef EHOSTUNREACH
#define EHOSTUNREACH 113 /* No route to host */ #define EHOSTUNREACH 113 /* No route to host */
#undef EALREADY #endif
#ifndef EALREADY
#define EALREADY 114 /* Operation already in progress */ #define EALREADY 114 /* Operation already in progress */
#undef EINPROGRESS #endif
#ifndef EINPROGRESS
#define EINPROGRESS 115 /* Operation now in progress */ #define EINPROGRESS 115 /* Operation now in progress */
#undef ESTALE #endif
#ifndef ESTALE
#define ESTALE 116 /* Stale NFS file handle */ #define ESTALE 116 /* Stale NFS file handle */
#undef EUCLEAN #endif
#ifndef EUCLEAN
#define EUCLEAN 117 /* Structure needs cleaning */ #define EUCLEAN 117 /* Structure needs cleaning */
#undef ENOTNAM #endif
#ifndef ENOTNAM
#define ENOTNAM 118 /* Not a XENIX named type file */ #define ENOTNAM 118 /* Not a XENIX named type file */
#undef ENAVAIL #endif
#ifndef ENAVAIL
#define ENAVAIL 119 /* No XENIX semaphores available */ #define ENAVAIL 119 /* No XENIX semaphores available */
#undef EISNAM #endif
#ifndef EISNAM
#define EISNAM 120 /* Is a named type file */ #define EISNAM 120 /* Is a named type file */
#undef EREMOTEIO #endif
#ifndef EREMOTEIO
#define EREMOTEIO 121 /* Remote I/O error */ #define EREMOTEIO 121 /* Remote I/O error */
#undef EDQUOT #endif
#ifndef EDQUOT
#define EDQUOT 122 /* Quota exceeded */ #define EDQUOT 122 /* Quota exceeded */
#undef ENOMEDIUM #endif
#ifndef ENOMEDIUM
#define ENOMEDIUM 123 /* No medium found */ #define ENOMEDIUM 123 /* No medium found */
#undef EMEDIUMTYPE #endif
#ifndef EMEDIUMTYPE
#define EMEDIUMTYPE 124 /* Wrong medium type */ #define EMEDIUMTYPE 124 /* Wrong medium type */
#undef ECANCELED #endif
#ifndef ECANCELED
#define ECANCELED 125 /* Operation Canceled */ #define ECANCELED 125 /* Operation Canceled */
#undef ENOKEY #endif
#ifndef ENOKEY
#define ENOKEY 126 /* Required key not available */ #define ENOKEY 126 /* Required key not available */
#undef EKEYEXPIRED #endif
#ifndef EKEYEXPIRED
#define EKEYEXPIRED 127 /* Key has expired */ #define EKEYEXPIRED 127 /* Key has expired */
#undef EKEYREVOKED #endif
#ifndef EKEYREVOKED
#define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREVOKED 128 /* Key has been revoked */
#undef EKEYREJECTED #endif
#ifndef EKEYREJECTED
#define EKEYREJECTED 129 /* Key was rejected by service */ #define EKEYREJECTED 129 /* Key was rejected by service */
#undef EOWNERDEAD #endif
#ifndef EOWNERDEAD
#define EOWNERDEAD 130 /* Owner died */ #define EOWNERDEAD 130 /* Owner died */
#undef ENOTRECOVERABLE #endif
#ifndef ENOTRECOVERABLE
#define ENOTRECOVERABLE 131 /* State not recoverable */ #define ENOTRECOVERABLE 131 /* State not recoverable */
#endif
/* Missing stat.h defines. /* Missing stat.h defines.
* The following are sys/stat.h definitions not currently present in the ARMCC * The following are sys/stat.h definitions not currently present in the ARMCC

View File

@ -1180,7 +1180,7 @@ extern "C" int fcntl(int fildes, int cmd, ...)
switch (cmd) { switch (cmd) {
case F_GETFL: { case F_GETFL: {
int flags = 0; int flags = 0;
if (fhc->is_blocking()) { if (!fhc->is_blocking()) {
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
} }
return flags; return flags;
@ -1190,11 +1190,15 @@ extern "C" int fcntl(int fildes, int cmd, ...)
va_start(ap, cmd); va_start(ap, cmd);
int flags = va_arg(ap, int); int flags = va_arg(ap, int);
va_end(ap); va_end(ap);
int ret = fhc->set_blocking(flags & O_NONBLOCK); if (flags & O_NONBLOCK)
if (ret < 0) { {
errno = -ret; int ret = fhc->set_blocking(false);
return -1; if (ret < 0) {
errno = -ret;
return -1;
}
} }
return 0; return 0;
} }