00001 /* 00002 Check _POSIX_SYNCHRONIZED_IO and _POSIX_ASYNCHRONOUS_IO 00003 AUP2, Sec. 1.05.4, 2.16.2 00004 00005 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00006 May be copied only for purposes and under conditions described 00007 on the Web page www.basepath.com/aup/copyright.htm. 00008 00009 The Example Files are provided "as is," without any warranty; 00010 without even the implied warranty of merchantability or fitness 00011 for a particular purpose. The author and his publisher are not 00012 responsible for any damages, direct or incidental, resulting 00013 from the use or non-use of these Example Files. 00014 00015 The Example Files may contain defects, and some contain deliberate 00016 coding mistakes that were included for educational reasons. 00017 You are responsible for determining if and how the Example Files 00018 are to be used. 00019 00020 */ 00021 #include "defs.h" 00022 00023 /*[option_sync_io]*/ 00024 OPT_RETURN option_sync_io(const char *path) 00025 { 00026 #if _POSIX_SYNCHRONIZED_IO <= 0 00027 return OPT_NO; 00028 #elif _XOPEN_VERSION >= 500 && !defined(LINUX) 00029 #if !defined(_POSIX_SYNC_IO) 00030 errno = 0; 00031 if (pathconf(path, _PC_SYNC_IO) == -1) 00032 if (errno == 0) 00033 return OPT_NO; 00034 else 00035 EC_FAIL 00036 else 00037 return OPT_YES; 00038 00039 EC_CLEANUP_BGN 00040 return OPT_ERROR; 00041 EC_CLEANUP_END 00042 #elif _POSIX_SYNC_IO == -1 00043 return OPT_NO; 00044 #else 00045 return OPT_YES; 00046 #endif /* _POSIX_SYNC_IO */ 00047 #elif _POSIX_VERSION >= 199309L 00048 return OPT_YES; 00049 #else 00050 errno = EINVAL; 00051 return OPT_ERROR; 00052 #endif /* _POSIX_SYNCHRONIZED_IO */ 00053 } 00054 /*[option_async_io]*/ 00055 OPT_RETURN option_async_io(const char *path) 00056 { 00057 #if _POSIX_ASYNCHRONOUS_IO <= 0 00058 return OPT_NO; 00059 #elif _XOPEN_VERSION >= 500 && !defined(LINUX) 00060 #if !defined(_POSIX_ASYNC_IO) 00061 errno = 0; 00062 if (pathconf(path, _PC_ASYNC_IO) == -1) 00063 if (errno == 0) 00064 return OPT_NO; 00065 else 00066 EC_FAIL 00067 else 00068 return OPT_YES; 00069 00070 EC_CLEANUP_BGN 00071 return OPT_ERROR; 00072 EC_CLEANUP_END 00073 #elif _POSIX_ASYNC_IO == -1 00074 return OPT_NO; 00075 #else 00076 return OPT_YES; 00077 #endif /* _POSIX_ASYNC_IO */ 00078 #elif _POSIX_VERSION >= 199309L 00079 return OPT_YES; 00080 #else 00081 errno = EINVAL; 00082 return OPT_ERROR; 00083 #endif /* _POSIX_ASYNCHRONOUS_IO */ 00084 } 00085 /*[]*/