malloc inside atomic transaction

malloc inside atomic transaction

Hello,I just want to add a remark about the Intel STM compiler.ICC STM 4.0

../../test/intset/intset.c(173) (col. 5): error: non  function "malloc" called inside  routine

ICC STM 3.0

../../test/intset/intset.c(173) (col. 5): error: non tm_safe/tm_pure function "malloc" called inside tm_safe routine

icc complains about malloc() function because it is inside a transaction and it is non safe function. But Intel STM Compiler knows how to manage malloc/free inside transaction. So, why does the programmer have to add explicitly pure or safe attribute to it?Moreover even if it is annotate as pure, the malloc is wrapped.

callq  0x419630 

why there is no problem with free() function?Anyway, thanks a lot for this great work!Sincerely,Patrick Marlier

2 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Sorry, my mistake... Actually version 3.0 and 4.0 react the same way and free has the same problem as malloc.Here an example:

#include 
#include 


void *myalloc()
{
     return malloc(16);
}

int main()
{
   void *area;
   __transaction  {
     area = myalloc();
   }
   if (area == NULL)
     return 1;
   __transaction  {
     free(area);
   }
   return 0;
}

malloc.c(8) (col. 5): error: non  function "malloc" 
called inside  routine

In this example, malloc isn't implicit declared safe whereas free is implicit declared safe. But I am wondering if this behavior is correct : malloc/free is implicitly declared safe in an atomic transaction block and not inside a safe function.Thank in advance for the clarification,Patrick Marlier.

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen