CVS commit: src/sys/arch/riscv/starfive

2024-02-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  8 07:13:10 UTC 2024

Modified Files:
src/sys/arch/riscv/starfive: jh7100_pinctrl.c

Log Message:
Some fixes from Roland Illig
- fix a locking bug
- '\n' at the end of error messages


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/starfive/jh7100_pinctrl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/riscv/starfive/jh7100_pinctrl.c
diff -u src/sys/arch/riscv/starfive/jh7100_pinctrl.c:1.1 src/sys/arch/riscv/starfive/jh7100_pinctrl.c:1.2
--- src/sys/arch/riscv/starfive/jh7100_pinctrl.c:1.1	Wed Feb  7 17:17:59 2024
+++ src/sys/arch/riscv/starfive/jh7100_pinctrl.c	Thu Feb  8 07:13:10 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: jh7100_pinctrl.c,v 1.1 2024/02/07 17:17:59 skrll Exp $ */
+/* $NetBSD: jh7100_pinctrl.c,v 1.2 2024/02/08 07:13:10 skrll Exp $ */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: jh7100_pinctrl.c,v 1.1 2024/02/07 17:17:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: jh7100_pinctrl.c,v 1.2 2024/02/08 07:13:10 skrll Exp $");
 
 #include 
 
@@ -222,7 +222,7 @@ jh7100_pinctrl_pin_properties(struct jh7
 	case -1:
 		break;
 	default:
-		aprint_error_dev(sc->sc_dev, "invalid slew rate");
+		aprint_error_dev(sc->sc_dev, "invalid slew rate\n");
 	}
 
 	if (of_hasprop(phandle, "starfive,strong-pull-up")) {
@@ -322,7 +322,6 @@ jh7100_pinctrl_set_config_group(struct j
 			jh7100_padctl_rmw(sc, sc->sc_padctl_gpio + pin_no,
 			val, mask);
 		}
-
 	}
 }
 
