Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / SPIPE_Stream.cpp
blobb824d53a62e4fd641768eac10fd5a781a225614c
1 #include "ace/SPIPE_Stream.h"
2 #include "ace/OS_Memory.h"
4 #if !defined (__ACE_INLINE__)
5 #include "ace/SPIPE_Stream.inl"
6 #endif /* __ACE_INLINE__ */
8 #if defined (ACE_HAS_ALLOC_HOOKS)
9 # include "ace/Malloc_Base.h"
10 #endif /* ACE_HAS_ALLOC_HOOKS */
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_ALLOC_HOOK_DEFINE(ACE_SPIPE_Stream)
16 void
17 ACE_SPIPE_Stream::dump () const
19 #if defined (ACE_HAS_DUMP)
20 ACE_TRACE ("ACE_SPIPE_Stream::dump");
21 #endif /* ACE_HAS_DUMP */
24 // Simple-minded do nothing constructor.
26 ACE_SPIPE_Stream::ACE_SPIPE_Stream ()
28 // ACE_TRACE ("ACE_SPIPE_Stream::ACE_SPIPE_Stream");
31 // Send N char *ptrs and int lengths. Note that the char *'s precede
32 // the ints (basically, an varargs version of writev). The count N is
33 // the *total* number of trailing arguments, *not* a couple of the
34 // number of tuple pairs!
36 #ifndef ACE_LACKS_VA_FUNCTIONS
37 ssize_t
38 ACE_SPIPE_Stream::send (size_t n, ...) const
40 // ACE_TRACE ("ACE_SPIPE_Stream::send");
41 va_list argp;
42 int total_tuples = static_cast<int> (n / 2);
43 iovec *iovp;
44 #if defined (ACE_HAS_ALLOCA)
45 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
46 #else
47 # ifdef ACE_HAS_ALLOC_HOOKS
48 ACE_ALLOCATOR_RETURN (iovp, (iovec *)
49 ACE_Allocator::instance ()->malloc (total_tuples *
50 sizeof (iovec)),
51 -1);
52 # else
53 ACE_NEW_RETURN (iovp,
54 iovec[total_tuples],
55 -1);
56 # endif /* ACE_HAS_ALLOC_HOOKS */
57 #endif /* !defined (ACE_HAS_ALLOCA) */
59 va_start (argp, n);
61 for (int i = 0; i < total_tuples; i++)
63 iovp[i].iov_base = va_arg (argp, char *);
64 iovp[i].iov_len = va_arg (argp, int);
67 ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
68 #if !defined (ACE_HAS_ALLOCA)
69 # ifdef ACE_HAS_ALLOC_HOOKS
70 ACE_Allocator::instance ()->free (iovp);
71 # else
72 delete [] iovp;
73 # endif /* ACE_HAS_ALLOC_HOOKS */
74 #endif /* !defined (ACE_HAS_ALLOCA) */
75 va_end (argp);
76 return result;
79 // This is basically an interface to ACE_OS::readv, that doesn't use
80 // the struct iovec explicitly. The ... can be passed as an arbitrary
81 // number of (char *ptr, int len) tuples. However, the count N is the
82 // *total* number of trailing arguments, *not* a couple of the number
83 // of tuple pairs!
85 ssize_t
86 ACE_SPIPE_Stream::recv (size_t n, ...) const
88 ACE_TRACE ("ACE_SPIPE_Stream::recv");
89 va_list argp;
90 int total_tuples = static_cast<int> (n / 2);
91 iovec *iovp;
92 #if defined (ACE_HAS_ALLOCA)
93 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
94 #else
95 # ifdef ACE_HAS_ALLOC_HOOKS
96 ACE_ALLOCATOR_RETURN (iovp, (iovec *)
97 ACE_Allocator::instance ()->malloc (total_tuples *
98 sizeof (iovec)),
99 -1);
100 # else
101 ACE_NEW_RETURN (iovp,
102 iovec[total_tuples],
103 -1);
104 # endif /* ACE_HAS_ALLOC_HOOKS */
105 #endif /* !defined (ACE_HAS_ALLOCA) */
107 va_start (argp, n);
109 for (int i = 0; i < total_tuples; i++)
111 iovp[i].iov_base = va_arg (argp, char *);
112 iovp[i].iov_len = va_arg (argp, int);
115 ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
116 #if !defined (ACE_HAS_ALLOCA)
117 # ifdef ACE_HAS_ALLOC_HOOKS
118 ACE_Allocator::instance ()->free (iovp);
119 # else
120 delete [] iovp;
121 # endif /* ACE_HAS_ALLOC_HOOKS */
122 #endif /* !defined (ACE_HAS_ALLOCA) */
123 va_end (argp);
124 return result;
126 #endif // ACE_LACKS_VA_FUNCTIONS
128 ACE_END_VERSIONED_NAMESPACE_DECL