Resolve constness warning.
[libfirm] / ir / lpp / lpp_cplex.c
index 969defe..d24c874 100644 (file)
@@ -1,38 +1,43 @@
+/*
+ * Copyright (C) 2005-2011 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
 /**
- * Author:      Daniel Grund
- * Date:        02.06.2005
- * Copyright:   (c) Universitaet Karlsruhe
- * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ * @file
+ * @author  Daniel Grund
  */
 #include "config.h"
 
+#ifdef WITH_CPLEX
 #include "lpp_cplex.h"
 
 #include <stdio.h>
 #include <stdlib.h>
-
-#ifdef WITH_CPLEX
-
-#include "obst.h"
-
+#include <assert.h>
 #include <ilcplex/cplex.h>
 
-#include "assert.h"
+#include "obst.h"
+#include "stat_timing.h"
 #include "sp_matrix.h"
 
 static char cpx_cst_encoding[4] = "?ELG";
 static char cpx_var_encoding[4] = "??CB";
 
-#define my_timersub(tvp, uvp, vvp)                     \
-    do {                                \
-        (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;      \
-        (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;   \
-        if ((vvp)->tv_usec < 0) {               \
-            (vvp)->tv_sec--;                \
-            (vvp)->tv_usec += 1000000;          \
-        }                           \
-    } while (0)
-
 typedef struct _cpx_t {
        lpp_t *lpp;
        CPXENVptr env;
@@ -164,14 +169,15 @@ static void cpx_construct(cpx_t *cpx)
        chk_cpx_err(cpx);
 
        obstack_free(&obst, NULL);
-       free_lpp_matrix(lpp);
+       lpp_free_matrix(lpp);
 }
 
 static void cpx_solve(cpx_t *cpx)
 {
        int i, CPX_state, numcols;
        double *values;
-       struct timeval tvb, tva, tvdiff;
+       timing_ticks_t tvb;
+       timing_ticks_t tva;
 
        lpp_t *lpp = cpx->lpp;
        numcols = CPXgetnumcols(cpx->env, cpx->prob);
@@ -214,9 +220,9 @@ static void cpx_solve(cpx_t *cpx)
        // CPXsetintparam (cpx->env, CPX_PARAM_SCRIND, CPX_ON);
 
        /* solve */
-       gettimeofday(&tvb, NULL);
+       timing_ticks(tvb);
        cpx->status = CPXmipopt(cpx->env, cpx->prob);
-       gettimeofday(&tva, NULL);
+       timing_ticks(tva);
        chk_cpx_err(cpx);
 
        /* get solution status */
@@ -258,8 +264,8 @@ static void cpx_solve(cpx_t *cpx)
        CPXgetbestobjval(cpx->env, cpx->prob, &lpp->best_bound);
 
        /* get some statistics */
-       my_timersub(&tva, &tvb, &tvdiff);
-       lpp->sol_time = tvdiff.tv_sec + tvdiff.tv_usec / 1e6;
+       timing_ticks_sub(tva, tvb);
+       lpp->sol_time = timing_ticks_dbl(tva);
        lpp->iterations = CPXgetmipitcnt(cpx->env, cpx->prob);
 }