err.h revision f2427352ab8e77b3986a516b00dc9d658bdd280d
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * IPRT - Status Codes.
f7b81dcd1a01325f5ca2806c2694b8f1d3b9eb4cvboxsync * Copyright (C) 2006-2009 Oracle Corporation
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * available from http://www.virtualbox.org. This file is free software;
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * you can redistribute it and/or modify it under the terms of the GNU
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * General Public License (GPL) as published by the Free Software
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * The contents of this file may alternatively be used under the terms
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * of the Common Development and Distribution License Version 1.0
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * VirtualBox OSE distribution, in which case the provisions of the
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * CDDL are applicable instead of those of the GPL.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * You may elect to license modified versions of this file under the
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * terms and conditions of either the GPL or the CDDL or both.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync/** @defgroup grp_rt_err RTErr - Status Codes
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * @ingroup grp_rt
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync/** @defgroup grp_rt_err_hlp Status Code Helpers
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * @ingroup grp_rt_err
2599750883f13b2a38c421dc073df83e2f9cdae6vboxsync * Strict type validation class.
2599750883f13b2a38c421dc073df83e2f9cdae6vboxsync * This is only really useful for type checking the arguments to RT_SUCCESS,
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * RT_SUCCESS_NP, RT_FAILURE and RT_FAILURE_NP. The RTErrStrictType2
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * constructor is for integration with external status code strictness regimes.
2599750883f13b2a38c421dc073df83e2f9cdae6vboxsync * Constructor for interaction with external status code strictness regimes.
2599750883f13b2a38c421dc073df83e2f9cdae6vboxsync * This is a special constructor for helping external return code validator
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * classes interact cleanly with RT_SUCCESS, RT_SUCCESS_NP, RT_FAILURE and
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * RT_FAILURE_NP while barring automatic cast to integer.
b4b896baff58dad1f81179386beed73197bf59bevboxsync * @param rcObj IPRT status code object from an automatic cast.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * Integer constructor used by RT_SUCCESS_NP.
2599750883f13b2a38c421dc073df83e2f9cdae6vboxsync * @param rc IPRT style status code.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync#if 0 /** @todo figure where int32_t is long instead of int. */
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * Integer constructor used by RT_SUCCESS_NP.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * @param rc IPRT style status code.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync * Test for success.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync bool success() const
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync return m_rc >= 0;
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync /** @name Try ban a number of wrong types.
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync RTErrStrictType(uint8_t rc) : m_rc(-999) { NOREF(rc); }
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync RTErrStrictType(uint16_t rc) : m_rc(-999) { NOREF(rc); }
b4b896baff58dad1f81179386beed73197bf59bevboxsync RTErrStrictType(uint32_t rc) : m_rc(-999) { NOREF(rc); }
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync RTErrStrictType(uint64_t rc) : m_rc(-999) { NOREF(rc); }
b4b896baff58dad1f81179386beed73197bf59bevboxsync RTErrStrictType(int8_t rc) : m_rc(-999) { NOREF(rc); }
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync RTErrStrictType(int16_t rc) : m_rc(-999) { NOREF(rc); }
f74e35c55b43bdbc2d2ac21d61ac77ab764deadcvboxsync RTErrStrictType(int64_t rc) : m_rc(-999) { NOREF(rc); }
531c00db9f8998c8b606845f72098698c48e6290vboxsync /** @todo fight long here - clashes with int32_t/int64_t on some platforms. */
531c00db9f8998c8b606845f72098698c48e6290vboxsync#endif /* __cplusplus */
531c00db9f8998c8b606845f72098698c48e6290vboxsync/** @def RTERR_STRICT_RC
531c00db9f8998c8b606845f72098698c48e6290vboxsync * Indicates that RT_SUCCESS_NP, RT_SUCCESS, RT_FAILURE_NP and RT_FAILURE should
531c00db9f8998c8b606845f72098698c48e6290vboxsync * make type enforcing at compile time.
9b509d9e7070174b3bd5c80ce9ea52d42dd3de98vboxsync * @remarks Only define this for C++ code.
531c00db9f8998c8b606845f72098698c48e6290vboxsync#if defined(__cplusplus) \
531c00db9f8998c8b606845f72098698c48e6290vboxsync && !defined(RTERR_STRICT_RC) \
a0c1e203edd9781c6d0f7560e37dbc729fef5991vboxsync && ( defined(DOXYGEN_RUNNING) \
531c00db9f8998c8b606845f72098698c48e6290vboxsync || defined(DEBUG) \
531c00db9f8998c8b606845f72098698c48e6290vboxsync || defined(RT_STRICT) )
b4b896baff58dad1f81179386beed73197bf59bevboxsync/** @def RT_SUCCESS
b4b896baff58dad1f81179386beed73197bf59bevboxsync * Check for success. We expect success in normal cases, that is the code path depending on
b4b896baff58dad1f81179386beed73197bf59bevboxsync * this check is normally taken. To prevent any prediction use RT_SUCCESS_NP instead.
531c00db9f8998c8b606845f72098698c48e6290vboxsync * @returns true if rc indicates success.
bf94a12e434bda567d373eb5076cbf96aad6e987vboxsync * @returns false if rc indicates failure.
9b509d9e7070174b3bd5c80ce9ea52d42dd3de98vboxsync * @param rc The iprt status code to test.
2599750883f13b2a38c421dc073df83e2f9cdae6vboxsync#define RT_SUCCESS(rc) ( RT_LIKELY(RT_SUCCESS_NP(rc)) )
531c00db9f8998c8b606845f72098698c48e6290vboxsync/** @def RT_SUCCESS_NP
531c00db9f8998c8b606845f72098698c48e6290vboxsync * Check for success. Don't predict the result.
531c00db9f8998c8b606845f72098698c48e6290vboxsync * @returns true if rc indicates success.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @returns false if rc indicates failure.
531c00db9f8998c8b606845f72098698c48e6290vboxsync * @param rc The iprt status code to test.
531c00db9f8998c8b606845f72098698c48e6290vboxsync# define RT_SUCCESS_NP(rc) ( RTErrStrictType(rc).success() )
531c00db9f8998c8b606845f72098698c48e6290vboxsync# define RT_SUCCESS_NP(rc) ( (int)(rc) >= VINF_SUCCESS )
531c00db9f8998c8b606845f72098698c48e6290vboxsync/** @def RT_FAILURE
531c00db9f8998c8b606845f72098698c48e6290vboxsync * Check for failure. We don't expect in normal cases, that is the code path depending on
531c00db9f8998c8b606845f72098698c48e6290vboxsync * this check is normally NOT taken. To prevent any prediction use RT_FAILURE_NP instead.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @returns true if rc indicates failure.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @returns false if rc indicates success.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @param rc The iprt status code to test.
978580e1feeb8eb42df0b6366b9c8bebbb9fb02cvboxsync#define RT_FAILURE(rc) ( RT_UNLIKELY(!RT_SUCCESS_NP(rc)) )
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync/** @def RT_FAILURE_NP
978580e1feeb8eb42df0b6366b9c8bebbb9fb02cvboxsync * Check for failure. Don't predict the result.
978580e1feeb8eb42df0b6366b9c8bebbb9fb02cvboxsync * @returns true if rc indicates failure.
978580e1feeb8eb42df0b6366b9c8bebbb9fb02cvboxsync * @returns false if rc indicates success.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @param rc The iprt status code to test.
b4b896baff58dad1f81179386beed73197bf59bevboxsync * Converts a Darwin HRESULT error to an iprt status code.
b4b896baff58dad1f81179386beed73197bf59bevboxsync * @returns iprt status code.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @param iNativeCode HRESULT error code.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @remark Darwin ring-3 only.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsyncRTDECL(int) RTErrConvertFromDarwinCOM(int32_t iNativeCode);
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * Converts a Darwin IOReturn error to an iprt status code.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @returns iprt status code.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @param iNativeCode IOReturn error code.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @remark Darwin only.
ebb998c68d059fb28283dd5631df33cbca044519vboxsyncRTDECL(int) RTErrConvertFromDarwinIO(int iNativeCode);
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * Converts a Darwin kern_return_t error to an iprt status code.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @returns iprt status code.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @param iNativeCode kern_return_t error code.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @remark Darwin only.
18456bfb9f30d08e5347aa108a2fef0c49c0ab0bvboxsyncRTDECL(int) RTErrConvertFromDarwinKern(int iNativeCode);
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * Converts a Darwin error to an iprt status code.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * This will consult RTErrConvertFromDarwinKern, RTErrConvertFromDarwinIO
b4b896baff58dad1f81179386beed73197bf59bevboxsync * and RTErrConvertFromDarwinCOM in this order. The latter is ring-3 only as it
b4b896baff58dad1f81179386beed73197bf59bevboxsync * doesn't apply elsewhere.
b4b896baff58dad1f81179386beed73197bf59bevboxsync * @returns iprt status code.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @param iNativeCode Darwin error code.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @remarks Darwin only.
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * @remarks This is recommended over RTErrConvertFromDarwinKern and RTErrConvertFromDarwinIO
c0704390ccf86cde88ad1e69dedf77d3e57aa15avboxsync * since these are really just subsets of the same error space.
978580e1feeb8eb42df0b6366b9c8bebbb9fb02cvboxsyncRTDECL(int) RTErrConvertFromDarwin(int iNativeCode);
978580e1feeb8eb42df0b6366b9c8bebbb9fb02cvboxsync * Converts errno to iprt status code.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @returns iprt status code.
ebb998c68d059fb28283dd5631df33cbca044519vboxsync * @param uNativeCode errno code.
#ifdef IN_RING3
typedef struct RTSTATUSMSG
const char *pszMsgShort;
const char *pszMsgFull;
const char *pszDefine;
int iCode;
} RTSTATUSMSG;
#ifdef RT_OS_WINDOWS
typedef struct RTWINERRMSG
const char *pszMsgFull;
const char *pszDefine;
long iCode;
} RTWINERRMSG;
typedef struct RTCOMERRMSG
const char *pszMsgFull;
const char *pszDefine;
} RTCOMERRMSG;
#define VINF_SUCCESS 0
/** Encountered unicode code point which is reserved for use as endian indicator (0xffff or 0xfffe). */
/** Source/destination not found */
/** The ELF image is 'dynamic', the ELF loader can only deal with 'relocatable' images at present. */
/** The ELF image is 'executable', the ELF loader can only deal with 'relocatable' images at present. */
* the interface user screwed up, or we've got corruption/broken logic. */