Changeset 1402


Ignore:
Timestamp:
Apr 29, 2004, 6:12:23 AM (21 years ago)
Author:
bird
Message:

More TLS.

Location:
trunk/src/emx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/emx/include/InnoTekLIBC/thread.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1401 r1402  
    344344 *          this function. The result from doing that is undefined.
    345345 */
    346 int     __libc_TLSDestructor(int iIndex, void (*pfnDestructor)(void *pvValue, unsigned fFlags), unsigned fFlags);
     346int     __libc_TLSDestructor(int iIndex, void (*pfnDestructor)(void *pvValue, int iTLSIndex, unsigned fFlags), unsigned fFlags);
     347
     348
     349/**
     350 * Get pointer to the destructor function registered for the given TLS entry.
     351 *
     352 * @returns NULL if invalid entry, errno set.
     353 * @returns NULL if no entry registered.
     354 * @returns Pointer to destructor if registered.
     355 *
     356 * @param   iTLSIndex       Value returned by __libc_TLSAlloc().
     357 * @param   pfFlags         Where to store the flags supplied to __libc_TLSDestructor().
     358 *                          NULL is ok.
     359 */
     360void (*__libc_TLSGetDestructor(int iTLSIndex, unsigned *pfFlags))(void *, int, unsigned);
    347361
    348362/** @} */
  • TabularUnified trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.55 to 1.56
    r1401 r1402  
    10971097    "___libc_TLSDestructor" @1119
    10981098    "___libc_ThreadRegisterTermCallback" @1120
     1099    "___libc_TLSGetDestructor" @1121
  • TabularUnified trunk/src/emx/src/lib/process/tls.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1401 r1402  
    6969
    7070/** TLS Per Thread Destructors. */
    71 static   void (*gapfnDestructors[__LIBC_TLS_MAX])(void *, unsigned);
     71static   void (*gapfnDestructors[__LIBC_TLS_MAX])(void *, int, unsigned);
    7272
    7373/** Thread Termination Registration Record. */
     
    157157     */
    158158    gapfnDestructors[iIndex] = NULL;
     159    /* @todo do serialized NULLing of all threads! */
    159160    __atomic_clear_bit(&gauBitmap[0], iIndex);
    160161
     
    216217
    217218
    218 int     __libc_TLSDestructor(int iIndex, void (*pfnDestructor)(void *pvValue, unsigned fFlags), unsigned fFlags)
     219int     __libc_TLSDestructor(int iIndex, void (*pfnDestructor)(void *pvValue, int iTLSIndex, unsigned fFlags), unsigned fFlags)
    219220{
    220221    LIBCLOG_ENTER("iIndex=%d pfnDestructor=%p\n", iIndex, pfnDestructor);
     
    302303                    while (k < kEnd)
    303304                    {
    304                         void (*pfnDestructor)(void *, unsigned);
     305                        void (*pfnDestructor)(void *, int, unsigned);
     306                        void  *pvValue;
    305307                        if (    __atomic_test_bit(&gauBitmap[0], k)   
    306308                            &&  k < __LIBC_TLS_MAX
    307                             &&  pThrd->apvTLS[k]
     309                            &&  (pvValue = pThrd->apvTLS[k]) != NULL
    308310                            &&  (pfnDestructor = gapfnDestructors[k]) != NULL)
    309311                        {
    310312                            LIBCLOG_MSG("tls %d: calling %p with %p\n", k, (void *)pfnDestructor, pThrd->apvTLS[k]);
    311                             pfnDestructor(pThrd->apvTLS[k], fFlags);
     313                            pThrd->apvTLS[k] = NULL;
     314                            pfnDestructor(pvValue, k, fFlags);
    312315                        }
    313316
     
    321324    LIBCLOG_RETURN_VOID();
    322325}
     326
     327
     328void (*__libc_TLSGetDestructor(int iTLSIndex, unsigned *pfFlags))(void *, int, unsigned)
     329{
     330    LIBCLOG_ENTER("iTLSIndex=%d, pfFlags=%p\n", iTLSIndex, pfFlags);
     331    void (*pfnDestructor)(void *, int, unsigned);
     332
     333    /*
     334     * Validate index
     335     */
     336    if (    iTLSIndex < 0
     337        ||  iTLSIndex >= __LIBC_TLS_MAX
     338        ||  !__atomic_test_bit(&gauBitmap[0], iTLSIndex)
     339            )
     340    {
     341        LIBC_ASSERTM_FAILED("Bad index %d. (max=%d)\n", iTLSIndex, __LIBC_TLS_MAX);
     342        errno = EINVAL;
     343        LIBCLOG_RETURN_P(NULL);
     344    }
     345
     346    pfnDestructor = gapfnDestructors[iTLSIndex];
     347    if (pfFlags)
     348        *pfFlags = 0;
     349    LIBCLOG_RETURN_P(pfnDestructor);
     350}
Note: See TracChangeset for help on using the changeset viewer.