Ajout de l'ensemble du workspace.
[GPU.git] / WCudaMSE / API_CppTest / SRC / core / missing.cpp
1 // ---
2 //
3 // $Id: missing.cpp,v 1.4 2008/07/15 20:33:31 hartwork Exp $
4 //
5 // CppTest - A C++ Unit Testing Framework
6 // Copyright (c) 2003 Niklas Lundell
7 //
8 // ---
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the
22 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 // Boston, MA 02111-1307, USA.
24 //
25 // ---
26
27 #if (defined(__WIN32__) || defined(WIN32))
28 # include "winconfig.h"
29 #else
30 # include "config.h"
31 #endif
32
33 #include "missing.h"
34
35 #ifdef HAVE_GETTICKCOUNT
36 #include <windows.h>
37 #endif
38
39 #ifndef __BORLANDC__
40 #include <cmath>
41 #else
42 #include <math.h>
43 #endif
44
45 #include <cassert>
46 #include <ctime>
47
48 namespace Test
49 {
50 #ifndef HAVE_GETTIMEOFDAY
51
52 int
53 gettimeofday(timeval* tv, void*)
54 {
55 assert(tv);
56
57 #ifdef HAVE_GETTICKCOUNT
58 long now = GetTickCount();
59 tv->tv_sec = now / 1000;
60 tv->tv_usec = (now % 1000) * 1000;
61 #else
62 tv->tv_sec = time(0);
63 tv->tv_usec = 0;
64 #endif // #ifdef HAVE_GETTICKCOUNT
65
66 return 0;
67 }
68
69 #endif // #ifndef HAVE_GETTIMEOFDAY
70
71 #ifndef HAVE_ROUND
72 double
73 round(double d)
74 {
75 return d > 0.0 ? floor(d + 0.5) : ceil(d - 0.5);
76 }
77 #endif
78
79 } // namespace Test
80