2 * Lame time routines source file
4 * Copyright (c) 2000 Mark Taylor
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 /* $Id: lametime.c,v 1.1.1.2 2003/06/16 20:01:21 herman Exp $ */
25 * name: GetCPUTime ( void )
27 * description: returns CPU time used by the process
29 * output: time in seconds
30 * known bugs: may not work in SMP and RPC
33 * There is some old difficult to read code at the end of this file.
34 * Can someone integrate this into this function (if useful)?
52 double GetCPUTime ( void )
56 #if defined(_MSC_VER) || defined(__BORLANDC__)
61 return t
/ (double) CLOCKS_PER_SEC
;
66 * name: GetRealTime ( void )
68 * description: returns real (human) time elapsed relative to a fixed time (mostly 1970-01-01 00:00:00)
70 * output: time in seconds
71 * known bugs: bad precision with time()
74 #if defined(__unix__) || defined(SVR4) || defined(BSD)
76 # include <sys/time.h>
79 double GetRealTime ( void ) /* conforming: SVr4, BSD 4.3 */
83 if ( 0 != gettimeofday (&t
, NULL
) )
85 return t
.tv_sec
+ 1.e
-6 * t
.tv_usec
;
88 #elif defined(WIN16) || defined(WIN32)
91 # include <sys/types.h>
92 # include <sys/timeb.h>
94 double GetRealTime ( void ) /* conforming: Win 95, Win NT */
99 return t
.time
+ 1.e
-3 * t
.millitm
;
104 double GetRealTime ( void ) /* conforming: SVr4, SVID, POSIX, X/OPEN, BSD 4.3 */
105 { /* BUT NOT GUARANTEED BY ANSI */
115 #if defined(_WIN32) || defined(__CYGWIN__)
122 int lame_set_stream_binary_mode ( FILE* const fp
)
125 _fsetmode ( fp
, "b" );
126 #elif defined __BORLANDC__
127 setmode (_fileno(fp
), O_BINARY
);
128 #elif defined __CYGWIN__
129 setmode ( fileno(fp
), _O_BINARY
);
131 _setmode (_fileno(fp
), _O_BINARY
);
137 #if defined(__riscos__)
139 # include <sys/swis.h>
140 #elif defined(_WIN32)
141 # include <sys/types.h>
142 # include <sys/stat.h>
144 # include <sys/stat.h>
147 off_t
lame_get_file_size ( const char* const filename
)
151 if ( 0 == stat ( filename
, &sb
) )
156 /* End of lametime.c */