VirtualBox

Changeset 197 in vbox for trunk


Ignore:
Timestamp:
Jan 20, 2007 1:22:45 AM (18 years ago)
Author:
vboxsync
Message:

A stab at generic timers (untested).

Location:
trunk
Files:
2 added
1 deleted
8 edited

Legend:

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

    r1 r197  
    110110 *
    111111 * @returns iprt status code.
    112  * @param   pTimer      Timer to stop and destroy.
     112 * @param   pTimer      Timer to stop and destroy. NULL is ok.
    113113 */
    114114RTDECL(int) RTTimerDestroy(PRTTIMER pTimer);
     
    118118 *
    119119 * @returns IPRT status code.
    120  * @retval  VERR_INVALID_POINTER if pTimer isn't valid.
     120 * @retval  VERR_INVALID_HANDLE if pTimer isn't valid.
    121121 * @retval  VERR_TIMER_ACTIVE if the timer isn't suspended.
    122122 *
     
    132132 *
    133133 * @returns IPRT status code.
    134  * @retval  VERR_INVALID_POINTER if pTimer isn't valid.
     134 * @retval  VERR_INVALID_HANDLE if pTimer isn't valid.
    135135 * @retval  VERR_TIMER_SUSPENDED if the timer isn't active.
    136136 * @retval  VERR_NOT_SUPPORTED if the IPRT implementation doesn't support stopping a timer.
  • trunk/src/VBox/Runtime/Makefile

    r194 r197  
    572572        r0drv/darwin/thread-r0drv-darwin.cpp \
    573573        r0drv/darwin/time-r0drv-darwin.cpp \
     574        generic/timer-generic.cpp \
    574575
    575576RuntimeR0Drv_SOURCES.os2 = \
  • trunk/src/VBox/Runtime/include/internal/thread.h

    r1 r197  
    2525#include <iprt/types.h>
    2626#include <iprt/thread.h>
    27 #include <iprt/process.h>
    28 #include <iprt/critsect.h>
    29 #include <iprt/avl.h>
    30 
     27#ifdef IN_RING3
     28# include <iprt/process.h>
     29# include <iprt/critsect.h>
     30# include <iprt/avl.h>
     31#endif
    3132
    3233__BEGIN_DECLS
     34
    3335
    3436#ifdef IN_RING3
     
    212214void rtThreadUnblocked(PRTTHREADINT pThread, RTTHREADSTATE enmCurState);
    213215
    214 #endif /* IN_RING3 */
     216
     217#elif defined(IN_RING0)
     218
     219/**
     220 * Argument package for a ring-0 thread.
     221 */
     222typedef struct RTR0THREADARGS
     223{
     224    /** The thread function. */
     225    PFNRTTHREAD     pfnThread;
     226    /** The thread function argument. */
     227    void           *pvUser;
     228    /** The thread type. */
     229    RTTHREADTYPE    enmType;
     230} RTR0THREADARGS, *PRTR0THREADARGS;
     231
     232
     233
     234int rtThreadMain(PRTR0THREADARGS pArgs, RTNATIVETHREAD NativeThread);
     235
     236/**
     237 * Do the actual thread creation.
     238 *
     239 * @returns IPRT status code.
     240 *          On failure, no thread has been created.
     241 * @param   pArgs           The argument package.
     242 * @param   pNativeThread   Where to return the native thread handle.
     243 */
     244int rtThreadNativeCreate(PRTR0THREADARGS pArgs, PRTNATIVETHREAD pNativeThread);
     245
     246/**
     247 * Do the actual thread priority change.
     248 *
     249 * @returns IPRT status code.
     250 * @param   Thread      The thread which priority should be changed.
     251 *                      This is currently restricted to the current thread.
     252 * @param   enmType     The new thread priority type (valid).
     253 */
     254int rtThreadNativeSetPriority(RTTHREAD Thread, RTTHREADTYPE enmType);
     255
     256#endif /* !IN_RING0 */
    215257
    216258__END_DECLS
  • trunk/src/VBox/Runtime/r0drv/darwin/thread-r0drv-darwin.cpp

    r1 r197  
    2727#include <iprt/err.h>
    2828#include <iprt/assert.h>
    29 #include "r0drv/thread-r0drv.h"
     29#include "internal/thread.h"
    3030
    3131
     
    139139    const thread_t Self = current_thread();
    140140
    141     rtThreadMain((RTNATIVETHREAD)Self, (PRTR0THREADARGS)pvArg);
     141    rtThreadMain((PRTR0THREADARGS)pvArg, (RTNATIVETHREAD)Self);
    142142
    143143    kern_return_t rc = thread_terminate(Self);
  • trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp

    r1 r197  
    532532 * @returns IPRT status code.
    533533 * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
    534  * @param   MemToMap        The object to be map.
     534 * @param   MemObjToMap     The object to be map.
    535535 * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
    536536 * @param   uAlignment      The alignment of the reserved memory.
     
    538538 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    539539 */
    540 RTR0DECL(int) RTR0MemObjMapKernel(PRTR0MEMOBJ pMemObj, PRTR0MEMOBJ MemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
    541 {
    542     /* sanity checks. */
    543     AssertPtrReturn(pMemObj, VERR_INVALID_POINTER);
    544     *pMemObj = NIL_RTR0MEMOBJ;
    545     AssertPtrReturn(MemToMap, VERR_INVALID_HANDLE);
    546     PRTR0MEMOBJINTERNAL pMemToMap = (PRTR0MEMOBJINTERNAL)pMemToMap;
     540RTR0DECL(int) RTR0MemObjMapKernel(PRTR0MEMOBJ pMemObj, PRTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     541{
     542    /* sanity checks. */
     543    AssertPtrReturn(pMemObj, VERR_INVALID_POINTER);
     544    *pMemObj = NIL_RTR0MEMOBJ;
     545    AssertPtrReturn(MemObjToMap, VERR_INVALID_HANDLE);
     546    PRTR0MEMOBJINTERNAL pMemToMap = (PRTR0MEMOBJINTERNAL)MemObjToMap;
    547547    AssertReturn(pMemToMap->u32Magic == RTR0MEMOBJ_MAGIC, VERR_INVALID_HANDLE);
    548548    AssertReturn(pMemToMap->enmType > RTR0MEMOBJTYPE_INVALID && pMemToMap->enmType < RTR0MEMOBJTYPE_END, VERR_INVALID_HANDLE);
     
    587587 * @returns IPRT status code.
    588588 * @param   pMemObj         Where to store the ring-0 memory object handle of the mapping object.
    589  * @param   MemToMap        The object to be map.
     589 * @param   MemObjToMap     The object to be map.
    590590 * @param   pvFixed         Requested address. (void *)-1 means any address. This must match the alignment.
    591591 * @param   uAlignment      The alignment of the reserved memory.
     
    593593 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    594594 */
    595 RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, PRTR0MEMOBJ MemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
    596 {
    597     /* sanity checks. */
    598     AssertPtrReturn(pMemObj, VERR_INVALID_POINTER);
    599     *pMemObj = NIL_RTR0MEMOBJ;
    600     AssertPtrReturn(MemToMap, VERR_INVALID_HANDLE);
    601     PRTR0MEMOBJINTERNAL pMemToMap = (PRTR0MEMOBJINTERNAL)pMemToMap;
     595RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     596{
     597    /* sanity checks. */
     598    AssertPtrReturn(pMemObj, VERR_INVALID_POINTER);
     599    *pMemObj = NIL_RTR0MEMOBJ;
     600    AssertPtrReturn(MemObjToMap, VERR_INVALID_HANDLE);
     601    PRTR0MEMOBJINTERNAL pMemToMap = (PRTR0MEMOBJINTERNAL)MemObjToMap;
    602602    AssertReturn(pMemToMap->u32Magic == RTR0MEMOBJ_MAGIC, VERR_INVALID_HANDLE);
    603603    AssertReturn(pMemToMap->enmType > RTR0MEMOBJTYPE_INVALID && pMemToMap->enmType < RTR0MEMOBJTYPE_END, VERR_INVALID_HANDLE);
  • trunk/src/VBox/Runtime/r0drv/thread-r0drv.cpp

    r1 r197  
    2424*******************************************************************************/
    2525#define LOG_GROUP RTLOGGROUP_THREAD
    26 #include "r0drv/thread-r0drv.h"
     26#include "internal/thread.h"
    2727#include <iprt/thread.h>
    2828#include <iprt/alloc.h>
  • trunk/src/VBox/Runtime/r3/posix/timer-posix.cpp

    r1 r197  
    319319    LogFlow(("RTTimerDestroy: pTimer=%p\n", pTimer));
    320320
     321    /* NULL is ok. */
     322    if (!pTimer)
     323        return VINF_SUCCESS;
     324
    321325    /*
    322326     * Validate input.
    323327     */
    324328    int rc = VINF_SUCCESS;
    325     if (pTimer)
     329    if (VALID_PTR(pTimer))
    326330    {
    327331        /*
     
    354358    else
    355359    {
    356         AssertMsgFailed(("An attempt was made to destroy a NULL timer!\n"));
    357         rc = VERR_INVALID_POINTER;
     360        AssertMsgFailed(("Bad pTimer pointer %p!\n", pTimer));
     361        rc = VERR_INVALID_HANDLE;
    358362    }
    359363    return rc;
  • trunk/src/VBox/Runtime/r3/win32/timer-win32.cpp

    r1 r197  
    412412RTR3DECL(int)     RTTimerDestroy(PRTTIMER pTimer)
    413413{
     414    /* NULL is ok. */
     415    if (!pTimer)
     416        return VINF_SUCCESS;
     417
    414418    /*
    415419     * Validate handle first.
    416420     */
    417421    int rc;
    418     if (pTimer && pTimer->u32Magic == RTTIMER_MAGIC)
     422    if (    VALID_PTR(pTimer)
     423        &&  pTimer->u32Magic == RTTIMER_MAGIC)
    419424    {
    420425#ifdef USE_WINMM
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