X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Feglib%2Fgdate-unix.c;fp=mono%2Feglib%2Fgdate-unix.c;h=5573e0d3570f566dee6f6db31dd7825e51475cca;hb=9be68f8952ea0e1aad582bfe2f47bad71aee2cc7;hp=0000000000000000000000000000000000000000;hpb=f1ff42789be45c30cf3537ee986529179870df1e;p=mono.git diff --git a/mono/eglib/gdate-unix.c b/mono/eglib/gdate-unix.c new file mode 100644 index 00000000000..5573e0d3570 --- /dev/null +++ b/mono/eglib/gdate-unix.c @@ -0,0 +1,55 @@ +/* + * gdate-unix.c: Date and time utility functions. + * + * Author: + * Gonzalo Paniagua Javier (gonzalo@novell.com + * + * (C) 2006 Novell, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#include +#include +#include +#include +#include + +void +g_get_current_time (GTimeVal *result) +{ + struct timeval tv; + + g_return_if_fail (result != NULL); + gettimeofday (&tv, NULL); + result->tv_sec = tv.tv_sec; + result->tv_usec = tv.tv_usec; +} + +void +g_usleep (gulong microseconds) +{ + struct timespec req, rem; + + req.tv_sec = microseconds / 1000000; + req.tv_nsec = (microseconds % 1000000) * 1000; + + while (nanosleep (&req, &rem) == -1 && errno == EINTR) + req = rem; +}