1 /*
2 Copyright (c) 1994 Cygnus Support.
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms are permitted
6 provided that the above copyright notice and this paragraph are
7 duplicated in all such forms and that any documentation,
8 and/or other materials related to such
9 distribution and use acknowledge that the software was developed
10 at Cygnus Support, Inc.  Cygnus Support, Inc. may not be used to
11 endorse or promote products derived from this software without
12 specific prior written permission.
13 THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16 */
17 /*
18  * asctime.c
19  * Original Author:	G. Haley
20  *
21  * Converts the broken down time in the structure pointed to by tim_p into a
22  * string of the form
23  *
24  * Wed Jun 15 11:38:07 1988\n\0
25  *
26  * Returns a pointer to the string.
27  */
28 
29 /*
30 FUNCTION
31 <<asctime>>---format time as string
32 
33 INDEX
34 	asctime
35 INDEX
36 	_asctime_r
37 
38 SYNOPSIS
39 	#include <time.h>
40 	char *asctime(const struct tm *<[clock]>);
41 	char *_asctime_r(const struct tm *<[clock]>, char *<[buf]>);
42 
43 DESCRIPTION
44 Format the time value at <[clock]> into a string of the form
45 . Wed Jun 15 11:38:07 1988\n\0
46 The string is generated in a static buffer; each call to <<asctime>>
47 overwrites the string generated by previous calls.
48 
49 RETURNS
50 A pointer to the string containing a formatted timestamp.
51 
52 PORTABILITY
53 ANSI C requires <<asctime>>.
54 
55 <<asctime>> requires no supporting OS subroutines.
56 */
57 
58 #include <stdlib.h>
59 #include <string.h>
60 #include <time.h>
61 #include <_ansi.h>
62 
63 #ifndef _REENT_ONLY
64 
65 #define _ASCTIME_SIZE 26
66 
67 static NEWLIB_THREAD_LOCAL char _asctime_buf[_ASCTIME_SIZE];
68 
69 char *
asctime(const struct tm * tim_p)70 asctime (const struct tm *tim_p)
71 {
72   return asctime_r (tim_p, (char * __restrict) &_asctime_buf);
73 }
74 
75 #endif
76