Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1e4c33b1
Commit
1e4c33b1
authored
Sep 02, 2004
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix getrusage() emulation on Windows. Magnus Hagander
parent
3cc21343
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
5 deletions
+38
-5
src/port/getrusage.c
src/port/getrusage.c
+38
-5
No files found.
src/port/getrusage.c
View file @
1e4c33b1
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/getrusage.c,v 1.
6 2004/08/29 04:13:12 momjian
Exp $
* $PostgreSQL: pgsql/src/port/getrusage.c,v 1.
7 2004/09/02 17:55:16 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -26,6 +26,7 @@
* solaris_sparc
* svr4
* hpux 9.*
* win32
* which currently is all the supported platforms that don't have a
* native version of getrusage(). So, if configure decides to compile
* this file at all, we just use this version unconditionally.
...
...
@@ -35,9 +36,39 @@ int
getrusage
(
int
who
,
struct
rusage
*
rusage
)
{
#ifdef WIN32
if
(
rusage
)
memset
(
rusage
,
0
,
sizeof
(
rusage
));
#else
FILETIME
starttime
;
FILETIME
exittime
;
FILETIME
kerneltime
;
FILETIME
usertime
;
ULARGE_INTEGER
li
;
if
(
rusage
==
(
struct
rusage
*
)
NULL
)
{
errno
=
EFAULT
;
return
-
1
;
}
memset
(
rusage
,
0
,
sizeof
(
struct
rusage
));
if
(
GetProcessTimes
(
GetCurrentProcess
(),
&
starttime
,
&
exittime
,
&
kerneltime
,
&
usertime
)
==
0
)
{
_dosmaperr
(
GetLastError
());
return
-
1
;
}
/* Convert FILETIMEs (0.1 us) to struct timeval */
memcpy
(
&
li
,
&
kerneltime
,
sizeof
(
FILETIME
));
li
.
QuadPart
/=
10L
;
/* Convert to microseconds */
rusage
->
ru_stime
.
tv_sec
=
li
.
QuadPart
/
1000000L
;
rusage
->
ru_stime
.
tv_usec
=
li
.
QuadPart
%
1000000L
;
memcpy
(
&
li
,
&
usertime
,
sizeof
(
FILETIME
));
li
.
QuadPart
/=
10L
;
/* Convert to microseconds */
rusage
->
ru_utime
.
tv_sec
=
li
.
QuadPart
/
1000000L
;
rusage
->
ru_utime
.
tv_usec
=
li
.
QuadPart
%
1000000L
;
#else
/* all but WIN32 */
struct
tms
tms
;
int
tick_rate
=
CLK_TCK
;
/* ticks per second */
clock_t
u
,
...
...
@@ -73,6 +104,8 @@ getrusage(int who, struct rusage * rusage)
rusage
->
ru_utime
.
tv_usec
=
TICK_TO_USEC
(
u
,
tick_rate
);
rusage
->
ru_stime
.
tv_sec
=
TICK_TO_SEC
(
s
,
tick_rate
);
rusage
->
ru_stime
.
tv_usec
=
TICK_TO_USEC
(
u
,
tick_rate
);
#endif
#endif
/* WIN32 */
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment