Changeset 6937 in vbox
- Timestamp:
- Feb 13, 2008 8:26:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/thread.h
r5999 r6937 360 360 RTR3DECL(int) RTThreadSetAffinity(uint64_t u64Mask); 361 361 362 363 /** @name Thread Local Storage 364 * @{ 365 */ 366 /** A TLS index. */ 367 typedef int RTTLS; 368 /** Pointer to a TLS index. */ 369 typedef RTTLS *PRTTLS; 370 /** Pointer to a const TLS index. */ 371 typedef RTTLS const *PCRTTLS; 372 /** NIL TLS index value. */ 373 #define NIL_RTTLS (-1) 374 375 /** 376 * Allocates a TLS entry. 377 * 378 * @returns the index of the allocated TLS entry. 379 * @returns NIL_RTTLS on failure. 380 */ 381 RTR3DECL(int) RTTlsAlloc(void); 382 383 /** 384 * Allocates a TLS entry (with status code). 385 * 386 * @returns IPRT status code. 387 * @param piTls Where to store the index of the allocated TLS entry. 388 * This is set to NIL_RTTLS on failure. 389 */ 390 RTR3DECL(int) RTTlsAllocEx(PRTTLS piTls); 391 392 /** 393 * Frees a TLS entry. 394 * 395 * @returns IPRT status code. 396 * @param iTls The index of the TLS entry. 397 */ 398 RTR3DECL(int) RTTlsFree(RTTLS iTls); 399 400 /** 401 * Get the value stored in a TLS entry. 402 * 403 * @returns value in given TLS entry. 404 * @returns NULL on failure. 405 * @param iTls The index of the TLS entry. 406 */ 407 RTR3DECL(void *) RTTlsGet(RTTLS iTls); 408 409 /** 410 * Get the value stored in a TLS entry. 411 * 412 * @returns IPRT status code. 413 * @param iTls The index of the TLS entry. 414 * @param ppvValue Where to store the value. 415 */ 416 RTR3DECL(int) RTTlsGetEx(RTTLS iTls, void **ppvValue); 417 418 /** 419 * Set the value stored in an allocated TLS entry. 420 * 421 * @returns IPRT status. 422 * @param iTls The index of the TLS entry. 423 * @param pvValue The value to store. 424 * 425 * @remarks Note that NULL is considered to special value. 426 */ 427 RTR3DECL(int) RTTlsSet(RTTLS iTls, void *pvValue); 428 429 /** 430 * Thread termination callback for destroying a non-zero TLS entry. 431 * 432 * Registered and deregisterd by RTTlsSetDestructor(). 433 * 434 * @remarks It is not permittable to use any RTTls APIs at this time. Doing so 435 * may lead to endless loops, crashes, and other bad stuff. 436 * 437 * @param pvValue The current value. 438 * @param iTls The index of TLS entry. 439 * @param fFlags Reserved for the future. 440 */ 441 typedef DECLCALLBACK(void) FNRTTLSDTOR(void *pvValue, RTTLS iTls, uint32_t fFlags); 442 /** Pointer to a FNRTTLSDTOR. */ 443 typedef FNRTTLSDTOR *PFNRTTLSDTOR; 444 445 /** 446 * Register a thread termination destructor for a TLS entry. 447 * 448 * The destructor function will be called when a thread terminates 449 * in a normal fashion and the TLS entry iTls of that thread is 450 * not NULL. 451 * 452 * @remarks This is an optional feature and may therefore not be implemented 453 * on all platforms. VERR_NOT_SUPPORTED is returned then. 454 * 455 * @returns IPRT status code. 456 * @retval VERR_NOT_SUPPORTED if not supported on this platform. 457 * 458 * @param iTls The index of the TLS entry. 459 * @param pfnDestructor Callback function. Use NULL to unregister a previously 460 * registered destructor. 461 * 462 * It's pvValue argument is the non-zero value in the 463 * TLS entry for the thread it's called on. 464 * 465 * It's fFlags argument is reserved for future use, it will 466 * always be zero when the fFlags parameter to this API is zero. 467 * 468 * @param fFlags Flags reserved for future use. At the moment 469 * only ZERO is allowed. 470 * 471 */ 472 RTR3DECL(int) RTTlsSetDestructor(RTTLS iTls, PFNRTTLSDTOR pfnDestructor, uint32_t fFlags); 473 474 /** 475 * Get pointer to the destructor function registered for the given TLS entry. 476 * 477 * @remarks This may not necessarily be implemented even if RTTlsSetDestructor is. 478 * 479 * @returns IPRT status code. 480 * @retval VERR_NOT_SUPPORTED if not supported on this platform. 481 * 482 * @param iTls The index of the TLS entry. 483 * @param ppfnDestructor Where to store the destructor address. 484 * @param pfFlags Where to store the flags supplied to RTTlsSetDestructor(). NULL is fine. 485 */ 486 PFNRTTLSDTOR RTTlsGetDestructor(RTTLS iTls, PFNRTTLSDTOR *ppfnDestructor, uint32_t *pfFlags); 487 488 /** @} */ 489 362 490 #endif /* IN_RING3 */ 363 491 … … 367 495 368 496 #endif 497
Note:
See TracChangeset
for help on using the changeset viewer.