$search
00001 /* 00002 * OpenNL: Numerical Library 00003 * Copyright (C) 2004 Bruno Levy 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 * 00019 * If you modify this software, you should include a notice giving the 00020 * name of the person performing the modification, the date of modification, 00021 * and the reason for such modification. 00022 * 00023 * Contact: Bruno Levy 00024 * 00025 * levy@loria.fr 00026 * 00027 * ISA Project 00028 * LORIA, INRIA Lorraine, 00029 * Campus Scientifique, BP 239 00030 * 54506 VANDOEUVRE LES NANCY CEDEX 00031 * FRANCE 00032 * 00033 * Note that the GNU General Public License does not permit incorporating 00034 * the Software into proprietary programs. 00035 */ 00036 00037 #include <NL/nl_private.h> 00038 00039 00040 #ifdef WIN32 00041 #include <windows.h> 00042 #else 00043 #include <sys/types.h> 00044 #include <sys/times.h> 00045 #endif 00046 00047 /************************************************************************************/ 00048 /* Assertions */ 00049 00050 00051 void nl_assertion_failed(char* cond, char* file, int line) { 00052 fprintf( 00053 stderr, 00054 "OpenNL assertion failed: %s, file:%s, line:%d\n", 00055 cond,file,line 00056 ) ; 00057 abort() ; 00058 } 00059 00060 void nl_range_assertion_failed( 00061 double x, double min_val, double max_val, char* file, int line 00062 ) { 00063 fprintf( 00064 stderr, 00065 "OpenNL range assertion failed: %f in [ %f ... %f ], file:%s, line:%d\n", 00066 x, min_val, max_val, file,line 00067 ) ; 00068 abort() ; 00069 } 00070 00071 void nl_should_not_have_reached(char* file, int line) { 00072 fprintf( 00073 stderr, 00074 "OpenNL should not have reached this point: file:%s, line:%d\n", 00075 file,line 00076 ) ; 00077 abort() ; 00078 } 00079 00080 00081 /************************************************************************************/ 00082 /* Timing */ 00083 00084 #ifdef WIN32 00085 NLdouble nlCurrentTime() { 00086 return (NLdouble)GetTickCount() / 1000.0 ; 00087 } 00088 #else 00089 double nlCurrentTime() { 00090 clock_t user_clock ; 00091 struct tms user_tms ; 00092 user_clock = times(&user_tms) ; 00093 return (NLdouble)user_clock / 100.0 ; 00094 } 00095 #endif 00096 00097 00098 /************************************************************************************/ 00099 /* Error-reporting functions */ 00100 00101 void nlError(char* function, char* message) { 00102 fprintf(stderr, "OpenNL error in %s(): %s\n", function, message) ; 00103 } 00104 00105 void nlWarning(char* function, char* message) { 00106 fprintf(stderr, "OpenNL warning in %s(): %s\n", function, message) ; 00107 } 00108