gnuace: use list of generated files from GENERATED_DIRTY for ADDITIONAL_IDL_TARGETS
[ACE_TAO.git] / ACE / ace / Flag_Manip.cpp
blob0b5ec2d0eff08bfbbcf0f134630f92cadd650761
1 #include "ace/Flag_Manip.h"
3 #if defined (ACE_LACKS_FCNTL)
4 # include "ace/OS_NS_stropts.h"
5 # include "ace/OS_NS_errno.h"
6 #endif /* ACE_LACKS_FCNTL */
8 #if defined (ACE_LACKS_IOCTL)
9 # include "ace/OS_NS_devctl.h"
10 #endif
12 #if !defined (__ACE_INLINE__)
13 #include "ace/Flag_Manip.inl"
14 #endif /* __ACE_INLINE__ */
16 #if defined (CYGWIN32)
17 # include "ace/os_include/os_termios.h"
18 #endif /* CYGWIN32 */
20 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
22 // Flags are file status flags to turn on.
24 int
25 ACE::set_flags (ACE_HANDLE handle, int flags)
27 ACE_TRACE ("ACE::set_flags");
28 #if defined (ACE_LACKS_FCNTL)
29 switch (flags)
31 case ACE_NONBLOCK:
32 // nonblocking argument (1)
33 // blocking: (0)
35 int nonblock = 1;
36 # if defined (ACE_LACKS_IOCTL)
37 int dev_info;
38 return ACE_OS::posix_devctl (handle, FIONBIO, &nonblock,
39 sizeof nonblock, &dev_info);
40 # else
41 return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
42 # endif
44 default:
45 ACE_NOTSUP_RETURN (-1);
47 #else
48 int val = ACE_OS::fcntl (handle, F_GETFL, 0);
50 if (val == -1)
51 return -1;
53 // Turn on flags.
54 ACE_SET_BITS (val, flags);
56 if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
57 return -1;
58 else
59 return 0;
60 #endif /* ACE_LACKS_FCNTL */
63 // Flags are the file status flags to turn off.
65 int
66 ACE::clr_flags (ACE_HANDLE handle, int flags)
68 ACE_TRACE ("ACE::clr_flags");
69 #if defined (ACE_LACKS_FCNTL)
70 switch (flags)
72 case ACE_NONBLOCK:
73 // nonblocking argument (1)
74 // blocking: (0)
76 int nonblock = 0;
77 # if defined (ACE_LACKS_IOCTL)
78 int dev_info;
79 return ACE_OS::posix_devctl (handle, FIONBIO, &nonblock,
80 sizeof nonblock, &dev_info);
81 # else
82 return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
83 # endif
85 default:
86 ACE_NOTSUP_RETURN (-1);
88 #else
89 int val = ACE_OS::fcntl (handle, F_GETFL, 0);
91 if (val == -1)
92 return -1;
94 // Turn flags off.
95 ACE_CLR_BITS (val, flags);
97 if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
98 return -1;
99 else
100 return 0;
101 #endif /* ACE_LACKS_FCNTL */
104 ACE_END_VERSIONED_NAMESPACE_DECL