Restored somehow lost AMD Family 11h support.
[libfirm] / ir / libcore / lc_opts_enum.c
index cb66e54..e7ac648 100644 (file)
@@ -15,9 +15,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#if defined(__FreeBSD__)
-#include <stdlib.h>
-#elif defined(_WIN32)
+#ifdef _WIN32
 #include <malloc.h>
 #endif
 #ifdef HAVE_ALLOCA_H
 #include "lc_opts_t.h"
 #include "lc_opts_enum.h"
 
-static const char *delim                       = " \t|,";
+static const char *delim = " \t|,";
 
 #define DECL_CB(N, op) \
 int lc_opt_enum_ ## N ## _cb(LC_UNUSED(const char *name), LC_UNUSED(lc_opt_type_t type), void *data, size_t len, ...) \
 { \
-       lc_opt_enum_ ## N ## _var_t *var                                                = data; \
-       const lc_opt_enum_ ## N ## _items_t *items      = var->items; \
+       lc_opt_enum_ ## N ## _var_t *var           = (lc_opt_enum_ ## N ## _var_t*)data; \
+       const lc_opt_enum_ ## N ## _items_t *items = var->items; \
  \
        va_list args; \
        char *s, *tmp; \
@@ -46,12 +44,12 @@ int lc_opt_enum_ ## N ## _cb(LC_UNUSED(const char *name), LC_UNUSED(lc_opt_type_
        va_end(args); \
        \
        end     = strlen(arg); \
-       tmp = s = malloc((end + 1) * sizeof(arg[0])); \
+       tmp = s = (char*)malloc((end + 1) * sizeof(arg[0])); \
        strcpy(s, arg); \
        s[end]  = '\0'; \
        \
        end = 0; \
-       while(arg[end] != '\0') { \
+       while (arg[end] != '\0') { \
                unsigned int i; \
                \
                begin  = end + strspn(arg + end, delim); \
@@ -59,8 +57,8 @@ int lc_opt_enum_ ## N ## _cb(LC_UNUSED(const char *name), LC_UNUSED(lc_opt_type_
                s      = tmp + begin; \
                s[end - begin] = '\0'; \
                \
-               for(i = 0; items[i].name != NULL; ++i) { \
-                       if(strcmp(s, items[i].name) == 0) { \
+               for (i = 0; items[i].name != NULL; ++i) { \
+                       if (strcmp(s, items[i].name) == 0) { \
                                *var->value op items[i].value; \
                                res = 1; \
                        } \
@@ -79,9 +77,9 @@ DECL_CB(func_ptr, =)
 #define DECL_DUMP(T, N, cond) \
 int lc_opt_enum_ ## N ## _dump(char *buf, size_t n, LC_UNUSED(const char *name), LC_UNUSED(lc_opt_type_t type), void *data, LC_UNUSED(size_t len)) \
 { \
-       lc_opt_enum_ ## N ## _var_t *var                                                = data; \
-       const lc_opt_enum_ ## N ## _items_t *items      = var->items; \
-       const char *prefix                                                              = "";                    \
+       lc_opt_enum_ ## N ## _var_t *var           = (lc_opt_enum_ ## N ## _var_t*)data;       \
+       const lc_opt_enum_ ## N ## _items_t *items = var->items; \
+       const char *prefix                         = "";         \
        TYPE(value) = *var->value; \
        int i; \
        size_t l = strlen(buf); \
@@ -111,9 +109,9 @@ int lc_opt_enum_ ## N ## _dump(char *buf, size_t n, LC_UNUSED(const char *name),
 #define DECL_DUMP_VALS(T, N) \
 int lc_opt_enum_ ## N ## _dump_vals(char *buf, size_t n, LC_UNUSED(const char *name), LC_UNUSED(lc_opt_type_t type), void *data, LC_UNUSED(size_t len)) \
 { \
-       lc_opt_enum_ ## N ## _var_t *var                                                = data; \
-       const lc_opt_enum_ ## N ## _items_t *items      = var->items; \
-       const char *prefix                                                              = "";                    \
+       lc_opt_enum_ ## N ## _var_t *var           = (lc_opt_enum_ ## N ## _var_t*) data;       \
+       const lc_opt_enum_ ## N ## _items_t *items = var->items; \
+       const char *prefix                         = "";         \
        int i; \
        size_t l = strlen(buf); \
  \