Changeset 133 in flair-src for trunk/lib/FlairCore/src/SharedMem_impl.cpp


Ignore:
Timestamp:
02/09/17 11:08:31 (5 years ago)
Author:
Sanahuja Guillaume
Message:

modif sterror

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/SharedMem_impl.cpp

    r15 r133  
    3030  this->size = size;
    3131  this->self = self;
     32        char errorMsg[256];
    3233
    3334#ifdef __XENO__
     
    4041  }
    4142  if (status != 0) {
    42     self->Err("rt_heap_create error (%s)\n", strerror(-status));
     43    self->Err("rt_heap_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    4344    return;
    4445  }
     
    4748  status = rt_heap_alloc(&heap, 0, TM_NONBLOCK, &ptr);
    4849  if (status != 0) {
    49     self->Err("rt_heap_alloc error (%s)\n", strerror(-status));
     50    self->Err("rt_heap_alloc error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    5051  }
    5152  mem_segment = (char *)ptr;
     
    5960  }
    6061  if (status != 0) {
    61     self->Err("rt_mutex_create error (%s)\n", strerror(-status));
     62    self->Err("rt_mutex_create error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    6263    return;
    6364  }
     
    8788SharedMem_impl::~SharedMem_impl() {
    8889  int status;
     90        char errorMsg[256];
     91       
    8992#ifdef __XENO__
    9093  /* unnecessary because heap is opened in H_SINGLE mode
     
    9295  if(status!=0)
    9396  {
    94       self->Err("rt_heap_free error (%s)\n",strerror(-status));
     97      self->Err("rt_heap_free error (%s)\n",strerror_r(-status, errorMsg, sizeof(errorMsg)));
    9598  }
    9699  */
     
    99102    status = rt_heap_delete(&heap);
    100103    if (status != 0) {
    101       self->Err("rt_heap_delete error (%s)\n", strerror(-status));
     104      self->Err("rt_heap_delete error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    102105    }
    103106  }
     
    106109    status = rt_mutex_delete(&mutex);
    107110    if (status != 0) {
    108       self->Err("error destroying mutex (%s)\n", strerror(-status));
     111      self->Err("error destroying mutex (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    109112    }
    110113  }
     
    112115  status = munmap(mem_segment, size);
    113116  if (status != 0) {
    114     self->Err("Failed to unmap memory (%s)\n", strerror(-status));
     117    self->Err("Failed to unmap memory (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    115118  }
    116119
    117120  status = close(fd);
    118121  if (status != 0) {
    119     self->Err("Failed to close file (%s)\n", strerror(-status));
     122    self->Err("Failed to close file (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    120123  }
    121124
     
    124127   if(status!=0)
    125128   {
    126        self->Err("Failed to unlink memory (%s)\n",strerror(-status));
     129       self->Err("Failed to unlink memory (%s)\n",strerror_r(-status, errorMsg, sizeof(errorMsg)));
    127130   }
    128131*/
     
    131134   if(status!=0)
    132135   {
    133        self->Err("Failed to unlink semaphore (%s)\n",strerror(-status));
     136       self->Err("Failed to unlink semaphore (%s)\n",strerror_r(-status, errorMsg, sizeof(errorMsg)));
    134137   }*/
    135138
    136139  status = sem_close(sem);
    137140  if (status != 0) {
    138     self->Err("Failed to close semaphore (%s)\n", strerror(-status));
     141    self->Err("Failed to close semaphore (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
    139142  }
    140143#endif
     
    144147#ifdef __XENO__
    145148  int status = rt_mutex_acquire(&mutex, TM_INFINITE);
    146   if (status != 0)
    147     self->Err("error (%s)\n", strerror(-status));
     149  if (status != 0) {
     150                char errorMsg[256];
     151    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     152        }
    148153  memcpy(mem_segment, buf, size);
    149154  status = rt_mutex_release(&mutex);
    150   if (status != 0)
    151     self->Err("error (%s)\n", strerror(-status));
     155  if (status != 0) {
     156                char errorMsg[256];
     157    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     158        }
    152159#else
    153160  sem_wait(sem);
     
    160167#ifdef __XENO__
    161168  int status = rt_mutex_acquire(&mutex, TM_INFINITE);
    162   if (status != 0)
    163     self->Err("error (%s)\n", strerror(-status));
     169  if (status != 0) {
     170                char errorMsg[256];
     171    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     172        }
    164173  memcpy(buf, mem_segment, size);
    165174  status = rt_mutex_release(&mutex);
    166   if (status != 0)
    167     self->Err("error (%s)\n", strerror(-status));
     175  if (status != 0) {
     176                char errorMsg[256];
     177    self->Err("error (%s)\n", strerror_r(-status, errorMsg, sizeof(errorMsg)));
     178        }
    168179#else
    169180  sem_wait(sem);
Note: See TracChangeset for help on using the changeset viewer.