os/kernelhwsrv/kernel/eka/compsupp/rvct2_0/ucppfini.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/compsupp/rvct2_0/ucppfini.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "ARM EABI LICENCE.txt"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// in kernel/eka/compsupp.
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// toplevel destruction routines for 'user side' code compiled 
    1.18 +// with the ARMEDG compiler.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +#include "cppinit.h"
    1.23 +
    1.24 +extern "C" {
    1.25 +
    1.26 +// Need to decide what this should do
    1.27 +//void CppInitializationPanic(){};
    1.28 +
    1.29 +#define MAX_DTOR_RECORDS 256
    1.30 +static dtd dtor_rec[MAX_DTOR_RECORDS];
    1.31 +
    1.32 +typedef dtd **dso_handle;
    1.33 +dtd * __dso_handle = &dtor_rec[MAX_DTOR_RECORDS];
    1.34 +
    1.35 +int __cxa_atexit ( void (*f)(void *), void *p, dso_handle d )
    1.36 +    {
    1.37 +    dtd * drec = *d;
    1.38 +    drec--;
    1.39 +    // This is what the spec says to do!!
    1.40 +    if (drec < &dtor_rec[0]) return -1;
    1.41 +
    1.42 +    drec->dtor = f;
    1.43 +    drec->obj = p;
    1.44 +    *d = drec;
    1.45 +    return 0;
    1.46 +    }
    1.47 +
    1.48 +void __cxa_finalize ( dso_handle d )
    1.49 +    {
    1.50 +    dtd * drec = * d;
    1.51 +    dtd * lim = &dtor_rec[MAX_DTOR_RECORDS];
    1.52 +    while (drec < lim) 
    1.53 +        {
    1.54 +	drec->dtor(drec->obj);
    1.55 +	drec++;
    1.56 +        }
    1.57 +    *d = drec;
    1.58 +    }
    1.59 +
    1.60 +void run_static_dtors (void)
    1.61 +    {
    1.62 +    __cxa_finalize(&__dso_handle);
    1.63 +    }
    1.64 +}
    1.65 +