VirtualBox

Changeset 11018 in vbox for trunk/include/iprt


Ignore:
Timestamp:
Jul 30, 2008 10:40:35 PM (16 years ago)
Author:
vboxsync
Message:

iprt: Added a RT_NO_THROW macro for wrapping up the throw() stuff, applying it to mem.h and rand.h to try make RTMemAutoPtr work as efficiently as the pure C version of the stuff.

Location:
trunk/include/iprt
Files:
3 edited

Legend:

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

    r10998 r11018  
    437437#else
    438438# define RTCALL
     439#endif
     440
     441/** @def RT_NO_THROW
     442 * How to express that a function doesn't throw C++ exceptions
     443 * and the compiler can thus save itself the bother of trying
     444 * to catch any of them. Put this between the closing parenthesis
     445 * and the semicolon in function prototypes.
     446 */
     447#ifdef __cplusplus
     448# define RT_NO_THROW    throw()
     449#else
     450# define RT_NO_THROW
    439451#endif
    440452
  • trunk/include/iprt/mem.h

    r11017 r11018  
    7070 * @param   cb      Size in bytes of the memory block to allocated.
    7171 */
    72 RTDECL(void *)  RTMemTmpAlloc(size_t cb);
     72RTDECL(void *)  RTMemTmpAlloc(size_t cb) RT_NO_THROW;
    7373
    7474/**
     
    8181 * @param   cb      Size in bytes of the memory block to allocated.
    8282 */
    83 RTDECL(void *)  RTMemTmpAllocZ(size_t cb);
     83RTDECL(void *)  RTMemTmpAllocZ(size_t cb) RT_NO_THROW;
    8484
    8585/**
     
    8888 * @param   pv      Pointer to memory block.
    8989 */
    90 RTDECL(void)    RTMemTmpFree(void *pv);
     90RTDECL(void)    RTMemTmpFree(void *pv) RT_NO_THROW;
    9191
    9292
     
    9898 * @param   cb      Size in bytes of the memory block to allocated.
    9999 */
    100 RTDECL(void *)  RTMemAlloc(size_t cb);
     100RTDECL(void *)  RTMemAlloc(size_t cb) RT_NO_THROW;
    101101
    102102/**
     
    111111 * @param   cb      Size in bytes of the memory block to allocated.
    112112 */
    113 RTDECL(void *)  RTMemAllocZ(size_t cb);
     113RTDECL(void *)  RTMemAllocZ(size_t cb) RT_NO_THROW;
    114114
    115115/**
     
    121121 * @param   cb      The amount of memory to duplicate.
    122122 */
    123 RTDECL(void *) RTMemDup(const void *pvSrc, size_t cb);
     123RTDECL(void *) RTMemDup(const void *pvSrc, size_t cb) RT_NO_THROW;
    124124
    125125/**
     
    133133 * @param   cbExtra The amount of extra memory to allocate and zero.
    134134 */
    135 RTDECL(void *) RTMemDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra);
     135RTDECL(void *) RTMemDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW;
    136136
    137137/**
     
    143143 * @param   cbNew   The new block size (in bytes).
    144144 */
    145 RTDECL(void *)  RTMemRealloc(void *pvOld, size_t cbNew);
     145RTDECL(void *)  RTMemRealloc(void *pvOld, size_t cbNew) RT_NO_THROW;
    146146
    147147/**
     
    150150 * @param   pv      Pointer to memory block.
    151151 */
    152 RTDECL(void)    RTMemFree(void *pv);
     152RTDECL(void)    RTMemFree(void *pv) RT_NO_THROW;
    153153
    154154/**
     
    159159 * @param   cb      Size in bytes of the memory block to allocate.
    160160 */
    161 RTDECL(void *)    RTMemExecAlloc(size_t cb);
     161RTDECL(void *)    RTMemExecAlloc(size_t cb) RT_NO_THROW;
    162162
    163163/**
     
    166166 * @param   pv      Pointer to memory block.
    167167 */
    168 RTDECL(void)      RTMemExecFree(void *pv);
     168RTDECL(void)      RTMemExecFree(void *pv) RT_NO_THROW;
    169169
    170170#if defined(IN_RING0) && defined(RT_ARCH_AMD64) && defined(RT_OS_LINUX)
     
    184184 * @param   cb          The size of the memory block.
    185185 */
    186 RTR0DECL(int) RTR0MemExecDonate(void *pvMemory, size_t cb);
     186RTR0DECL(int) RTR0MemExecDonate(void *pvMemory, size_t cb) RT_NO_THROW;
    187187#endif /* R0+AMD64+LINUX */
    188188
     
    194194 * @param   cb  Size of the memory block. Will be rounded up to page size.
    195195 */
    196 RTDECL(void *) RTMemPageAlloc(size_t cb);
     196RTDECL(void *) RTMemPageAlloc(size_t cb) RT_NO_THROW;
    197197
    198198/**
     
    203203 * @param   cb  Size of the memory block. Will be rounded up to page size.
    204204 */
    205 RTDECL(void *) RTMemPageAllocZ(size_t cb);
     205RTDECL(void *) RTMemPageAllocZ(size_t cb) RT_NO_THROW;
    206206
    207207/**
     
    211211 *                  NULL will be ignored.
    212212 */
    213 RTDECL(void) RTMemPageFree(void *pv);
     213RTDECL(void) RTMemPageFree(void *pv) RT_NO_THROW;
    214214
    215215/** Page level protection flags for RTMemProtect().
     
    234234 * @param   fProtect    The new protection, a combination of the RTMEM_PROT_* defines.
    235235 */
    236 RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect);
     236RTDECL(int) RTMemProtect(void *pv, size_t cb, unsigned fProtect) RT_NO_THROW;
    237237
    238238
     
    248248 *                  rounded up to PAGE_SIZE.
    249249 */
    250 RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb);
     250RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb) RT_NO_THROW;
    251251
    252252/**
     
    256256 * @param   cb      The cb parameter passed to RTMemContAlloc().
    257257 */
    258 RTR0DECL(void) RTMemContFree(void *pv, size_t cb);
     258RTR0DECL(void) RTMemContFree(void *pv, size_t cb) RT_NO_THROW;
    259259
    260260#endif
     
    272272 * @param   cb      Size in bytes of the memory block to allocate.
    273273 */
    274 RTDECL(void *)  RTMemEfTmpAlloc(size_t cb);
     274RTDECL(void *)  RTMemEfTmpAlloc(size_t cb) RT_NO_THROW;
    275275
    276276/**
     
    281281 * @param   cb      Size in bytes of the memory block to allocate.
    282282 */
    283 RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb);
     283RTDECL(void *)  RTMemEfTmpAllocZ(size_t cb) RT_NO_THROW;
    284284
    285285/**
     
    288288 * @param   pv      Pointer to memory block.
    289289 */
    290 RTDECL(void)    RTMemEfTmpFree(void *pv);
     290RTDECL(void)    RTMemEfTmpFree(void *pv) RT_NO_THROW;
    291291
    292292/**
     
    297297 * @param   cb      Size in bytes of the memory block to allocate.
    298298 */
    299 RTDECL(void *)  RTMemEfAlloc(size_t cb);
     299RTDECL(void *)  RTMemEfAlloc(size_t cb) RT_NO_THROW;
    300300
    301301/**
     
    306306 * @param   cb      Size in bytes of the memory block to allocate.
    307307 */
    308 RTDECL(void *)  RTMemEfAllocZ(size_t cb);
     308RTDECL(void *)  RTMemEfAllocZ(size_t cb) RT_NO_THROW;
    309309
    310310/**
     
    316316 * @param   cbNew   The new block size (in bytes).
    317317 */
    318 RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew);
     318RTDECL(void *)  RTMemEfRealloc(void *pvOld, size_t cbNew) RT_NO_THROW;
    319319
    320320/**
     
    323323 * @param   pv      Pointer to memory block.
    324324 */
    325 RTDECL(void)    RTMemEfFree(void *pv);
     325RTDECL(void)    RTMemEfFree(void *pv) RT_NO_THROW;
    326326
    327327/**
     
    333333 * @param   cb      The amount of memory to duplicate.
    334334 */
    335 RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb);
     335RTDECL(void *) RTMemEfDup(const void *pvSrc, size_t cb) RT_NO_THROW;
    336336
    337337/**
     
    344344 * @param   cbExtra The amount of extra memory to allocate and zero.
    345345 */
    346 RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra);
     346RTDECL(void *) RTMemEfDupEx(const void *pvSrc, size_t cbSrc, size_t cbExtra) RT_NO_THROW;
    347347
    348348/** @def RTMEM_WRAP_TO_EF_APIS
     
    382382 */
    383383template <class T>
    384 inline void RTMemAutoDestructor(T *aMem)
     384inline void RTMemAutoDestructor(T *aMem) RT_NO_THROW
    385385{
    386386    RTMemFree(aMem);
     
    395395 * @param   cbNew       The amount of memory to allocate (in bytes).
    396396 */
    397 inline void *RTMemTmpAutoAllocator(void *pvOld, size_t cbNew)
     397inline void *RTMemTmpAutoAllocator(void *pvOld, size_t cbNew) RT_NO_THROW
    398398{
    399399    AssertReturn(!pvOld, NULL);
     
    413413 */
    414414template <class T>
    415 inline void RTMemTmpAutoDestructor(T *aMem)
     415inline void RTMemTmpAutoDestructor(T *aMem) RT_NO_THROW
    416416{
    417417    RTMemTmpFree(aMem);
     
    431431 */
    432432template <class T>
    433 inline void RTMemEfAutoFree(T *aMem)
     433inline void RTMemEfAutoFree(T *aMem) RT_NO_THROW
    434434{
    435435    RTMemEfFree(aMem);
     
    445445 */
    446446template <class T>
    447 inline T * RTMemAutoNil(void)
     447inline T * RTMemAutoNil(void) RT_NO_THROW
    448448{
    449449    return (T *)(NULL);
  • trunk/include/iprt/rand.h

    r8245 r11018  
    4747 * @param   cb  Number of bytes to generate.
    4848 */
    49 RTDECL(void) RTRandBytes(void *pv, size_t cb);
     49RTDECL(void) RTRandBytes(void *pv, size_t cb) RT_NO_THROW;
    5050
    5151/**
     
    5656 * @param   i32Last     Last number in the set.
    5757 */
    58 RTDECL(int32_t) RTRandS32Ex(int32_t i32First, int32_t i32Last);
     58RTDECL(int32_t) RTRandS32Ex(int32_t i32First, int32_t i32Last) RT_NO_THROW;
    5959
    6060/**
     
    6363 * @returns The random number.
    6464 */
    65 RTDECL(int32_t) RTRandS32(void);
     65RTDECL(int32_t) RTRandS32(void) RT_NO_THROW;
    6666
    6767/**
     
    7272 * @param   u32Last     Last number in the set.
    7373 */
    74 RTDECL(uint32_t) RTRandU32Ex(uint32_t u32First, uint32_t u32Last);
     74RTDECL(uint32_t) RTRandU32Ex(uint32_t u32First, uint32_t u32Last) RT_NO_THROW;
    7575
    7676/**
     
    7979 * @returns The random number.
    8080 */
    81 RTDECL(uint32_t) RTRandU32(void);
     81RTDECL(uint32_t) RTRandU32(void) RT_NO_THROW;
    8282
    8383/**
     
    8888 * @param   i64Last     Last number in the set.
    8989 */
    90 RTDECL(int64_t) RTRandS64Ex(int64_t i64First, int64_t i64Last);
     90RTDECL(int64_t) RTRandS64Ex(int64_t i64First, int64_t i64Last) RT_NO_THROW;
    9191
    9292/**
     
    9595 * @returns The random number.
    9696 */
    97 RTDECL(int64_t) RTRandS64(void);
     97RTDECL(int64_t) RTRandS64(void) RT_NO_THROW;
    9898
    9999/**
     
    104104 * @param   u64Last     Last number in the set.
    105105 */
    106 RTDECL(uint64_t) RTRandU64Ex(uint64_t u64First, uint64_t u64Last);
     106RTDECL(uint64_t) RTRandU64Ex(uint64_t u64First, uint64_t u64Last) RT_NO_THROW;
    107107
    108108/**
     
    111111 * @returns The random number.
    112112 */
    113 RTDECL(uint64_t) RTRandU64(void);
     113RTDECL(uint64_t) RTRandU64(void) RT_NO_THROW;
    114114
    115115/** @} */
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