Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[MSVC] use our extended xbt_malloc, but don't choke on 'strdup' that should read...
[simgrid.git] / include / xbt / sysdep.h
index 9ed7c53..d990aaa 100644 (file)
@@ -71,11 +71,8 @@ XBT_PUBLIC(char *) bprintf(const char *fmt, ...) _XBT_GNUC_PRINTF(1, 2);
  *  @{
  */
 
  *  @{
  */
 
-#if defined(__GNUC__) || defined(DOXYGEN)
 /** @brief Like strdup, but xbt_die() on error */
 /** @brief Like strdup, but xbt_die() on error */
-static inline __attribute__ ((always_inline))
-char *xbt_strdup(const char *s)
-{
+static XBT_ALWAYS_INLINE char *xbt_strdup(const char *s) {
   char *res = NULL;
   if (s) {
     res = strdup(s);
   char *res = NULL;
   if (s) {
     res = strdup(s);
@@ -89,9 +86,7 @@ XBT_PUBLIC(void) xbt_backtrace_display_current(void);
 
 /** @brief Like malloc, but xbt_die() on error
     @hideinitializer */
 
 /** @brief Like malloc, but xbt_die() on error
     @hideinitializer */
-static inline __attribute__ ((always_inline))
-void *xbt_malloc(size_t n)
-{
+static XBT_ALWAYS_INLINE void *xbt_malloc(size_t n) {
   void *res;
 /*  if (n==0) {
      xbt_backtrace_display_current();
   void *res;
 /*  if (n==0) {
      xbt_backtrace_display_current();
@@ -106,9 +101,7 @@ void *xbt_malloc(size_t n)
 
 /** @brief like malloc, but xbt_die() on error and memset data to 0
     @hideinitializer */
 
 /** @brief like malloc, but xbt_die() on error and memset data to 0
     @hideinitializer */
-static inline __attribute__ ((always_inline))
-void *xbt_malloc0(size_t n)
-{
+static XBT_ALWAYS_INLINE void *xbt_malloc0(size_t n) {
   void *res;
   //if (n==0) xbt_die("calloc(0) is not portable");
   res = calloc(n, 1);
   void *res;
   //if (n==0) xbt_die("calloc(0) is not portable");
   res = calloc(n, 1);
@@ -119,9 +112,7 @@ void *xbt_malloc0(size_t n)
 
 /** @brief like realloc, but xbt_die() on error
     @hideinitializer */
 
 /** @brief like realloc, but xbt_die() on error
     @hideinitializer */
-static inline __attribute__ ((always_inline))
-void *xbt_realloc(void *p, size_t s)
-{
+static XBT_ALWAYS_INLINE void *xbt_realloc(void *p, size_t s) {
   void *res = NULL;
   //if (s==0) xbt_die("realloc(0) is not portable");
   if (s) {
   void *res = NULL;
   //if (s==0) xbt_die("realloc(0) is not portable");
   if (s) {
@@ -137,12 +128,6 @@ void *xbt_realloc(void *p, size_t s)
   }
   return res;
 }
   }
   return res;
 }
-#else                           /* non __GNUC__  */
-#  define xbt_strdup(s)    strdup(s)
-#  define xbt_malloc(n)    malloc(n)
-#  define xbt_malloc0(n)   calloc(n,1)
-#  define xbt_realloc(p,s) realloc(p,s)
-#endif                          /* __GNUC__ ? */
 
 /** @brief like free
     @hideinitializer */
 
 /** @brief like free
     @hideinitializer */