@@ -413,7 +412,7 @@ jh7100_pinctrl_gpio_write(device_t dev, 
 
 	mutex_enter(>sc_lock);
 	GPIOWR4(sc, GPO_DOUT_CFG(pin_no), val);
-	mutex_enter(>sc_lock);
+	mutex_exit(>sc_lock);
 }
 
 static struct fdtbus_gpio_controller_func jh7100_pinctrl_gpio_funcs = {
@@ -446,7 +445,7 @@ jh7100_pinctrl_attach(device_t parent, d
 	sc->sc_bst = faa->faa_bst;
 
 	if (!of_hasprop(phandle, "gpio-controller")) {
-		aprint_error(": no gpio controller");
+		aprint_error(": no gpio controller\n");
 		return;
 	}
 
@@ -494,7 +493,7 @@ jh7100_pinctrl_attach(device_t parent, d
 		sc->sc_padctl_gpio = PAD_FUNC_SHARE(0);
 		break;
 	default:
-		aprint_error_dev(sc->sc_dev, "invalid signal group %u", sel);
+		aprint_error_dev(sc->sc_dev, "invalid signal group %u\n", sel);
 		return;
 	}
 



CVS commit: src/sys/arch/riscv/starfive

2024-02-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Feb  8 07:13:10 UTC 2024

Modified Files:
src/sys/arch/riscv/starfive: jh7100_pinctrl.c

Log Message:
Some fixes from Roland Illig
- fix a locking bug
- '\n' at the end of error messages


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/starfive/jh7100_pinctrl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:54:13 UTC 2024

Modified Files:
src/usr.bin/touch: touch.1

Log Message:
Document the -d posix-datetime arg variation, to allow specifying
fractional seconds.   (Alternate ways to achieve that for the other
ways of specifying the date and time may be forthcoming in a future
update).

Also add a warning about the (still far) future likely change of
the interpretation of 2 digit years (the coming POSIX standard
contains a similar warning).

While here, clean up wording, some macro usage, etc etc etc...


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/touch/touch.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/touch/touch.1
diff -u src/usr.bin/touch/touch.1:1.26 src/usr.bin/touch/touch.1:1.27
--- src/usr.bin/touch/touch.1:1.26	Sat Dec 24 15:49:18 2016
+++ src/usr.bin/touch/touch.1	Thu Feb  8 02:54:13 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: touch.1,v 1.26 2016/12/24 15:49:18 abhinav Exp $
+.\"	$NetBSD: touch.1,v 1.27 2024/02/08 02:54:13 kre Exp $
 .\"
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\" @(#)touch.1	8.3 (Berkeley) 4/28/95
 .\"
-.Dd December 24, 2016
+.Dd February 7, 2024
 .Dt TOUCH 1
 .Os
 .Sh NAME
@@ -41,63 +41,181 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl acfhm
-.Op Fl d Ar human-datetime
-.Op Fl Fl date Ar human-datetime
-.Op Fl r Ar file
-.Op Fl Fl reference Ar file
+.Op Fl d Ar posix-datetime|human-datetime
+.Op Fl Fl \|date Ar posix-datetime|human-datetime
+.Op Fl r Ar ref-file
+.Op Fl Fl \|reference Ar ref-file
 .Op Fl t Ar datetime
 .Ar file ...
 .Sh DESCRIPTION
 The
 .Nm
-utility changes the access and modification times of files to the
-current time of day.
-If the file doesn't exist, it is created with default permissions.
+utility changes either or both of the access and modification times of the
+.Ar file Ns s
+to the time specified by the options, described below,
+or to the current time of day, if none of those options is present.
+If the file doesn't exist, it is first created with default permissions.
 .Pp
 The following options are available:
-.Bl -tag -width "-d human-datetime"
+.Bl -tag -compact -width Fl
+.Pp
 .It Fl a
-Change the access time of the file.
-The modification time of the file is not changed unless the
+Change the access time of the
+.Ar file .
+The modification time of the
+.Ar file
+is not changed unless the
 .Fl m
 flag is also specified.
+.Pp
 .It Fl c
-Do not create the file if it does not exist.
+Do not create the
+.Ar file
+if it does not exist.
 The
 .Nm
 utility does not treat this as an error.
 No error messages are displayed and the exit value is not affected.
+.Pp
+.It Fl d Ar posix-datetime
 .It Fl d Ar human-datetime
-.It Fl Fl date Ar human-datetime
-Parse
+.It Fl Fl \|date Ar posix-datetime
+.It Fl Fl \|date Ar human-datetime
+Attempt to parse the arg
+.Ar posix-datetime
+as a POSIX time string
+.Dq CCYY\-MM\-DDThh:mm:ss[.frac][Z]
+where the minus (or hyphen)
+.Pq Sq \&\-
+and colon
+.Pq Sq \&:
+characters are literals, and:
+.Bl -bullet -compact
+.It
+.Cm CCYY
+represents a 4 (or more) digit year number,
+.It
+.Cm MM
+represents a 2 digit month number (1\-12),
+.It
+.Cm DD
+represents a 2 digit day of the month (1\-31),
+.It
+.Cm T
+represents either the character
+.Sq T
+or a single space character (in which case the
+space, at least, may need to be quoted to the shell to
+avoid the arg being split into two words),
+.It
+.Cm hh
+represents a 2 digit hour of the day (00\-23),
+.It
+.Cm mm
+represents a 2 digit minute of the hour (00\-59),
+.It
+.Cm ss
+represents a 2 digit second of the minute (00\-60)
+where 60 indicates the occurrence of a leap second,
+which POSIX systems ignore, resulting in the following
+second being generated instead (:00 of the next minute),
+.It
+.Cm .frac
+represents optional factional seconds, where the
+.Sq \&.
+can be a period
+.Pq Sq \&.
+or a comma
+.Pq Sq \&,
+and
+.Cm frac
+gives one or more digits, interpreted as if
+in a floating-point representation of the seconds,
+so 
+.Dq \&.3
+represents three tenths of a second, and
+.Dq \&,17
+represents seventeen hundredths of a second, etc.
+Note that if the period or comma is given, there
+must be at least one following digit.
+If no fraction of a second is to be specified,
+also omit the period (or comma).
+If omitted, the fractional seconds are set to 0,
+so specifying
+.Dq \&.0
+or
+.Dq \&,0
+is identical to omitting the
+.Cm \&.frac
+field entirely,
+.It
+.Cm Z
+represents an optional literal
+.Sq Z
+character, indicating the the time given is to
+be considered as a Co-ordinated Universal Time (UTC) value.
+If omitted, the time is considered as being in the local
+timezone, as specified by the
+.Ev TZ
+environment variable.
+.El
+.Pp
+Note that parsing of this string is quite strict.
+If 

CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:54:07 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
Check that mktime() (or timegm() the one time it is used) do not
alter any of the material fields of the struct tm that was handed
to it.   If any were altered, then the time string passed in was
not a valid time representation, and so should be rejected.

This one is not an invisible change, it prevents use of things like
"-t 20240230"  (which previously would have been interpreted as
"-t 20240301" - the day after the 29th of Feb in 2024).

I believe this is an improvement however, and in line with the
general intent that if you specify a date and time, that exact
date and time is what touch should be using.   It does mean that
specifying "60" for the seconds field is almost guaranteed to
fail on any POSIX system, as leap seconds simply don't exist
there (on a non-POSIX-conforming system that uses leap seconds,
the :60 should work, if specified with the correct date and time
at which the leap second actually occurs).

The one exception is when parsedate(3) is used, as that does not
do this check (which allows things like "-1 day" on the 1st of
a month to work).

(This is the last of this sequence of updates to touch.c, an
update to touch.1 follows).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/touch/touch.c
diff -u src/usr.bin/touch/touch.c:1.37 src/usr.bin/touch/touch.c:1.38
--- src/usr.bin/touch/touch.c:1.37	Thu Feb  8 02:53:53 2024
+++ src/usr.bin/touch/touch.c	Thu Feb  8 02:54:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: touch.c,v 1.37 2024/02/08 02:53:53 kre Exp $	*/
+/*	$NetBSD: touch.c,v 1.38 2024/02/08 02:54:07 kre Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)touch.c	8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.37 2024/02/08 02:53:53 kre Exp $");
+__RCSID("$NetBSD: touch.c,v 1.38 2024/02/08 02:54:07 kre Exp $");
 #endif /* not lint */
 
 #include 
@@ -67,6 +67,7 @@ static void	stime_arg1(char *, struct ti
 static void	stime_arg2(const char *, int, struct timespec *);
 static void	stime_file(const char *, struct timespec *);
 static int	stime_posix(const char *, struct timespec *);
+static int	difftm(const struct tm *, const struct tm *);
 __dead static void	usage(void);
 
 struct option touch_longopts[] = {
@@ -233,7 +234,7 @@ stime_arg0(const char *arg, struct times
 static void
 stime_arg1(char *arg, struct timespec *tsp)
 {
-	struct tm *t;
+	struct tm *t, tm;
 	time_t tmptime;
 	int yearset;
 	char *p;
@@ -290,8 +291,9 @@ stime_arg1(char *arg, struct timespec *t
 	}
 
 	t->tm_isdst = -1;		/* Figure out DST. */
+	tm = *t;
 	tsp[0].tv_sec = tsp[1].tv_sec = mktime(t);
-	if (tsp[0].tv_sec == NO_TIME)
+	if (tsp[0].tv_sec == NO_TIME || difftm(t, ))
  terr:		errx(EXIT_FAILURE, "out of range or bad time specification:\n"
 		"\t'%s' should be [[CC]YY]MMDDhhmm[.ss]", initarg);
 
@@ -301,7 +303,7 @@ stime_arg1(char *arg, struct timespec *t
 static void
 stime_arg2(const char *arg, int year, struct timespec *tsp)
 {
-	struct tm *t;
+	struct tm *t, tm;
 	time_t tmptime;
 	/* Start with the current time. */
 	tmptime = tsp[0].tv_sec;
@@ -323,8 +325,9 @@ stime_arg2(const char *arg, int year, st
 	t->tm_sec = 0;
 
 	t->tm_isdst = -1;		/* Figure out DST. */
+	tm = *t;
 	tsp[0].tv_sec = tsp[1].tv_sec = mktime(t);
-	if (tsp[0].tv_sec == NO_TIME)
+	if (tsp[0].tv_sec == NO_TIME || difftm(t, ))
 		errx(EXIT_FAILURE,
 		"out of range or bad time specification: MMDDhhmm[YY]");
 
@@ -345,7 +348,7 @@ stime_file(const char *fname, struct tim
 static int
 stime_posix(const char *arg, struct timespec *tsp)
 {
-	struct tm tm;
+	struct tm tm, tms;
 	const char *p;
 	char *ep;
 	int utc = 0;
@@ -361,6 +364,8 @@ stime_posix(const char *arg, struct time
 	if (!isdigch(arg[0]))	/* and the first must be a digit! */
 		return 0;
 
+	(void)memset(, 0, sizeof tm);
+
 	errno = 0;
 	val = strtol(arg, , 10);		/*  */
 	if (val < 0 || val > INT_MAX)
@@ -472,17 +477,46 @@ stime_posix(const char *arg, struct time
 		return 0;
 
 	tm.tm_isdst = -1;
+	tms = tm;
 	if (utc)
 		tsp[0].tv_sec = tsp[1].tv_sec = timegm();
 	else
 		tsp[0].tv_sec = tsp[1].tv_sec = mktime();
 
-	if (errno != 0 && tsp[1].tv_sec == NO_TIME)
+	if ((errno != 0 && tsp[1].tv_sec == NO_TIME) || difftm(, ))
 		return 0;
 
 	return 1;
 }
 
+/*
+ * Determine whether 2 struct tn's are different
+ * return true (1) if theu are, false (0) otherwise.
+ *
+ * Note that we only consider the fields that are set
+ * for mktime() to use - if mktime() returns them
+ * differently than was set, then there was a problem
+ * with the setting.
+ */
+static int
+difftm(const struct tm *t1, const struct tm *t2)
+{
+#define CHK(fld) do 

CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:54:13 UTC 2024

Modified Files:
src/usr.bin/touch: touch.1

Log Message:
Document the -d posix-datetime arg variation, to allow specifying
fractional seconds.   (Alternate ways to achieve that for the other
ways of specifying the date and time may be forthcoming in a future
update).

Also add a warning about the (still far) future likely change of
the interpretation of 2 digit years (the coming POSIX standard
contains a similar warning).

While here, clean up wording, some macro usage, etc etc etc...


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/touch/touch.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:54:07 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
Check that mktime() (or timegm() the one time it is used) do not
alter any of the material fields of the struct tm that was handed
to it.   If any were altered, then the time string passed in was
not a valid time representation, and so should be rejected.

This one is not an invisible change, it prevents use of things like
"-t 20240230"  (which previously would have been interpreted as
"-t 20240301" - the day after the 29th of Feb in 2024).

I believe this is an improvement however, and in line with the
general intent that if you specify a date and time, that exact
date and time is what touch should be using.   It does mean that
specifying "60" for the seconds field is almost guaranteed to
fail on any POSIX system, as leap seconds simply don't exist
there (on a non-POSIX-conforming system that uses leap seconds,
the :60 should work, if specified with the correct date and time
at which the leap second actually occurs).

The one exception is when parsedate(3) is used, as that does not
do this check (which allows things like "-1 day" on the 1st of
a month to work).

(This is the last of this sequence of updates to touch.c, an
update to touch.1 follows).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:53 UTC 2024

Modified Files:
src/usr.bin/touch: Makefile touch.c

Log Message:
Properly implement the POSIX format -d option.

Previously we have hacked that using parsedate(3) - but parsedate()
returns a time_t and consequently while it "handles" fractional seconds,
all that meant (all it really can mean) is that they're ignored.

The POSIX spec expects that (at least if the filesystem supports them)
fractional seconds can be set using the -d option.

Handle that by first attempting to parse the -d arg as a posix format
date-time string (using a reasonably strict parser), and if that fails,
then fall back on parsedate(3) to parse the arg.

If the posix format parse succeeds, the result will be the same as
parsedate(3) would return for the same string - except any fractional
seconds will be handled properly.   If it fails, then nothing changes
from what we currently do.

Note the POSIX string is
-MM-DDThh:mm:ss[.frac][Z]
where  is (at least) 4 digits (leading 0's are acceptable if
you really must!) all the MM DD hh mm ss fields are exactly 2
digits, T is either 'T' or ' ', '.' is either itself, or ',',
and 'frac' is one or more digits.  Z (if given) is 'Z'.  The
[.,]frac and Z fields are optional.   Specify a time in a
slight shorthand like 2024-2-8T7:44:20  and the POSIX parse
will fail, leaving parsedate() to handle that (which it should).
But any fractional seconds which were given would be ignored.

Doc update coming - note the doc will call the  field CCYY
instead, that's just a convenience to make other parts of what
is there make more sense - it is still one 4 (or more) digit field.

This should be an almost invisible change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/touch/Makefile
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/touch/Makefile
diff -u src/usr.bin/touch/Makefile:1.4 src/usr.bin/touch/Makefile:1.5
--- src/usr.bin/touch/Makefile:1.4	Wed Jul 25 01:23:46 2012
+++ src/usr.bin/touch/Makefile	Thu Feb  8 02:53:53 2024
@@ -1,8 +1,9 @@
-#	$NetBSD: Makefile,v 1.4 2012/07/25 01:23:46 christos Exp $
+#	$NetBSD: Makefile,v 1.5 2024/02/08 02:53:53 kre Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 PROG=	touch
 LDADD+=	-lutil
+LDADD+=	-lm
 DPADD+=	${LIBUTIL}
 
 .include 

Index: src/usr.bin/touch/touch.c
diff -u src/usr.bin/touch/touch.c:1.36 src/usr.bin/touch/touch.c:1.37
--- src/usr.bin/touch/touch.c:1.36	Thu Feb  8 02:53:40 2024
+++ src/usr.bin/touch/touch.c	Thu Feb  8 02:53:53 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: touch.c,v 1.36 2024/02/08 02:53:40 kre Exp $	*/
+/*	$NetBSD: touch.c,v 1.37 2024/02/08 02:53:53 kre Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -39,16 +39,19 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)touch.c	8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.36 2024/02/08 02:53:40 kre Exp $");
+__RCSID("$NetBSD: touch.c,v 1.37 2024/02/08 02:53:53 kre Exp $");
 #endif /* not lint */
 
 #include 
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -63,6 +66,7 @@ static void	stime_arg0(const char *, str
 static void	stime_arg1(char *, struct timespec *);
 static void	stime_arg2(const char *, int, struct timespec *);
 static void	stime_file(const char *, struct timespec *);
+static int	stime_posix(const char *, struct timespec *);
 __dead static void	usage(void);
 
 struct option touch_longopts[] = {
@@ -107,7 +111,8 @@ main(int argc, char *argv[])
 			break;
 		case 'd':
 			timeset = 1;
-			stime_arg0(optarg, ts);
+			if (!stime_posix(optarg, ts))
+stime_arg0(optarg, ts);
 			break;
 		case 'f':
 			break;
@@ -337,6 +342,147 @@ stime_file(const char *fname, struct tim
 	tsp[1] = sb.st_mtimespec;
 }
 
+static int
+stime_posix(const char *arg, struct timespec *tsp)
+{
+	struct tm tm;
+	const char *p;
+	char *ep;
+	int utc = 0;
+	long val;
+
+#define	isdigch(c)	(isdigit((int)((unsigned char)(c
+
+	if ((p = strchr(arg, '-')) == NULL)
+		return 0;
+	if (p - arg < 4)	/* at least 4 year digits required */
+		return 0;
+
+	if (!isdigch(arg[0]))	/* and the first must be a digit! */
+		return 0;
+
+	errno = 0;
+	val = strtol(arg, , 10);		/*  */
+	if (val < 0 || val > INT_MAX)
+		return 0;
+	if (*ep != '-')
+		return 0;
+	tm.tm_year = (int)val - 1900;
+
+	p = ep + 1;
+
+	if (!isdigch(*p))
+		return 0;
+	val = strtol(p, , 10);		/* MM */
+	if (val < 1 || val > 12)
+		return 0;
+	if (*ep != '-' || ep != p + 2)
+		return 0;
+	tm.tm_mon = (int)val - 1;
+
+	p = ep + 1;
+
+	if (!isdigch(*p))
+		return 0;
+	val = strtol(p, , 10);		/* DD */
+	if (val < 1 || val > 31)
+		return 0;
+	if ((*ep != 'T' && *ep != ' ') || ep != p + 2)
+		return 0;
+	tm.tm_mday = (int)val;
+
+	p = ep + 1;
+
+	if 

CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:53 UTC 2024

Modified Files:
src/usr.bin/touch: Makefile touch.c

Log Message:
Properly implement the POSIX format -d option.

Previously we have hacked that using parsedate(3) - but parsedate()
returns a time_t and consequently while it "handles" fractional seconds,
all that meant (all it really can mean) is that they're ignored.

The POSIX spec expects that (at least if the filesystem supports them)
fractional seconds can be set using the -d option.

Handle that by first attempting to parse the -d arg as a posix format
date-time string (using a reasonably strict parser), and if that fails,
then fall back on parsedate(3) to parse the arg.

If the posix format parse succeeds, the result will be the same as
parsedate(3) would return for the same string - except any fractional
seconds will be handled properly.   If it fails, then nothing changes
from what we currently do.

Note the POSIX string is
-MM-DDThh:mm:ss[.frac][Z]
where  is (at least) 4 digits (leading 0's are acceptable if
you really must!) all the MM DD hh mm ss fields are exactly 2
digits, T is either 'T' or ' ', '.' is either itself, or ',',
and 'frac' is one or more digits.  Z (if given) is 'Z'.  The
[.,]frac and Z fields are optional.   Specify a time in a
slight shorthand like 2024-2-8T7:44:20  and the POSIX parse
will fail, leaving parsedate() to handle that (which it should).
But any fractional seconds which were given would be ignored.

Doc update coming - note the doc will call the  field CCYY
instead, that's just a convenience to make other parts of what
is there make more sense - it is still one 4 (or more) digit field.

This should be an almost invisible change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/touch/Makefile
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:40 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
Sprinkle come const - but not too much of a good thing.

NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/touch/touch.c
diff -u src/usr.bin/touch/touch.c:1.35 src/usr.bin/touch/touch.c:1.36
--- src/usr.bin/touch/touch.c:1.35	Thu Feb  8 02:53:28 2024
+++ src/usr.bin/touch/touch.c	Thu Feb  8 02:53:40 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: touch.c,v 1.35 2024/02/08 02:53:28 kre Exp $	*/
+/*	$NetBSD: touch.c,v 1.36 2024/02/08 02:53:40 kre Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)touch.c	8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.35 2024/02/08 02:53:28 kre Exp $");
+__RCSID("$NetBSD: touch.c,v 1.36 2024/02/08 02:53:40 kre Exp $");
 #endif /* not lint */
 
 #include 
@@ -59,10 +59,10 @@ __RCSID("$NetBSD: touch.c,v 1.35 2024/02
 #include 
 #include 
 
-static void	stime_arg0(char *, struct timespec *);
+static void	stime_arg0(const char *, struct timespec *);
 static void	stime_arg1(char *, struct timespec *);
-static void	stime_arg2(char *, int, struct timespec *);
-static void	stime_file(char *, struct timespec *);
+static void	stime_arg2(const char *, int, struct timespec *);
+static void	stime_file(const char *, struct timespec *);
 __dead static void	usage(void);
 
 struct option touch_longopts[] = {
@@ -217,7 +217,7 @@ main(int argc, char *argv[])
 #define	ATOI2(s)	((s) += 2, ((s)[-2] - '0') * 10 + ((s)[-1] - '0'))
 
 static void
-stime_arg0(char *arg, struct timespec *tsp)
+stime_arg0(const char *arg, struct timespec *tsp)
 {
 	tsp[1].tv_sec = tsp[0].tv_sec = parsedate(arg, NULL, NULL);
 	if (tsp[0].tv_sec == NO_TIME)
@@ -294,7 +294,7 @@ stime_arg1(char *arg, struct timespec *t
 }
 
 static void
-stime_arg2(char *arg, int year, struct timespec *tsp)
+stime_arg2(const char *arg, int year, struct timespec *tsp)
 {
 	struct tm *t;
 	time_t tmptime;
@@ -327,7 +327,7 @@ stime_arg2(char *arg, int year, struct t
 }
 
 static void
-stime_file(char *fname, struct timespec *tsp)
+stime_file(const char *fname, struct timespec *tsp)
 {
 	struct stat sb;
 



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:40 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
Sprinkle come const - but not too much of a good thing.

NFCI


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:28 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
Parameterise the "if year < 69 it is 20xx and if >=69 it is 19xx" rule
to make it simpler to (eventually, many years hence) to change that rule
to be "if year is < NN it is 21xx and if >= NN it is 20xx" instead.

Avoid comparing a time_t to -1 directly, as time_t might be unsigned.
Instead define NO_TIME as ((time_t)-1) and compare with that instead.
This makes no difference at all when time_t is signed (as it is on
NetBSD).

Use "ss" rather than "SS" as the seconds indicators (in messages)
to match with hh (hours) and mm (minutes) rather than looking like
some relation to YY (year) MM (month) and DD (day).   Why this was
ever written as SS is beyond me, but it has been that way forever.
(doc update will follow).

Minor improvement to the error message if the arg to a -t option
is unable to be parsed correctly.

NMFCI (No meaningful...)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/touch/touch.c
diff -u src/usr.bin/touch/touch.c:1.34 src/usr.bin/touch/touch.c:1.35
--- src/usr.bin/touch/touch.c:1.34	Thu Feb  8 02:53:13 2024
+++ src/usr.bin/touch/touch.c	Thu Feb  8 02:53:28 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: touch.c,v 1.34 2024/02/08 02:53:13 kre Exp $	*/
+/*	$NetBSD: touch.c,v 1.35 2024/02/08 02:53:28 kre Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)touch.c	8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.34 2024/02/08 02:53:13 kre Exp $");
+__RCSID("$NetBSD: touch.c,v 1.35 2024/02/08 02:53:28 kre Exp $");
 #endif /* not lint */
 
 #include 
@@ -74,6 +74,12 @@ struct option touch_longopts[] = {
 		0 },
 };
 
+#define	YEAR_BOUNDARY		69
+#define	LOW_YEAR_CENTURY	2000	/* for 2 digit years < YEAR_BOUNDARY */
+#define	HIGH_YEAR_CENTURY	1900	/* for 2 digit years >=  "  */
+
+#define	NO_TIME		((time_t)-1)	/* time_t might be unsigned */
+
 int
 main(int argc, char *argv[])
 {
@@ -214,7 +220,7 @@ static void
 stime_arg0(char *arg, struct timespec *tsp)
 {
 	tsp[1].tv_sec = tsp[0].tv_sec = parsedate(arg, NULL, NULL);
-	if (tsp[0].tv_sec == -1)
+	if (tsp[0].tv_sec == NO_TIME)
 		errx(EXIT_FAILURE, "Could not parse `%s'", arg);
 	tsp[0].tv_nsec = tsp[1].tv_nsec = 0;
 }
@@ -226,11 +232,13 @@ stime_arg1(char *arg, struct timespec *t
 	time_t tmptime;
 	int yearset;
 	char *p;
+	char *initarg = arg;
+
 	/* Start with the current time. */
 	tmptime = tsp[0].tv_sec;
 	if ((t = localtime()) == NULL)
 		err(EXIT_FAILURE, "localtime");
-	/* [[CC]YY]MMDDhhmm[.SS] */
+	/* [[CC]YY]MMDDhhmm[.ss] */
 	if ((p = strchr(arg, '.')) == NULL)
 		t->tm_sec = 0;		/* Seconds defaults to 0. */
 	else {
@@ -251,10 +259,12 @@ stime_arg1(char *arg, struct timespec *t
 			t->tm_year += ATOI2(arg);
 		} else {
 			yearset = ATOI2(arg);
-			if (yearset < 69)
-t->tm_year = yearset + 2000 - TM_YEAR_BASE;
+			if (yearset < YEAR_BOUNDARY)
+t->tm_year = yearset +
+LOW_YEAR_CENTURY - TM_YEAR_BASE;
 			else
-t->tm_year = yearset + 1900 - TM_YEAR_BASE;
+t->tm_year = yearset +
+HIGH_YEAR_CENTURY - TM_YEAR_BASE;
 		}
 		/* FALLTHROUGH */
 	case 8:/* MMDDhhmm */
@@ -276,9 +286,9 @@ stime_arg1(char *arg, struct timespec *t
 
 	t->tm_isdst = -1;		/* Figure out DST. */
 	tsp[0].tv_sec = tsp[1].tv_sec = mktime(t);
-	if (tsp[0].tv_sec == -1)
-terr:		errx(EXIT_FAILURE,
-	"out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
+	if (tsp[0].tv_sec == NO_TIME)
+ terr:		errx(EXIT_FAILURE, "out of range or bad time specification:\n"
+		"\t'%s' should be [[CC]YY]MMDDhhmm[.ss]", initarg);
 
 	tsp[0].tv_nsec = tsp[1].tv_nsec = 0;
 }
@@ -300,18 +310,18 @@ stime_arg2(char *arg, int year, struct t
 	t->tm_min = ATOI2(arg);
 	if (year) {
 		year = ATOI2(arg);
-		if (year < 69)
-			t->tm_year = year + 2000 - TM_YEAR_BASE;
+		if (year < YEAR_BOUNDARY)
+			t->tm_year = year + LOW_YEAR_CENTURY - TM_YEAR_BASE;
 		else
-			t->tm_year = year + 1900 - TM_YEAR_BASE;
+			t->tm_year = year + HIGH_YEAR_CENTURY - TM_YEAR_BASE;
 	}
 	t->tm_sec = 0;
 
 	t->tm_isdst = -1;		/* Figure out DST. */
 	tsp[0].tv_sec = tsp[1].tv_sec = mktime(t);
-	if (tsp[0].tv_sec == -1)
+	if (tsp[0].tv_sec == NO_TIME)
 		errx(EXIT_FAILURE,
-	"out of range or illegal time specification: MMDDhhmm[yy]");
+		"out of range or bad time specification: MMDDhhmm[YY]");
 
 	tsp[0].tv_nsec = tsp[1].tv_nsec = 0;
 }



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:28 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
Parameterise the "if year < 69 it is 20xx and if >=69 it is 19xx" rule
to make it simpler to (eventually, many years hence) to change that rule
to be "if year is < NN it is 21xx and if >= NN it is 20xx" instead.

Avoid comparing a time_t to -1 directly, as time_t might be unsigned.
Instead define NO_TIME as ((time_t)-1) and compare with that instead.
This makes no difference at all when time_t is signed (as it is on
NetBSD).

Use "ss" rather than "SS" as the seconds indicators (in messages)
to match with hh (hours) and mm (minutes) rather than looking like
some relation to YY (year) MM (month) and DD (day).   Why this was
ever written as SS is beyond me, but it has been that way forever.
(doc update will follow).

Minor improvement to the error message if the arg to a -t option
is unable to be parsed correctly.

NMFCI (No meaningful...)


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:13 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
KNF (space after keyword, and 80 column police).

NFCI

(This is the first of a series of changes to be committed
in rapid sequence).


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/touch/touch.c
diff -u src/usr.bin/touch/touch.c:1.33 src/usr.bin/touch/touch.c:1.34
--- src/usr.bin/touch/touch.c:1.33	Mon Mar  2 03:17:24 2015
+++ src/usr.bin/touch/touch.c	Thu Feb  8 02:53:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: touch.c,v 1.33 2015/03/02 03:17:24 enami Exp $	*/
+/*	$NetBSD: touch.c,v 1.34 2024/02/08 02:53:13 kre Exp $	*/
 
 /*
  * Copyright (c) 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)touch.c	8.2 (Berkeley) 4/28/95";
 #endif
-__RCSID("$NetBSD: touch.c,v 1.33 2015/03/02 03:17:24 enami Exp $");
+__RCSID("$NetBSD: touch.c,v 1.34 2024/02/08 02:53:13 kre Exp $");
 #endif /* not lint */
 
 #include 
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
 
 	while ((ch = getopt_long(argc, argv, "acd:fhmr:t:", touch_longopts,
 	NULL)) != -1)
-		switch(ch) {
+		switch (ch) {
 		case 'a':
 			aflag = 1;
 			break;
@@ -331,7 +331,7 @@ static void
 usage(void)
 {
 	(void)fprintf(stderr,
-	"Usage: %s [-acfhm] [-d|--date datetime] [-r|--reference file] [-t time] file ...\n",
-	getprogname());
+	"Usage: %s [-acfhm] [-d|--date datetime] [-r|--reference file]"
+	" [-t time] file ...\n", getprogname());
 	exit(EXIT_FAILURE);
 }



CVS commit: src/usr.bin/touch

2024-02-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  8 02:53:13 UTC 2024

Modified Files:
src/usr.bin/touch: touch.c

Log Message:
KNF (space after keyword, and 80 column police).

NFCI

(This is the first of a series of changes to be committed
in rapid sequence).


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/touch/touch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/xlint/lint1

2024-02-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 22:59:28 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_ilp32_trad.c

Log Message:
tests/lint: sync test for integer constant type on ILP32 platforms

The test was broken since lex.c 1.214 from today.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_ilp32_trad.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/platform_ilp32_trad.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ilp32_trad.c:1.3 src/tests/usr.bin/xlint/lint1/platform_ilp32_trad.c:1.4
--- src/tests/usr.bin/xlint/lint1/platform_ilp32_trad.c:1.3	Sun Jan 28 08:26:07 2024
+++ src/tests/usr.bin/xlint/lint1/platform_ilp32_trad.c	Wed Feb  7 22:59:28 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: platform_ilp32_trad.c,v 1.3 2024/01/28 08:26:07 rillig Exp $	*/
+/*	$NetBSD: platform_ilp32_trad.c,v 1.4 2024/02/07 22:59:28 rillig Exp $	*/
 # 3 "platform_ilp32_trad.c"
 
 /*
@@ -13,10 +13,12 @@ void *lex_integer[] = {
 	2147483647,
 	/* expect+1: ... integer 'int' ... */
 	0x7fff,
+	/* expect+2: warning: integer constant out of range [252] */
 	/* expect+1: ... integer 'long' ... */
 	2147483648,
 	/* expect+1: ... integer 'long' ... */
 	0x8000,
+	/* expect+2: warning: integer constant out of range [252] */
 	/* expect+1: ... integer 'long' ... */
 	4294967295,
 	/* expect+1: ... integer 'long' ... */



CVS commit: src/tests/usr.bin/xlint/lint1

2024-02-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 22:59:28 UTC 2024

Modified Files:
src/tests/usr.bin/xlint/lint1: platform_ilp32_trad.c

Log Message:
tests/lint: sync test for integer constant type on ILP32 platforms

The test was broken since lex.c 1.214 from today.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_ilp32_trad.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2024-02-07 Thread Olaf Seibert
Module Name:xsrc
Committed By:   rhialto
Date:   Wed Feb  7 18:01:48 UTC 2024

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c

Log Message:
xf86-input-ws: print log message about touchpad scrolling only once.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 xsrc/external/mit/xf86-input-ws/dist/src/ws.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2024-02-07 Thread Olaf Seibert
Module Name:xsrc
Committed By:   rhialto
Date:   Wed Feb  7 18:01:48 UTC 2024

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c

Log Message:
xf86-input-ws: print log message about touchpad scrolling only once.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 xsrc/external/mit/xf86-input-ws/dist/src/ws.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-input-ws/dist/src/ws.c
diff -u xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.16 xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.17
--- xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.16	Sat Dec  4 15:21:55 2021
+++ xsrc/external/mit/xf86-input-ws/dist/src/ws.c	Wed Feb  7 18:01:48 2024
@@ -747,7 +747,9 @@ wsReadInput(InputInfoPtr pInfo)
 			dw = 0;
 		}
 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 14
-		if (hscroll || vscroll) {
+		static int warned = 0;
+		if ((hscroll || vscroll) && !warned) {
+			warned = 1;
 			xf86Msg(X_WARNING, "%s: hscroll=%d, vscroll=%d\n",
 			pInfo->name, hscroll, vscroll);
 			valuator_mask_zero(priv->scroll_mask);



CVS commit: src/sys/arch/riscv

2024-02-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb  7 17:17:59 UTC 2024

Modified Files:
src/sys/arch/riscv/conf: GENERIC64
src/sys/arch/riscv/starfive: files.starfive
Added Files:
src/sys/arch/riscv/starfive: jh7100_pinctrl.c

Log Message:
risc-v: add a driver the JH7100 pin controller


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/riscv/conf/GENERIC64
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/starfive/files.starfive
cvs rdiff -u -r0 -r1.1 src/sys/arch/riscv/starfive/jh7100_pinctrl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/riscv/conf/GENERIC64
diff -u src/sys/arch/riscv/conf/GENERIC64:1.7 src/sys/arch/riscv/conf/GENERIC64:1.8
--- src/sys/arch/riscv/conf/GENERIC64:1.7	Wed Feb  7 17:03:35 2024
+++ src/sys/arch/riscv/conf/GENERIC64	Wed Feb  7 17:17:59 2024
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC64,v 1.7 2024/02/07 17:03:35 skrll Exp $
+# $NetBSD: GENERIC64,v 1.8 2024/02/07 17:17:59 skrll Exp $
 #
 # GENERIC machine description file
 #
@@ -52,6 +52,9 @@ ccache* 	at fdt?			# SiFive FU[57]40 L2 
 # Clock controller
 jh7100clkc* 	at fdt?	pass 2		# StarFive JH7100 clock controller
 
+# Pin control
+jh7100pinctrl* 	at fdt? pass 2		# StarFive JH7100 pinctrl driver
+
 # SDMMC
 dwcmmc* 	at fdt?			# DesignWare SD/MMC
 sdmmc* 		at sdmmcbus?

Index: src/sys/arch/riscv/starfive/files.starfive
diff -u src/sys/arch/riscv/starfive/files.starfive:1.2 src/sys/arch/riscv/starfive/files.starfive:1.3
--- src/sys/arch/riscv/starfive/files.starfive:1.2	Thu Jan 18 07:48:57 2024
+++ src/sys/arch/riscv/starfive/files.starfive	Wed Feb  7 17:17:59 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: files.starfive,v 1.2 2024/01/18 07:48:57 skrll Exp $
+#	$NetBSD: files.starfive,v 1.3 2024/02/07 17:17:59 skrll Exp $
 #
 # Configuration info for StarFive SoCs
 #
@@ -12,3 +12,8 @@ file	arch/riscv/starfive/jh7100_clkc.c		
 device	jh71x0usb
 attach	jh71x0usb at fdt with jh71x0_usb
 file	arch/riscv/starfive/jh71x0_usb.c		jh71x0_usb
+
+# JH7100 Pin control
+device	jh7100pinctrl
+attach	jh7100pinctrl at fdt with jh7100_pinctrl
+file	arch/riscv/starfive/jh7100_pinctrl.c		jh7100_pinctrl

Added files:

Index: src/sys/arch/riscv/starfive/jh7100_pinctrl.c
diff -u /dev/null src/sys/arch/riscv/starfive/jh7100_pinctrl.c:1.1
--- /dev/null	Wed Feb  7 17:17:59 2024
+++ src/sys/arch/riscv/starfive/jh7100_pinctrl.c	Wed Feb  7 17:17:59 2024
@@ -0,0 +1,513 @@
+/* $NetBSD: jh7100_pinctrl.c,v 1.1 2024/02/07 17:17:59 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: jh7100_pinctrl.c,v 1.1 2024/02/07 17:17:59 skrll Exp $");
+
+#include 
+
+#include 
+
+#include 
+
+struct jh7100_pinctrl_softc {
+	device_t		 sc_dev;
+	bus_space_tag_t		 sc_bst;
+	bus_space_handle_t	 sc_gpio_bsh;
+	bus_space_handle_t	 sc_padctl_bsh;
+	int			 sc_phandle;
+
+	kmutex_t		 sc_lock;
+	u_int			 sc_padctl_gpio;
+};
+
+struct jh7100_pinctrl_gpio_pin {
+	struct jh7100_pinctrl_softc	*pin_sc;
+	u_int pin_no;
+	bool pin_actlo;
+};
+
+#define	GPIORD4(sc, reg)		   \
+	bus_space_read_4((sc)->sc_bst, (sc)->sc_gpio_bsh, (reg))
+#define	GPIOWR4(sc, reg, val)		   \
+	bus_space_write_4((sc)->sc_bst, (sc)->sc_gpio_bsh, (reg), (val))
+
+#define GPIO_DIN(pin)			(0x0048 + (((pin) / 32) * 4))
+
+#define GPO_DOUT_CFG(pin)		(0x0050 + ((pin) * 8))
+#define  GPO_DOUT_REVERSE		__BIT(31)
+#define  GPO_DOUT_MASK			__BITS(30,  0)
+#define 

CVS commit: src/sys/arch/riscv

2024-02-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb  7 17:17:59 UTC 2024

Modified Files:
src/sys/arch/riscv/conf: GENERIC64
src/sys/arch/riscv/starfive: files.starfive
Added Files:
src/sys/arch/riscv/starfive: jh7100_pinctrl.c

Log Message:
risc-v: add a driver the JH7100 pin controller


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/riscv/conf/GENERIC64
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/starfive/files.starfive
cvs rdiff -u -r0 -r1.1 src/sys/arch/riscv/starfive/jh7100_pinctrl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/riscv/conf

2024-02-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb  7 17:03:35 UTC 2024

Modified Files:
src/sys/arch/riscv/conf: GENERIC64

Log Message:
Use  consistently


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/riscv/conf/GENERIC64

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/riscv/conf/GENERIC64
diff -u src/sys/arch/riscv/conf/GENERIC64:1.6 src/sys/arch/riscv/conf/GENERIC64:1.7
--- src/sys/arch/riscv/conf/GENERIC64:1.6	Sat Jan 20 08:05:37 2024
+++ src/sys/arch/riscv/conf/GENERIC64	Wed Feb  7 17:03:35 2024
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC64,v 1.6 2024/01/20 08:05:37 skrll Exp $
+# $NetBSD: GENERIC64,v 1.7 2024/02/07 17:03:35 skrll Exp $
 #
 # GENERIC machine description file
 #
@@ -54,8 +54,8 @@ jh7100clkc* 	at fdt?	pass 2		# StarFive 
 
 # SDMMC
 dwcmmc* 	at fdt?			# DesignWare SD/MMC
-sdmmc*		at sdmmcbus?
-bwfm*		at sdmmc?		# Broadcom BCM43xxx WiFi Interface
+sdmmc* 		at sdmmcbus?
+bwfm* 		at sdmmc?		# Broadcom BCM43xxx WiFi Interface
 
 # USB
 jh71x0usb* 	at fdt?			# StarFive JH71x0 usb
@@ -64,7 +64,7 @@ jh71x0usb* 	at fdt?			# StarFive JH71x0 
 xhci* 		at fdt?			# XHCI
 usb* 		at usbus?
 include "dev/usb/usbdevices.config"
-midi*		at midibus?
+midi* 		at midibus?
 
 # Pull in optional local configuration - always at end
 cinclude 	"arch/riscv/conf/GENERIC64.local"



CVS commit: src/sys/arch/riscv/conf

2024-02-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Feb  7 17:03:35 UTC 2024

Modified Files:
src/sys/arch/riscv/conf: GENERIC64

Log Message:
Use  consistently


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/riscv/conf/GENERIC64

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/doc

2024-02-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb  7 09:18:20 UTC 2024

Modified Files:
src/doc: 3RDPARTY

Log Message:
expat 2.6.0 out


To generate a diff of this commit:
cvs rdiff -u -r1.1983 -r1.1984 src/doc/3RDPARTY

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/doc

2024-02-07 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Feb  7 09:18:20 UTC 2024

Modified Files:
src/doc: 3RDPARTY

Log Message:
expat 2.6.0 out


To generate a diff of this commit:
cvs rdiff -u -r1.1983 -r1.1984 src/doc/3RDPARTY

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1983 src/doc/3RDPARTY:1.1984
--- src/doc/3RDPARTY:1.1983	Mon Feb  5 21:57:00 2024
+++ src/doc/3RDPARTY	Wed Feb  7 09:18:19 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1983 2024/02/05 21:57:00 kre Exp $
+#	$NetBSD: 3RDPARTY,v 1.1984 2024/02/07 09:18:19 wiz Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -409,11 +409,11 @@ Notes:
 
 Package:	expat
 Version:	2.4.6
-Current Vers:	2.5.0
+Current Vers:	2.6.0
 Maintainer:	Expat Project
 Archive Site:	https://github.com/libexpat/libexpat/releases
 Home Page:	http://www.libexpat.org/
-Date:		2022-09-21
+Date:		2024-02-07
 Mailing List:	expat-disc...@libexpat.org
 Responsible:	mrg
 License:	MIT



CVS commit: src/usr.bin/xlint/lint1

2024-02-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 08:00:37 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: lex.c

Log Message:
lint: use consistent variable names, reduce code for reading a byte

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/xlint/lint1/lex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.214 src/usr.bin/xlint/lint1/lex.c:1.215
--- src/usr.bin/xlint/lint1/lex.c:1.214	Wed Feb  7 07:42:50 2024
+++ src/usr.bin/xlint/lint1/lex.c	Wed Feb  7 08:00:36 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.214 2024/02/07 07:42:50 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.215 2024/02/07 08:00:36 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID)
-__RCSID("$NetBSD: lex.c,v 1.214 2024/02/07 07:42:50 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.215 2024/02/07 08:00:36 rillig Exp $");
 #endif
 
 #include 
@@ -423,15 +423,11 @@ init_lex(void)
 static int
 read_byte(void)
 {
-	int c;
+	int c = lex_input();
 
-	if ((c = lex_input()) == EOF)
-		return c;
-	if (c == '\0')
-		return EOF;	/* lex returns 0 on EOF. */
 	if (c == '\n')
 		lex_next_line();
-	return c;
+	return c == '\0' ? EOF : c;	/* lex returns 0 on EOF. */
 }
 
 static int
@@ -485,16 +481,16 @@ lex_name(const char *yytext, size_t yyle
 // Determines whether the constant is signed in traditional C but unsigned in
 // C90 and later.
 static bool
-is_unsigned_since_c90(tspec_t typ, uint64_t ui, int base)
+is_unsigned_since_c90(tspec_t t, uint64_t ui, int base)
 {
 	if (!(allow_trad && allow_c90))
 		return false;
-	if (typ == INT) {
+	if (t == INT) {
 		if (ui > TARG_INT_MAX && ui <= TARG_UINT_MAX && base != 10)
 			return true;
 		return ui > TARG_LONG_MAX;
 	}
-	return typ == LONG && ui > TARG_LONG_MAX;
+	return t == LONG && ui > TARG_LONG_MAX;
 }
 
 static tspec_t
@@ -657,17 +653,17 @@ lex_floating_constant(const char *yytext
 		len--;
 
 	char c = cp[len - 1];
-	tspec_t typ;
+	tspec_t t;
 	if (c == 'f' || c == 'F') {
-		typ = imaginary ? FCOMPLEX : FLOAT;
+		t = imaginary ? FCOMPLEX : FLOAT;
 		len--;
 	} else if (c == 'l' || c == 'L') {
-		typ = imaginary ? LCOMPLEX : LDOUBLE;
+		t = imaginary ? LCOMPLEX : LDOUBLE;
 		len--;
 	} else
-		typ = imaginary ? DCOMPLEX : DOUBLE;
+		t = imaginary ? DCOMPLEX : DOUBLE;
 
-	if (!allow_c90 && typ != DOUBLE) {
+	if (!allow_c90 && t != DOUBLE) {
 		/* suffixes 'F' and 'L' are illegal in traditional C */
 		warning(98);
 	}
@@ -679,14 +675,14 @@ lex_floating_constant(const char *yytext
 	if (errno != 0) {
 		/* floating-point constant out of range */
 		warning(248);
-	} else if (typ == FLOAT) {
+	} else if (t == FLOAT) {
 		ld = (float)ld;
 		if (isfinite(ld) == 0) {
 			/* floating-point constant out of range */
 			warning(248);
 			ld = ld > 0 ? FLT_MAX : -FLT_MAX;
 		}
-	} else if (typ == DOUBLE
+	} else if (t == DOUBLE
 	|| /* CONSTCOND */ LDOUBLE_SIZE == DOUBLE_SIZE) {
 		ld = (double)ld;
 		if (isfinite(ld) == 0) {
@@ -697,7 +693,7 @@ lex_floating_constant(const char *yytext
 	}
 
 	yylval.y_val = xcalloc(1, sizeof(*yylval.y_val));
-	yylval.y_val->v_tspec = typ;
+	yylval.y_val->v_tspec = t;
 	yylval.y_val->u.floating = ld;
 
 	return T_CON;



CVS commit: src/usr.bin/xlint/lint1

2024-02-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 08:00:37 UTC 2024

Modified Files:
src/usr.bin/xlint/lint1: lex.c

Log Message:
lint: use consistent variable names, reduce code for reading a byte

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/xlint/lint1/lex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.