kernel/eka/compsupp/symaehabi/cppsemantics.cpp
changeset 266 0008ccd16016
parent 0 a41df078684a
equal deleted inserted replaced
259:57b9594f5772 266:0008ccd16016
     4  *
     4  *
     5  * Your rights to use this code are set out in the accompanying licence
     5  * Your rights to use this code are set out in the accompanying licence
     6  * text file LICENCE.txt (ARM contract number LEC-ELA-00080 v1.0).
     6  * text file LICENCE.txt (ARM contract number LEC-ELA-00080 v1.0).
     7  */
     7  */
     8 
     8 
     9 /* Portions copyright Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). */
     9 /* Portions copyright Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). */
    10 
    10 
    11 /*
    11 /*
    12  * RCS $Revision: 92950 $
    12  * RCS $Revision: 92950 $
    13  * Checkin $Date: 2005-10-12 11:08:47 +0100 (Wed, 12 Oct 2005) $
    13  * Checkin $Date: 2005-10-12 11:08:47 +0100 (Wed, 12 Oct 2005) $
    14  * Revising $Author: achapman $
    14  * Revising $Author: achapman $
   352 
   352 
   353 // Allocator
   353 // Allocator
   354 void *__ARM_exceptions_buffer_allocate(void *buffer, size_t size)
   354 void *__ARM_exceptions_buffer_allocate(void *buffer, size_t size)
   355 {
   355 {
   356   emergency_buffer *b = (emergency_buffer *)buffer;
   356   emergency_buffer *b = (emergency_buffer *)buffer;
       
   357 
       
   358   #ifndef __EPOC32__
   357   if (size > sizeof(emergency_eco) || b == NULL || b->inuse) return NULL;
   359   if (size > sizeof(emergency_eco) || b == NULL || b->inuse) return NULL;
   358   b->inuse = true;
   360   b->inuse = true;
   359   return &b->eco;
   361   return &b->eco;
       
   362   #else
       
   363   ASSERT(b);
       
   364 
       
   365   if (size > sizeof(emergency_eco) || b->inuse) {
       
   366     // The first buffer isn't usable; try the second one instead, if it exists.
       
   367     if (b->em_buf2_p)
       
   368     	return b->em_buf2_p->Alloc(size);
       
   369     else
       
   370     	return NULL;
       
   371   }
       
   372   else {
       
   373     b->inuse = true;
       
   374     return &b->eco;
       
   375   }
       
   376   #endif
   360 }
   377 }
   361 
   378 
   362 // Deallocator: Must return non-NULL if and only if it recognises
   379 // Deallocator: Must return non-NULL if and only if it recognises
   363 // and releases the supplied object
   380 // and releases the supplied object
   364 void *__ARM_exceptions_buffer_free(void *buffer, void *addr)
   381 void *__ARM_exceptions_buffer_free(void *buffer, void *addr)
   365 {
   382 {
   366   emergency_buffer *b = (emergency_buffer *)buffer;
   383   emergency_buffer *b = (emergency_buffer *)buffer;
       
   384 
       
   385   #ifndef __EPOC32__
   367   if (b == NULL || addr != &b->eco) return NULL;
   386   if (b == NULL || addr != &b->eco) return NULL;
   368   b->inuse = false;
   387   b->inuse = false;
   369   return b;
   388   return b;
       
   389   #else
       
   390   ASSERT(b);
       
   391 
       
   392   if (addr != &b->eco) {
       
   393     // The object wasn't from the first buffer; see if it is from the second one.
       
   394     if (b->em_buf2_p)
       
   395       return b->em_buf2_p->Free(addr);
       
   396     else
       
   397       return NULL;
       
   398   }
       
   399   else {
       
   400     b->inuse = false;
       
   401     return b;
       
   402   }
       
   403   #endif
   370 }
   404 }
   371 
   405 
   372 #  if 0
   406 #  if 0
   373 // Hook activation support - see comments earlier
   407 // Hook activation support - see comments earlier
   374 extern "C" WEAKDECL void __ARM_exceptions_buffer_required(void);
   408 extern "C" WEAKDECL void __ARM_exceptions_buffer_required(void);