summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChad Elliott <elliottc@objectcomputing.com>2019-06-06 09:15:02 -0500
committerChad Elliott <elliottc@objectcomputing.com>2019-06-06 09:15:02 -0500
commit4c69b74225cf6d9479caa7a31ab38fa6d70ad669 (patch)
treed2d2f9fb0d357c58063bc310c2c82d4f200b9321
parenta580273d5fc7a820ab23b1aa40faf23e97063000 (diff)
downloadATCD-4c69b74225cf6d9479caa7a31ab38fa6d70ad669.tar.gz
- Use ACE_OS::send and ACE_OS::recv on MQX, instead of write and read.
- Added static casts where pid_t is assumed to be an int. - Use configurable macro for the "use_select" parameter. - MQX does not follow conventional standards when it comes to HTONS and NTOHS and must be configured accordingly. - Modified ACE_Handle_Set so that the use of fd_array is not conditional upon ACE_WIN32. It is now enabled through ACE_HANDLE_SET_USES_FD_ARRAY. - Implement UNIX File IO Functions for MQX in MQX_Filesystem.* - Use the existing implementation to simulate condition variables. - Use emulation for diropen on MQX as is done for Windows. - Convert from MQX error to standard error number. - Use _mqx_exit in ACE_OS::_exit for MQX. - Added a nop in ACE_OS::ioctl for MQX. - Added a definition of ACE_TMAIN for MQX so that MQX is initialized and RTCS and the MQX Filesystem code is initialized before calling ace_main_i(). - Fixed a compile error in SOCK_Dgram.cpp introduced months ago. - Use struct initialization to avoid using the l_linger member directly. - Modified ACE_Select_Reactor_Base to use a hash map for handle storage based on ACE_SELECT_REACTOR_BASE_USES_HASH_MAP instead of ACE_WIN32. - Added the IAR compiler to define ACE_NOTREACHED(a) as empty. - Made ACE_IPPROTO_TCP conditionally defined. - Added error values required for ACE. - Skip the wide-character strtok test if ACE_LACKS_WCSTOK is defined in ACE/tests/OS_Test.cpp. - Added the ability to compile tests so that they output to stderr instead of a file.
-rw-r--r--ACE/ace/ACE.inl4
-rw-r--r--ACE/ace/Acceptor.h14
-rw-r--r--ACE/ace/Basic_Types.h10
-rw-r--r--ACE/ace/Default_Constants.h4
-rw-r--r--ACE/ace/Handle_Set.cpp50
-rw-r--r--ACE/ace/Handle_Set.h18
-rw-r--r--ACE/ace/Handle_Set.inl16
-rw-r--r--ACE/ace/Log_Msg.cpp6
-rw-r--r--ACE/ace/MQX_Filesystem.cpp551
-rw-r--r--ACE/ace/MQX_Filesystem.h260
-rw-r--r--ACE/ace/OS_NS_Thread.cpp14
-rw-r--r--ACE/ace/OS_NS_Thread.h4
-rw-r--r--ACE/ace/OS_NS_Thread.inl1
-rw-r--r--ACE/ace/OS_NS_dirent.inl6
-rw-r--r--ACE/ace/OS_NS_errno.cpp143
-rw-r--r--ACE/ace/OS_NS_errno.h4
-rw-r--r--ACE/ace/OS_NS_fcntl.cpp4
-rw-r--r--ACE/ace/OS_NS_stdio.h3
-rw-r--r--ACE/ace/OS_NS_stdio.inl13
-rw-r--r--ACE/ace/OS_NS_stdlib.inl2
-rw-r--r--ACE/ace/OS_NS_stropts.inl3
-rw-r--r--ACE/ace/OS_NS_sys_select.inl6
-rw-r--r--ACE/ace/OS_NS_sys_socket.inl54
-rw-r--r--ACE/ace/OS_NS_sys_stat.inl20
-rw-r--r--ACE/ace/OS_NS_sys_time.inl9
-rw-r--r--ACE/ace/OS_NS_unistd.cpp2
-rw-r--r--ACE/ace/OS_NS_unistd.inl54
-rw-r--r--ACE/ace/OS_main.h31
-rw-r--r--ACE/ace/Process.cpp2
-rw-r--r--ACE/ace/SOCK_Dgram.cpp5
-rw-r--r--ACE/ace/SOCK_SEQPACK_Association.cpp4
-rw-r--r--ACE/ace/Select_Reactor_Base.cpp62
-rw-r--r--ACE/ace/Select_Reactor_Base.h16
-rw-r--r--ACE/ace/Select_Reactor_Base.inl16
-rw-r--r--ACE/ace/Strategies_T.cpp2
-rw-r--r--ACE/ace/ace.mpc1
-rw-r--r--ACE/ace/ace_for_tao.mpc2
-rw-r--r--ACE/ace/config-macros.h2
-rw-r--r--ACE/ace/config-mqx.h509
-rw-r--r--ACE/ace/os_include/netinet/os_in.h2
-rw-r--r--ACE/ace/os_include/os_dirent.h2
-rw-r--r--ACE/ace/os_include/os_errno.h48
-rw-r--r--ACE/ace/os_include/os_pthread.h2
-rw-r--r--ACE/ace/os_include/os_unistd.h12
-rw-r--r--ACE/ace/os_include/sys/os_socket.h6
-rw-r--r--ACE/include/makeinclude/platform_mqx_icc.GNU92
-rw-r--r--ACE/tests/OS_Test.cpp4
-rw-r--r--ACE/tests/test_config.h39
-rw-r--r--TAO/tao/IIOP_Acceptor.cpp4
-rw-r--r--TAO/tao/IIOP_Connection_Handler.cpp7
50 files changed, 1988 insertions, 157 deletions
diff --git a/ACE/ace/ACE.inl b/ACE/ace/ACE.inl
index f95982d7357..3da4d87fd13 100644
--- a/ACE/ace/ACE.inl
+++ b/ACE/ace/ACE.inl
@@ -217,7 +217,7 @@ ACE::sendv_n (ACE_HANDLE handle,
ACE_INLINE ssize_t
ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len)
{
-#if defined (ACE_WIN32) || defined (HPUX)
+#if defined (ACE_WIN32) || defined (HPUX) || defined (ACE_MQX)
return ACE_OS::send (handle, (const char *) buf, len);
#else
return ACE_OS::write (handle, (const char *) buf, len);
@@ -227,7 +227,7 @@ ACE::send_i (ACE_HANDLE handle, const void *buf, size_t len)
ACE_INLINE ssize_t
ACE::recv_i (ACE_HANDLE handle, void *buf, size_t len)
{
-#if defined (ACE_WIN32) || defined (ACE_OPENVMS)
+#if defined (ACE_WIN32) || defined (ACE_OPENVMS) || defined (ACE_MQX)
return ACE_OS::recv (handle, (char *) buf, len);
#else
return ACE_OS::read (handle, (char *) buf, len);
diff --git a/ACE/ace/Acceptor.h b/ACE/ace/Acceptor.h
index f4c7754f88b..5deb1d172fd 100644
--- a/ACE/ace/Acceptor.h
+++ b/ACE/ace/Acceptor.h
@@ -68,7 +68,7 @@ public:
/// "Do-nothing" constructor.
ACE_Acceptor (ACE_Reactor * = 0,
- int use_select = 1);
+ int use_select = ACE_DEFAULT_ACCEPTOR_USE_SELECT);
/**
* Open the contained @c PEER_ACCEPTOR object to begin listening, and
@@ -106,7 +106,7 @@ public:
ACE_Acceptor (const typename PEER_ACCEPTOR::PEER_ADDR &local_addr,
ACE_Reactor *reactor = ACE_Reactor::instance (),
int flags = 0,
- int use_select = 1,
+ int use_select = ACE_DEFAULT_ACCEPTOR_USE_SELECT,
int reuse_addr = 1);
/**
@@ -148,7 +148,7 @@ public:
virtual int open (const typename PEER_ACCEPTOR::PEER_ADDR &local_addr,
ACE_Reactor *reactor = ACE_Reactor::instance (),
int flags = 0,
- int use_select = 1,
+ int use_select = ACE_DEFAULT_ACCEPTOR_USE_SELECT,
int reuse_addr = 1);
/// Close down the Acceptor's resources.
@@ -302,7 +302,7 @@ public:
/// Default constructor.
ACE_Strategy_Acceptor (const ACE_TCHAR service_name[] = 0,
const ACE_TCHAR service_description[] = 0,
- int use_select = 1,
+ int use_select = ACE_DEFAULT_ACCEPTOR_USE_SELECT,
int reuse_addr = 1);
/**
@@ -319,7 +319,7 @@ public:
ACE_Scheduling_Strategy<SVC_HANDLER> * = 0,
const ACE_TCHAR service_name[] = 0,
const ACE_TCHAR service_description[] = 0,
- int use_select = 1,
+ int use_select = ACE_DEFAULT_ACCEPTOR_USE_SELECT,
int reuse_addr = 1);
/**
@@ -359,7 +359,7 @@ public:
virtual int open (const typename PEER_ACCEPTOR::PEER_ADDR &local_addr,
ACE_Reactor *reactor,
int flags = 0,
- int use_select = 1,
+ int use_select = ACE_DEFAULT_ACCEPTOR_USE_SELECT,
int reuse_addr = 1);
/**
@@ -376,7 +376,7 @@ public:
ACE_Scheduling_Strategy<SVC_HANDLER> * = 0,
const ACE_TCHAR *service_name = 0,
const ACE_TCHAR *service_description = 0,
- int use_select = 1,
+ int use_select = ACE_DEFAULT_ACCEPTOR_USE_SELECT,
int reuse_addr = 1);
/// Close down the Strategy_Acceptor's resources.
diff --git a/ACE/ace/Basic_Types.h b/ACE/ace/Basic_Types.h
index b9feefb5ea4..f621ce65c8c 100644
--- a/ACE/ace/Basic_Types.h
+++ b/ACE/ace/Basic_Types.h
@@ -393,8 +393,14 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# define ACE_IDL_NSTOHL(X) ((X) << 16)
# endif /* ACE_LITTLE_ENDIAN */
-#define ACE_HTONS(x) htons(x)
-#define ACE_NTOHS(x) ntohs(x)
+// MQX doesn't define these macros correctly.
+# if defined (ACE_LITTLE_ENDIAN) && defined (ACE_MQX)
+# define ACE_HTONS(x) x
+# define ACE_NTOHS(x) x
+# else
+# define ACE_HTONS(x) htons(x)
+# define ACE_NTOHS(x) ntohs(x)
+# endif
# define ACE_LONGLONG_TO_PTR(PTR_TYPE, L) \
reinterpret_cast<PTR_TYPE> (static_cast<intptr_t> (L))
diff --git a/ACE/ace/Default_Constants.h b/ACE/ace/Default_Constants.h
index 6a8d4acc8ec..383679a1eac 100644
--- a/ACE/ace/Default_Constants.h
+++ b/ACE/ace/Default_Constants.h
@@ -584,5 +584,9 @@
# define ACE_SYSCALL_FAILED -1
# endif /* ACE_WIN32 */
+#if !defined (ACE_DEFAULT_ACCEPTOR_USE_SELECT)
+# define ACE_DEFAULT_ACCEPTOR_USE_SELECT 1
+#endif /* ACE_DEFAULT_ACCEPTOR_USE_SELECT */
+
#include /**/ "ace/post.h"
#endif /*ACE_DEFAULT_CONSTANTS_H*/
diff --git a/ACE/ace/Handle_Set.cpp b/ACE/ace/Handle_Set.cpp
index 0643de5dc9e..8f1831757ee 100644
--- a/ACE/ace/Handle_Set.cpp
+++ b/ACE/ace/Handle_Set.cpp
@@ -16,12 +16,12 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set)
// ACE_MSB_MASK is only used here.
// This needs to go here to avoid overflow problems on some compilers.
-#if defined (ACE_WIN32)
- // Does ACE_WIN32 have an fd_mask?
+#if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
+ // Do we have an fd_mask?
# define ACE_MSB_MASK (~(1 << (NFDBITS - 1)))
-#else /* ! ACE_WIN32 */
+#else /* ! ACE_HANDLE_SET_USES_FD_ARRAY */
# define ACE_MSB_MASK (~((fd_mask) 1 << (NFDBITS - 1)))
-#endif /* ! ACE_WIN32 */
+#endif /* ! ACE_HANDLE_SET_USES_FD_ARRAY */
#if defined (ACE_LINUX) && __GLIBC__ > 1 && __GLIBC_MINOR__ >= 1 && !defined (_XOPEN_SOURCE)
// XPG4.2 requires the fds_bits member name, so it is not enabled by
@@ -44,14 +44,14 @@ ACE_Handle_Set::dump (void) const
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nmax_handle_ = %d"), this->max_handle_));
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\n[ ")));
-#if defined (ACE_WIN32)
+#if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
for (size_t i = 0; i < (size_t) this->mask_.fd_count + 1; i++)
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT (" %x "), this->mask_.fd_array[i]));
-#else /* !ACE_WIN32 */
+#else /* !ACE_HANDLE_SET_USES_FD_ARRAY */
for (ACE_HANDLE i = 0; i < this->max_handle_ + 1; i++)
if (this->is_set (i))
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT (" %d "), i));
-#endif /* ACE_WIN32 */
+#endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT (" ]\n")));
ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
@@ -104,12 +104,12 @@ ACE_Handle_Set::ACE_Handle_Set (const fd_set &fd_mask)
ACE_OS::memcpy ((void *) &this->mask_,
(void *) &fd_mask,
sizeof this->mask_);
-#if !defined (ACE_WIN32)
+#if !defined (ACE_HANDLE_SET_USES_FD_ARRAY)
this->sync (ACE_Handle_Set::MAXSIZE);
#if defined (ACE_HAS_BIG_FD_SET)
this->min_handle_ = 0;
#endif /* ACE_HAS_BIG_FD_SET */
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_HANDLE_SET_USES_FD_ARRAY */
}
// Counts the number of bits enabled in N. Uses a table lookup to
@@ -193,7 +193,7 @@ void
ACE_Handle_Set::sync (ACE_HANDLE max)
{
ACE_TRACE ("ACE_Handle_Set::sync");
-#if !defined (ACE_WIN32)
+#if !defined (ACE_HANDLE_SET_USES_FD_ARRAY)
fd_mask *maskp = (fd_mask *)(this->mask_.fds_bits);
this->size_ = 0;
@@ -205,7 +205,7 @@ ACE_Handle_Set::sync (ACE_HANDLE max)
this->set_max (max);
#else
ACE_UNUSED_ARG (max);
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_HANDLE_SET_USES_FD_ARRAY */
}
// Resets the MAX_FD after a clear of the original MAX_FD.
@@ -214,7 +214,7 @@ void
ACE_Handle_Set::set_max (ACE_HANDLE current_max)
{
ACE_TRACE ("ACE_Handle_Set::set_max");
-#if !defined(ACE_WIN32)
+#if !defined(ACE_HANDLE_SET_USES_FD_ARRAY)
fd_mask * maskp = (fd_mask *)(this->mask_.fds_bits);
if (this->size_ == 0)
@@ -239,7 +239,7 @@ ACE_Handle_Set::set_max (ACE_HANDLE current_max)
this->max_handle_ = ACE_Handle_Set::MAXSIZE - 1;
#else
ACE_UNUSED_ARG (current_max);
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_HANDLE_SET_USES_FD_ARRAY */
}
ACE_ALLOC_HOOK_DEFINE(ACE_Handle_Set_Iterator)
@@ -251,7 +251,7 @@ ACE_Handle_Set_Iterator::dump (void) const
ACE_TRACE ("ACE_Handle_Set_Iterator::dump");
ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
-#if defined(ACE_WIN32) || !defined(ACE_HAS_BIG_FD_SET)
+#if defined(ACE_HANDLE_SET_USES_FD_ARRAY) || !defined(ACE_HAS_BIG_FD_SET)
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nhandle_index_ = %d"), this->handle_index_));
#elif defined(ACE_HAS_BIG_FD_SET)
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nword_max_ = %d"), this->word_max_));
@@ -266,14 +266,14 @@ ACE_HANDLE
ACE_Handle_Set_Iterator::operator () (void)
{
ACE_TRACE ("ACE_Handle_Set_Iterator::operator");
-#if defined (ACE_WIN32)
+#if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
if (this->handle_index_ < this->handles_.mask_.fd_count)
// Return the handle and advance the iterator.
return (ACE_HANDLE) this->handles_.mask_.fd_array[this->handle_index_++];
else
return ACE_INVALID_HANDLE;
-#elif !defined (ACE_HAS_BIG_FD_SET) /* !ACE_WIN32 */
+#elif !defined (ACE_HAS_BIG_FD_SET) /* !ACE_HANDLE_SET_USES_FD_ARRAY */
// No sense searching further than the max_handle_ + 1;
ACE_HANDLE maxhandlep1 = this->handles_.max_handle_ + 1;
@@ -400,12 +400,12 @@ ACE_Handle_Set_Iterator::operator () (void)
}
return this->handle_index_;
-#endif /* ACE_WIN32 */
+#endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
}
ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs)
: handles_ (hs),
-#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_WIN32)
+#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_HANDLE_SET_USES_FD_ARRAY)
handle_index_ (0),
word_num_ (-1)
#elif defined (ACE_HAS_BIG_FD_SET)
@@ -417,7 +417,7 @@ ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs)
#endif /* ACE_HAS_BIG_FD_SET */
{
ACE_TRACE ("ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator");
-#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET)
+#if !defined (ACE_HANDLE_SET_USES_FD_ARRAY) && !defined (ACE_HAS_BIG_FD_SET)
// No sense searching further than the max_handle_ + 1;
ACE_HANDLE maxhandlep1 =
this->handles_.max_handle_ + 1;
@@ -446,7 +446,7 @@ ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs)
&& this->handle_index_ < maxhandlep1;
this->handle_index_++)
this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK;
-#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET)
+#elif !defined (ACE_HANDLE_SET_USES_FD_ARRAY) && defined (ACE_HAS_BIG_FD_SET)
if (this->word_max_==0)
{
this->word_num_ = -1;
@@ -458,7 +458,7 @@ ACE_Handle_Set_Iterator::ACE_Handle_Set_Iterator (const ACE_Handle_Set &hs)
ACE_DIV_BY_WORDSIZE (this->handles_.min_handle_) - 1;
this->word_val_ = 0;
}
-#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */
+#endif /* !ACE_HANDLE_SET_USES_FD_ARRAY && !ACE_HAS_BIG_FD_SET */
}
void
@@ -466,7 +466,7 @@ ACE_Handle_Set_Iterator::reset_state (void)
{
ACE_TRACE ("ACE_Handle_Set_Iterator::reset_state");
-#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_WIN32)
+#if !defined (ACE_HAS_BIG_FD_SET) || defined (ACE_HANDLE_SET_USES_FD_ARRAY)
this->handle_index_ = 0;
this->word_num_ = -1;
#elif defined (ACE_HAS_BIG_FD_SET)
@@ -476,7 +476,7 @@ ACE_Handle_Set_Iterator::reset_state (void)
: ((ACE_DIV_BY_WORDSIZE (this->handles_.max_handle_)) + 1);
#endif /* ACE_HAS_BIG_FD_SET */
-#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET)
+#if !defined (ACE_HANDLE_SET_USES_FD_ARRAY) && !defined (ACE_HAS_BIG_FD_SET)
// No sense searching further than the max_handle_ + 1;
ACE_HANDLE maxhandlep1 =
this->handles_.max_handle_ + 1;
@@ -505,7 +505,7 @@ ACE_Handle_Set_Iterator::reset_state (void)
&& this->handle_index_ < maxhandlep1;
this->handle_index_++)
this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK;
-#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET)
+#elif !defined (ACE_HANDLE_SET_USES_FD_ARRAY) && defined (ACE_HAS_BIG_FD_SET)
if (this->word_max_==0)
{
this->word_num_ = -1;
@@ -517,7 +517,7 @@ ACE_Handle_Set_Iterator::reset_state (void)
ACE_DIV_BY_WORDSIZE (this->handles_.min_handle_) - 1;
this->word_val_ = 0;
}
-#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */
+#endif /* !ACE_HANDLE_SET_USES_FD_ARRAY && !ACE_HAS_BIG_FD_SET */
}
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Handle_Set.h b/ACE/ace/Handle_Set.h
index 21b239e42a0..a12d06f41be 100644
--- a/ACE/ace/Handle_Set.h
+++ b/ACE/ace/Handle_Set.h
@@ -36,6 +36,10 @@
# define ACE_DEFAULT_SELECT_REACTOR_SIZE ACE_FD_SETSIZE
#endif /* ACE_DEFAULT_SELECT_REACTOR_SIZE */
+#if defined (ACE_WIN32) || defined (ACE_MQX)
+# define ACE_HANDLE_SET_USES_FD_ARRAY
+#endif
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
/**
@@ -139,9 +143,9 @@ private:
enum
{
WORDSIZE = NFDBITS,
-#if !defined (ACE_WIN32)
+#if !defined (ACE_HANDLE_SET_USES_FD_ARRAY)
NUM_WORDS = howmany (MAXSIZE, NFDBITS),
-#endif /* ACE_WIN32 */
+#endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
NBITS = 256
};
@@ -201,14 +205,14 @@ private:
const ACE_Handle_Set &handles_;
/// Index of the bit we're examining in the current word_num_() word.
-#if defined (ACE_WIN32)
+#if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
u_int handle_index_;
#elif !defined (ACE_HAS_BIG_FD_SET)
int handle_index_;
#elif defined (ACE_HAS_BIG_FD_SET)
int handle_index_;
u_long oldlsb_;
-#endif /* ACE_WIN32 */
+#endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
/// Number of the word we're iterating over (typically between 0..7).
int word_num_;
@@ -218,13 +222,13 @@ private:
int word_max_;
#endif /* ACE_HAS_BIG_FD_SET */
-#if !defined (ACE_WIN32) && !defined (ACE_HAS_BIG_FD_SET)
+#if !defined (ACE_HANDLE_SET_USES_FD_ARRAY) && !defined (ACE_HAS_BIG_FD_SET)
/// Value of the bits in the word we're iterating on.
fd_mask word_val_;
-#elif !defined (ACE_WIN32) && defined (ACE_HAS_BIG_FD_SET)
+#elif !defined (ACE_HANDLE_SET_USES_FD_ARRAY) && defined (ACE_HAS_BIG_FD_SET)
/// Value of the bits in the word we're iterating on.
u_long word_val_;
-#endif /* !ACE_WIN32 && !ACE_HAS_BIG_FD_SET */
+#endif /* !ACE_HANDLE_SET_USES_FD_ARRAY && !ACE_HAS_BIG_FD_SET */
};
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/Handle_Set.inl b/ACE/ace/Handle_Set.inl
index d3cfe6d3822..db76152f168 100644
--- a/ACE/ace/Handle_Set.inl
+++ b/ACE/ace/Handle_Set.inl
@@ -86,11 +86,11 @@ ACE_Handle_Set::set_bit (ACE_HANDLE handle)
if ((handle != ACE_INVALID_HANDLE)
&& (!this->is_set (handle)))
{
-#if defined (ACE_WIN32)
+#if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
FD_SET ((SOCKET) handle,
&this->mask_);
++this->size_;
-#else /* ACE_WIN32 */
+#else /* ACE_HANDLE_SET_USES_FD_ARRAY */
#if defined (ACE_HAS_BIG_FD_SET)
if (this->size_ == 0)
FD_ZERO (&this->mask_);
@@ -105,7 +105,7 @@ ACE_Handle_Set::set_bit (ACE_HANDLE handle)
if (handle > this->max_handle_)
this->max_handle_ = handle;
-#endif /* ACE_WIN32 */
+#endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
}
}
@@ -123,10 +123,10 @@ ACE_Handle_Set::clr_bit (ACE_HANDLE handle)
&this->mask_);
--this->size_;
-#if !defined (ACE_WIN32)
+#if !defined (ACE_HANDLE_SET_USES_FD_ARRAY)
if (handle == this->max_handle_)
this->set_max (this->max_handle_);
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_HANDLE_SET_USES_FD_ARRAY */
}
}
@@ -136,11 +136,11 @@ ACE_INLINE int
ACE_Handle_Set::num_set (void) const
{
ACE_TRACE ("ACE_Handle_Set::num_set");
-#if defined (ACE_WIN32)
+#if defined (ACE_HANDLE_SET_USES_FD_ARRAY)
return this->mask_.fd_count;
-#else /* !ACE_WIN32 */
+#else /* !ACE_HANDLE_SET_USES_FD_ARRAY */
return this->size_;
-#endif /* ACE_WIN32 */
+#endif /* ACE_HANDLE_SET_USES_FD_ARRAY */
}
// Returns a pointer to the underlying fd_set.
diff --git a/ACE/ace/Log_Msg.cpp b/ACE/ace/Log_Msg.cpp
index 190c6d7815d..d1dcc1c449e 100644
--- a/ACE/ace/Log_Msg.cpp
+++ b/ACE/ace/Log_Msg.cpp
@@ -19,7 +19,7 @@
#include "ace/os_include/os_typeinfo.h"
#if !defined (ACE_MT_SAFE) || (ACE_MT_SAFE != 0)
-# include "ace/Object_Manager_Base.h"
+# include "ace/Object_Manager.h"
#endif /* ! ACE_MT_SAFE */
#if !defined (ACE_LACKS_IOSTREAM_TOTALLY)
@@ -1000,7 +1000,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
#else
// External decls.
- typedef void (*PTF)(...);
+ typedef void (*PointerToFunction)(...);
// Check if there were any conditional values set.
bool const conditional_values = this->conditional_values_.is_set_;
@@ -1672,7 +1672,7 @@ ACE_Log_Msg::log (const ACE_TCHAR *format_str,
}
ACE_Log_Msg::msg_off_ = bp - this->msg_;
- (*va_arg (argp, PTF))();
+ (*va_arg (argp, PointerToFunction))();
if (ACE_BIT_ENABLED (flags,
ACE_Log_Msg::SILENT) &&
diff --git a/ACE/ace/MQX_Filesystem.cpp b/ACE/ace/MQX_Filesystem.cpp
new file mode 100644
index 00000000000..3bdbe3cfb31
--- /dev/null
+++ b/ACE/ace/MQX_Filesystem.cpp
@@ -0,0 +1,551 @@
+#include "MQX_Filesystem.h"
+
+#ifdef ACE_MQX
+
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_sys_stat.h"
+
+#include <mqx.h>
+#include <fio.h>
+#include <mfs.h>
+
+#include <string.h>
+
+#ifndef FOPEN_MAX
+# error "FOPEN_MAX, the max number of open files, must be defined"
+#endif
+#if FOPEN_MAX < 3
+# error "FOPEN_MAX is less than 3, no room for standard streams, let alone other files descriptors"
+#endif
+
+#define MQX_FILE_ERROR static_cast<size_t>(-1)
+
+MQX_Filesystem MQX_Filesystem::instance_;
+
+MQX_Filesystem::MQX_Filesystem ()
+ : current_fs_ (NULL)
+ , current_fs_name_len_ (0)
+ , max_fd_ (255)
+ , last_fd_ (-1)
+{
+ current_fs_name_[0] = '\0';
+
+ // Initialize files_
+ for (unsigned i = 0; i < FOPEN_MAX; i++)
+ {
+ files_[i].fd = -1;
+ files_[i].mqx_file = NULL;
+ }
+}
+
+void MQX_Filesystem::complete_initialization ()
+{
+ // Set the Standard Streams
+ files_[0] = {ACE_STDIN, (MQX_FILE_PTR) _io_get_handle (IO_STDIN), true};
+ files_[1] = {ACE_STDOUT, (MQX_FILE_PTR) _io_get_handle (IO_STDOUT), true};
+ files_[2] = {ACE_STDERR, (MQX_FILE_PTR) _io_get_handle (IO_STDERR), true};
+
+ /*
+ * Try to set the current filesystem. Ignore the error return because if
+ * we're missing a filesystem now, it's okay because a filesystem might be
+ * added later.
+ */
+ reset_state ();
+}
+
+bool
+MQX_Filesystem::check_state ()
+{
+ if (!_io_is_fs_valid (current_fs_))
+ {
+ if (reset_state ())
+ {
+ errno = ENODEV;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool
+MQX_Filesystem::reset_state ()
+{
+ update_fs (_io_get_first_valid_fs ());
+ if (current_fs_ != NULL)
+ chdir ("\\");
+ return current_fs_ == NULL;
+}
+
+void
+MQX_Filesystem::update_fs (MQX_FILE_PTR fs)
+{
+ current_fs_ = fs;
+ bool invalid = false;
+ if (fs == NULL)
+ invalid = true;
+ else if (_io_get_fs_name (fs, current_fs_name_, IOCFG_FS_MAX_DEVLEN) != MQX_OK)
+ invalid = true;
+ else
+ current_fs_name_len_ = strlen (current_fs_name_);
+
+ if (invalid)
+ {
+ current_fs_ = NULL;
+ current_fs_name_[0] = '\0';
+ current_fs_name_len_ = 0;
+ }
+}
+
+int
+MQX_Filesystem::open (const char *path, int mode)
+{
+ if (check_state ()) return -1;
+
+ // Convert open mode to fopen mode
+ bool r = ACE_BIT_DISABLED (mode, O_RDONLY);
+ bool w = ACE_BIT_ENABLED (mode, O_WRONLY);
+ bool rw = ACE_BIT_ENABLED (mode, O_RDWR);
+ bool a = ACE_BIT_ENABLED (mode, O_CREAT | O_APPEND);
+ bool t = ACE_BIT_ENABLED (mode, O_CREAT | O_TRUNC);
+ if (!(r || (w && (a || t)) || rw))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ char cstdlib_mode[4] = {0}; // r/w/a, t/b, +?, null terminator
+ cstdlib_mode[0] = r ? 'r' : a ? 'a' : 'w';
+ cstdlib_mode[1] = 'b';
+ cstdlib_mode[2] = rw ? '+' : '\0';
+
+ /// Get Absolute Path
+ char cwd[FS_FILENAME_SIZE];
+ int mqx_error = _io_ioctl (current_fs_, IO_IOCTL_GET_CURRENT_DIR, (uint32_t*) cwd);
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ char abspath[ACE_MQX_ABS_PATH_SIZE];
+ mqx_error = _io_rel2abs (abspath, cwd, path, ACE_MQX_ABS_PATH_SIZE, current_fs_name_);
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+
+ // Set up a new File Entry
+ File *file = get_new_file ();
+ if (file == NULL) return -1;
+
+ // Call into MQX
+ file->mqx_file = _io_fopen (abspath, cstdlib_mode);
+ if (file->mqx_file == NULL)
+ {
+ file->fd = -1; // Free File in Our Array
+ errno = ACE_OS::mqx_error_to_errno (_task_get_error());
+ if (_task_get_error() == FS_FILE_NOT_FOUND)
+ _task_set_error(MQX_OK);
+ }
+
+ return file->fd;
+}
+
+int
+MQX_Filesystem::close (int fd)
+{
+ File *file = get_file (fd);
+ if (file == NULL) return -1;
+ int mqx_error = _io_fclose (file->mqx_file);
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ return 0;
+}
+
+size_t
+MQX_Filesystem::read (int fd, unsigned char *buffer, size_t size)
+{
+ File *file = get_file (fd);
+ if (file == NULL) return MQX_FILE_ERROR;
+ int result = _io_read (file->mqx_file, buffer, size);
+ if (result == IO_ERROR)
+ {
+ errno = EIO;
+ return MQX_FILE_ERROR;
+ }
+ return result;
+}
+
+size_t
+MQX_Filesystem::write (int fd, const unsigned char *buffer, size_t size)
+{
+ File *file = get_file (fd);
+ if (file == NULL) return MQX_FILE_ERROR;
+ int result = _io_write (file->mqx_file, const_cast<unsigned char *> (buffer), size);
+ if (result == IO_ERROR)
+ {
+ errno = EIO;
+ return MQX_FILE_ERROR;
+ }
+ return result;
+}
+
+long
+MQX_Filesystem::lseek (int fd, long offset, int whence)
+{
+ switch (whence)
+ {
+ case SEEK_SET:
+ whence = IO_SEEK_SET;
+ break;
+ case SEEK_CUR:
+ whence = IO_SEEK_CUR;
+ break;
+ case SEEK_END:
+ whence = IO_SEEK_END;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ File *file = get_file (fd);
+ if (file == NULL) return -1;
+ return _io_fseek (file->mqx_file, offset, whence) == MQX_OK ? 0 : -1;
+}
+
+char*
+MQX_Filesystem::getcwd (char *buf, size_t size)
+{
+ if (check_state ()) return NULL;
+ if (buf == NULL)
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ char curdirtmp[FS_FILENAME_SIZE];
+ int mqx_error = _io_ioctl (current_fs_, IO_IOCTL_GET_CURRENT_DIR, (uint32_t*) curdirtmp);
+ if (mqx_error != MFS_NO_ERROR)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return NULL;
+ }
+ if ((current_fs_name_len_ + strlen (curdirtmp) + 1) > size)
+ {
+ errno = ERANGE;
+ return NULL;
+ }
+ strcpy (buf, current_fs_name_);
+ strcat (buf, curdirtmp);
+ return buf;
+}
+
+MQX_FILE_PTR
+MQX_Filesystem::resolve_fs (const char *path, int *fs_name_len)
+{
+ if (check_state ()) return NULL;
+
+ if (fs_name_len == NULL || path == NULL || path[0] == '\0')
+ {
+ errno = EINVAL;
+ return NULL;
+ }
+ MQX_FILE_PTR fs;
+ char fs_name[IOCFG_FS_MAX_DEVLEN];
+ bool fs_in_path;
+ *fs_name_len = _io_get_dev_for_path (
+ fs_name, &fs_in_path, IOCFG_FS_MAX_DEVLEN, path, current_fs_name_);
+ if (fs_in_path)
+ {
+ fs = _io_get_fs_by_name (fs_name);
+ }
+ else if (*fs_name_len)
+ {
+ fs = current_fs_;
+ *fs_name_len = 0;
+ }
+ else
+ {
+ errno = EINVAL;
+ fs = NULL;
+ }
+ return fs;
+}
+
+int
+MQX_Filesystem::mkdir (const char *path)
+{
+ int fs_name_len;
+ MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
+ if (fs == NULL) return -1;
+ int mqx_error = _io_ioctl (
+ fs, IO_IOCTL_CREATE_SUBDIR, (uint32_t*) (path + fs_name_len));
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ return 0;
+}
+
+int
+MQX_Filesystem::chdir (const char *path)
+{
+ int fs_name_len;
+ MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
+ if (fs == NULL) return -1;
+ if (fs != current_fs_) update_fs(fs);
+ int mqx_error = _io_ioctl (fs, IO_IOCTL_CHANGE_CURRENT_DIR,
+ (uint32_t*) (path + fs_name_len));
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ return 0;
+}
+
+int
+MQX_Filesystem::rmdir (const char *path)
+{
+ int fs_name_len;
+ MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
+ if (fs == NULL) return -1;
+ int mqx_error = _io_ioctl (fs, IO_IOCTL_REMOVE_SUBDIR,
+ (uint32_t*) (path + fs_name_len));
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ return 0;
+}
+
+int
+MQX_Filesystem::unlink (const char *path)
+{
+ int fs_name_len;
+ MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
+ if (fs == NULL) return -1;
+ int mqx_error = _io_ioctl (fs, IO_IOCTL_DELETE_FILE,
+ (uint32_t*) (path + fs_name_len));
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ return 0;
+}
+
+int
+MQX_Filesystem::rename (const char *oldpath, const char *newpath)
+{
+ // TODO: Handle Moving Directories?
+ int old_fs_name_len;
+ MQX_FILE_PTR fs = resolve_fs (oldpath, &old_fs_name_len);
+ int new_fs_name_len;
+ MQX_FILE_PTR other_fs = resolve_fs (newpath, &new_fs_name_len);
+ if (fs == NULL || other_fs == NULL) return -1;
+ if (fs != other_fs)
+ {
+ errno = EXDEV;
+ return -1;
+ }
+
+ ACE_stat file_status;
+ if (this->stat (newpath, &file_status) == 0)
+ {
+ // New path already exists...
+ if (file_status.st_mode & S_IFREG)
+ {
+ // It's a file, we can delete it.
+ if (this->unlink (newpath))
+ {
+ return -1;
+ }
+ }
+ else if (file_status.st_mode & S_IFDIR)
+ {
+ // It's a directory, we can't delete that.
+ errno = EEXIST;
+ return -1;
+ }
+ else
+ {
+ // Unknown type, error
+ errno = EINVAL;
+ return -1;
+ }
+ }
+
+ MFS_RENAME_PARAM mfs_rename;
+ char oldtmp[FS_FILENAME_SIZE];
+ strcpy (oldtmp, oldpath + old_fs_name_len);
+ mfs_rename.OLD_PATHNAME = oldtmp;
+ char newtmp[FS_FILENAME_SIZE];
+ strcpy (newtmp, newpath + new_fs_name_len);
+ mfs_rename.NEW_PATHNAME = newtmp;
+
+ int mqx_error = _io_ioctl (fs, IO_IOCTL_RENAME_FILE, (uint32_t*) &mfs_rename);
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ return 0;
+}
+
+MQX_Filesystem::File *
+MQX_Filesystem::get_file (int fd)
+{
+ for (int i = 0; i < FOPEN_MAX; i++)
+ {
+ if (files_[i].fd == fd) return &files_[i];
+ }
+ errno = EBADF;
+ return NULL;
+}
+
+MQX_Filesystem::File *
+MQX_Filesystem::get_new_file ()
+{
+ // Get Unused File Struct
+ File *file = get_file (-1);
+ if (file != NULL)
+ {
+ file->mqx_file = NULL;
+ // Get Unused File Descriptor
+ for (int fd = last_fd_ + 1; fd != last_fd_; fd++)
+ {
+ if (get_file (fd) == NULL)
+ {
+ file->fd = fd;
+ last_fd_ = fd;
+ return file;
+ }
+ if (fd == max_fd_) fd = 0;
+ }
+ }
+ errno = ENFILE;
+ return NULL;
+}
+
+static inline int
+mfs_file_attrs_to_stat_mode (int attributes)
+{
+ int mode = (attributes & MFS_ATTR_DIR_NAME) ? S_IFDIR : S_IFREG;
+ return mode;
+}
+
+int
+MQX_Filesystem::stat (const char * path, ACE_stat *statbuf)
+{
+ if (statbuf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ int fs_name_len;
+ MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len);
+ if (fs == NULL) return -1;
+
+ statbuf->st_size = 0;
+ statbuf->st_mtime = 0;
+ statbuf->st_mode = 0;
+ statbuf->st_nlink = 0;
+
+ MFS_SEARCH_PARAM search;
+ search.ATTRIBUTE = MFS_SEARCH_ANY;
+ char tmppath[ACE_MQX_ABS_PATH_SIZE];
+ strcpy (&tmppath[0], path);
+ search.WILDCARD = &tmppath[fs_name_len];
+ MFS_SEARCH_DATA search_results;
+ search.SEARCH_DATA_PTR = &search_results;
+ int mqx_error = _io_ioctl (fs, IO_IOCTL_FIND_FIRST_FILE, (uint32_t *) &search);
+ if (mqx_error == MFS_NO_ERROR)
+ {
+ statbuf->st_size = search_results.FILE_SIZE;
+ statbuf->st_mode = mfs_file_attrs_to_stat_mode (search_results.ATTRIBUTE);
+ statbuf->st_nlink = 1;
+ // TODO: statbuf->st_mtime
+ return 0;
+ }
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+}
+
+int
+MQX_Filesystem::fstat (int fd, ACE_stat *statbuf)
+{
+ if (statbuf == NULL)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ File *file = get_file (fd);
+ if (file == NULL) return -1;
+
+ statbuf->st_size = 0;
+ statbuf->st_mtime = 0;
+ statbuf->st_mode = 0;
+ statbuf->st_nlink = 0;
+
+ if (file->chardev_file)
+ {
+ statbuf->st_mode &= S_IFCHR;
+ return 0;
+ }
+
+ int attributes = 0;
+ int mqx_error = _io_ioctl (file->mqx_file, IO_IOCTL_GET_FILE_ATTR, (uint32_t *) &attributes);
+ if (mqx_error != MQX_OK)
+ {
+ errno = ACE_OS::mqx_error_to_errno (mqx_error);
+ return -1;
+ }
+ statbuf->st_mode = mfs_file_attrs_to_stat_mode (attributes);
+ statbuf->st_nlink = 1;
+
+ // TODO: statbuf->st_mtime
+
+ return 0;
+}
+
+/* The following are the function definitions that DLib will use to access MQX
+ * IO through MQX_Filesystem.
+ */
+
+extern "C" {
+
+int __open (const char *filename, int mode)
+{
+ return MQX_Filesystem::inst ().open (filename, mode);
+}
+
+size_t __read (int handle, unsigned char *buffer, size_t size)
+{
+ return MQX_Filesystem::inst ().read (handle, buffer, size);
+}
+
+size_t __write (int handle, const unsigned char *buffer, size_t size)
+{
+ return MQX_Filesystem::inst ().write (handle, buffer, size);
+}
+
+long __lseek (int handle, long offset, int whence)
+{
+ return MQX_Filesystem::inst ().lseek (handle, offset, whence);
+}
+
+int __close (int handle)
+{
+ return MQX_Filesystem::inst ().close (handle);
+}
+
+} // extern "C"
+
+#endif // ACE_MQX
diff --git a/ACE/ace/MQX_Filesystem.h b/ACE/ace/MQX_Filesystem.h
new file mode 100644
index 00000000000..70953945479
--- /dev/null
+++ b/ACE/ace/MQX_Filesystem.h
@@ -0,0 +1,260 @@
+/**
+ * @file MQX_Filesystem.h
+ *
+ * @author Frederick Hornsey <hornseyf@objectcomputing.com>
+ */
+
+#ifndef MQX_FILESYSTEM_HEADER
+#define MQX_FILESYSTEM_HEADER
+
+#include "ace/config-all.h"
+
+#ifdef ACE_MQX
+
+#include <mqx.h>
+#include <fio.h>
+
+#if !defined (FOPEN_MAX)
+# define FOPEN_MAX 20
+#endif
+
+#if !defined (ACE_MQX_DLIB_FULL)
+# undef read
+# undef write
+#endif
+
+struct stat;
+typedef struct stat ACE_stat;
+
+#define ACE_MQX_ABS_PATH_SIZE (IOCFG_FS_MAX_DEVLEN + FS_FILENAME_SIZE - 1)
+
+/**
+ * Since MQX has an unusual filesystem API, this class is provided to try to
+ * normalize it by managing the current working directory on a global context
+ * instead of a device by device context provided by MQX. It also tries to make
+ * these functions act more like their UNIX counterparts to some extent.
+ *
+ * This class is also the interface between the DLib IO functions and MQX file
+ * IO. It does this by implementing the classic UNIX IO functions below.
+ *
+ * WARNING: This is already being done in the ACE_TMAIN macro, but
+ * complete_initialization() should be called before using DLib or ACE file IO
+ * functions, but after MQX has been initialized. Either way, standard streams
+ * will not work properly, or some other behavior depending on the what
+ * functions are called in what order.
+ */
+class MQX_Filesystem {
+public:
+ /// Get the singleton instance of the class
+ inline static MQX_Filesystem &inst() {
+ return instance_;
+ }
+
+ /**
+ * Initialize the Standard Streams and the Current Filesystem
+ *
+ * This must be done after MQX has been initialized. See warning in class
+ * documenting comment.
+ */
+ void complete_initialization ();
+
+ /**
+ * Attempt to reset the cwd state by asking MQX for the first valid filesystem
+ * and "cd-ing" into the root of it.
+ */
+ bool reset_state ();
+
+ /**
+ * @name Unix-like File Functions
+ *
+ * Classic UNIX-like Operations Implemented for for DLib
+ */
+ ///@{
+ /**
+ * Open a file and return the file descriptor.
+ *
+ * Returns the file descriptor if successful, -1 otherwise.
+ *
+ * Known Limitations:
+ * - Mode is being converted from DLib Unix-like mode to MQX cstdlib mode.
+ * This is not perfected yet and is limited by the common denominator of
+ * what is supported by both systems.
+ */
+ int open (const char *path, int mode);
+ int close (int fd);
+ size_t read (int fd, unsigned char *buffer, size_t size);
+ size_t write (int fd, const unsigned char *buffer, size_t size);
+ long lseek (int fd, long offset, int whence);
+ ///@}
+
+ /**
+ * @name Unix-like Filesystem Functions
+ */
+ ///@{
+ /**
+ * Put the current directory path in buf of size.
+ *
+ * Returns NULL if an error occurred, otherwise buf.
+ */
+ char *getcwd (char *buf, size_t size);
+
+ /**
+ * Create a directory at path.
+ *
+ * Returns -1 if an error occurred, otherwise 0.
+ */
+ int mkdir (const char *path);
+
+ /**
+ * Change to the directory at path.
+ *
+ * Returns -1 if an error occurred, otherwise 0.
+ */
+ int chdir (const char *path);
+
+ /**
+ * Remove the empty directory at path.
+ *
+ * Returns -1 if an error occurred, otherwise 0.
+ */
+ int rmdir (const char *path);
+
+ /**
+ * Unlink the file at path.
+ *
+ * Returns -1 if an error occurred, otherwise 0.
+ */
+ int unlink (const char *path);
+
+ /**
+ * Rename or move the file or rename the directory from newpath to oldpath.
+ *
+ * Returns -1 if an error occurred, otherwise 0.
+ *
+ * As standard rename does, this sets errno to EXDEV if you try to move a
+ * file across filesystems. It also overwrites regular files that occupy the
+ * new path.
+ *
+ * Known Limitations:
+ * - Can only rename directories, will refuse to move them. This is MFS's
+ * IO_IOCTL_RENAME_FILE refusing to do this. This could be implemented by
+ * the function, but would involve either manually copying the file tree
+ * or refusing to move nonempty directories.
+ */
+ int rename (const char *oldpath, const char *newpath);
+
+ /**
+ * Get status of file given by path.
+ *
+ * Returns -1 if an error occurred, otherwise 0.
+ *
+ * Known Limitations:
+ * - st_mtime is currently not implemented and is set to 0.
+ * - st_mode is limited to
+ * - S_IFDIR: file is a directory
+ * - S_IFREG: file is a regular file
+ */
+ int stat (const char * path, ACE_stat *statbuf);
+
+ /**
+ * Get status of file given by file descriptor.
+ *
+ * Returns -1 if an error occurred, otherwise 0.
+ *
+ * Known Limitations:
+ * - st_mtime is currently not implemented and returns 0
+ * - In MFS there seems to be no direct way to get st_msize from a MQX file
+ * alone. The only way to get a file size using the documented API seems
+ * to be IO_IOCTL_FIND_FIRST_FILE, which requires the path. For now this
+ * will be set to 0.
+ * - st_mode is limited to
+ * - S_IFDIR: file is a directory
+ * - S_IFREG: file is a regular file
+ * - S_IFCHR: file is a special character device file, (e.g. ACE_STDOUT)
+ */
+ int fstat (int fd, ACE_stat *statbuf);
+ ///@}
+
+private:
+ /// The singleton instance of the class
+ static MQX_Filesystem instance_;
+
+ MQX_Filesystem();
+
+ /**
+ * @name Current Filesystem for resolving relative paths.
+ */
+ ///@{
+ MQX_FILE_PTR current_fs_;
+ char current_fs_name_[IOCFG_FS_MAX_DEVLEN];
+ unsigned current_fs_name_len_;
+ ///@}
+
+ /**
+ * @name Manage open files using file descriptors.
+ */
+ ///@{
+ struct File {
+ /// DLib File Descriptor. Invalid if -1.
+ int fd;
+ /// MQX File
+ MQX_FILE_PTR mqx_file;
+ /// Mark this as special character device file (Standard Streams)
+ bool chardev_file;
+ };
+ File files_[FOPEN_MAX];
+
+ /**
+ * Last file descriptor created.
+ */
+ int last_fd_;
+
+ /**
+ * Max VALUE for File Descriptors.
+ *
+ * NOTE: Max open file count is FOPEN_MAX, defined by DLib. This creates a
+ * limit on the number of unique file descriptor values.
+ */
+ int max_fd_;
+
+ /**
+ * Get a File struct for the file descriptor.
+ *
+ * Returns NULL and sets EBADF if no such file exists
+ */
+ File *get_file (int fd);
+
+ /**
+ * Get a File struct pointer to use for a new file.
+ *
+ * Returns NULL and sets ENFILE if exceeded max number of open files.
+ */
+ File *get_new_file ();
+ ///@}
+
+ /**
+ * Check to see if the current filesystem is valid, if not reset it.
+ *
+ * Returns true if reseting failed, otherwise false. Failure would probably
+ * mean no filesystems are mounted.
+ */
+ bool check_state ();
+
+ /**
+ * Set the supplied pointer as the filesystem of the current working
+ * directory.
+ */
+ void update_fs (MQX_FILE_PTR fs);
+
+ /**
+ * Resolve the filesystem of the supplied path and return it.
+ *
+ * This will be the filesystem of the current working directory if the path
+ * is relative. Sets the fs_name_len to the length of the device name in the
+ * path. This would be 0 if the path is relative.
+ */
+ MQX_FILE_PTR resolve_fs (const char *path, int *fs_name_len);
+};
+
+#endif // ACE_MQX
+#endif // MQX_FILESYSTEM_HEADER
diff --git a/ACE/ace/OS_NS_Thread.cpp b/ACE/ace/OS_NS_Thread.cpp
index 8a052271775..f50db85ceb0 100644
--- a/ACE/ace/OS_NS_Thread.cpp
+++ b/ACE/ace/OS_NS_Thread.cpp
@@ -1153,7 +1153,7 @@ ACE_OS::cond_broadcast (ACE_cond_t *cv)
result = -1;
// Wait for all the awakened threads to acquire their part of
// the counting semaphore.
-# if defined (ACE_VXWORKS)
+# if defined (ACE_VXWORKS) || defined (ACE_MQX)
else if (ACE_OS::sema_wait (&cv->waiters_done_) == -1)
# else
else if (ACE_OS::event_wait (&cv->waiters_done_) == -1)
@@ -1177,7 +1177,7 @@ ACE_OS::cond_destroy (ACE_cond_t *cv)
# if defined (ACE_HAS_THREADS)
# if defined (ACE_HAS_WTHREADS)
ACE_OS::event_destroy (&cv->waiters_done_);
-# elif defined (ACE_VXWORKS)
+# elif defined (ACE_VXWORKS) || defined (ACE_MQX)
ACE_OS::sema_destroy (&cv->waiters_done_);
# endif /* ACE_VXWORKS */
int result = 0;
@@ -1227,7 +1227,7 @@ ACE_OS::cond_init (ACE_cond_t *cv, short type, const char *name, void *arg)
result = -1;
else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1)
result = -1;
-# if defined (ACE_VXWORKS)
+# if defined (ACE_VXWORKS) || defined (ACE_MQX)
else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1)
# else
else if (ACE_OS::event_init (&cv->waiters_done_) == -1)
@@ -1257,7 +1257,7 @@ ACE_OS::cond_init (ACE_cond_t *cv, short type, const wchar_t *name, void *arg)
result = -1;
else if (ACE_OS::thread_mutex_init (&cv->waiters_lock_) == -1)
result = -1;
-# if defined (ACE_VXWORKS)
+# if defined (ACE_VXWORKS) || defined (ACE_MQX)
else if (ACE_OS::sema_init (&cv->waiters_done_, 0, type) == -1)
# else
else if (ACE_OS::event_init (&cv->waiters_done_) == -1)
@@ -1388,7 +1388,7 @@ ACE_OS::cond_wait (ACE_cond_t *cv,
// If we're the last waiter thread during this particular broadcast
// then let all the other threads proceed.
else if (last_waiter)
-# if defined (ACE_VXWORKS)
+# if defined (ACE_VXWORKS) || defined (ACE_MQX)
ACE_OS::sema_post (&cv->waiters_done_);
# else
ACE_OS::event_signal (&cv->waiters_done_);
@@ -1416,7 +1416,7 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
// Handle the easy case first.
if (timeout == 0)
return ACE_OS::cond_wait (cv, external_mutex);
-# if defined (ACE_HAS_WTHREADS) || defined (ACE_VXWORKS)
+# if defined (ACE_HAS_WTHREADS) || defined (ACE_VXWORKS) || defined (ACE_MQX)
// Prevent race conditions on the <waiters_> count.
if (ACE_OS::thread_mutex_lock (&cv->waiters_lock_) != 0)
@@ -1478,6 +1478,8 @@ ACE_OS::cond_timedwait (ACE_cond_t *cv,
int const ticks_per_sec = ::sysClkRateGet ();
int const ticks = msec_timeout * ticks_per_sec / ACE_ONE_SECOND_IN_MSECS;
result = ::semTake (cv->sema_.sema_, ticks);
+# else
+ result = ACE_OS::sema_wait (&cv->sema_, timeout);
# endif /* ACE_WIN32 || VXWORKS */
}
diff --git a/ACE/ace/OS_NS_Thread.h b/ACE/ace/OS_NS_Thread.h
index f932a701cea..38b62b83392 100644
--- a/ACE/ace/OS_NS_Thread.h
+++ b/ACE/ace/OS_NS_Thread.h
@@ -356,7 +356,7 @@ public:
/// Queue up threads waiting for the condition to become signaled.
ACE_sema_t sema_;
-# if defined (ACE_VXWORKS)
+# if defined (ACE_VXWORKS) || defined (ACE_MQX)
/**
* A semaphore used by the broadcast/signal thread to wait for all
* the waiting thread(s) to wake up and be released from the
@@ -391,10 +391,12 @@ struct ACE_Export ACE_condattr_t
int type;
};
+#if !defined (ACE_MQX)
struct ACE_Export ACE_mutexattr_t
{
int type;
};
+#endif
ACE_END_VERSIONED_NAMESPACE_DECL
diff --git a/ACE/ace/OS_NS_Thread.inl b/ACE/ace/OS_NS_Thread.inl
index d4023d05704..7fafcb77d1e 100644
--- a/ACE/ace/OS_NS_Thread.inl
+++ b/ACE/ace/OS_NS_Thread.inl
@@ -1679,6 +1679,7 @@ ACE_OS::sema_init (ACE_sema_t *s,
# if defined (ACE_LACKS_NAMED_POSIX_SEM)
s->new_sema_ = true;
# endif /* ACE_LACKS_NAMED_POSIX_SEM */
+ ACE_OS::memset(s->sema_, 0, sizeof(*s->sema_));
ACE_OSCALL_RETURN (::sem_init (s->sema_,
type != USYNC_THREAD,
count), int, -1);
diff --git a/ACE/ace/OS_NS_dirent.inl b/ACE/ace/OS_NS_dirent.inl
index 6e31c21a13e..145ccb17970 100644
--- a/ACE/ace/OS_NS_dirent.inl
+++ b/ACE/ace/OS_NS_dirent.inl
@@ -14,7 +14,7 @@ ACE_INLINE void
closedir (ACE_DIR *d)
{
#if defined (ACE_HAS_DIRENT)
-# if defined (ACE_WIN32) && defined (ACE_LACKS_CLOSEDIR)
+# if (defined (ACE_WIN32) || defined (ACE_MQX)) && defined (ACE_LACKS_CLOSEDIR)
ACE_OS::closedir_emulation (d);
delete [] d->directory_name_;
delete d;
@@ -33,7 +33,7 @@ ACE_INLINE ACE_DIR *
opendir (const ACE_TCHAR *filename)
{
#if defined (ACE_HAS_DIRENT)
-# if defined (ACE_WIN32) && defined (ACE_LACKS_OPENDIR)
+# if (defined (ACE_WIN32) || defined(ACE_MQX)) && defined (ACE_LACKS_OPENDIR)
return ::ACE_OS::opendir_emulation (filename);
# elif defined (ACE_HAS_WOPENDIR) && defined (ACE_USES_WCHAR)
return ::wopendir (filename);
@@ -52,7 +52,7 @@ ACE_INLINE struct ACE_DIRENT *
readdir (ACE_DIR *d)
{
#if defined (ACE_HAS_DIRENT)
-# if defined (ACE_WIN32) && defined (ACE_LACKS_READDIR)
+# if (defined (ACE_WIN32) || defined (ACE_MQX)) && defined (ACE_LACKS_READDIR)
return ACE_OS::readdir_emulation (d);
# elif defined (ACE_HAS_WREADDIR) && defined (ACE_USES_WCHAR)
return ::wreaddir (d);
diff --git a/ACE/ace/OS_NS_errno.cpp b/ACE/ace/OS_NS_errno.cpp
index f84975d40af..537b3259257 100644
--- a/ACE/ace/OS_NS_errno.cpp
+++ b/ACE/ace/OS_NS_errno.cpp
@@ -5,3 +5,146 @@
# include "ace/OS_NS_errno.inl"
#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#ifdef ACE_MQX
+int
+ACE_OS::mqx_error_to_errno(int mqx_error)
+{
+ switch (mqx_error)
+ {
+ // Not really an error.
+ case FS_EOF:
+ return 0;
+
+ case FS_INVALID_FUNCTION_CODE:
+ case FS_INVALID_PARAMETER:
+ case FS_INVALID_HANDLE:
+ case FS_ERROR_INVALID_DRIVE_HANDLE:
+ case FS_ERROR_INVALID_FILE_HANDLE:
+ case MQX_INVALID_POINTER:
+ case MQX_INVALID_PARAMETER:
+ case FS_INVALID_MEMORY_BLOCK_ADDRESS:
+ case MQX_INVALID_SIZE:
+ case MQX_INVALID_MEMORY_BLOCK:
+ case MQX_INVALID_TASK_PRIORITY:
+ case MQX_INVALID_TASK_STATE:
+ case MQX_INVALID_TASK_ID:
+ case MQX_INVALID_PROCESSOR_NUMBER:
+ case MQX_INVALID_VECTORED_INTERRUPT:
+ case MQX_INVALID_TEMPLATE_INDEX:
+ case MQX_INVALID_CONFIGURATION:
+ case MQX_INVALID_COMPONENT_HANDLE:
+ case MQX_INVALID_COMPONENT_BASE:
+ case MQX_INVALID_COMPONENT_NAME:
+ case MQX_INVALID_HANDLE:
+ case MQX_INVALID_TASK_QUEUE:
+ case MQX_INVALID_LWSEM:
+ case MQX_SCHED_INVALID_POLICY:
+ case MQX_SCHED_INVALID_PARAMETER_PTR:
+ case MQX_SCHED_INVALID_PARAMETER:
+ case MQX_SCHED_INVALID_TASK_ID:
+ case MQX_INVALID_IO_CHANNEL:
+ case MQX_INVALID_DEVICE:
+ case MQX_INVALID_CLOCK_SPEED:
+ case MQX_IPC_INVALID_MESSAGE:
+ case MQX_MEM_POOL_INVALID:
+ case MQX_LWMEM_POOL_INVALID:
+ case MQX_LWEVENT_INVALID:
+ case MQX_LWTIMER_INVALID:
+ return EINVAL;
+ case FS_FILE_NOT_FOUND:
+ case FS_PATH_NOT_FOUND:
+ return ENOENT;
+ case FS_ACCESS_DENIED:
+ case FS_OPERATION_NOT_ALLOWED:
+ case FS_SHARING_VIOLATION:
+ case MQX_NOT_RESOURCE_OWNER:
+ case MQX_ACCESS_ERROR:
+ return EPERM;
+ case FS_INSUFFICIENT_MEMORY:
+ case FS_PMGR_INSUF_MEMORY:
+ case MQX_OUT_OF_MEMORY:
+ case MQX_KERNEL_MEMORY_TOO_SMALL:
+ case MQX_MEM_POOL_TOO_SMALL:
+ case MQX_OUT_OF_MMU_PAGE_TABLES:
+ return ENOMEM;
+ case FS_FILE_EXISTS:
+ case MQX_COMPONENT_EXISTS:
+ case MQX_IPC_ROUTE_EXISTS:
+ case MQX_MMU_CONTEXT_EXISTS:
+ case FS_ALREADY_ASSIGNED:
+ return EEXIST;
+ case FS_DISK_FULL:
+ case FS_ROOT_DIR_FULL:
+ return ENOSPC;
+ case FS_DISK_IS_WRITE_PROTECTED:
+ return EROFS;
+ case FS_BAD_DISK_UNIT:
+ case FS_INVALID_LENGTH_IN_DISK_OPERATION:
+ case FS_NOT_A_DOS_DISK:
+ case FS_SECTOR_NOT_FOUND:
+ case FS_WRITE_FAULT:
+ case FS_READ_FAULT:
+ case FS_NOT_INITIALIZED:
+ case FS_ERROR_UNKNOWN_FS_VERSION:
+ case FS_LOST_CHAIN:
+ case FS_INVALID_DEVICE:
+ case FS_INVALID_CLUSTER_NUMBER:
+ case FS_FAILED_TO_DELETE_LFN:
+ case FS_BAD_LFN_ENTRY:
+ case FS_PMGR_INVALID_PARTITION:
+ case FS_PMGR_UNKNOWN_PARTITION:
+ case FS_PMGR_INVALID_PARTTABLE:
+ case FS_PMGR_EXFAT_PARTITION:
+ case MQX_IO_OPERATION_NOT_AVAILABLE:
+ return EIO;
+ case FS_CANNOT_CREATE_DIRECTORY:
+ return ENOTDIR;
+ case MQX_LWSEM_WAIT_TIMEOUT:
+ return ETIME;
+
+ // These seem like generic errors
+ case MQX_MMU_ERROR:
+ case MQX_ERROR:
+
+ // Need more info to categorize
+ case FS_ATTEMPT_TO_REMOVE_CURRENT_DIR:
+ case MQX_INVALID_CHECKSUM:
+ case MQX_OUT_OF_TASK_DESCRIPTORS:
+ case MQX_CANNOT_CALL_FUNCTION_FROM_ISR:
+ case MQX_TASK_QUEUE_EMPTY:
+ case MQX_NO_TASK_TEMPLATE:
+ case MQX_COMPONENT_DOES_NOT_EXIST:
+ case MQX_COULD_NOT_CREATE_IPC_TASK:
+ case MQX_TOO_MANY_PRIORITY_LEVELS:
+ case MQX_TOO_MANY_INTERRUPTS:
+ case MQX_DUPLICATE_TASK_TEMPLATE_INDEX:
+ case MQX_TIMER_ISR_INSTALL_FAIL:
+ case MQX_INTER_PROCESSOR_INIT_FAILED:
+ case MQX_IPC_SERVICE_NOT_AVAILABLE:
+ case MQX_MMU_CONTEXT_DOES_NOT_EXIST:
+ case MQX_MMU_PARENT_TASK_CANNOT_BE_MMU:
+ case MQX_RTC_UNLOCK_FAILED:
+ case MQX_NO_USER_TASKS:
+ case MQX_TOO_MANY_USER_TASKS:
+ case MQX_TASKQ_CREATE_FAILED:
+ case MQX_INVALD_INT_ENABLE:
+ case MQX_UNABLE_TO_CREATE_COMPONENT:
+ case MQX_CLOCK_TRIM_FAILED:
+
+ /* These are serious and should definitely return EFAULT unless there is a
+ * more appropriate error code.
+ */
+ case MQX_CORRUPT_MEMORY_SYSTEM:
+ case MQX_CORRUPT_STORAGE_POOL:
+ case MQX_CORRUPT_STORAGE_POOL_FREE_LIST:
+ case MQX_CORRUPT_STORAGE_POOL_POINTERS:
+ case MQX_CORRUPT_QUEUE:
+ case MQX_CORRUPT_INTERRUPT_STACK:
+ case MQX_UNHANDLED_INTERRUPT:
+
+ default:
+ return EFAULT;
+ }
+}
+#endif
diff --git a/ACE/ace/OS_NS_errno.h b/ACE/ace/OS_NS_errno.h
index 821bb7d09a8..a240a7fa9ff 100644
--- a/ACE/ace/OS_NS_errno.h
+++ b/ACE/ace/OS_NS_errno.h
@@ -47,6 +47,10 @@ namespace ACE_OS {
ACE_NAMESPACE_INLINE_FUNCTION
int set_errno_to_wsa_last_error (void);
+#ifdef ACE_MQX
+ int mqx_error_to_errno(int mqx_error);
+#endif
+
} /* namespace ACE_OS */
#if defined (ACE_HAS_WINCE_BROKEN_ERRNO)
diff --git a/ACE/ace/OS_NS_fcntl.cpp b/ACE/ace/OS_NS_fcntl.cpp
index 54786876551..d530a27ecc8 100644
--- a/ACE/ace/OS_NS_fcntl.cpp
+++ b/ACE/ace/OS_NS_fcntl.cpp
@@ -125,6 +125,10 @@ ACE_OS::open (const char *filename,
else {
ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, -1);
}
+#elif defined (ACE_MQX)
+ ACE_UNUSED_ARG (perms);
+ ACE_UNUSED_ARG (sa);
+ return MQX_Filesystem::inst ().open (filename, mode);
#else
ACE_UNUSED_ARG (sa);
ACE_OSCALL_RETURN (::open (filename, mode, perms), ACE_HANDLE, ACE_INVALID_HANDLE);
diff --git a/ACE/ace/OS_NS_stdio.h b/ACE/ace/OS_NS_stdio.h
index 8895c77b018..d9a73a7bddf 100644
--- a/ACE/ace/OS_NS_stdio.h
+++ b/ACE/ace/OS_NS_stdio.h
@@ -126,6 +126,9 @@ inline ACE_HANDLE ace_fileno_helper (FILE *fp)
# if defined (fileno)
return (ACE_HANDLE)fileno (fp);
# undef fileno
+# elif defined (ACE_LACKS_FILENO)
+ ACE_UNUSED_ARG (fp);
+ return ACE_INVALID_HANDLE;
# else
return (ACE_HANDLE)(intptr_t)ACE_STD_NAMESPACE::fileno (fp);
# endif /* defined (fileno) */
diff --git a/ACE/ace/OS_NS_stdio.inl b/ACE/ace/OS_NS_stdio.inl
index 28da671eae6..57349ea9873 100644
--- a/ACE/ace/OS_NS_stdio.inl
+++ b/ACE/ace/OS_NS_stdio.inl
@@ -17,6 +17,10 @@
# include "ace/Malloc_Base.h"
#endif /* ACE_HAS_ALLOC_HOOKS */
+#ifdef ACE_MQX
+# include "ace/MQX_Filesystem.h"
+#endif
+
/*****************************************************************************/
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -752,6 +756,11 @@ ACE_OS::freopen (const ACE_TCHAR *filename, const ACE_TCHAR *mode, FILE* stream)
ACE_TEXT_ALWAYS_WCHAR (mode),
stream),
FILE *, 0);
+#elif defined (ACE_LACKS_FREOPEN)
+ ACE_UNUSED_ARG (filename);
+ ACE_UNUSED_ARG (mode);
+ ACE_UNUSED_ARG (stream);
+ ACE_NOTSUP_RETURN (0);
#else
ACE_OSCALL_RETURN
(ACE_STD_NAMESPACE::freopen (ACE_TEXT_ALWAYS_CHAR (filename),
@@ -895,6 +904,8 @@ ACE_OS::rename (const char *old_name,
if (::MoveFileExA (old_name, new_name, flags) == 0)
ACE_FAIL_RETURN (-1);
return 0;
+#elif defined (ACE_RENAME_EQUIVALENT)
+ ACE_OSCALL_RETURN (ACE_RENAME_EQUIVALENT (old_name, new_name), int, -1);
# else
ACE_UNUSED_ARG (flags);
ACE_OSCALL_RETURN (::rename (old_name, new_name), int, -1);
@@ -941,7 +952,7 @@ ACE_OS::rename (const wchar_t *old_name,
ACE_INLINE void
ACE_OS::rewind (FILE *fp)
{
-#if !defined (ACE_HAS_WINCE)
+#if !defined (ACE_HAS_WINCE) && !defined (ACE_MQX)
ACE_OS_TRACE ("ACE_OS::rewind");
# if defined (ACE_LACKS_REWIND)
ACE_UNUSED_ARG (fp);
diff --git a/ACE/ace/OS_NS_stdlib.inl b/ACE/ace/OS_NS_stdlib.inl
index cb59874b3cf..26fa3b0ab93 100644
--- a/ACE/ace/OS_NS_stdlib.inl
+++ b/ACE/ace/OS_NS_stdlib.inl
@@ -27,6 +27,8 @@ ACE_OS::_exit (int status)
::exit (status);
#elif defined (ACE_HAS_WINCE)
::TerminateProcess (::GetCurrentProcess (), status);
+#elif defined (ACE_MQX)
+ _mqx_exit (status);
#elif !defined (ACE_LACKS__EXIT)
::_exit (status);
#else
diff --git a/ACE/ace/OS_NS_stropts.inl b/ACE/ace/OS_NS_stropts.inl
index 919ac531c0e..6f433a441ce 100644
--- a/ACE/ace/OS_NS_stropts.inl
+++ b/ACE/ace/OS_NS_stropts.inl
@@ -123,6 +123,9 @@ ACE_OS::ioctl (ACE_HANDLE handle,
#elif defined (ACE_HAS_IOCTL_INT_3_PARAM)
ACE_OSCALL_RETURN (::ioctl (handle, cmd, reinterpret_cast<int> (val)),
int, -1);
+#elif defined (ACE_MQX)
+ // TBD: See if there is a way to provide this functionality
+ ACE_NOTSUP_RETURN (0);
#else
ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1);
#endif /* ACE_WIN32 */
diff --git a/ACE/ace/OS_NS_sys_select.inl b/ACE/ace/OS_NS_sys_select.inl
index 396ffe729ca..a7dfcc462b0 100644
--- a/ACE/ace/OS_NS_sys_select.inl
+++ b/ACE/ace/OS_NS_sys_select.inl
@@ -35,6 +35,9 @@ ACE_OS::select (int width,
ACE_UNUSED_ARG (efds);
ACE_UNUSED_ARG (timeout);
ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_MQX)
+ ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, timeout->msec()),
+ int, -1);
#else
ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, timep),
int, -1);
@@ -61,6 +64,9 @@ ACE_OS::select (int width,
ACE_UNUSED_ARG (efds);
ACE_UNUSED_ARG (timeout);
ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_MQX)
+ ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, timeout.msec()),
+ int, -1);
#else
ACE_SOCKCALL_RETURN (::select (width, rfds, wfds, efds, ___ACE_TIMEOUT),
int, -1);
diff --git a/ACE/ace/OS_NS_sys_socket.inl b/ACE/ace/OS_NS_sys_socket.inl
index 3055da01876..54aa02395c3 100644
--- a/ACE/ace/OS_NS_sys_socket.inl
+++ b/ACE/ace/OS_NS_sys_socket.inl
@@ -128,7 +128,7 @@ ACE_INLINE int
ACE_OS::closesocket (ACE_HANDLE handle)
{
ACE_OS_TRACE ("ACE_OS::closesocket");
-#if defined (ACE_WIN32)
+#if defined (ACE_WIN32) || defined (ACE_MQX)
// @note Do not shutdown the write end here. Doing so will break
// applications that duplicate a handle on fork(), for
// example, and expect to continue writing in the fork()ed
@@ -274,6 +274,10 @@ ACE_OS::getsockname (ACE_HANDLE handle,
#endif /* ACE_GETNAME_RETURNS_RANDOM_SIN_ZERO */
}
+#if !defined(ACE_SOCKOPT_LEN)
+#define ACE_SOCKOPT_LEN ACE_SOCKET_LEN
+#endif
+
ACE_INLINE int
ACE_OS::getsockopt (ACE_HANDLE handle,
int level,
@@ -294,7 +298,7 @@ ACE_OS::getsockopt (ACE_HANDLE handle,
level,
optname,
optval,
- (ACE_SOCKET_LEN *) optlen),
+ (ACE_SOCKOPT_LEN *) optlen),
int,
-1);
#endif /* ACE_LACKS_GETSOCKOPT */
@@ -589,7 +593,11 @@ ACE_OS::send (ACE_HANDLE handle, const char *buf, size_t len, int flags)
return result;
#else
+# if defined (ACE_MQX)
+ ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, (void*)buf, len, flags);
+#else
ssize_t const ace_result_ = ::send ((ACE_SOCKET) handle, buf, len, flags);
+#endif
# if !(defined (EAGAIN) && defined (EWOULDBLOCK) && EAGAIN == EWOULDBLOCK)
// Optimize this code out if we can detect that EAGAIN ==
@@ -686,6 +694,14 @@ ACE_OS::sendto (ACE_HANDLE handle,
const_cast<struct sockaddr *> (addr),
addrlen),
ssize_t, -1);
+#elif defined (ACE_MQX)
+ ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
+ (void*)buf,
+ len,
+ flags,
+ const_cast<struct sockaddr *> (addr),
+ addrlen),
+ ssize_t, -1);
#else
ACE_SOCKCALL_RETURN (::sendto ((ACE_SOCKET) handle,
buf,
@@ -823,6 +839,40 @@ ACE_OS::sendv (ACE_HANDLE handle,
return (ssize_t) bytes_sent;
+#elif defined (ACE_MQX)
+ ssize_t bytes_sent = 0;
+ for (int i = 0; i < n; ++i)
+ {
+ ssize_t result = ACE_OS::send (handle, buffers[i].iov_base,
+ buffers[i].iov_len, 0);
+
+ if (result == -1)
+ {
+ // There is a subtle difference in behaviour depending on
+ // whether or not any data was sent. If no data was sent,
+ // then always return -1. Otherwise return bytes_sent.
+ // This gives the caller an opportunity to keep track of
+ // bytes that have already been sent.
+ if (bytes_sent > 0)
+ break;
+ else
+ {
+ // errno should already be set from the ACE_OS::send call.
+ return -1;
+ }
+ }
+ else
+ {
+ // Gets ignored on error anyway
+ bytes_sent += result;
+
+ // If the transfer isn't complete just drop out of the loop.
+ if (result < buffers[i].iov_len)
+ break;
+ }
+ }
+
+ return bytes_sent;
#elif defined (ACE_HAS_SOCK_BUF_SIZE_MAX)
// Platform limits the maximum socket message size. Pare down the
diff --git a/ACE/ace/OS_NS_sys_stat.inl b/ACE/ace/OS_NS_sys_stat.inl
index 93e321dd177..cd0ef6eb770 100644
--- a/ACE/ace/OS_NS_sys_stat.inl
+++ b/ACE/ace/OS_NS_sys_stat.inl
@@ -4,6 +4,10 @@
#include "ace/OS_NS_errno.h"
#include "ace/OS_NS_macros.h"
+#ifdef ACE_MQX
+# include "ace/MQX_Filesystem.h"
+#endif
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
namespace ACE_OS
@@ -13,7 +17,7 @@ namespace ACE_OS
creat (const ACE_TCHAR *filename, mode_t mode)
{
ACE_OS_TRACE ("ACE_OS::creat");
-#if defined (ACE_WIN32)
+#if defined (ACE_WIN32) || defined (ACE_MQX)
return ACE_OS::open (filename, O_CREAT|O_TRUNC|O_WRONLY, mode);
#else
ACE_OSCALL_RETURN (::creat (ACE_TEXT_ALWAYS_CHAR (filename), mode),
@@ -56,14 +60,18 @@ namespace ACE_OS
(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? S_IFDIR : S_IFREG);
}
return 0;
+#elif defined (ACE_LACKS_FSTAT)
+ ACE_NOTSUP_RETURN (-1);
+#elif defined (ACE_MQX)
+ return MQX_Filesystem::inst ().fstat (handle, stp);
#else
-# if defined (ACE_OPENVMS)
+# if defined (ACE_OPENVMS)
//FUZZ: disable check_for_lack_ACE_OS
::fsync(handle);
//FUZZ: enable check_for_lack_ACE_OS
- #endif
+# endif
ACE_OSCALL_RETURN (::fstat (handle, stp), int, -1);
-# endif /* !ACE_HAS_X86_STAT_MACROS */
+#endif /* !ACE_HAS_X86_STAT_MACROS */
}
// This function returns the number of bytes in the file referenced by
@@ -197,6 +205,8 @@ namespace ACE_OS
ACE_OS_TRACE ("ACE_OS::stat");
#if defined (ACE_HAS_NONCONST_STAT)
ACE_OSCALL_RETURN (::stat (const_cast <char *> (file), stp), int, -1);
+#elif defined (ACE_LACKS_STAT)
+ ACE_NOTSUP_RETURN (-1);
#elif defined (ACE_HAS_WINCE)
ACE_TEXT_WIN32_FIND_DATA fdata;
@@ -229,6 +239,8 @@ namespace ACE_OS
// Solaris for intel uses an macro for stat(), this macro is a
// wrapper for _xstat().
ACE_OSCALL_RETURN (::_xstat (_STAT_VER, file, stp), int, -1);
+#elif defined (ACE_MQX)
+ return MQX_Filesystem::inst ().stat (file, stp);
#else
ACE_OSCALL_RETURN (ACE_STAT_FUNC_NAME (file, stp), int, -1);
#endif /* ACE_HAS_NONCONST_STAT */
diff --git a/ACE/ace/OS_NS_sys_time.inl b/ACE/ace/OS_NS_sys_time.inl
index acaf2f9f424..488e6a1f205 100644
--- a/ACE/ace/OS_NS_sys_time.inl
+++ b/ACE/ace/OS_NS_sys_time.inl
@@ -13,7 +13,7 @@ ACE_OS::gettimeofday (void)
{
// ACE_OS_TRACE ("ACE_OS::gettimeofday");
-#if !defined (ACE_WIN32)
+#if !defined (ACE_WIN32) && !defined (ACE_LACKS_GETTIMEOFDAY)
timeval tv;
int result = 0;
#endif // !defined (ACE_WIN32)
@@ -59,6 +59,11 @@ ACE_OS::gettimeofday (void)
ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
tv.tv_sec = ts.tv_sec;
tv.tv_usec = ts.tv_nsec / 1000L; // timespec has nsec, but timeval has usec
+# elif defined (ACE_MQX)
+ TIME_STRUCT ts;
+ _time_get(&ts);
+ tv.tv_sec = ts.SECONDS;
+ tv.tv_usec = ts.MILLISECONDS * 1000;
# else
# if defined (ACE_LACKS_GETTIMEOFDAY)
ACE_NOTSUP_RETURN (ACE_Time_Value ((time_t)-1));
@@ -67,7 +72,7 @@ ACE_OS::gettimeofday (void)
# endif /* ACE_LACKS_GETTIMEOFDAY */
# endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
#endif /* 0 */
-#if !defined (ACE_WIN32)
+#if !defined (ACE_WIN32) && !defined (ACE_LACKS_GETTIMEOFDAY)
if (result == -1)
return ACE_Time_Value ((time_t)-1);
else
diff --git a/ACE/ace/OS_NS_unistd.cpp b/ACE/ace/OS_NS_unistd.cpp
index 1bf7a4cdc4b..f316b888c51 100644
--- a/ACE/ace/OS_NS_unistd.cpp
+++ b/ACE/ace/OS_NS_unistd.cpp
@@ -357,7 +357,7 @@ ACE_OS::fork_exec (ACE_TCHAR *argv[])
switch (result)
{
- case -1:
+ case static_cast<pid_t>(-1):
// Error.
return -1;
case 0:
diff --git a/ACE/ace/OS_NS_unistd.inl b/ACE/ace/OS_NS_unistd.inl
index 9019916acae..035f19baf11 100644
--- a/ACE/ace/OS_NS_unistd.inl
+++ b/ACE/ace/OS_NS_unistd.inl
@@ -28,6 +28,10 @@
# endif
#endif
+#ifdef ACE_MQX
+# include "ace/MQX_Filesystem.h"
+#endif
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE int
@@ -191,6 +195,8 @@ ACE_OS::close (ACE_HANDLE handle)
ACE_OS_TRACE ("ACE_OS::close");
#if defined (ACE_WIN32)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::CloseHandle (handle), ace_result_), int, -1);
+#elif defined (ACE_MQX)
+ return MQX_Filesystem::inst ().close (handle);
#else
ACE_OSCALL_RETURN (::close (handle), int, -1);
#endif /* ACE_WIN32 */
@@ -397,6 +403,8 @@ ACE_OS::ftruncate (ACE_HANDLE handle, ACE_OFF_T offset)
ACE_WIN32CALL_RETURN (ACE_ADAPT_RETVAL (::SetEndOfFile (handle), ace_result_), int, -1);
else
ACE_FAIL_RETURN (-1);
+#elif defined (ACE_LACKS_FTRUNCATE)
+ ACE_NOTSUP_RETURN (-1);
#else
ACE_OSCALL_RETURN (::ftruncate (handle, offset), int, -1);
#endif /* ACE_WIN32 */
@@ -410,12 +418,10 @@ ACE_OS::getcwd (char *buf, size_t size)
ACE_UNUSED_ARG (buf);
ACE_UNUSED_ARG (size);
ACE_NOTSUP_RETURN (0);
-#elif defined (ACE_WIN32)
-# if defined (ACE_GETCWD_EQUIVALENT)
+#elif defined (ACE_GETCWD_EQUIVALENT)
return ACE_GETCWD_EQUIVALENT (buf, static_cast<int> (size));
-# else
+#elif defined (ACE_WIN32)
return ::getcwd (buf, static_cast<int> (size));
-# endif
#else
ACE_OSCALL_RETURN (::getcwd (buf, size), char *, 0);
#endif /* ACE_LACKS_GETCWD */
@@ -573,6 +579,17 @@ ACE_OS::hostname (char name[], size_t maxnamelen)
LPDWORD (&maxnamelen)),
ace_result_), int, -1);
}
+#elif defined (ACE_MQX)
+ const int enet_device = 0;
+ IPCFG_IP_ADDRESS_DATA ip_data;
+ if (ipcfg_get_ip (enet_device, &ip_data))
+ {
+ ACE_OS::snprintf(name, maxnamelen, "%d.%d.%d.%d", IPBYTES(ip_data.ip));
+ return 0;
+ }
+ return -1;
+#elif defined (ACE_LACKS_GETHOSTNAME)
+ ACE_NOTSUP_RETURN (-1);
#else /* ACE_HAS_PHARLAP */
ACE_utsname host_info;
@@ -675,6 +692,23 @@ ACE_OS::lseek (ACE_HANDLE handle, ACE_OFF_T offset, int whence)
ACE_FAIL_RETURN (static_cast<ACE_OFF_T> (-1));
else
return result;
+#elif defined (ACE_MQX)
+ switch (whence)
+ {
+ case SEEK_SET:
+ whence = IO_SEEK_SET;
+ break;
+ case SEEK_CUR:
+ whence = IO_SEEK_CUR;
+ break;
+ case SEEK_END:
+ whence = IO_SEEK_END;
+ break;
+ default:
+ errno = EINVAL;
+ return static_cast<ACE_OFF_T> (-1);
+ }
+ return static_cast<ACE_OFF_T> (MQX_Filesystem::inst ().lseek (handle, offset, whence));
#else
ACE_OSCALL_RETURN (::lseek (handle, offset, whence), ACE_OFF_T, -1);
#endif /* ACE_WIN32 */
@@ -737,6 +771,10 @@ ACE_OS::read (ACE_HANDLE handle, void *buf, size_t len)
return (ssize_t) ok_len;
else
ACE_FAIL_RETURN (-1);
+
+#elif defined (ACE_MQX)
+ return MQX_Filesystem::inst ().read (handle, reinterpret_cast<unsigned char *> (buf), len);
+
#else
ssize_t result;
@@ -945,6 +983,9 @@ ACE_OS::sleep (u_int seconds)
#elif defined (ACE_WIN32)
::Sleep (seconds * ACE_ONE_SECOND_IN_MSECS);
return 0;
+#elif defined (ACE_MQX)
+ _time_delay (seconds * ACE_ONE_SECOND_IN_MSECS);
+ return 0;
#else
ACE_OSCALL_RETURN (::sleep (seconds), int, -1);
#endif /* ACE_WIN32 */
@@ -957,6 +998,9 @@ ACE_OS::sleep (const ACE_Time_Value &tv)
#if defined (ACE_WIN32)
::Sleep (tv.msec ());
return 0;
+#elif defined (ACE_MQX)
+ _time_delay (tv.msec ());
+ return 0;
#elif defined (ACE_HAS_CLOCK_GETTIME)
timespec_t rqtp = tv;
//FUZZ: disable check_for_lack_ACE_OS
@@ -1220,6 +1264,8 @@ ACE_OS::write (ACE_HANDLE handle, const void *buf, size_t nbyte)
return (ssize_t) bytes_written;
else
ACE_FAIL_RETURN (-1);
+#elif defined (ACE_MQX)
+ return MQX_Filesystem::inst ().write (handle, reinterpret_cast<const unsigned char *> (buf), nbyte);
#else
# if defined (ACE_HAS_CHARPTR_SOCKOPT)
ACE_OSCALL_RETURN (::write (handle, static_cast <char *> (const_cast <void *> (buf)), nbyte), ssize_t, -1);
diff --git a/ACE/ace/OS_main.h b/ACE/ace/OS_main.h
index b1ffac914a5..4dd48ffa794 100644
--- a/ACE/ace/OS_main.h
+++ b/ACE/ace/OS_main.h
@@ -23,6 +23,10 @@
# pragma once
# endif /* ACE_LACKS_PRAGMA_ONCE */
+#if defined (ACE_MQX)
+# include "ace/MQX_Filesystem.h"
+#endif
+
# if !defined (ACE_DOESNT_DEFINE_MAIN)
# if defined (ACE_HAS_RTEMS)
@@ -55,7 +59,7 @@ extern char* rtems_progname;
return ace_main_i (argc, wide_argv.get_TCHAR_argv ()); \
} \
int ace_main_i
-# else
+# elif !defined (ACE_MQX)
# define ACE_TMAIN main
# endif /* ACE_USES_WCHAR */
# endif
@@ -301,6 +305,31 @@ int ace_main_i
# endif /* ACE_PSOSIM */
# endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
+# ifdef ACE_MQX
+# include <iar_dynamic_init.h>
+# include "ace/MQX_Filesystem.h"
+# define ACE_TMAIN \
+ace_main_i(int argc, ACE_TCHAR *argv[]); \
+static void main_task(uint32_t param) { \
+ __iar_dynamic_initialization(); \
+ RTCS_create(); \
+ MQX_Filesystem::inst ().complete_initialization (); \
+ ace_main_i(0, 0); \
+} \
+static TASK_TEMPLATE_STRUCT MQX_template_list[] = { \
+ {1, main_task, 25000, 9, "Main", MQX_AUTO_START_TASK, 0, 0 }, { 0 } \
+}; \
+static const MQX_INITIALIZATION_STRUCT MQX_init_struct = { \
+ BSP_DEFAULT_PROCESSOR_NUMBER, BSP_DEFAULT_START_OF_KERNEL_MEMORY, \
+ BSP_DEFAULT_END_OF_KERNEL_MEMORY, BSP_DEFAULT_INTERRUPT_STACK_SIZE, \
+ MQX_template_list, BSP_DEFAULT_MQX_HARDWARE_INTERRUPT_LEVEL_MAX, \
+ BSP_DEFAULT_MAX_MSGPOOLS, BSP_DEFAULT_MAX_MSGQS, \
+ BSP_DEFAULT_IO_CHANNEL, (char const*)BSP_DEFAULT_IO_OPEN_MODE, 0, 0 \
+}; \
+int main() { return _mqx( (MQX_INITIALIZATION_STRUCT_PTR) &MQX_init_struct ); } \
+int ace_main_i
+# endif /* ACE_MQX */
+
#endif /* ACE_DOESNT_DEFINE_MAIN */
# include /**/ "ace/post.h"
diff --git a/ACE/ace/Process.cpp b/ACE/ace/Process.cpp
index 6cf5433c0e0..ed29ffd5c5a 100644
--- a/ACE/ace/Process.cpp
+++ b/ACE/ace/Process.cpp
@@ -453,7 +453,7 @@ ACE_Process::spawn (ACE_Process_Options &options)
switch (this->child_id_)
{
- case -1:
+ case static_cast<pid_t>(-1):
// Error.
return ACE_INVALID_PID;
case 0:
diff --git a/ACE/ace/SOCK_Dgram.cpp b/ACE/ace/SOCK_Dgram.cpp
index 3c5d4739922..95b213b24d3 100644
--- a/ACE/ace/SOCK_Dgram.cpp
+++ b/ACE/ace/SOCK_Dgram.cpp
@@ -466,13 +466,16 @@ ssize_t
ACE_SOCK_Dgram::recv (iovec iov[],
int n,
ACE_Addr &addr,
- int flags) const
+ int flags,
+ ACE_INET_Addr *to_addr) const
{
ACE_TRACE ("ACE_SOCK_Dgram::recv");
ssize_t length = 0;
int i;
+ ACE_UNUSED_ARG (to_addr);
+
for (i = 0; i < n; i++)
#if ! (defined(__BORLANDC__) || defined(ACE_LINUX) || defined(ACE_HAS_RTEMS))
// The iov_len is unsigned on Linux, RTEMS and with Borland. If we go
diff --git a/ACE/ace/SOCK_SEQPACK_Association.cpp b/ACE/ace/SOCK_SEQPACK_Association.cpp
index 8c3f2a001cf..024de691a2e 100644
--- a/ACE/ace/SOCK_SEQPACK_Association.cpp
+++ b/ACE/ace/SOCK_SEQPACK_Association.cpp
@@ -49,10 +49,8 @@ ACE_SOCK_SEQPACK_Association::abort (void)
// setsockopt() SO_LINGER configures socket to reap immediately.
// Normal close then aborts the association.
//
- linger slinger;
-
+ linger slinger = { 0 };
slinger.l_onoff = 1;
- slinger.l_linger = 0;
if (-1 == ACE_OS::setsockopt (this->get_handle (),
SOL_SOCKET,
diff --git a/ACE/ace/Select_Reactor_Base.cpp b/ACE/ace/Select_Reactor_Base.cpp
index f5d5252dec6..62b116907d6 100644
--- a/ACE/ace/Select_Reactor_Base.cpp
+++ b/ACE/ace/Select_Reactor_Base.cpp
@@ -12,9 +12,9 @@
#include "ace/Select_Reactor_Base.inl"
#endif /* __ACE_INLINE__ */
-#ifndef ACE_WIN32
+#ifndef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
# include <algorithm>
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -26,11 +26,11 @@ template<typename iterator>
inline ACE_Event_Handler *
ACE_SELECT_REACTOR_EVENT_HANDLER (iterator i)
{
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
return (*i).item ();
#else
return (*i);
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
}
// Performs sanity checking on the ACE_HANDLE.
@@ -39,14 +39,14 @@ bool
ACE_Select_Reactor_Handler_Repository::invalid_handle (ACE_HANDLE handle)
{
ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::invalid_handle");
-#if defined (ACE_WIN32)
+#if defined (ACE_SELECT_REACTOR_BASE_USES_HASH_MAP)
// It's too expensive to perform more exhaustive validity checks on
// Win32 due to the way that they implement SOCKET HANDLEs.
if (handle == ACE_INVALID_HANDLE)
-#else /* !ACE_WIN32 */
+#else /* !ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
if (handle < 0
|| static_cast<size_type> (handle) >= this->event_handlers_.size ())
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
{
errno = EINVAL;
return true;
@@ -61,13 +61,13 @@ bool
ACE_Select_Reactor_Handler_Repository::handle_in_range (ACE_HANDLE handle)
{
ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::handle_in_range");
-#if defined (ACE_WIN32)
+#if defined (ACE_SELECT_REACTOR_BASE_USES_HASH_MAP)
// It's too expensive to perform more exhaustive validity checks on
// Win32 due to the way that they implement SOCKET HANDLEs.
if (handle != ACE_INVALID_HANDLE)
-#else /* !ACE_WIN32 */
+#else /* !ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
if (handle >= 0 && handle < this->max_handlep1_)
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
{
return true;
}
@@ -84,7 +84,7 @@ ACE_Select_Reactor_Handler_Repository::open (size_type size)
{
ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::open");
-#if defined (ACE_WIN32)
+#if defined (ACE_SELECT_REACTOR_BASE_USES_HASH_MAP)
if (this->event_handlers_.open (size) == -1)
return -1;
#else
@@ -97,7 +97,7 @@ ACE_Select_Reactor_Handler_Repository::open (size_type size)
static_cast<ACE_Event_Handler *> (0));
this->max_handlep1_ = 0;
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
// Try to increase the number of handles if <size> is greater than
// the current limit.
@@ -108,9 +108,9 @@ ACE_Select_Reactor_Handler_Repository::open (size_type size)
ACE_Select_Reactor_Handler_Repository::ACE_Select_Reactor_Handler_Repository (ACE_Select_Reactor_Impl &select_reactor)
: select_reactor_ (select_reactor),
-#ifndef ACE_WIN32
+#ifndef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
max_handlep1_ (0),
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
event_handlers_ ()
{
ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::ACE_Select_Reactor_Handler_Repository");
@@ -120,7 +120,7 @@ int
ACE_Select_Reactor_Handler_Repository::unbind_all (void)
{
// Unbind all of the <handle, ACE_Event_Handler>s.
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
map_type::iterator const end = this->event_handlers_.end ();
for (map_type::iterator pos = this->event_handlers_.begin ();
pos != end;
@@ -152,7 +152,7 @@ ACE_Select_Reactor_Handler_Repository::unbind_all (void)
ACE_Event_Handler::ALL_EVENTS_MASK);
++pos;
}
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
return 0;
}
@@ -173,14 +173,14 @@ ACE_Select_Reactor_Handler_Repository::find_eh (ACE_HANDLE handle)
map_type::iterator pos (this->event_handlers_.end ());
// this code assumes the handle is in range.
-#if defined (ACE_WIN32)
+#if defined (ACE_SELECT_REACTOR_BASE_USES_HASH_MAP)
this->event_handlers_.find (handle, pos);
#else
map_type::iterator const tmp = &this->event_handlers_[handle];
if (*tmp != 0)
pos = tmp;
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
return pos;
}
@@ -205,7 +205,7 @@ ACE_Select_Reactor_Handler_Repository::bind (ACE_HANDLE handle,
// Is this handle already in the Reactor?
bool existing_handle = false;
-#if defined (ACE_WIN32)
+#if defined (ACE_SELECT_REACTOR_BASE_USES_HASH_MAP)
map_type::ENTRY * entry = 0;
@@ -253,7 +253,7 @@ ACE_Select_Reactor_Handler_Repository::bind (ACE_HANDLE handle,
if (this->max_handlep1_ < handle + 1)
this->max_handlep1_ = handle + 1;
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
if (this->select_reactor_.is_suspended_i (handle))
{
@@ -333,7 +333,7 @@ ACE_Select_Reactor_Handler_Repository::unbind (
if (!has_any_wait_mask && !has_any_suspend_mask)
{
-#if defined (ACE_WIN32)
+#if defined (ACE_SELECT_REACTOR_BASE_USES_HASH_MAP)
if (event_handler != 0 && this->event_handlers_.unbind (pos) == -1)
return -1; // Should not happen!
#else
@@ -375,7 +375,7 @@ ACE_Select_Reactor_Handler_Repository::unbind (
++this->max_handlep1_;
}
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
// The handle has been completely removed.
complete_removal = true;
@@ -408,7 +408,7 @@ ACE_Select_Reactor_Handler_Repository_Iterator::ACE_Select_Reactor_Handler_Repos
: rep_ (s),
current_ (s->event_handlers_.begin ())
{
-#ifndef ACE_WIN32
+#ifndef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
// Don't use ACE_Array_Base::end() since it may be larger than
// event_handlers[max_handlep1_].
const_base_iterator const end =
@@ -444,7 +444,7 @@ ACE_Select_Reactor_Handler_Repository_Iterator::next (
bool
ACE_Select_Reactor_Handler_Repository_Iterator::advance (void)
{
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
// No need to explicitly limit search to "current" to
// max_handlep1_ range.
const_base_iterator const end = this->rep_->event_handlers_.end ();
@@ -453,18 +453,18 @@ ACE_Select_Reactor_Handler_Repository_Iterator::advance (void)
// event_handlers[max_handlep1_].
const_base_iterator const end =
&this->rep_->event_handlers_[this->rep_->max_handlep1 ()];
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
if (this->current_ != end)
++this->current_;
-#ifndef ACE_WIN32
+#ifndef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
// Advance to the next element containing a non-zero event handler.
// There's no need to do this for the Windows case since the hash
// map will only contain non-zero event handlers.
while (this->current_ != end && (*(this->current_) == 0))
++this->current_;
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
return this->current_ != end;
}
@@ -479,12 +479,12 @@ ACE_Select_Reactor_Handler_Repository_Iterator::dump (void) const
ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("rep_ = %u"), this->rep_));
-# ifdef ACE_WIN32
+# ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("current_ = ")));
this->current_.dump ();
# else
ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("current_ = %@"), this->current_));
-# endif /* ACE_WIN32 */
+# endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
@@ -495,13 +495,13 @@ ACE_Select_Reactor_Handler_Repository::dump (void) const
#if defined (ACE_HAS_DUMP)
ACE_TRACE ("ACE_Select_Reactor_Handler_Repository::dump");
-# ifdef ACE_WIN32
+# ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
# define ACE_HANDLE_FORMAT_SPECIFIER ACE_TEXT("%@")
# define ACE_MAX_HANDLEP1_FORMAT_SPECIFIER ACE_TEXT("%u")
# else
# define ACE_HANDLE_FORMAT_SPECIFIER ACE_TEXT("%d")
# define ACE_MAX_HANDLEP1_FORMAT_SPECIFIER ACE_TEXT("%d")
-# endif /* ACE_WIN32 */
+# endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACELIB_DEBUG ((LM_DEBUG,
diff --git a/ACE/ace/Select_Reactor_Base.h b/ACE/ace/Select_Reactor_Base.h
index 54f3f45f21d..8a686341cd5 100644
--- a/ACE/ace/Select_Reactor_Base.h
+++ b/ACE/ace/Select_Reactor_Base.h
@@ -28,14 +28,18 @@
# include "ace/Notification_Queue.h"
#endif /* ACE_HAS_REACTOR_NOTIFICATION_QUEUE */
-#ifdef ACE_WIN32
+#if defined (ACE_WIN32) || defined (ACE_MQX)
+# define ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
+#endif
+
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
# include "ace/Null_Mutex.h"
# include "ace/Hash_Map_Manager_T.h"
# include "ace/Functor.h" /* For ACE_Hash<void *> */
# include <functional> /* For std::equal_to<> */
#else
# include "ace/Array_Base.h"
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
#if !defined (ACE_DISABLE_NOTIFY_PIPE_DEFAULT)
# define ACE_DISABLE_NOTIFY_PIPE_DEFAULT 0
@@ -289,7 +293,7 @@ public:
typedef ACE_Event_Handler * value_type;
// = The mapping from <HANDLES> to <Event_Handlers>.
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
/**
* The NT version implements this via a hash map
* @c ACE_Event_Handler*. Since NT implements @c ACE_HANDLE
@@ -311,7 +315,7 @@ public:
*/
typedef ACE_Array_Base<value_type> map_type;
typedef ACE_HANDLE max_handlep1_type;
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
typedef map_type::size_type size_type;
@@ -395,11 +399,11 @@ private:
/// Reference to our @c Select_Reactor.
ACE_Select_Reactor_Impl &select_reactor_;
-#ifndef ACE_WIN32
+#ifndef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
/// The highest currently active handle, plus 1 (ranges between 0 and
/// @c max_size_.
max_handlep1_type max_handlep1_;
-#endif /* !ACE_WIN32 */
+#endif /* !ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
/// Underlying table of event handlers.
map_type event_handlers_;
diff --git a/ACE/ace/Select_Reactor_Base.inl b/ACE/ace/Select_Reactor_Base.inl
index 3993e9ff75e..68933bb2e04 100644
--- a/ACE/ace/Select_Reactor_Base.inl
+++ b/ACE/ace/Select_Reactor_Base.inl
@@ -6,21 +6,21 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_INLINE ACE_Select_Reactor_Handler_Repository::size_type
ACE_Select_Reactor_Handler_Repository::size (void) const
{
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
return this->event_handlers_.total_size ();
#else
return this->event_handlers_.size ();
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
}
ACE_INLINE ACE_Select_Reactor_Handler_Repository::max_handlep1_type
ACE_Select_Reactor_Handler_Repository::max_handlep1 (void) const
{
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
return this->event_handlers_.current_size ();
#else
return this->max_handlep1_;
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
}
ACE_INLINE int
@@ -50,11 +50,11 @@ ACE_Select_Reactor_Handler_Repository::find (ACE_HANDLE handle)
if (pos != this->event_handlers_.end ())
{
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
eh = (*pos).item ();
#else
eh = *pos;
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
}
}
// Don't bother setting errno. It isn't used in the select()-based
@@ -72,12 +72,12 @@ ACE_Select_Reactor_Handler_Repository::find (ACE_HANDLE handle)
ACE_INLINE bool
ACE_Select_Reactor_Handler_Repository_Iterator::done (void) const
{
-#ifdef ACE_WIN32
+#ifdef ACE_SELECT_REACTOR_BASE_USES_HASH_MAP
return this->current_ == this->rep_->event_handlers_.end ();
#else
return this->current_ == (this->rep_->event_handlers_.begin ()
+ this->rep_->max_handlep1 ());
-#endif /* ACE_WIN32 */
+#endif /* ACE_SELECT_REACTOR_BASE_USES_HASH_MAP */
}
// ------------------------------------------------------------------
diff --git a/ACE/ace/Strategies_T.cpp b/ACE/ace/Strategies_T.cpp
index 761ca762da1..723bc1e2749 100644
--- a/ACE/ace/Strategies_T.cpp
+++ b/ACE/ace/Strategies_T.cpp
@@ -436,7 +436,7 @@ ACE_Process_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *svc_handle
// If <flags_> is non-0 then we won't create zombies.
switch (ACE::fork (ACE_TEXT ("child"), this->flags_))
{
- case -1:
+ case static_cast<pid_t>(-1):
{
ACE_Errno_Guard error (errno);
svc_handler->close ();
diff --git a/ACE/ace/ace.mpc b/ACE/ace/ace.mpc
index dac0888baef..07fc18646bf 100644
--- a/ACE/ace/ace.mpc
+++ b/ACE/ace/ace.mpc
@@ -121,6 +121,7 @@ project(ACE) : ace_output, acedefaults, install, other, codecs, token, svcconf,
Message_Queue_Vx.cpp
Method_Request.cpp
MMAP_Memory_Pool.cpp
+ MQX_Filesystem.cpp
Msg_WFMO_Reactor.cpp
Monitor_Admin.cpp
Monitor_Admin_Manager.cpp
diff --git a/ACE/ace/ace_for_tao.mpc b/ACE/ace/ace_for_tao.mpc
index 1c5cfcb4dff..f1667345ede 100644
--- a/ACE/ace/ace_for_tao.mpc
+++ b/ACE/ace/ace_for_tao.mpc
@@ -91,6 +91,7 @@ project(ACE_FOR_TAO) : acedefaults, install, svcconf, uuid, versioned_namespace,
Monitor_Control_Types.cpp
Monitor_Control_Action.cpp
Monotonic_Time_Policy.cpp
+ MQX_Filesystem.cpp
Mutex.cpp
Notification_Strategy.cpp
Notification_Queue.cpp
@@ -328,6 +329,7 @@ project(ACE_FOR_TAO) : acedefaults, install, svcconf, uuid, versioned_namespace,
Mem_Map.h
Min_Max.h
Monotonic_Time_Policy.h
+ MQX_Filesystem.h
Null_Barrier.h
Null_Condition.h
Null_Mutex.h
diff --git a/ACE/ace/config-macros.h b/ACE/ace/config-macros.h
index cbeae46908e..dc292523ffb 100644
--- a/ACE/ace/config-macros.h
+++ b/ACE/ace/config-macros.h
@@ -271,7 +271,7 @@
# endif /* ghs || __GNUC__ || ..... */
#endif /* !ACE_UNUSED_ARG */
-#if defined (_MSC_VER) || defined (ghs) || defined (__DECCXX) || defined(__BORLANDC__) || defined (ACE_RM544) || defined (__USLC__) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) || (defined (__HP_aCC) && (__HP_aCC < 39000 || __HP_aCC >= 60500))
+#if defined (_MSC_VER) || defined (ghs) || defined (__DECCXX) || defined(__BORLANDC__) || defined (ACE_RM544) || defined (__USLC__) || defined (__DCC__) || defined (__PGI) || defined (__TANDEM) || (defined (__HP_aCC) && (__HP_aCC < 39000 || __HP_aCC >= 60500)) || defined (__IAR_SYSTEMS_ICC__)
# define ACE_NOTREACHED(a)
#else /* ghs || ..... */
# define ACE_NOTREACHED(a) a
diff --git a/ACE/ace/config-mqx.h b/ACE/ace/config-mqx.h
new file mode 100644
index 00000000000..da4c5b2ab3b
--- /dev/null
+++ b/ACE/ace/config-mqx.h
@@ -0,0 +1,509 @@
+#ifndef CONFIG_MQX_H
+#define CONFIG_MQX_H
+
+// This macro is required in order to build the SOCK_Connector_Test
+#define ACE_LACKS_GETHOSTENT
+
+#if defined(ACE_MQX_DLIB_FULL)
+# define MQX_SUPPRESS_FILE_DEF 1
+# define MQX_SUPPRESS_STDIO_MACROS 1
+#endif
+
+#define MQX_STD_TIME_API 0
+
+#include <time32.h>
+#define _SIGNAL
+
+#include <mfs.h>
+#include <rtcs.h>
+#include <mutex.h>
+#include <fio.h>
+
+// These headers do not have the proper guards for C++
+extern "C" {
+// Allowing p_time.h to be included causes conflicts
+// with time.h
+#define __p_time_h__
+
+#include <sys_types.h>
+#include <p_pthread.h>
+#include <p_signal.h>
+#include <p_semaphore.h>
+}
+
+#if MQX_STD_TIME_API == 0
+# define ACE_LACKS_LOCALTIME_R
+#endif
+
+#if !defined (ACE_DEFAULT_MAP_SIZE)
+# define ACE_DEFAULT_MAP_SIZE 64
+#endif /* ACE_DEFAULT_MAP_SIZE */
+
+#if !defined (ACE_MAXLOGMSGLEN)
+# define ACE_MAXLOGMSGLEN 1024
+#endif /* ACE_MAXLOGMSGLEN */
+
+#if !defined (ACE_DEFAULT_ACCEPTOR_USE_SELECT)
+# define ACE_DEFAULT_ACCEPTOR_USE_SELECT 0
+#endif /* ACE_DEFAULT_ACCEPTOR_USE_SELECT */
+
+#define ACE_CHDIR_EQUIVALENT MQX_Filesystem::inst().chdir
+#define ACE_RMDIR_EQUIVALENT MQX_Filesystem::inst().rmdir
+#define ACE_GETCWD_EQUIVALENT MQX_Filesystem::inst().getcwd
+#define ACE_UNLINK_EQUIVALENT MQX_Filesystem::inst().unlink
+#define ACE_MKDIR_EQUIVALENT MQX_Filesystem::inst().mkdir
+#define ACE_RENAME_EQUIVALENT MQX_Filesystem::inst().rename
+
+#define ACE_MQX
+#define ACE_TEMPLATES_REQUIRE_SOURCE
+#define ACE_PAGE_SIZE 4096
+#define ACE_SOCKET_LEN uint16_t
+#define ACE_SOCKOPT_LEN socklen_t
+typedef int SOCKET;
+
+#define ACE_UNUSED_ARG(X)
+
+// Add a check for null pointer before calling free(). This is not
+// completely necessary, but MQX will set a task error of MQX_INVALID_POINTER
+// if we call free with a null pointer.
+#define ACE_FREE_FUNC(X) if ((X) != 0) ::free(X)
+
+#define ACE_USES_SOCKET_H
+
+#define ACE_LACKS_SIGINFO_H
+#define ACE_LACKS_NEW_H
+#define ACE_LACKS_UNISTD_H
+#define ACE_LACKS_FCNTL_H
+#define ACE_LACKS_UCONTEXT_H
+#define ACE_LACKS_SEARCH_H
+#define ACE_LACKS_PWD_H
+#define ACE_LACKS_PTHREAD_H
+#define ACE_LACKS_SCHED_H
+#define ACE_LACKS_SEMAPHORE_H
+#define ACE_LACKS_STROPTS_H
+#define ACE_LACKS_DLFCN_H
+#define ACE_LACKS_NETDB_H
+#define ACE_LACKS_DIRENT_H
+#define ACE_LACKS_STRINGS_H
+#define ACE_LACKS_SYSLOG_H
+#define ACE_LACKS_POLL_H
+#define ACE_LACKS_REGEX_H
+
+#define ACE_LACKS_SYS_TYPES_H
+#define ACE_LACKS_SYS_STAT_H
+#define ACE_LACKS_SYS_PARAM_H
+#define ACE_LACKS_SYS_TIME_H
+#define ACE_LACKS_SYS_RESOURCE_H
+#define ACE_LACKS_SYS_WAIT_H
+#define ACE_LACKS_SYS_UTSNAME_H
+#define ACE_LACKS_SYS_MMAN_H
+#define ACE_LACKS_SYS_IPC_H
+#define ACE_LACKS_SYS_SEM_H
+#define ACE_LACKS_SYS_UIO_H
+#define ACE_LACKS_SYS_SOCKET_H
+#define ACE_LACKS_SYS_IOCTL_H
+#define ACE_LACKS_SYS_SELECT_H
+#define ACE_LACKS_SYS_UN_H
+#define ACE_LACKS_SYS_MSG_H
+#define ACE_LACKS_SYS_SHM_H
+#define ACE_LACKS_SYS_SYSCTL_H
+
+#define ACE_LACKS_NETINET_IN_H
+#define ACE_LACKS_NETINET_TCP_H
+#define ACE_LACKS_NET_IF_H
+#define ACE_LACKS_ARPA_INET_H
+
+#define ACE_HAS_THREADS
+#define ACE_HAS_PTHREADS
+#define ACE_LACKS_COND_T
+#define ACE_LACKS_RWLOCK_T
+#define ACE_MT_SAFE 1
+#define ACE_LACKS_SIGPROCMASK
+#define ACE_LACKS_CONDATTR
+#define ACE_LACKS_PTHREAD_CLEANUP
+#define ACE_HAS_SIGINFO_T
+#define ACE_HAS_POSIX_SEM
+#define ACE_HAS_POSIX_SEM_TIMEOUT
+#define ACE_LACKS_PTHREAD_CANCEL
+#define ACE_HAS_CONSISTENT_SIGNAL_PROTOTYPES
+#define ACE_HAS_THREAD_SPECIFIC_STORAGE
+#define ACE_LACKS_NAMED_POSIX_SEM
+#define ACE_DEFAULT_SEM_KEY { 1234 }
+// MQX POSIX has this, but it doesn't appear to work
+#define ACE_LACKS_SETINHERITSCHED
+typedef pthread_mutex_t ACE_mutex_t;
+typedef pthread_mutexattr_t ACE_mutexattr_t;
+
+#if !defined(ACE_MQX_DLIB_FULL)
+#define ACE_LACKS_FGETWC
+#define ACE_LACKS_FGETWS
+#define ACE_LACKS_FPUTWS
+#define ACE_LACKS_FGETPOS
+#define ACE_LACKS_FSETPOS
+#define ACE_LACKS_FREOPEN
+#define ACE_LACKS_FDOPEN
+#define ACE_LACKS_FILENO
+#define ACE_LACKS_LOCALECONV
+
+#define BUFSIZ 512
+
+#undef ungetc
+#undef sscanf
+#undef snprintf
+#undef vsnprintf
+#undef getchar
+#undef putchar
+#undef status
+
+#define getc(X) _io_fgetc(X)
+#define ungetc(X,Y) _io_fungetc(X,Y)
+
+#ifdef fgetc
+#undef fgetc
+inline int fgetc(FILE* f) {
+ return _io_fgetc(f);
+}
+#endif
+#ifdef fread
+#undef fread
+inline size_t fread(void* ptr, size_t so, size_t no,FILE* f) {
+ return (_io_read((f),(ptr),(so)*(no))/(so));
+}
+#endif
+#ifdef fwrite
+#undef fwrite
+inline size_t fwrite(const void* ptr, size_t so, size_t no, FILE* f) {
+ return (_io_write((f),(void*)(ptr),(so)*(no))/(so));
+}
+#endif
+#ifdef puts
+#undef puts
+#define def_puts
+#endif
+#ifdef getline
+#undef getline
+inline int getline(char* x, int y) {
+ return _io_fgetline(stdin, x, y);
+}
+#endif
+#ifdef read
+#undef read
+inline int read(FILE* f, const void* b, int a) {
+ return _io_read(f, (void*)b, a);
+}
+#endif
+#ifdef write
+#undef write
+inline int write(FILE* f, void* b, int a) {
+ return _io_write(f, b, a);
+}
+#endif
+#ifdef printf
+#undef printf
+#define def_printf
+#endif
+#ifdef sprintf
+#undef sprintf
+#define def_sprintf
+#endif
+#ifdef fprintf
+#undef fprintf
+inline int fprintf(FILE* s, const char* f, ...) {
+ va_list argp;
+ va_start(argp, f);
+ const int r = _io_vfprintf(s, f, argp);
+ va_end (argp);
+ return r;
+}
+#endif
+#ifdef vprintf
+#undef vprintf
+#define def_vprintf
+#endif
+#ifdef vsprintf
+#undef vsprintf
+#define def_vsprintf
+#endif
+#ifdef vfprintf
+#undef vfprintf
+inline int vfprintf(FILE* s, const char* f, va_list argp) {
+ return _io_vfprintf(s, f, argp);
+}
+#endif
+#ifdef fclose
+#undef fclose
+inline int fclose(FILE* f) {
+ return _io_fclose(f);
+}
+#endif
+#ifdef fflush
+#undef fflush
+inline int fflush(FILE* f) {
+ return _io_fflush(f);
+}
+#endif
+#ifdef fgets
+#undef fgets
+inline char* fgets(char* b, int a, FILE* f) {
+ return _io_fgets(b, a, f);
+}
+#endif
+#ifdef fputs
+#undef fputs
+inline int fputs(const char* s, FILE* f) {
+ return _io_fputs(s, f);
+}
+#endif
+#ifdef fopen
+#undef fopen
+inline FILE* fopen(const char* f, const char* m) {
+ return _io_fopen(f, m);
+}
+#endif
+#ifdef fseek
+#undef fseek
+inline int fseek(FILE* f, long o, int s) {
+ return _io_fseek(f, o, s);
+}
+#endif
+#ifdef ftell
+#undef ftell
+inline int ftell(FILE* f) {
+ return _io_ftell(f);
+}
+#endif
+#ifdef ioctl
+#undef ioctl
+inline int ioctl(FILE* f, unsigned int r, void* p)
+{
+ return _io_ioctl(f, r, p);
+}
+#endif
+
+#include <stdio.h>
+
+#ifdef def_printf
+#undef def_printf
+inline int printf(const char* f, ...) {
+ va_list argp;
+ va_start(argp, f);
+ const int r = _io_vprintf(f, argp);
+ va_end (argp);
+ return r;
+}
+#endif
+#ifdef def_sprintf
+#undef def_sprintf
+inline int sprintf(char* s, const char* f, ...) {
+ va_list argp;
+ va_start(argp, f);
+ const int r = _io_vsprintf(s, f, argp);
+ va_end (argp);
+ return r;
+}
+#endif
+#ifdef def_vprintf
+#undef def_vprintf
+inline int vprintf(const char* f, va_list argp) {
+ return _io_vprintf(f, argp);
+}
+#endif
+#ifdef def_vsprintf
+#undef def_vsprintf
+inline int vsprintf(char* s, const char* f, va_list argp) {
+ return _io_vsprintf(s, f, argp);
+}
+#endif
+#ifdef def_puts
+#undef def_puts
+inline int puts(const char* str) {
+ return _io_fputs(str, stdout);
+}
+#endif
+#endif
+
+#define ACE_HAS_LINGER_MS
+#define ACE_HAS_WCHAR
+#define ACE_SIZEOF_WCHAR 4
+#define ACE_HAS_SSIZE_T
+#define ACE_HAS_SIG_ATOMIC_T
+#define ACE_HAS_POSIX_TIME
+#define ACE_HAS_SOCKLEN_T
+#define ACE_HAS_DIRENT
+
+#define ACE_NEW_THROWS_EXCEPTIONS
+#define ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB
+#define ACE_TEXT_WIN32_FIND_DATA MFS_SEARCH_DATA
+
+#define ACE_LACKS_UNIX_SIGNALS
+#define ACE_LACKS_SO_DONTROUTE
+#define ACE_LACKS_WCSDUP
+#define ACE_LACKS_WCSTOK
+#define ACE_LACKS_ITOW
+#define ACE_LACKS_WCSICMP
+#define ACE_LACKS_WCSNICMP
+#define ACE_LACKS_INET_NTOA
+#define ACE_LACKS_RAND_R
+#define ACE_LACKS_PUTENV
+#define ACE_LACKS_PWD_FUNCTIONS
+#define ACE_LACKS_SETSID
+#define ACE_LACKS_SETGID
+#define ACE_LACKS_GETEGID
+#define ACE_LACKS_GETGID
+#define ACE_LACKS_GETEUID
+#define ACE_LACKS_SETEGID
+#define ACE_LACKS_SETEUID
+#define ACE_LACKS_SETREUID
+#define ACE_LACKS_SETREGID
+#define ACE_LACKS_SETUID
+#define ACE_LACKS_GETUID
+#define ACE_LACKS_GETPGID
+#define ACE_LACKS_SETPGID
+#define ACE_LACKS_GETPPID
+#define ACE_LACKS_GETPID
+#define ACE_LACKS_EXEC
+#define ACE_LACKS_FORK
+#define ACE_LACKS_GETOPT
+#define ACE_LACKS_SBRK
+#define ACE_LACKS_PIPE
+#define ACE_DISABLE_NOTIFY_PIPE_DEFAULT 1
+#define ACE_LACKS_ISATTY
+#define ACE_LACKS_ALARM
+#define ACE_LACKS_SYSCONF
+#define ACE_LACKS_SWAB
+#define ACE_LACKS_CADDR_T
+#define ACE_LACKS_SETENV
+#define ACE_LACKS_UNSETENV
+#define ACE_LACKS_CUSERID
+#define ACE_LACKS_MADVISE
+#define ACE_LACKS_MMAP
+#define ACE_LACKS_MPROTECT
+#define ACE_LACKS_MSYNC
+#define ACE_LACKS_MUNMAP
+#define ACE_LACKS_STRPTIME
+#define ACE_LACKS_GMTIME_R
+#define ACE_LACKS_ASCTIME_R
+#define ACE_LACKS_TZSET
+#define ACE_LACKS_IOVEC
+#define ACE_LACKS_ISASCII
+#define ACE_LACKS_ISCTYPE
+#define ACE_LACKS_READV
+#define ACE_LACKS_WRITEV
+#define ACE_LACKS_RECVMSG
+#define ACE_LACKS_SENDMSG
+#define ACE_LACKS_SOCKETPAIR
+#define ACE_LACKS_GETHOSTBYADDR
+#define ACE_LACKS_GETHOSTBYADDR_R
+#define ACE_LACKS_GETHOSTBYNAME
+#define ACE_LACKS_GETSERVBYNAME
+#define ACE_LACKS_GETSERVBYNAME_R
+#define ACE_LACKS_GAI_STRERROR
+#define ACE_LACKS_GETPROTOBYNUMBER
+#define ACE_LACKS_GETPROTOBYNUMBER_R
+#define ACE_LACKS_GETPROTOBYNAME
+#define ACE_LACKS_GETPROTOBYNAME_R
+#define ACE_LACKS_STRUCT_DIR
+#define ACE_LACKS_HOSTENT
+#define ACE_LACKS_PROTOENT
+#define ACE_LACKS_SERVENT
+#define ACE_LACKS_RLIMIT
+#define ACE_LACKS_WAIT
+#define ACE_LACKS_WAITPID
+#define ACE_LACKS_SIGEMPTYSET
+#define ACE_LACKS_SIGADDSET
+#define ACE_LACKS_IOSTREAM_TOTALLY
+#define ACE_LACKS_ACE_IOSTREAM
+#define ACE_LACKS_UNIX_SYSLOG
+#define ACE_LACKS_UNAME
+#define ACE_LACKS_IFCONF
+#define ACE_LACKS_IFREQ
+#define ACE_LACKS_STRRECVFD
+#define ACE_MKDIR_LACKS_MODE
+
+// POSIX
+#define ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE
+#define ACE_LACKS_SEMBUF_T
+#define ACE_LACKS_UNIX_DOMAIN_SOCKETS
+#define ACE_LACKS_KILL
+#define NSIG 64
+#define FD_SETSIZE RTCSCFG_FD_SETSIZE
+#define FD_SET RTCS_FD_SET
+#define FD_CLR RTCS_FD_CLR
+#define FD_ZERO RTCS_FD_ZERO
+#define FD_ISSET RTCS_FD_ISSET
+#define NFDBITS (sizeof (fd_mask) * 8)
+typedef long fd_mask;
+struct fd_set: public rtcs_fd_set {
+ fd_set()
+ : fds_bits(fd_array) {
+ }
+ uint32_t* fds_bits;
+};
+
+// File System Related
+#define ACE_LACKS_MKTEMP
+#define ACE_LACKS_MKSTEMP
+#define ACE_LACKS_ACCESS
+#define ACE_LACKS_REALPATH
+#define ACE_LACKS_LSTAT
+#define ACE_LACKS_MKFIFO
+#define ACE_LACKS_UMASK
+#define ACE_LACKS_DUP
+#define ACE_LACKS_DUP2
+#define ACE_LACKS_FSYNC
+#define ACE_LACKS_FTRUNCATE
+#define ACE_LACKS_READLINK
+#define ACE_LACKS_TRUNCATE
+#define ACE_LACKS_TEMPNAM
+#define ACE_LACKS_FCNTL
+#define ACE_LACKS_REWINDDIR
+#define ACE_LACKS_OPENDIR
+#define ACE_LACKS_READDIR
+#define ACE_LACKS_SEEKDIR
+#define ACE_LACKS_TELLDIR
+#define ACE_LACKS_CLOSEDIR
+#define ACE_LACKS_ALPHASORT
+
+#define ACE_DEFINE_MISSING_ERRNOS
+
+#define O_NDELAY 1
+
+struct stat
+{
+ long st_size;
+ long st_mtime;
+ long st_mode;
+ long st_nlink;
+};
+
+typedef unsigned int uid_t;
+typedef unsigned int gid_t;
+typedef long off_t;
+typedef long loff_t;
+typedef unsigned int mode_t;
+typedef struct timespec timespec_t;
+
+struct timeval
+{
+ int tv_sec;
+ suseconds_t tv_usec;
+};
+
+#define MAXSYMLINKS 1
+
+#define FIONBIO 0
+
+#define S_IFMT 00170000
+#define S_IFREG 00100000
+#define S_IFDIR 00040000
+#define S_IFCHR 00020000
+#define ACE_LACKS_MODE_MASKS
+
+#define IP_TTL 0
+#define IP_TOS 0
+
+#define ACE_IPPROTO_TCP SOL_TCP
+#define TCP_NODELAY OPT_NOWAIT
+
+#endif
+
diff --git a/ACE/ace/os_include/netinet/os_in.h b/ACE/ace/os_include/netinet/os_in.h
index 4c82df46183..f71e757532b 100644
--- a/ACE/ace/os_include/netinet/os_in.h
+++ b/ACE/ace/os_include/netinet/os_in.h
@@ -43,7 +43,7 @@ extern "C"
# if defined (ACE_HAS_PHARLAP_RT)
# define ACE_IPPROTO_TCP SOL_SOCKET
-# else
+# elif !defined (ACE_IPPROTO_TCP)
# define ACE_IPPROTO_TCP IPPROTO_TCP
# endif /* ACE_HAS_PHARLAP_RT */
diff --git a/ACE/ace/os_include/os_dirent.h b/ACE/ace/os_include/os_dirent.h
index b5ce357e866..650fb402d96 100644
--- a/ACE/ace/os_include/os_dirent.h
+++ b/ACE/ace/os_include/os_dirent.h
@@ -64,8 +64,10 @@ struct ACE_DIR {
/// The name of the directory we are looking into
ACE_TCHAR *directory_name_;
+#if !defined (ACE_MQX)
/// Remember the handle between calls.
HANDLE current_handle_;
+#endif
/// The struct for the results
ACE_DIRENT *dirent_;
diff --git a/ACE/ace/os_include/os_errno.h b/ACE/ace/os_include/os_errno.h
index c083e7407ee..d132d73882c 100644
--- a/ACE/ace/os_include/os_errno.h
+++ b/ACE/ace/os_include/os_errno.h
@@ -31,6 +31,10 @@
#include /**/ <errnoLib.h>
#endif /* ACE_VXWORKS */
+#ifndef ACE_CUSTOM_ERRNO_BASE
+# define ACE_CUSTOM_ERRNO_BASE 1000
+#endif
+
// Place all additions (especially function declarations) within extern "C" {}
#ifdef __cplusplus
extern "C"
@@ -281,7 +285,7 @@ extern "C"
void herror (const char *str);
#endif /* ACE_HAS_H_ERRNO */
-#if defined (ACE_LACKS_ERRNO_H)
+#if defined (ACE_LACKS_ERRNO_H) || defined (ACE_DEFINE_MISSING_ERRNOS)
# if !defined (EPERM)
# define EPERM 1
# endif /* EPERM */
@@ -378,7 +382,7 @@ void herror (const char *str);
# if !defined (ERANGE)
# define ERANGE 34
# endif /* ERANGE */
-# if !defined (EDEADLK)
+# if !defined (EDEADLK) && !defined (ACE_MQX) // Conflicts with EILSEQ
# define EDEADLK 36
# endif /* EDEADLK */
# if !defined (ENAMETOOLONG)
@@ -393,7 +397,38 @@ void herror (const char *str);
# if !defined (ENOTEMPTY)
# define ENOTEMPTY 41
# endif /* ENOTEMPTY */
-#endif /* ACE_LACKS_ERRNO_H */
+# ifndef ETIME
+# define ETIME 62
+# endif
+# ifndef ECOMM
+# define ECOMM 70
+# endif
+# ifndef EAFNOSUPPORT
+# define EAFNOSUPPORT 97
+# endif
+# ifndef EADDRIUNSE
+# define EADDRINUSE 98
+# endif
+# ifndef ENETUNREACH
+# define ENETUNREACH 101
+# endif
+# ifndef ECONNRESET
+# define ECONNRESET 104
+# endif
+# ifndef ENOBUFS
+# define ENOBUFS 105
+# endif
+# ifndef EISCONN
+# define EISCONN 106
+# endif
+# ifndef ECONNREFUSED
+# define ECONNREFUSED 111
+# endif
+# ifndef EINPROGRESS
+# define EINPROGRESS 115
+# endif
+
+#endif /* ACE_DEFINE_MISSING_ERRNOS */
#if defined (ACE_LACKS_T_ERRNO)
extern int t_errno;
@@ -425,7 +460,7 @@ extern int t_errno;
#endif /* ECOMM */
#if !defined (EDEADLK)
-# define EDEADLK 1000 /* Some large number.... */
+# define EDEADLK (ACE_CUSTOM_ERRNO_BASE) + 1
#endif /* !EDEADLK */
#if !defined (ENXIO) /* Needed in SOCK_Dgram_Mcast */
@@ -452,6 +487,11 @@ extern int t_errno;
#define ESHUTDOWN ECANCELED
#endif
+#ifdef ACE_MQX
+# define EWOULDBLOCK EAGAIN
+# define ELOOP (ACE_CUSTOM_ERRNO_BASE) + 2
+#endif
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/ACE/ace/os_include/os_pthread.h b/ACE/ace/os_include/os_pthread.h
index 6b2582b21c8..5693cb880e2 100644
--- a/ACE/ace/os_include/os_pthread.h
+++ b/ACE/ace/os_include/os_pthread.h
@@ -292,7 +292,7 @@
# define THR_EXPLICIT_SCHED 0x00800000
# define THR_SCHED_IO 0x01000000
-# if !defined (ACE_HAS_STHREADS)
+# if !defined (ACE_HAS_STHREADS) && !defined (ACE_MQX)
# if !defined (ACE_HAS_POSIX_SEM) && !defined (ACE_USES_FIFO_SEM)
// This needs to be moved out of here.
diff --git a/ACE/ace/os_include/os_unistd.h b/ACE/ace/os_include/os_unistd.h
index 942a40c431f..55235d30398 100644
--- a/ACE/ace/os_include/os_unistd.h
+++ b/ACE/ace/os_include/os_unistd.h
@@ -51,6 +51,18 @@
# include /**/ <hostLib.h>
#endif /* ACE_VXWORKS */
+#ifdef ACE_MQX
+# if !defined (STDIN_FILENO) && defined (_LLIO_STDIN)
+# define STDIN_FILENO (_LLIO_STDIN)
+# endif
+# if !defined (STDOUT_FILENO) && defined (_LLIO_STDOUT)
+# define STDOUT_FILENO (_LLIO_STDOUT)
+# endif
+# if !defined (STDERR_FILENO) && defined (_LLIO_STDERR)
+# define STDERR_FILENO (_LLIO_STDERR)
+# endif
+#endif
+
// Place all additions (especially function declarations) within extern "C" {}
#ifdef __cplusplus
extern "C"
diff --git a/ACE/ace/os_include/sys/os_socket.h b/ACE/ace/os_include/sys/os_socket.h
index 19b0eadb7cf..dbdba632729 100644
--- a/ACE/ace/os_include/sys/os_socket.h
+++ b/ACE/ace/os_include/sys/os_socket.h
@@ -28,6 +28,10 @@
# include /**/ <sys/socket.h>
#endif /* !ACE_LACKS_SYS_SOCKET_H */
+#if defined (ACE_USES_SOCKET_H)
+# include /**/ <socket.h>
+#endif /* ACE_USES_SOCKET_H */
+
#if defined (ACE_USES_SOCKLIB_H)
# include /**/ <sockLib.h>
#endif /* ACE_USES_SOCKLIB_H */
@@ -215,6 +219,7 @@ extern "C"
#define ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE SSIZE_MAX
#endif /* ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE */
+#if !defined (ACE_SOCKET_LEN)
#if defined (ACE_HAS_SOCKLEN_T)
# if defined (__hpux)
/*
@@ -240,6 +245,7 @@ typedef size_t ACE_SOCKET_LEN;
#else
typedef int ACE_SOCKET_LEN;
#endif /* ACE_HAS_SIZET_SOCKET_LEN */
+#endif /* ACE_SOCKET_LEN */
#if defined (ACE_HAS_NETLINK)
# include /**/ <asm/types.h>
diff --git a/ACE/include/makeinclude/platform_mqx_icc.GNU b/ACE/include/makeinclude/platform_mqx_icc.GNU
new file mode 100644
index 00000000000..4f0716d00c4
--- /dev/null
+++ b/ACE/include/makeinclude/platform_mqx_icc.GNU
@@ -0,0 +1,92 @@
+# $Id$
+
+# This file should allow ACE to be built on Windows, using the IAR compiler.
+
+MQX_CPU = PSP_CPU_MK70F120M
+MQX_CPU_INC = cortex_m
+
+ifndef MQX_ROOT
+ $(error Please set MQX_ROOT to the toplevel directory of the MQX code.)
+endif
+
+MQX_CONFIG_COMMON_DIR ?= "$(MQX_ROOT)/config/common"
+
+ifndef MQX_USER_CONFIG_DIR
+ $(error Please set MQX_USER_CONFIG_DIR to the directory containing the MQX user_config.h.)
+endif
+
+ACE_PLATFORM_CONFIG ?= config-mqx.h
+debug ?= 1
+optimize ?= 1
+threads ?= 1
+static_libs_only = 1
+gruntimelibselect ?= 1
+
+AR = iarchive
+ARFLAGS = -o
+RANLIB = @true
+AR.cc.override = $(RM) $@; echo $(filter %.o, $^) | xargs $(AR) $(ARFLAGS) $@ $(AREXTRA)
+
+fast ?= 0
+
+IAR_PLATFORM ?= arm
+
+CC = icc$(IAR_PLATFORM)
+CXX = icc$(IAR_PLATFORM) --c++
+
+ifndef CXX_VERSION
+ CXX_VERSION := $(shell $(CXX) --version)
+endif
+
+no_hidden_visibility ?= 1
+
+ifeq ($(inline),0)
+ CPPFLAGS += --no_inline
+endif
+
+ifeq ($(gruntimelibselect),1)
+ CFLAGS += --dlib_config DLib_Config_Normal.h
+endif
+ifeq ($(gruntimelibselect),2)
+ CFLAGS += --dlib_config DLib_Config_Full.h -DACE_MQX_DLIB_FULL
+endif
+ifeq ($(gruntimelibselect),3)
+ CFLAGS += --dlib_config $(DLIB_CONFIG)
+endif
+
+CFLAGS += -I$(MQX_CONFIG_COMMON_DIR) -I$(MQX_USER_CONFIG_DIR)
+MQX_IO_DIR=$(MQX_ROOT)/mqx/source/io
+CFLAGS += -DMQX_CPU=$(MQX_CPU) --enable_restrict -I$(MQX_ROOT)/mqx/source/include -I$(MQX_ROOT)/mqx/source/psp/$(MQX_CPU_INC) -I$(MQX_ROOT)/mqx/source/psp/$(MQX_CPU_INC)/cpu -I$(MQX_ROOT)/mqx/source/psp/$(MQX_CPU_INC)/compiler/iar -I$(MQX_ROOT)/rtcs/source/include -I$(MQX_ROOT)/mqx/source/bsp/twrk70f120m -I$(MQX_IO_DIR)/adc -I$(MQX_IO_DIR)/asrc -I$(MQX_IO_DIR)/can -I$(MQX_IO_DIR)/cm -I$(MQX_IO_DIR)/core_mutex -I$(MQX_IO_DIR)/dcu4 -I$(MQX_IO_DIR)/debug -I$(MQX_IO_DIR)/dma -I$(MQX_IO_DIR)/enet -I$(MQX_IO_DIR)/esai -I$(MQX_IO_DIR)/esdhc -I$(MQX_IO_DIR)/fbdev -I$(MQX_IO_DIR)/flashx -I$(MQX_IO_DIR)/flextimer -I$(MQX_IO_DIR)/ftm -I$(MQX_IO_DIR)/gpio -I$(MQX_IO_DIR)/hmi -I$(MQX_IO_DIR)/hwtimer -I$(MQX_IO_DIR)/i2c -I$(MQX_IO_DIR)/i2s -I$(MQX_IO_DIR)/imxrt -I$(MQX_IO_DIR)/int_ctrl -I$(MQX_IO_DIR)/io_expander -I$(MQX_IO_DIR)/io_mem -I$(MQX_IO_DIR)/io_null -I$(MQX_IO_DIR)/lcd -I$(MQX_IO_DIR)/lpm -I$(MQX_IO_DIR)/lpm_mcore -I$(MQX_IO_DIR)/lwadc -I$(MQX_IO_DIR)/lwgpio -I$(MQX_IO_DIR)/mcg -I$(MQX_IO_DIR)/mu -I$(MQX_IO_DIR)/nandflash -I$(MQX_IO_DIR)/pcb -I$(MQX_IO_DIR)/pccard -I$(MQX_IO_DIR)/pcflash -I$(MQX_IO_DIR)/pipe -I$(MQX_IO_DIR)/qspi -I$(MQX_IO_DIR)/rnga -I$(MQX_IO_DIR)/rtc -I$(MQX_IO_DIR)/sai -I$(MQX_IO_DIR)/sdcard -I$(MQX_IO_DIR)/sdram -I$(MQX_IO_DIR)/sensor -I$(MQX_IO_DIR)/serial -I$(MQX_IO_DIR)/sim -I$(MQX_IO_DIR)/spi -I$(MQX_IO_DIR)/spi_legacy -I$(MQX_IO_DIR)/spi_slave -I$(MQX_IO_DIR)/tchres -I$(MQX_IO_DIR)/tfs -I$(MQX_IO_DIR)/timer -I$(MQX_IO_DIR)/usb -I$(MQX_IO_DIR)/usb_dcd -I$(MQX_IO_DIR)/gpio/kgpio -I$(MQX_IO_DIR)/sdcard/sdcard_spi -I$(MQX_IO_DIR)/sdcard/sdcard_esdhc -I$(MQX_IO_DIR)/flashx/freescale -I$(MQX_IO_DIR)/enet/macnet -I$(MQX_IO_DIR)/adc/kadc -I$(MQX_ROOT)/mfs/source/include -I$(MQX_ROOT)/posix/source/include
+
+ifeq ($(threads),1)
+ CPPFLAGS += -D_REENTRANT
+endif # threads
+
+CCFLAGS += $(CFLAGS)
+DCFLAGS += --debug
+DLD = ilinkarm
+LD = ilinkarm
+
+MQX_LIB_DIR ?= $(MQX_ROOT)/lib/twrk70f120m.iar/debug
+
+LDFLAGS += --config $(MQX_LIB_DIR)/bsp/intflash_sramdata.icf --redirect __iar_dlmalloc=malloc \
+ --redirect __iar_dlcalloc=calloc --redirect __iar_dlfree=free --manual_dynamic_initialization
+SYSTEM_LIBS = -L$(MQX_LIB_DIR)/bsp bsp.a \
+ -L$(MQX_LIB_DIR)/psp psp.a \
+ -L$(MQX_LIB_DIR)/mfs mfs.a \
+ -L$(MQX_LIB_DIR)/rtcs rtcs.a \
+ -L$(MQX_LIB_DIR)/posix posix.a
+
+LINK.cc.override = $(PURELINK) $(PRELINK) $(LD) $(LDFLAGS) $(CC_OUTPUT_FLAG) $@ $(SYSTEM_LIBS) $(filter-out %.a,$^) $(VLDLIBS) $(POSTLINK)
+
+OCFLAGS += -O
+
+ifeq ($(optimize),0)
+ # Disable all optimizing in code
+ CPPFLAGS += -On
+endif
+
+SOFLAGS += $(CPPFLAGS) -shared
+SOBUILD = $(COMPILE.cc) $(PIC) -o $(VSHDIR)$*.so $<; \
+ $(SOLINK.cc) -o $@ $(LDFLAGS) $(VSHDIR)$*.o
+PRELIB = @true
diff --git a/ACE/tests/OS_Test.cpp b/ACE/tests/OS_Test.cpp
index bf1101c1c77..65115e9b27b 100644
--- a/ACE/tests/OS_Test.cpp
+++ b/ACE/tests/OS_Test.cpp
@@ -548,6 +548,9 @@ string_emulation_test (void)
// ========================================================================
// Test strtok (wchar_t version)
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing strtok (wchar_t version)\n")));
+# ifdef ACE_LACKS_WCSTOK
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" Skipped because platform lacks wcstok\n")));
+# else
//FUZZ: enable check_for_lack_ACE_OS
wchar_t strtok_r1[] = ACE_TEXT_WIDE ("A string of tokens");
@@ -565,6 +568,7 @@ string_emulation_test (void)
ACE_TEXT_WIDE (" ")),
ACE_TEXT_WIDE ("tokens") ) == 0);
THIS_IS_NOT_AN_ASSERT_IT_IS_A_NON_DEBUG_TEST_AS_WELL (ACE_OS::strtok (0, ACE_TEXT_WIDE (" ")) == 0);
+# endif /* ACE_LACKS_WCSTOK */
}
diff --git a/ACE/tests/test_config.h b/ACE/tests/test_config.h
index 1d1feaa3547..e606f048a21 100644
--- a/ACE/tests/test_config.h
+++ b/ACE/tests/test_config.h
@@ -88,36 +88,43 @@ size_t const ACE_MAX_THREADS = 4;
#endif /* ACE_END_TEST */
#endif /* ACE_HAS_CONSOLE_TEST_OUTPUT */
-#ifndef ACE_START_TEST
-#define ACE_START_TEST(NAME) \
+#ifdef ACE_TEST_LOG_TO_STDERR
+# define ACE_TEST_LOG_MSG_FLAGS ACE_Log_Msg::STDERR | ACE_Log_Msg::VERBOSE_LITE
+# define ACE_TEST_SET_OUTPUT(APPEND)
+# define ACE_CLOSE_TEST_LOG
+#else
+# define ACE_TEST_LOG_MSG_FLAGS ACE_Log_Msg::OSTREAM | ACE_Log_Msg::VERBOSE_LITE
+# define ACE_TEST_SET_OUTPUT(APPEND) \
+ if (ace_file_stream::instance ()->set_output (program, APPEND) != 0) \
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("set_output failed")), -1);
+# define ACE_CLOSE_TEST_LOG ace_file_stream::instance ()->close ()
+#endif
+
+#define ACE_START_TEST_TEMPLATE(NAME, APPEND) \
const ACE_TCHAR *program = NAME; \
- if (ACE_LOG_MSG->open (program, ACE_Log_Msg::OSTREAM | ACE_Log_Msg::VERBOSE_LITE) != 0) \
+ if (ACE_LOG_MSG->open (program, ACE_TEST_LOG_MSG_FLAGS) != 0) \
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open log_msg failed")), -1); \
- if (ace_file_stream::instance()->set_output (program) != 0) \
- ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("set_output failed")), -1); \
+ ACE_TEST_SET_OUTPUT (APPEND); \
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Starting %s test at %D\n"), program))
+
+#ifndef ACE_START_TEST
+# define ACE_START_TEST(NAME) ACE_START_TEST_TEMPLATE (NAME, 0)
#endif /* ACE_START_TEST */
#ifndef ACE_END_TEST
#define ACE_END_TEST \
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Ending %s test at %D\n"), program)); \
- ace_file_stream::instance()->close ()
+ ACE_CLOSE_TEST_LOG;
#endif /* ACE_END_TEST */
-#define ACE_CLOSE_TEST_LOG ace_file_stream::instance()->close ()
-
-#define ACE_APPEND_LOG(NAME) \
- const ACE_TCHAR *program = NAME; \
- if (ACE_LOG_MSG->open (program, ACE_Log_Msg::OSTREAM | ACE_Log_Msg::VERBOSE_LITE) != 0) \
- ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open log_msg failed")), -1); \
- if (ace_file_stream::instance()->set_output (program, 1) != 0) \
- ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("set_output failed")), -1); \
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Starting %s test at %D\n"), program));
+#ifndef ACE_APPEND_LOG
+# define ACE_APPEND_LOG(NAME) ACE_START_TEST_TEMPLATE (NAME, 1)
+#endif /* ACE_APPEND_LOG */
#define ACE_END_LOG \
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Ending %s test at %D\n\n"), program)); \
ACE_LOG_MSG->set_flags(ACE_Log_Msg::SILENT); \
- ace_file_stream::instance()->close ();
+ ACE_CLOSE_TEST_LOG;
#if defined (ACE_VXWORKS)
// This is the only way I could figure out to avoid an error
diff --git a/TAO/tao/IIOP_Acceptor.cpp b/TAO/tao/IIOP_Acceptor.cpp
index 32eebdc1b99..3a7f2807b69 100644
--- a/TAO/tao/IIOP_Acceptor.cpp
+++ b/TAO/tao/IIOP_Acceptor.cpp
@@ -462,7 +462,7 @@ TAO_IIOP_Acceptor::open_i (const ACE_INET_Addr& addr,
this->creation_strategy_,
this->accept_strategy_,
this->concurrency_strategy_,
- 0, 0, 0, 1,
+ 0, 0, 0, ACE_DEFAULT_ACCEPTOR_USE_SELECT,
this->reuse_addr_) == -1)
{
if (TAO_debug_level > 0)
@@ -498,7 +498,7 @@ TAO_IIOP_Acceptor::open_i (const ACE_INET_Addr& addr,
this->creation_strategy_,
this->accept_strategy_,
this->concurrency_strategy_,
- 0, 0, 0, 1,
+ 0, 0, 0, ACE_DEFAULT_ACCEPTOR_USE_SELECT,
this->reuse_addr_) != -1)
{
found_a_port = true;
diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp
index c9f13c78cff..bf4bb930103 100644
--- a/TAO/tao/IIOP_Connection_Handler.cpp
+++ b/TAO/tao/IIOP_Connection_Handler.cpp
@@ -380,7 +380,11 @@ TAO_IIOP_Connection_Handler::close_connection (void)
{
struct linger lval;
lval.l_onoff = 1;
+#if defined(ACE_HAS_LINGER_MS)
+ lval.l_linger_ms = linger * 1000;
+#else
lval.l_linger = (u_short)linger;
+#endif
if (this->peer ().set_option(SOL_SOCKET,
SO_LINGER,
(void*) &lval,
@@ -662,9 +666,8 @@ TAO_IIOP_Connection_Handler::set_dscp_codepoint (CORBA::Boolean set_network_prio
void
TAO_IIOP_Connection_Handler::abort (void)
{
- struct linger lval;
+ struct linger lval = { 0 };
lval.l_onoff = 1;
- lval.l_linger = 0;
if (this->peer ().set_option(SOL_SOCKET,
SO_LINGER,