Mercurial > hg > octave-jordi > gnulib-hg
annotate tests/test-gettimeofday.c @ 7907:1be30ef548f5
Make it compile again. suseconds_t does not exist on Cygwin.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 19 Jan 2007 02:18:25 +0000 |
parents | b7a83a69ac23 |
children | bbbbbf4cd1c5 |
rev | line source |
---|---|
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
1 /* |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
2 * Copyright (C) 2005, 2007 Free Software Foundation |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
3 * Written by Jim Meyering. |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
4 * |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
7 * the Free Software Foundation; either version 2, or (at your option) |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
8 * any later version. |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
9 * |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
14 * |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
18 * 02110-1301, USA. */ |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
19 |
7891
83934c71372e
Various fixes to Martin Lambers' gettimeofday patch.
Bruno Haible <bruno@clisp.org>
parents:
7890
diff
changeset
|
20 #include <config.h> |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
21 |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
22 #include <sys/time.h> |
7907
1be30ef548f5
Make it compile again. suseconds_t does not exist on Cygwin.
Bruno Haible <bruno@clisp.org>
parents:
7897
diff
changeset
|
23 #include <time.h> |
7897
b7a83a69ac23
* MODULES.html.sh (Support for systems lacking POSIX:2001): New
Paul Eggert <eggert@cs.ucla.edu>
parents:
7891
diff
changeset
|
24 |
7890
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
25 #include <stdio.h> |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
26 #include <string.h> |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
27 |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
28 int |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
29 main (int argc, char *argv[]) |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
30 { |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
31 time_t t = 0; |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
32 struct tm *lt; |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
33 struct tm saved_lt; |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
34 struct timeval tv; |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
35 lt = localtime (&t); |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
36 saved_lt = *lt; |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
37 gettimeofday (&tv, NULL); |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
38 if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0) |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
39 { |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
40 fprintf (stderr, "gettimeofday still clobbers the localtime buffer!\n"); |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
41 return 1; |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
42 } |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
43 else |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
44 { |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
45 return 0; |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
46 } |
99d5ec1dbe15
Patch from Martin Lambers <marlam@marlam.de>, from 2005-10-08
Bruno Haible <bruno@clisp.org>
parents:
diff
changeset
|
47 } |