Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / DEV_IO.cpp
blob617d72e80b84b1b62a3828af73c5fb86f3eee62b
1 #include "ace/DEV_IO.h"
2 #include "ace/Log_Category.h"
3 #if defined (ACE_HAS_ALLOC_HOOKS)
4 # include "ace/Malloc_Base.h"
5 #endif /* ACE_HAS_ALLOC_HOOKS */
7 #if !defined (__ACE_INLINE__)
8 #include "ace/DEV_IO.inl"
9 #endif /* __ACE_INLINE__ */
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 ACE_ALLOC_HOOK_DEFINE(ACE_DEV_IO)
15 // Return the local endpoint address.
17 int
18 ACE_DEV_IO::get_local_addr (ACE_DEV_Addr &addr) const
20 ACE_TRACE ("ACE_DEV_IO::get_local_addr");
22 addr = this->addr_;
23 return 0;
26 // Return the address of the remotely connected peer (if there is
27 // one).
29 int
30 ACE_DEV_IO::get_remote_addr (ACE_DEV_Addr &addr) const
32 ACE_TRACE ("ACE_DEV_IO::get_remote_addr");
33 addr = this->addr_;
34 return 0;
37 void
38 ACE_DEV_IO::dump () const
40 #if defined (ACE_HAS_DUMP)
41 ACE_TRACE ("ACE_DEV_IO::dump");
43 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
44 this->addr_.dump ();
45 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
46 #endif /* ACE_HAS_DUMP */
49 // Simple-minded do nothing constructor.
51 ACE_DEV_IO::ACE_DEV_IO ()
53 ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO");
56 // Send N char *ptrs and int lengths. Note that the char *'s precede
57 // the ints (basically, an varargs version of writev). The count N is
58 // the *total* number of trailing arguments, *not* a couple of the
59 // number of tuple pairs!
61 ssize_t
62 ACE_DEV_IO::send (size_t n, ...) const
64 ACE_TRACE ("ACE_DEV_IO::send");
65 #ifdef ACE_LACKS_VA_FUNCTIONS
66 ACE_UNUSED_ARG (n);
67 ACE_NOTSUP_RETURN (-1);
68 #else
69 va_list argp;
70 int total_tuples = static_cast<int> (n / 2);
71 iovec *iovp;
72 #if defined (ACE_HAS_ALLOCA)
73 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
74 #else
75 # ifdef ACE_HAS_ALLOC_HOOKS
76 ACE_ALLOCATOR_RETURN (iovp, (iovec *)
77 ACE_Allocator::instance ()->malloc (total_tuples *
78 sizeof (iovec)),
79 -1);
80 # else
81 ACE_NEW_RETURN (iovp,
82 iovec[total_tuples],
83 -1);
84 # endif /* ACE_HAS_ALLOC_HOOKS */
85 #endif /* !defined (ACE_HAS_ALLOCA) */
87 va_start (argp, n);
89 for (int i = 0; i < total_tuples; i++)
91 iovp[i].iov_base = va_arg (argp, char *);
92 iovp[i].iov_len = va_arg (argp, int);
95 ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
96 #if !defined (ACE_HAS_ALLOCA)
97 # ifdef ACE_HAS_ALLOC_HOOKS
98 ACE_Allocator::instance ()->free (iovp);
99 # else
100 delete [] iovp;
101 # endif /* ACE_HAS_ALLOC_HOOKS */
102 #endif /* !defined (ACE_HAS_ALLOCA) */
103 va_end (argp);
104 return result;
105 #endif // ACE_LACKS_VA_FUNCTIONS
108 // This is basically an interface to ACE_OS::readv, that doesn't use the
109 // struct iovec explicitly. The ... can be passed as an arbitrary
110 // number of (char *ptr, int len) tuples. However, the count N is the
111 // *total* number of trailing arguments, *not* a couple of the number
112 // of tuple pairs!
114 ssize_t
115 ACE_DEV_IO::recv (size_t n, ...) const
117 ACE_TRACE ("ACE_DEV_IO::recv");
118 #ifdef ACE_LACKS_VA_FUNCTIONS
119 ACE_UNUSED_ARG (n);
120 ACE_NOTSUP_RETURN (-1);
121 #else
122 va_list argp;
123 int total_tuples = static_cast<int> (n / 2);
124 iovec *iovp;
125 #if defined (ACE_HAS_ALLOCA)
126 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
127 #else
128 # ifdef ACE_HAS_ALLOC_HOOKS
129 ACE_ALLOCATOR_RETURN (iovp, (iovec *)
130 ACE_Allocator::instance ()->malloc (total_tuples *
131 sizeof (iovec)),
132 -1);
133 # else
134 ACE_NEW_RETURN (iovp,
135 iovec[total_tuples],
136 -1);
137 # endif /* ACE_HAS_ALLOC_HOOKS */
138 #endif /* !defined (ACE_HAS_ALLOCA) */
140 va_start (argp, n);
142 for (int i = 0; i < total_tuples; i++)
144 iovp[i].iov_base = va_arg (argp, char *);
145 iovp[i].iov_len = va_arg (argp, int);
148 ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
149 #if !defined (ACE_HAS_ALLOCA)
150 # ifdef ACE_HAS_ALLOC_HOOKS
151 ACE_Allocator::instance ()->free (iovp);
152 # else
153 delete [] iovp;
154 # endif /* ACE_HAS_ALLOC_HOOKS */
155 #endif /* !defined (ACE_HAS_ALLOCA) */
156 va_end (argp);
157 return result;
158 #endif // ACE_LACKS_VA_FUNCTIONS
161 ACE_END_VERSIONED_NAMESPACE_DECL