aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/times.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2004-01-19 05:46:54 +0000
committerChristopher Faylor <me@cgf.cx>2004-01-19 05:46:54 +0000
commitf6936c48f382a12b7b67fda40352b8e377662743 (patch)
tree7626bb0ad181997983640b51113c01231992c729 /winsup/cygwin/times.cc
parent49fec4c011d14ee74fa4811559009c623ceab82e (diff)
downloadnewlib-f6936c48f382a12b7b67fda40352b8e377662743.zip
newlib-f6936c48f382a12b7b67fda40352b8e377662743.tar.gz
newlib-f6936c48f382a12b7b67fda40352b8e377662743.tar.bz2
* cygwin/include/signal.h: Add copyright notice.
* cygwin.din: Make clock SIGFE. Add clock_gettime, sigwaitinfo, timer_create, timer_delete, timer_settime. * include/cygwin/version.h: Reflect above additions. * fork.cc (fork_child): Call fixup_timers_after_fork. * signal.cc (sigwait): Remove unused variable. * timer.cc: New file. (clock_gettime): Define new function. (timer_tracker): Define new struct used by timer functions. (timer_tracker::timer_tracker): New function. (to_us): New function. (timer_thread): New function. (timer_tracker::settime): New function. (timer_create): New function. (timer_settime): New function. (timer_delete): New function. (fixup_timers_after_fork): New function. * cygthread.cc: Bump thread count. * signal.cc (sigwaitinfo): Define new function. (sigwait): Redefine based on sigwaitinfo. * include/cygwin/signal.h (sigwaitinfo): Declare. (sigwait): Ditto. * dtable.cc (dtable::vfork_parent_restore): Avoid double close of ctty when ctty == ctty_on_hold. * cygtls.h (_threadinfo::threadkill): New element. (_threadinfo::set_threadkill): Declare new function. (_threadinfo::reset_threadkill): Declare new function. * dcrt0.cc (dcrt0_1): Call here so that it will be possible to attach to running process with #(*& Windows Me/9x. (initial_env): Try to initialize strace if uninitialized. * gendef: Don't zero signal if threadkill is set since that will happen in the called function. * signal.cc (sigwait): Ensure cleanup in error conditions. * sigproc.cc (sig_send): Clear packet mask storage. (wait_subproc): Fill in child exit code in siginfo_t structure. * thread.cc (pthread_kill): Set threadkill flag. * tlsoffsets.h: Regenerate. Throughout, use siginfo_t to fill out all signal information for "kernel" signals. * cygtls.h (_threadinfo::set_siginfo): Declare new function. * cygtls.cc (_threadinfo::set_siginfo): Define new function. * dcrt0.cc (do_exit): Accommodate siginfo_t considerations. * exceptions.cc (handle_exceptions): Ditto. (sig_handle_tty_stop): Ditto. (ctrl_c_handler): Use killsys() to send signal. (sigpacket::process): Rename from sig_handle. Use siginfo_t field from sigpacket for everything. (tty_min::kill_pgrp): Accommodate siginfo_t considerations. (fhandler_termios::bg_check): Ditto. * fhandler_tty.cc (fhandler_tty_slave::ioctl): Use killsys() to send signal. * signal.cc (kill_worker): Rewrite to use siginfo_t second argument. (kill_pgrp): Ditto. (kill0): Define new function pulled from kill(). (kill): Rewrite as frontend to kill0. (killsys): Define new function. * sigproc.cc (sigelem): Eliminate. (sigpacket): Move to sigproc.h. Subsume sigelem. (pending_signals): Use sigpacket rather than sigelem for everything. (sig_clear): Ditto. (wait_sig): Ditto. (sig_send): Rewrite to use siginfo_t argument. (sig_send): New function wratpper to sig_send with siginfo_t argument. (wait_subproc): Accommodate siginfo_t considerations. * thread.cc (pthread_kill): Ditto. * sigproc.h (sigpacket): Move here. (sigpacket::process): Declare "new" function. (sig_handle): Eliminate declaration. (sig_send): Declare with new paramaters. (killsys): Declare new function. (kill_pgrp): Declare. * winsup.h: Move some signal-specific stuff to sigproc.h. * include/cygwin/signal.h: Tweak some siginfo_t stuff.
Diffstat (limited to 'winsup/cygwin/times.cc')
-rw-r--r--winsup/cygwin/times.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 46e0243..635d05a 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -1,6 +1,6 @@
/* times.cc
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
This file is part of Cygwin.
@@ -15,6 +15,7 @@ details. */
#include <utime.h>
#include <stdio.h>
#include <stdlib.h>
+#include <pthread.h>
#include "cygerrno.h"
#include "security.h"
#include "path.h"
@@ -22,6 +23,9 @@ details. */
#include "pinfo.h"
#include "hires.h"
#include "cygtls.h"
+#include "cygthread.h"
+#include "sigproc.h"
+#include "sync.h"
#define FACTOR (0x19db1ded53e8000LL)
#define NSPERSEC 10000000LL
@@ -612,7 +616,8 @@ hires_us::usecs (bool justdelta)
// FIXME: Use round() here?
now.QuadPart = (LONGLONG) (freq * (double) (now.QuadPart - primed_pc.QuadPart));
- return justdelta ? now.QuadPart : primed_ft.QuadPart + now.QuadPart;
+ LONGLONG res = justdelta ? now.QuadPart : primed_ft.QuadPart + now.QuadPart;
+ return res;
}
UINT
@@ -657,3 +662,21 @@ hires_ms::usecs (bool justdelta)
LONGLONG res = initime_us.QuadPart + ((LONGLONG) (now - initime_ms) * 1000);
return res;
}
+
+extern "C" int
+clock_gettime (clockid_t clk_id, struct timespec *tp)
+{
+ if (clk_id != CLOCK_REALTIME)
+ {
+ set_errno (ENOSYS);
+ return -1;
+ }
+
+ LONGLONG now = gtod.usecs (false);
+ if (now == (LONGLONG) -1)
+ return -1;
+
+ tp->tv_sec = now / 1000000;
+ tp->tv_nsec = (now % 1000000) * 1000;
+ return 0;
+}