Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/time localtime.c: add back storage class 'register'
details: https://anonhg.NetBSD.org/src/rev/ede21f08823d
branches: trunk
changeset: 364444:ede21f08823d
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Mar 25 18:35:50 2022 +0000
description:
localtime.c: add back storage class 'register'
This reduces the differences to the upstream code.
No binary change.
diffstat:
lib/libc/time/localtime.c | 182 +++++++++++++++++++++++----------------------
1 files changed, 92 insertions(+), 90 deletions(-)
diffs (truncated from 491 to 300 lines):
diff -r 6884373a760e -r ede21f08823d lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Fri Mar 25 12:24:44 2022 +0000
+++ b/lib/libc/time/localtime.c Fri Mar 25 18:35:50 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: localtime.c,v 1.129 2022/03/24 16:15:05 christos Exp $ */
+/* $NetBSD: localtime.c,v 1.130 2022/03/25 18:35:50 rillig Exp $ */
/* Convert timestamp from time_t to struct tm. */
@@ -12,7 +12,7 @@
#if 0
static char elsieid[] = "@(#)localtime.c 8.17";
#else
-__RCSID("$NetBSD: localtime.c,v 1.129 2022/03/24 16:15:05 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.130 2022/03/25 18:35:50 rillig Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -257,8 +257,8 @@
static int_fast32_t
detzcode(const char *const codep)
{
- int_fast32_t result;
- int i;
+ register int_fast32_t result;
+ register int i;
int_fast32_t one = 1;
int_fast32_t halfmaxval = one << (32 - 2);
int_fast32_t maxval = halfmaxval - 1 + halfmaxval;
@@ -280,8 +280,8 @@
static int_fast64_t
detzcode64(const char *const codep)
{
- int_fast64_t result;
- int i;
+ register int_fast64_t result;
+ register int i;
int_fast64_t one = 1;
int_fast64_t halfmaxval = one << (64 - 2);
int_fast64_t maxval = halfmaxval - 1 + halfmaxval;
@@ -354,8 +354,8 @@
static void
settzname(void)
{
- timezone_t const sp = __lclptr;
- int i;
+ register timezone_t const sp = __lclptr;
+ register int i;
#if HAVE_TZNAME
tzname[0] = tzname[1] =
@@ -378,7 +378,9 @@
update_tzname_etc(sp, &sp->ttis[i]);
for (i = 0; i < sp->timecnt; ++i) {
- const struct ttinfo * const ttisp = &sp->ttis[sp->types[i]];
+ register const struct ttinfo * const ttisp =
+ &sp->ttis[
+ sp->types[i]];
update_tzname_etc(sp, ttisp);
#if USG_COMPAT
if (ttisp->tt_isdst)
@@ -401,7 +403,7 @@
** Second, truncate long abbreviations.
*/
for (i = 0; i < sp->typecnt; ++i) {
- const struct ttinfo * const ttisp = &sp->ttis[i];
+ register const struct ttinfo * const ttisp = &sp->ttis[i];
char *cp = &sp->chars[ttisp->tt_desigidx];
if (strlen(cp) > TZ_ABBR_MAX_LEN &&
@@ -446,13 +448,13 @@
tzloadbody(char const *name, struct state *sp, bool doextend,
union local_storage *lsp)
{
- int i;
- int fid;
- int stored;
- ssize_t nread;
- bool doaccess;
- union input_buffer *up = &lsp->u.u;
- size_t tzheadsize = sizeof(struct tzhead);
+ register int i;
+ register int fid;
+ register int stored;
+ register ssize_t nread;
+ register bool doaccess;
+ register union input_buffer *up = &lsp->u.u;
+ register size_t tzheadsize = sizeof(struct tzhead);
sp->goback = sp->goahead = false;
@@ -588,7 +590,7 @@
}
sp->timecnt = timecnt;
for (i = 0; i < sp->typecnt; ++i) {
- struct ttinfo * ttisp;
+ register struct ttinfo * ttisp;
unsigned char isdst, desigidx;
ttisp = &sp->ttis[i];
@@ -645,7 +647,7 @@
sp->leapcnt = leapcnt;
for (i = 0; i < sp->typecnt; ++i) {
- struct ttinfo * ttisp;
+ register struct ttinfo * ttisp;
ttisp = &sp->ttis[i];
if (ttisstdcnt == 0)
@@ -657,7 +659,7 @@
}
}
for (i = 0; i < sp->typecnt; ++i) {
- struct ttinfo * ttisp;
+ register struct ttinfo * ttisp;
ttisp = &sp->ttis[i];
if (ttisutcnt == 0)
@@ -841,15 +843,15 @@
static bool
typesequiv(const struct state *sp, int a, int b)
{
- bool result;
+ register bool result;
if (sp == NULL ||
a < 0 || a >= sp->typecnt ||
b < 0 || b >= sp->typecnt)
result = false;
else {
- const struct ttinfo * ap = &sp->ttis[a];
- const struct ttinfo * bp = &sp->ttis[b];
+ register const struct ttinfo * ap = &sp->ttis[a];
+ register const struct ttinfo * bp = &sp->ttis[b];
result = (ap->tt_utoff == bp->tt_utoff
&& ap->tt_isdst == bp->tt_isdst
&& ap->tt_ttisstd == bp->tt_ttisstd
@@ -884,9 +886,9 @@
*/
static ATTRIBUTE_PURE const char *
-getzname(const char *strp)
+getzname(register const char *strp)
{
- char c;
+ register char c;
while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
c != '+')
@@ -905,9 +907,9 @@
*/
static ATTRIBUTE_PURE const char *
-getqzname(const char *strp, const int delim)
+getqzname(register const char *strp, const int delim)
{
- int c;
+ register int c;
while ((c = *strp) != '\0' && c != delim)
++strp;
@@ -922,10 +924,10 @@
*/
static const char *
-getnum(const char *strp, int *const nump, const int min, const int max)
+getnum(register const char *strp, int *const nump, const int min, const int max)
{
- char c;
- int num;
+ register char c;
+ register int num;
if (strp == NULL || !is_digit(c = *strp)) {
errno = EINVAL;
@@ -957,7 +959,7 @@
*/
static const char *
-getsecs(const char *strp, int_fast32_t *const secsp)
+getsecs(register const char *strp, int_fast32_t *const secsp)
{
int num;
int_fast32_t secsperhour = SECSPERHOUR;
@@ -998,9 +1000,9 @@
*/
static const char *
-getoffset(const char *strp, int_fast32_t *const offsetp)
+getoffset(register const char *strp, int_fast32_t *const offsetp)
{
- bool neg = false;
+ register bool neg = false;
if (*strp == '-') {
neg = true;
@@ -1023,7 +1025,7 @@
*/
static const char *
-getrule(const char *strp, struct rule *const rulep)
+getrule(const char *strp, register struct rule *const rulep)
{
if (*strp == 'J') {
/*
@@ -1074,12 +1076,12 @@
*/
static int_fast32_t
-transtime(const int year, const struct rule *const rulep,
+transtime(const int year, register const struct rule *const rulep,
const int_fast32_t offset)
{
- bool leapyear;
- int_fast32_t value;
- int i;
+ register bool leapyear;
+ register int_fast32_t value;
+ register int i;
int d, m1, yy0, yy1, yy2, dow;
leapyear = isleap(year);
@@ -1175,8 +1177,8 @@
size_t charcnt;
int_fast32_t stdoffset;
int_fast32_t dstoffset;
- char * cp;
- bool load_ok;
+ register char * cp;
+ register bool load_ok;
time_t atlo = TIME_T_MIN, leaplo = TIME_T_MIN;
dstname = NULL; /* XXX gcc */
@@ -1242,8 +1244,8 @@
if (*name == ',' || *name == ';') {
struct rule start;
struct rule end;
- int year;
- int timecnt;
+ register int year;
+ register int timecnt;
__time_t janfirst;
int_fast32_t janoffset = 0;
int yearbeg, yearlim;
@@ -1262,7 +1264,7 @@
** Two transitions per year, from EPOCH_YEAR forward.
*/
init_ttinfo(&sp->ttis[0], -stdoffset, false, 0);
- init_ttinfo(&sp->ttis[1], -dstoffset, true,
+ init_ttinfo(&sp->ttis[1], -dstoffset, true,
(int)(stdlen + 1));
sp->defaulttype = 0;
timecnt = 0;
@@ -1346,12 +1348,12 @@
} else if (YEARSPERREPEAT < year - yearbeg)
sp->goback = sp->goahead = true;
} else {
- int_fast32_t theirstdoffset;
- int_fast32_t theirdstoffset;
- int_fast32_t theiroffset;
- bool isdst;
- int i;
- int j;
+ register int_fast32_t theirstdoffset;
+ register int_fast32_t theirdstoffset;
+ register int_fast32_t theiroffset;
+ register bool isdst;
+ register int i;
+ register int j;
if (*name != '\0')
return false;
@@ -1482,7 +1484,7 @@
return err;
}
}
-
+
static void
tzsetlcl(char const *name)
{
@@ -1557,7 +1559,7 @@
}
}
#if !HAVE_MALLOC_ERRNO
- } else
+ } else
errno = ENOMEM;
#endif
return sp;
@@ -1600,9 +1602,9 @@
localsub(struct state const *sp, time_t const *timep, int_fast32_t setname,
struct tm *const tmp)
{
- const struct ttinfo * ttisp;
- int i;
- struct tm * result;
+ register const struct ttinfo * ttisp;
+ register int i;
Home |
Main Index |
Thread Index |
Old Index