1 /*
2 * Copyright (c) 2004, Bull S.A.. All rights reserved.
3 * Created by: Sebastien Decugis
4
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17
18 * This file is a wrapper to use the tests from the NPTL Test & Trace Project
19 * with either the Linux Test Project or the Open POSIX Test Suite.
20
21 * The following function are defined:
22 * void output_init()
23 * void output_fini()
24 * void output(char * string, ...)
25 *
26 * The are used to output informative text (as a printf).
27 */
28
29 #include <time.h>
30 #include <sys/types.h>
31 #include <pthread.h>
32 #include <stdarg.h>
33
34 /* We use a mutex to avoid conflicts in traces */
35 static pthread_mutex_t m_trace = PTHREAD_MUTEX_INITIALIZER;
36
output_init(void)37 void output_init(void)
38 {
39 return;
40 }
41
output(char * string,...)42 void output(char *string, ...)
43 {
44 va_list ap;
45 struct tm *now;
46 time_t nw;
47 int oldstate;
48
49 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
50 pthread_mutex_lock(&m_trace);
51 nw = time(NULL);
52 now = localtime(&nw);
53 if (now == NULL)
54 printf("[??:??:??]");
55 else
56 printf("[%2.2d:%2.2d:%2.2d]",
57 now->tm_hour, now->tm_min, now->tm_sec);
58 va_start(ap, string);
59 vprintf(string, ap);
60 va_end(ap);
61 pthread_mutex_unlock(&m_trace);
62 pthread_setcancelstate(oldstate, NULL);
63 }
64
output_fini(void)65 void output_fini(void)
66 {
67 return;
68 }
69