httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject Re: ap_status_t for Win32
Date Sat, 01 Apr 2000 17:28:14 GMT


This is the general approach which the error code started with.  The
general idea being that all errno errors should be valid across platforms.
This only works one of two ways:

1)  Everybody returns the errno value (bad idea)

2)  Everybody returns system error codes, and we have a function that
converts to errno values for a small subset.  This function should not be
called often.

I just re-read Brian's last post where he outlines the advantages of his
scheme.  I think the problem is Brian didn't understand what I thought I
said.  :-)

I am all for Brian's scheme, where an offset is defined for OSCODE's.  I
just think that most if not all of the primitives are there to support it.

We have four definitions in apr_errno.h.  Those are currently hard-coded
the same for all platforms.  These should be different for each platform.
Then, if we want to add a fifth definition for those platforms that need
it, we can.

I don't think we need bit masks, just integer values.  I still haven't see
an argument that bitmasks are important.

Ryan

On Sat, 1 Apr 2000, Jeff Trawick wrote:

> Here are some excerpts of a version of apr_errno.h which I was playing
> with last night.  I just quickly drafted in some OS2 logic.  More
> macros are needed for testing the type of error code and for
> extracting a certain type of error code, but those are pretty simple.
> 
> What changes are needed from this for OS/2?  Is there anything which this
> doesn't handle?
> 
> The definitions of the offsets need to be in an OS-specific header
> file.  This is pretty darn ugly.
> 
> /* Define four layers of status code offsets so that we don't interfere
>  * with the predefined errno codes on the operating system.  Codes beyond
>  * APR_OS_START_USEERR are reserved for applications that use APR that
>  * layer their own error codes along with APR's.
>  *
>  * For platforms where errnos and system error codes collide, use an offset
>  * for errnos as well.
>  */
> 
> #ifdef WIN32
> 
> /* In order to represent system error codes or APR error codes or other types
>  * of error codes in an int, use offsets like with other platforms but also 
>  * turn on bit 29 because all other values are reserved for the system.
>  */
> 
> #ifndef APR_OS_START_OSERR
> #define APR_OS_START_OSERR      0x00000000
> #endif
> #ifndef APR_OS_START_APRERROR
> #define APR_OS_START_APRERROR   0x20000000
> #endif
> #ifndef APR_OS_START_APRSTATUS  
> #define APR_OS_START_APRSTATUS  0x20000200
> #endif
> #ifndef APR_OS_START_SYSERR
> #define APR_OS_START_SYSERR     0x20000400
> #endif
> #ifndef APR_OS_START_ERRNO
> #define APR_OS_START_ERRNO      0x20000600
> #endif
> #ifndef APR_OS_START_USEERR
> #define APR_OS_START_USEERR     0x20000800
> #endif
>  
> #else
> 
> #ifdef OS2
> 
> #ifndef APR_OS_START_OSERR
> #define APR_OS_START_OSERR      some-magic-number
> #endif
> 
> #else
> 
> #ifndef APR_OS_START_OSERR
> #define APR_OS_START_OSERR      0 /* UNIX */
> #endif
> 
> #endif
> 
> #ifndef APR_OS_START_ERRNO
> #define APR_OS_START_ERRNO      0
> #endif
> #ifndef APR_OS_START_APRERROR
> #define APR_OS_START_APRERROR   4000
> #endif
> #ifndef APR_OS_START_APRSTATUS
> #define APR_OS_START_APRSTATUS  (APR_OS_START_APRERROR + 500)
> #endif
> #ifndef APR_OS_START_SYSERR
> #define APR_OS_START_SYSERR  (APR_OS_START_STATUS + 500)
> #endif
> #ifndef APR_OS_START_USEERR
> #define APR_OS_START_USEERR  (APR_OS_START_SYSERR + 10000)
> #endif
> #endif /* WIN32 */
> 
> #ifndef APR_STATUS_FROM_OSERR
> #define APR_STATUS_FROM_OSERR(err) ((err) + APR_OS_START_OSERR)
> #endif
> #ifndef APR_STATUS_FROM_APRERROR
> #define APR_STATUS_FROM_APRERROR(err) ((err) + APR_OS_START_APRERROR)
> #endif
> #ifndef APR_STATUS_FROM_APRSTATUS
> #define APR_STATUS_FROM_APRSTATUS(err) ((err) + APR_OS_START_STATUS)
> #endif
> #ifndef APR_STATUS_FROM_SYSERR
> #define APR_STATUS_FROM_SYSERR(err) ((err) + APR_OS_START_SYSERR)
> #endif
> #ifndef APR_STATUS_FROM_ERRNO
> #define APR_STATUS_FROM_ERRNO(err) ((err) + APR_OS_START_ERRNO)
> #endif
> 
> #define APR_SUCCESS 0
> 
> /* APR ERROR VALUES */
> #define APR_ENOSTAT        APR_STATUS_FROM_APRERROR(1)
> #define APR_ENOPOOL        APR_STATUS_FROM_APRERROR(2)
> #define APR_ENOFILE        APR_STATUS_FROM_APRERROR(3)
> 
> ...
> 
> /* APR STATUS VALUES */
> #define APR_INCHILD        APR_STATUS_FROM_APRSTATUS(1)
> #define APR_INPARENT       APR_STATUS_FROM_APRSTATUS(2)
> #define APR_DETACH         APR_STATUS_FROM_APRSTATUS(3)
> #define APR_NOTDETACH      APR_STATUS_FROM_APRSTATUS(4)
> 
> ...
> 
> /*
>  * APR equivalents to what should be standard errno codes.
>  */
> #ifdef EACCES
> #define APR_EACCES APR_STATUS_FROM_ERRNO(EACCES)
> #else
> #define APR_EACCES APR_STATUS_FROM_SYSERR(0)
> #endif
> 
> #ifdef EEXIST
> #define APR_EEXIST APR_STATUS_FROM_ERRNO(EEXIST)
> #else
> #define APR_EEXIST APR_STATUS_FROM_SYSERR(1)
> #endif
> 
> ...
> 
> /* never use h_errno values as-is because they can't be distinguished
>  * from errno values
>  * APR_EHOSTNOTFOUND corresponds to HOST_NOT_FOUND
>  * APR_ENODATA corresponds to NO_DATA
>  * APR_ENOADDRESS corresponds to NO_ADDRESS
>  * APR_ENORECOVERY corresponds to NO_RECOVERY
>  */
> #define APR_EHOSTNOTFOUND APR_STATUS_FROM_SYSERR(36)
> 
> #define APR_ENODATA APR_STATUS_FROM_SYSERR(37)
> 
> #define APR_ENOADDRESS APR_STATUS_FROM_SYSERR(38)
> 
> #define APR_ENORECOVERY APR_STATUS_FROM_SYSERR(39)
> 
> #ifdef EISCONN
> #define APR_EISCONN APR_STATUS_FROM_ERRNO(EISCONN)
> #else
> #define APR_EISCONN APR_STATUS_FROM_SYSERR(40)
> #endif
> 
> 
> 
> -- 
> Jeff Trawick | trawick@ibm.net | PGP public key at web site:
>      http://www.geocities.com/SiliconValley/Park/9289/
>           Born in Roswell... married an alien...
> 


_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------



Mime
View raw message