Take care of IN_LIBINTL situation.
[gnulib.git] / tests / test-gettimeofday.c
1 /*
2  * Copyright (C) 2005, 2007 Free Software Foundation
3  * Written by Jim Meyering.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA.  */
19
20 #include <config.h>
21
22 #include <sys/time.h>
23 #include <time.h>
24
25 #include <stdio.h>
26 #include <string.h>
27
28 int
29 main (int argc, char *argv[])
30 {
31   time_t t = 0;
32   struct tm *lt;
33   struct tm saved_lt;
34   struct timeval tv;
35   lt = localtime (&t);
36   saved_lt = *lt;
37   gettimeofday (&tv, NULL);
38   if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0)
39     {
40       fprintf (stderr, "gettimeofday still clobbers the localtime buffer!\n");
41       return 1;
42     }
43   else
44     {
45       return 0;
46     }
47 }