Create deprecation management functions.
gone_in(majar, msg); If we're running in FreeBSD major, tell the user this code may be deleted soon. If we're running in FreeBSD major - 1, the the user is deprecated and will be gone in major. Otherwise say nothing. gone_in_dev(dev, major, msg) Just like gone_in, except use device_printf. New tunable / sysctl debug.oboslete_panic: 0 - don't panic, 1 - panic in major or newer , 2 - panic in major - 1 or newer default: 0 if NO_OBSOLETE_CODE is defined, then both of these turn into compile time errors when building for major. Add options NO_OBSOLETE_CODE to kernel build system. This lets us tag code that's going away so users know it will be gone, as well as automatically manage things. Differential Review: https://reviews.freebsd.org/D13818
This commit is contained in:
parent
29077eb456
commit
7faed6e3e9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328522
@ -177,6 +177,7 @@ NO_ADAPTIVE_MUTEXES opt_adaptive_mutexes.h
|
||||
NO_ADAPTIVE_RWLOCKS
|
||||
NO_ADAPTIVE_SX
|
||||
NO_EVENTTIMERS opt_timer.h
|
||||
NO_OBSOLETE_CODE opt_global.h
|
||||
NO_SYSCTL_DESCR opt_global.h
|
||||
NSWBUF_MIN opt_swap.h
|
||||
MBUF_PACKET_ZONE_DISABLE opt_global.h
|
||||
|
@ -5605,6 +5605,56 @@ devctl2_init(void)
|
||||
UID_ROOT, GID_WHEEL, 0600, "devctl2");
|
||||
}
|
||||
|
||||
/*
|
||||
* APIs to manage deprecation and obsolescence.
|
||||
*/
|
||||
static int obsolete_panic = 0;
|
||||
SYSCTL_INT(_debug, OID_AUTO, obsolete_panic, CTLFLAG_RWTUN, &obsolete_panic, 0,
|
||||
"Bus debug level");
|
||||
/* 0 - don't panic, 1 - panic if already obsolete, 2 - panic if deprecated */
|
||||
static void
|
||||
gone_panic(int major, int running, const char *msg)
|
||||
{
|
||||
|
||||
switch (obsolete_panic)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
if (running < major)
|
||||
return;
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
panic("%s", msg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_gone_in(int major, const char *msg)
|
||||
{
|
||||
|
||||
gone_panic(major, P_OSREL_MAJOR(__FreeBSD_version), msg);
|
||||
if (P_OSREL_MAJOR(__FreeBSD_version) >= major)
|
||||
printf("Obsolete code will removed soon: %s\n", msg);
|
||||
else if (P_OSREL_MAJOR(__FreeBSD_version) + 1 == major)
|
||||
printf("Deprecated code (to be removed in FreeBSD %d): %s\n",
|
||||
major, msg);
|
||||
}
|
||||
|
||||
void
|
||||
_gone_in_dev(device_t dev, int major, const char *msg)
|
||||
{
|
||||
|
||||
gone_panic(major, P_OSREL_MAJOR(__FreeBSD_version), msg);
|
||||
if (P_OSREL_MAJOR(__FreeBSD_version) >= major)
|
||||
device_printf(dev,
|
||||
"Obsolete code will removed soon: %s\n", msg);
|
||||
else if (P_OSREL_MAJOR(__FreeBSD_version) + 1 == major)
|
||||
device_printf(dev,
|
||||
"Deprecated code (to be removed in FreeBSD %d): %s\n",
|
||||
major, msg);
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
DB_SHOW_COMMAND(device, db_show_device)
|
||||
{
|
||||
|
@ -464,6 +464,22 @@ void intr_prof_stack_use(struct thread *td, struct trapframe *frame);
|
||||
|
||||
void counted_warning(unsigned *counter, const char *msg);
|
||||
|
||||
/*
|
||||
* APIs to manage deprecation and obsolescence.
|
||||
*/
|
||||
struct device;
|
||||
void _gone_in(int major, const char *msg);
|
||||
void _gone_in_dev(struct device *dev, int major, const char *msg);
|
||||
#ifdef NO_OBSOLETE_CODE
|
||||
#define __gone_ok(m, msg) \
|
||||
_Static_assert(m < P_OSREL_MAJOR(__FreeBSD_version)), \
|
||||
"Obsolete code" msg);
|
||||
#else
|
||||
#define __gone_ok(m, msg)
|
||||
#endif
|
||||
#define gone_in(major, msg) __gone_ok(major, msg) _gone_in(major, msg)
|
||||
#define gone_in_dev(dev, major, msg) __gone_ok(major, msg) _gone_in_dev(dev, major, msg)
|
||||
|
||||
__NULLABILITY_PRAGMA_POP
|
||||
|
||||
#endif /* !_SYS_SYSTM_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user