On Wed, Jan 22, 2003 at 11:45:34PM -0500, Rodent of Unusual Size wrote:
>       Some headers with issues: 
>         apr_fnmatch.h         (FNM_foo)
>         apr_general.h         (MAXIMUM_WAIT_OBJECTS)
>         apr_md5.h             (MD5_DIGESTSIZE)
>         apr_network_io.h      (MAX_SECONDS_TO_LINGER)
>         apr.hnw               (READDIR_IS_THREAD_SAFE, ENUM_BITFIELD, 
>                               _POSIX_THREAD_SAFE_FUNCTIONS (?),
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Whoa...this not not good.  _POSIX_THREAD_SAFE_FUNCTIONS is a
manifest POSIX constant that should *not* be defined by
the application.  A POSIX conformant application should
include <unistd.h> and *check* the value of this constant only.

See:
http://www.opengroup.org/onlinepubs/007904975/basedefs/unistd.h.html

Note, that the valid values of any of the POSIX manifest constants
defined in <unistd.h> can be:

- 200112L (or > 0) which means the feature is always supported
- -1, means the feature is not supported at all 
- 0, means the option may be present, and the application must check
  at runtime with sysconf() to see if the feature is supported.

It took me a while to get all this straight, but it is important
to understand in order to write portable and compliant POSIX code.

I recommend the attached patches.


-- 
Craig Rodrigues        
http://home.attbi.com/~rodrigc
[EMAIL PROTECTED]
Index: file_io/unix/dir.c
===================================================================
RCS file: /home/cvspublic/apr/file_io/unix/dir.c,v
retrieving revision 1.75
diff -u -r1.75 dir.c
--- file_io/unix/dir.c  7 Jan 2003 00:52:52 -0000       1.75
+++ file_io/unix/dir.c  23 Jan 2003 05:33:09 -0000
@@ -61,6 +61,7 @@
 #if APR_HAVE_LIMITS_H
 #include <limits.h>
 #endif
+#include <unistd.h>
 
 static apr_status_t dir_cleanup(void *thedir)
 {
@@ -176,7 +177,7 @@
     apr_filetype_e type;
 #endif
 #if APR_HAS_THREADS && defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
-                    && !defined(READDIR_IS_THREAD_SAFE)
+    && (_POSIX_THREAD_SAFE_FUNCTIONS > 0) && !defined(READDIR_IS_THREAD_SAFE)
     struct dirent *retent;
 
     ret = readdir_r(thedir->dirstruct, thedir->entry, &retent);
Index: include/apr.hnw
===================================================================
RCS file: /home/cvspublic/apr/include/apr.hnw,v
retrieving revision 1.27
diff -u -r1.27 apr.hnw
--- include/apr.hnw     14 Jan 2003 00:51:36 -0000      1.27
+++ include/apr.hnw     23 Jan 2003 05:33:10 -0000
@@ -89,7 +89,6 @@
 
 #include <novsock2.h>
 
-#define _POSIX_THREAD_SAFE_FUNCTIONS    1
 #define READDIR_IS_THREAD_SAFE          1
 
 #define APR_INLINE 

Reply via email to