fixed bug: Wrong opcode range was requested in be
[libfirm] / ir / be / beutil.c
index 1dd5d08..ee4506c 100644 (file)
  */
 
 /**
- * Contains some useful function for the backend.
- * @author  Sebastian Hack
- * @version $Id$
+ * @file
+ * @brief       Contains some useful function for the backend.
+ * @author      Sebastian Hack
+ * @version     $Id$
  */
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -268,3 +269,16 @@ ir_node *be_get_Proj_for_pn(const ir_node *irn, long pn) {
 
        return NULL;
 }
+
+FILE *be_ffopen(const char *base, const char *ext, const char *mode) {
+       FILE *out;
+       char buf[1024];
+
+       snprintf(buf, sizeof(buf), "%s.%s", base, ext);
+       buf[sizeof(buf) - 1] = '\0';
+       if (! (out = fopen(buf, mode))) {
+               fprintf(stderr, "Cannot open file %s in mode %s\n", buf, mode);
+               return NULL;
+       }
+       return out;
+}