* times.cc (settimeofday): Add EFAULT handler.
Set errno to EINVAL if tv.tv_nsec is invalid, and to EPERM if SetSystemTime fails. Return -1 in case of failure, all for compatibility with BSD and Linux. (clock_settime): New function. * cygwin.din (clock_settime): Export. * posix.sgml (std-susv4): Add clock_settime. Move clock_setres from here... (std-deprec): ... to here. (std-notes): Correct limitation of clock_setres to only CLOCK_REALTIME. Add limitation of clock_settime to only CLOCK_REALTIME. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
This commit is contained in:
parent
b6a46e417b
commit
6758d2a3aa
|
@ -1,3 +1,18 @@
|
|||
2011-05-08 Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
|
||||
|
||||
* times.cc (settimeofday): Add EFAULT handler.
|
||||
Set errno to EINVAL if tv.tv_nsec is invalid, and to EPERM if
|
||||
SetSystemTime fails. Return -1 in case of failure, all for
|
||||
compatibility with BSD and Linux.
|
||||
(clock_settime): New function.
|
||||
* cygwin.din (clock_settime): Export.
|
||||
* posix.sgml (std-susv4): Add clock_settime.
|
||||
Move clock_setres from here...
|
||||
(std-deprec): ... to here.
|
||||
(std-notes): Correct limitation of clock_setres to only CLOCK_REALTIME.
|
||||
Add limitation of clock_settime to only CLOCK_REALTIME.
|
||||
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
|
||||
|
||||
2011-05-07 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* registry.cc (get_registry_hive_path): Change system_printf to
|
||||
|
|
|
@ -220,6 +220,7 @@ _clock = clock SIGFE
|
|||
clock_getres SIGFE
|
||||
clock_gettime SIGFE
|
||||
clock_setres SIGFE
|
||||
clock_settime SIGFE
|
||||
clog NOSIGFE
|
||||
clogf NOSIGFE
|
||||
close SIGFE
|
||||
|
|
|
@ -409,12 +409,13 @@ details. */
|
|||
pthread_getattr_np.
|
||||
242: Export psiginfo, psignal, sys_siglist.
|
||||
243: Export sysinfo.
|
||||
244: Export clock_settime.
|
||||
*/
|
||||
|
||||
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
|
||||
|
||||
#define CYGWIN_VERSION_API_MAJOR 0
|
||||
#define CYGWIN_VERSION_API_MINOR 243
|
||||
#define CYGWIN_VERSION_API_MINOR 244
|
||||
|
||||
/* There is also a compatibity version number associated with the
|
||||
shared memory regions. It is incremented when incompatible
|
||||
|
|
|
@ -92,7 +92,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
|
|||
clock
|
||||
clock_getres (see chapter "Implementation Notes")
|
||||
clock_gettime (see chapter "Implementation Notes")
|
||||
clock_setres (see chapter "Implementation Notes")
|
||||
clock_settime (see chapter "Implementation Notes")
|
||||
clog
|
||||
clogf
|
||||
close
|
||||
|
@ -1214,6 +1214,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
|
|||
bcmp (POSIX.1-2001, SUSv3)
|
||||
bcopy (SUSv3)
|
||||
bzero (SUSv3)
|
||||
clock_setres (QNX, VxWorks) (see chapter "Implementation Notes")
|
||||
cuserid (POSIX.1-1988, SUSv2)
|
||||
ecvt (SUSv3)
|
||||
endutent (XPG2)
|
||||
|
@ -1439,9 +1440,9 @@ by keeping track of the current root and accomodating this in the file
|
|||
related function calls. A real chroot functionality is not supported by
|
||||
Windows however.</para>
|
||||
|
||||
<para><function>clock_getres</function>, <function>clock_gettime</function>
|
||||
and <function>clock_setres</function> only support CLOCK_REALTIME and
|
||||
CLOCK_MONOTONIC for now.</para>
|
||||
<para><function>clock_getres</function> and <function>clock_gettime</function>
|
||||
only support CLOCK_REALTIME and CLOCK_MONOTONIC for now. <function>clock_setres</function>
|
||||
and <function>clock_settime</function> only support CLOCK_REALTIME.</para>
|
||||
|
||||
<para>BSD file locks created via <function>flock</function> are not
|
||||
propagated to the parent process and sibling processes. The locks are
|
||||
|
|
|
@ -109,7 +109,15 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
|
|||
struct tm *ptm;
|
||||
int res;
|
||||
|
||||
tz = tz; /* silence warning about unused variable */
|
||||
myfault efault;
|
||||
if (efault.faulted (EFAULT))
|
||||
return -1;
|
||||
|
||||
if (tv->tv_usec < 0 || tv->tv_usec >= 1000000)
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ptm = gmtime (&tv->tv_sec);
|
||||
st.wYear = ptm->tm_year + 1900;
|
||||
|
@ -121,11 +129,14 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
|
|||
st.wSecond = ptm->tm_sec;
|
||||
st.wMilliseconds = tv->tv_usec / 1000;
|
||||
|
||||
res = !SetSystemTime (&st);
|
||||
res = -!SetSystemTime (&st);
|
||||
gtod.reset ();
|
||||
|
||||
syscall_printf ("%d = settimeofday (%x, %x)", res, tv, tz);
|
||||
|
||||
if (res != 0)
|
||||
set_errno (EPERM);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -614,6 +625,23 @@ clock_gettime (clockid_t clk_id, struct timespec *tp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
clock_settime (clockid_t clk_id, const struct timespec *tp)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (clk_id != CLOCK_REALTIME)
|
||||
{
|
||||
set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tv.tv_sec = tp->tv_sec;
|
||||
tv.tv_usec = tp->tv_nsec / 1000;
|
||||
|
||||
return settimeofday (&tv, NULL);
|
||||
}
|
||||
|
||||
static DWORD minperiod; // FIXME: Maintain period after a fork.
|
||||
|
||||
LONGLONG
|
||||
|
|
Loading…
Reference in New Issue