VirtualBox

Changeset 8288 in vbox


Ignore:
Timestamp:
Apr 22, 2008 1:25:55 PM (17 years ago)
Author:
vboxsync
Message:

Added RTErrConvertFromDarwin() as a merge of the IO, Kern and COM versions.

Location:
trunk
Files:
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/err.h

    r8245 r8288  
    9292 *
    9393 * @returns iprt status code.
    94  * @param   iNativeCode    errno code.
     94 * @param   iNativeCode    HRESULT error code.
     95 * @remark  Darwin ring-3 only.
     96 */
     97RTDECL(int)  RTErrConvertFromDarwinCOM(int32_t iNativeCode);
     98
     99/**
     100 * Converts a Darwin IOReturn error to an iprt status code.
     101 *
     102 * @returns iprt status code.
     103 * @param   iNativeCode    IOReturn error code.
    95104 * @remark  Darwin only.
    96105 */
    97 RTDECL(int)  RTErrConvertFromDarwinCOM(int32_t iNativeCode);
    98 
    99 /**
    100  * Converts a Darwin IOReturn error to an iprt status code.
     106RTDECL(int)  RTErrConvertFromDarwinIO(int iNativeCode);
     107
     108/**
     109 * Converts a Darwin kern_return_t error to an iprt status code.
    101110 *
    102111 * @returns iprt status code.
    103  * @param   iNativeCode    errno code.
     112 * @param   iNativeCode    kern_return_t error code.
    104113 * @remark  Darwin only.
    105114 */
    106 RTDECL(int)  RTErrConvertFromDarwinIO(int iNativeCode);
    107 
    108 /**
    109  * Converts a Darwin kern_return_t error to an iprt status code.
     115RTDECL(int)  RTErrConvertFromDarwinKern(int iNativeCode);
     116
     117/**
     118 * Converts a Darwin error to an iprt status code.
     119 *
     120 * This will consult RTErrConvertFromDarwinKern, RTErrConvertFromDarwinIO
     121 * and RTErrConvertFromDarwinCOM in this order. The latter is ring-3 only as it
     122 * doesn't apply elsewhere.
    110123 *
    111124 * @returns iprt status code.
    112  * @param   iNativeCode    errno code.
    113  * @remark  Darwin only.
    114  */
    115 RTDECL(int)  RTErrConvertFromDarwinKern(int iNativeCode);
     125 * @param   iNativeCode    Darwin error code.
     126 * @remarks Darwin only.
     127 * @remarks This is recommended over RTErrConvertFromDarwinKern and RTErrConvertFromDarwinIO
     128 *          since these are really just subsets of the same error space.
     129 */
     130RTDECL(int)  RTErrConvertFromDarwin(int iNativeCode);
    116131
    117132/**
  • trunk/src/VBox/Runtime/Makefile.kmk

    r8284 r8288  
    372372
    373373RuntimeR3_SOURCES.darwin = \
     374        darwin/RTErrConvertFromDarwin.cpp \
    374375        darwin/RTErrConvertFromDarwinCOM.cpp \
    375376        darwin/RTErrConvertFromDarwinIO.cpp \
     
    945946        common/string/memchr.asm \
    946947        common/string/strpbrk.cpp \
     948        darwin/RTErrConvertFromDarwin.cpp \
    947949        darwin/RTErrConvertFromDarwinIO.cpp \
    948950        darwin/RTErrConvertFromDarwinKern.cpp \
  • trunk/src/VBox/Runtime/darwin/RTErrConvertFromDarwin.cpp

    r8269 r8288  
    1 /* $Id $ */
     1/* $Id:$ */
    22/** @file
    33 * IPRT - Convert Darwin Mach returns codes to iprt status codes.
     
    3333*******************************************************************************/
    3434#include <mach/kern_return.h>
     35#include <IOKit/IOReturn.h>
    3536
    3637#include <iprt/err.h>
     
    3839
    3940
    40 RTDECL(int) RTErrConvertFromDarwinKern(int iNativeCode)
     41RTDECL(int) RTErrConvertFromDarwin(int iNativeCode)
    4142{
    4243    /*
     
    4849    switch (iNativeCode)
    4950    {
     51        /*
     52         * Mach.
     53         */
    5054        case KERN_INVALID_ADDRESS:      return VERR_INVALID_POINTER;
    5155        //case KERN_PROTECTION_FAILURE:
     
    97101        //case KERN_NOT_WAITING:
    98102        case KERN_OPERATION_TIMED_OUT:  return VERR_TIMEOUT;
     103
     104
     105        /*
     106         * I/O Kit.
     107         */
     108        case kIOReturnNoDevice:         return VERR_IO_BAD_UNIT;
     109        case kIOReturnUnsupported:      return VERR_NOT_SUPPORTED;
     110
     111#ifdef IN_RING3
     112        /*
     113         * CoreFoundation COM (may overlap with I/O Kit and Mach).
     114         */
     115        default:
     116            if (    iNativeCode >= 0x80000000
     117                &&  iNativeCode >= 0x8000FFFFL)
     118                return RTErrConvertFromDarwinCOM(iNativeCode);
     119            break;
     120#endif /* IN_RING3 */
    99121    }
    100122
     
    104126}
    105127
    106 
  • trunk/src/VBox/Runtime/darwin/RTErrConvertFromDarwinCOM.cpp

    r8245 r8288  
    1 /* $Id $ */
     1/* $Id:$ */
    22/** @file
    33 * IPRT - Convert Darwin COM returns codes to iprt status codes.
     
    3737#include <iprt/assert.h>
    3838
     39
    3940RTDECL(int) RTErrConvertFromDarwinCOM(int32_t iNativeCode)
    4041{
  • trunk/src/VBox/Runtime/darwin/RTErrConvertFromDarwinIO.cpp

    r8245 r8288  
    1 /* $Id $ */
     1/* $Id:$ */
    22/** @file
    33 * IPRT - Convert Darwin IOKit returns codes to iprt status codes.
     
    4545    if (iNativeCode == kIOReturnSuccess)
    4646        return VINF_SUCCESS;
    47 
    48     switch (iNativeCode)
    49     {
    50         case kIOReturnNoDevice:     return VERR_IO_BAD_UNIT;
    51         case kIOReturnUnsupported:  return VERR_NOT_SUPPORTED;
    52     }
    53 
    54     /* unknown error. */
    55     AssertMsgFailed(("Unhandled error %#x\n", iNativeCode));
    56     return VERR_UNRESOLVED_ERROR;
     47    return RTErrConvertFromDarwin(iNativeCode);
    5748}
    5849
  • trunk/src/VBox/Runtime/darwin/RTErrConvertFromDarwinKern.cpp

    r8245 r8288  
    1 /* $Id $ */
     1/* $Id:$ */
    22/** @file
    33 * IPRT - Convert Darwin Mach returns codes to iprt status codes.
     
    4545    if (iNativeCode == KERN_SUCCESS)
    4646        return VINF_SUCCESS;
    47 
    48     switch (iNativeCode)
    49     {
    50         case KERN_INVALID_ADDRESS:      return VERR_INVALID_POINTER;
    51         //case KERN_PROTECTION_FAILURE:
    52         //case KERN_NO_SPACE:
    53         case KERN_INVALID_ARGUMENT:     return VERR_INVALID_PARAMETER;
    54         //case KERN_FAILURE:
    55         //case KERN_RESOURCE_SHORTAGE:
    56         //case KERN_NOT_RECEIVER:
    57         case KERN_NO_ACCESS:            return VERR_ACCESS_DENIED;
    58         //case KERN_MEMORY_FAILURE:
    59         //case KERN_MEMORY_ERROR:
    60         //case KERN_ALREADY_IN_SET:
    61         //case KERN_NOT_IN_SET:
    62         //case KERN_NAME_EXISTS:
    63         //case KERN_ABORTED:
    64         //case KERN_INVALID_NAME:
    65         //case KERN_INVALID_TASK:
    66         //case KERN_INVALID_RIGHT:
    67         //case KERN_INVALID_VALUE:
    68         //case KERN_UREFS_OVERFLOW:
    69         //case KERN_INVALID_CAPABILITY:
    70         //case KERN_RIGHT_EXISTS:
    71         //case KERN_INVALID_HOST:
    72         //case KERN_MEMORY_PRESENT:
    73         //case KERN_MEMORY_DATA_MOVED:
    74         //case KERN_MEMORY_RESTART_COPY:
    75         //case KERN_INVALID_PROCESSOR_SET:
    76         //case KERN_POLICY_LIMIT:
    77         //case KERN_INVALID_POLICY:
    78         //case KERN_INVALID_OBJECT:
    79         //case KERN_ALREADY_WAITING:
    80         //case KERN_DEFAULT_SET:
    81         //case KERN_EXCEPTION_PROTECTED:
    82         //case KERN_INVALID_LEDGER:
    83         //case KERN_INVALID_MEMORY_CONTROL:
    84         //case KERN_INVALID_SECURITY:
    85         //case KERN_NOT_DEPRESSED:
    86         //case KERN_TERMINATED:
    87         //case KERN_LOCK_SET_DESTROYED:
    88         //case KERN_LOCK_UNSTABLE:
    89         case KERN_LOCK_OWNED:           return VERR_SEM_BUSY;
    90         //case KERN_LOCK_OWNED_SELF:
    91         case KERN_SEMAPHORE_DESTROYED:  return VERR_SEM_DESTROYED;
    92         //case KERN_RPC_SERVER_TERMINATED:
    93         //case KERN_RPC_TERMINATE_ORPHAN:
    94         //case KERN_RPC_CONTINUE_ORPHAN:
    95         case KERN_NOT_SUPPORTED:        return VERR_NOT_SUPPORTED;
    96         //case KERN_NODE_DOWN:
    97         //case KERN_NOT_WAITING:
    98         case KERN_OPERATION_TIMED_OUT:  return VERR_TIMEOUT;
    99     }
    100 
    101     /* unknown error. */
    102     AssertMsgFailed(("Unhandled error %#x\n", iNativeCode));
    103     return VERR_UNRESOLVED_ERROR;
     47    return RTErrConvertFromDarwin(iNativeCode);
    10448}
    10549
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette