Module Name: src
Committed By: thorpej
Date: Mon Jan 15 18:14:24 UTC 2024
Modified Files:
src/sys/sys: device.h evcnt.h
Log Message:
Provide an ev_count32 field for situations where a 32-bit counter is
sufficient (and, notably, might be desirable to avoid 64-bit math on
an older 32-bit platform). This is overlaid on the 64-bit counter
field, and simply references the correct half based on byte order.
To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 src/sys/sys/device.h
cvs rdiff -u -r1.10 -r1.11 src/sys/sys/evcnt.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/sys/device.h
diff -u src/sys/sys/device.h:1.186 src/sys/sys/device.h:1.187
--- src/sys/sys/device.h:1.186 Mon May 22 14:58:22 2023
+++ src/sys/sys/device.h Mon Jan 15 18:14:23 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: device.h,v 1.186 2023/05/22 14:58:22 riastradh Exp $ */
+/* $NetBSD: device.h,v 1.187 2024/01/15 18:14:23 thorpej Exp $ */
/*
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -622,11 +622,16 @@ bool devhandle_is_valid(devhandle_t);
devhandle_t devhandle_invalid(void);
devhandle_type_t devhandle_type(devhandle_t);
int devhandle_compare(devhandle_t, devhandle_t);
+devhandle_t devhandle_subclass(devhandle_t, struct devhandle_impl *,
+ device_call_t (*)(devhandle_t, const char *,
+ devhandle_t *));
device_call_t devhandle_lookup_device_call(devhandle_t, const char *,
devhandle_t *);
-void devhandle_impl_inherit(struct devhandle_impl *,
- const struct devhandle_impl *);
+void devhandle_impl_subclass(struct devhandle_impl *,
+ const struct devhandle_impl *,
+ device_call_t (*)(devhandle_t, const char *,
+ devhandle_t *));
device_t deviter_first(deviter_t *, deviter_flags_t);
void deviter_init(deviter_t *, deviter_flags_t);
@@ -717,10 +722,13 @@ struct device_call_generic {
void *args;
};
-int device_call_generic(device_t, const struct device_call_generic *);
+int device_call_generic(device_t, devhandle_t,
+ const struct device_call_generic *);
#define device_call(dev, call) \
- device_call_generic((dev), &(call)->generic)
+ device_call_generic((dev), device_handle(dev), &(call)->generic)
+#define devhandle_call(handle, call) \
+ device_call_generic(NULL, (handle), &(call)->generic)
#endif /* _KERNEL */
Index: src/sys/sys/evcnt.h
diff -u src/sys/sys/evcnt.h:1.10 src/sys/sys/evcnt.h:1.11
--- src/sys/sys/evcnt.h:1.10 Tue Aug 3 23:12:14 2021
+++ src/sys/sys/evcnt.h Mon Jan 15 18:14:23 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: evcnt.h,v 1.10 2021/08/03 23:12:14 andvar Exp $ */
+/* $NetBSD: evcnt.h,v 1.11 2024/01/15 18:14:23 thorpej Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -83,7 +83,10 @@
*/
struct evcnt {
- uint64_t ev_count; /* how many have occurred */
+ union {
+ uint64_t ev_count; /* how many have occurred */
+ uint32_t ev__count32[2];
+ };
TAILQ_ENTRY(evcnt) ev_list; /* entry on list of all counters */
unsigned char ev_type; /* counter type; see below */
unsigned char ev_grouplen; /* 'group' len, excluding NUL */
@@ -95,6 +98,16 @@ struct evcnt {
};
TAILQ_HEAD(evcntlist, evcnt);
+/*
+ * For 32-bit counters, ev_count32 is the correct half of the 64-bit
+ * counter field.
+ */
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define ev_count32 ev__count32[1]
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define ev_count32 ev__count32[0]
+#endif
+
/* maximum group/name lengths, including trailing NUL */
#define EVCNT_STRING_MAX 255