Print this page
Thread safety fixes.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/port/locale/timelocal.c
+++ new/usr/src/lib/libc/port/locale/timelocal.c
1 1 /*
2 2 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
3 3 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
4 4 * Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
5 5 * Copyright (c) 1997 FreeBSD Inc.
6 6 * All rights reserved.
7 7 *
8 8 * Redistribution and use in source and binary forms, with or without
9 9 * modification, are permitted provided that the following conditions
10 10 * are met:
11 11 * 1. Redistributions of source code must retain the above copyright
12 12 * notice, this list of conditions and the following disclaimer.
13 13 * 2. Redistributions in binary form must reproduce the above copyright
14 14 * notice, this list of conditions and the following disclaimer in the
15 15 * documentation and/or other materials provided with the distribution.
16 16 *
17 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 27 * SUCH DAMAGE.
28 28 */
29 29
30 30 #include "lint.h"
31 31 #include <stddef.h>
32 32 #include <errno.h>
33 33 #include "ldpart.h"
34 34 #include "timelocal.h"
35 35 #include "localeimpl.h"
36 36
37 37 #define LCTIME_SIZE (sizeof (struct lc_time) / sizeof (char *))
38 38
39 39 struct lc_time lc_time_posix = {
40 40 {
41 41 "Jan", "Feb", "Mar", "Apr", "May", "Jun",
42 42 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
43 43 }, {
44 44 "January", "February", "March", "April", "May", "June",
45 45 "July", "August", "September", "October", "November", "December"
46 46 }, {
47 47 "Sun", "Mon", "Tue", "Wed",
48 48 "Thu", "Fri", "Sat"
49 49 }, {
50 50 "Sunday", "Monday", "Tuesday", "Wednesday",
51 51 "Thursday", "Friday", "Saturday"
52 52 },
53 53
54 54 /* X_fmt */
55 55 "%H:%M:%S",
56 56
57 57 /*
58 58 * x_fmt
59 59 * Since the C language standard calls for
60 60 * "date, using locale's date format," anything goes.
61 61 * Using just numbers (as here) makes Quakers happier;
62 62 * it's also compatible with SVR4.
63 63 */
64 64 "%m/%d/%y",
65 65
66 66 /*
67 67 * c_fmt
68 68 */
69 69 "%a %b %e %H:%M:%S %Y",
70 70
71 71 /* am */
72 72 "AM",
73 73
74 74 /* pm */
75 75 "PM",
76 76
77 77 /* date_fmt */
↓ open down ↓ |
77 lines elided |
↑ open up ↑ |
78 78 "%a %b %e %H:%M:%S %Z %Y",
79 79
80 80 /*
81 81 * ampm_fmt - To determine 12-hour clock format time (empty, if N/A)
82 82 */
83 83 "%I:%M:%S %p"
84 84 };
85 85
86 86 struct locdata __posix_time_locdata = {
87 87 .l_lname = "C",
88 - .l_refcnt = (uint32_t)-1,
89 88 .l_data = { &lc_time_posix }
90 89 };
91 90
92 91 struct locdata *
93 92 __lc_time_load(const char *name)
94 93 {
95 94 struct locdata *ldata;
96 95 struct lc_time *ltime;
97 96 int ret;
98 97
99 98 if ((ldata = __locdata_alloc(name, sizeof (*ltime))) == NULL) {
100 99 errno = EINVAL;
101 100 return (NULL);
102 101 }
103 102 ltime = ldata->l_data[0];
104 103
105 104 ret = __part_load_locale(name, (char **)&ldata->l_data[1],
106 105 "LC_TIME", LCTIME_SIZE, LCTIME_SIZE, (const char **)ltime);
107 106
108 107 if (ret != _LDP_LOADED) {
109 - __locdata_release(ldata);
108 + __locdata_free(ldata);
110 109 errno = EINVAL;
111 110 return (NULL);
112 111 }
113 112
114 113 return (ldata);
115 114 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX