diff options
author | alfred <alfred@FreeBSD.org> | 2002-11-17 04:15:34 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-11-17 04:15:34 +0000 |
commit | 404161b0ebc663732ff605fa1cec5fc6f2cbf76d (patch) | |
tree | e2dfa1f642b4d621b045178bb552f0214e31be7a | |
parent | 788d21c22efba82ded14c4c83035501ce6be4936 (diff) | |
download | FreeBSD-src-404161b0ebc663732ff605fa1cec5fc6f2cbf76d.zip FreeBSD-src-404161b0ebc663732ff605fa1cec5fc6f2cbf76d.tar.gz |
Rework the sysconf(3) interaction with aio:
sysconf.c:
Use 'break' rather than 'goto yesno' in sysconf.c so that we report a '0'
return value from the kernel sysctl.
vfs_aio.c:
Make aio reset its configuration parameters to -1 after unloading
instead of 0.
posix4_mib.c:
Initialize the aio configuration parameters to -1
to indicate that it is not loaded.
Add a facility (p31b_iscfg()) to determine if a posix4 facility has been
initialized to avoid having to re-order the SYSINITs.
Use p31b_iscfg() to determine if aio has had a chance to run yet which
is likely if it is compiled into the kernel and avoid spamming its
values.
Introduce a macro P31B_VALID() instead of doing the same comparison over
and over.
posix4.h:
Prototype p31b_iscfg().
-rw-r--r-- | lib/libc/gen/sysconf.c | 9 | ||||
-rw-r--r-- | sys/kern/posix4_mib.c | 24 | ||||
-rw-r--r-- | sys/kern/vfs_aio.c | 6 | ||||
-rw-r--r-- | sys/posix4/posix4.h | 1 | ||||
-rw-r--r-- | sys/posix4/posix4_mib.c | 24 | ||||
-rw-r--r-- | sys/sys/posix4.h | 1 |
6 files changed, 52 insertions, 13 deletions
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index aa906f6..ecb833e 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -254,20 +254,17 @@ do_NAME_MAX: return (_POSIX_TIMERS); #endif case _SC_AIO_LISTIO_MAX: - defaultresult = _POSIX_AIO_LISTIO_MAX; mib[0] = CTL_P1003_1B; mib[1] = CTL_P1003_1B_AIO_LISTIO_MAX; - goto yesno; + goto break; case _SC_AIO_MAX: - defaultresult = _POSIX_AIO_MAX; mib[0] = CTL_P1003_1B; mib[1] = CTL_P1003_1B_AIO_MAX; - goto yesno; + goto break; case _SC_AIO_PRIO_DELTA_MAX: - defaultresult = 0; mib[0] = CTL_P1003_1B; mib[1] = CTL_P1003_1B_AIO_PRIO_DELTA_MAX; - goto yesno; + goto break; case _SC_DELAYTIMER_MAX: mib[0] = CTL_P1003_1B; mib[1] = CTL_P1003_1B_DELAYTIMER_MAX; diff --git a/sys/kern/posix4_mib.c b/sys/kern/posix4_mib.c index 6f1fe46..12d5fec 100644 --- a/sys/kern/posix4_mib.c +++ b/sys/kern/posix4_mib.c @@ -40,6 +40,7 @@ #include <posix4/posix4.h> static int facility[CTL_P1003_1B_MAXID - 1]; +static int facility_initialized[CTL_P1003_1B_MAXID - 1]; /* OID_AUTO isn't working with sysconf(3). I guess I'd have to * modify it to do a lookup by name from the index. @@ -92,25 +93,38 @@ P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max); P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max); P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max); +#define P31B_VALID(num) ((num) >= 1 && (num) < CTL_P1003_1B_MAXID) + /* p31b_setcfg: Set the configuration */ void p31b_setcfg(int num, int value) { - if (num >= 1 && num < CTL_P1003_1B_MAXID) + if (P31B_VALID(num)) { facility[num - 1] = value; + facility_initialized[num - 1] = 1; + } } int p31b_getcfg(int num) { - if (num >= 1 && num < CTL_P1003_1B_MAXID) + if (P31B_VALID(num)) return (facility[num - 1]); return (0); } +int +p31b_iscfg(int num) +{ + + if (P31B_VALID(num)) + return (facility_initialized[num - 1]); + return (0); +} + /* * Turn on indications for standard (non-configurable) kernel features. */ @@ -121,6 +135,12 @@ p31b_set_standard(void *dummy) p31b_setcfg(CTL_P1003_1B_MAPPED_FILES, 1); p31b_setcfg(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, 1); p31b_setcfg(CTL_P1003_1B_PAGESIZE, PAGE_SIZE); + if (!p31b_iscfg(CTL_P1003_1B_AIO_LISTIO_MAX)) + p31b_setcfg(CTL_P1003_1B_AIO_LISTIO_MAX, -1); + if (!p31b_iscfg(CTL_P1003_1B_AIO_MAX)) + p31b_setcfg(CTL_P1003_1B_AIO_MAX, -1); + if (!p31b_iscfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX)) + p31b_setcfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, -1); } SYSINIT(p31b_set_standard, SI_SUB_P1003_1B, SI_ORDER_ANY, p31b_set_standard, diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 5254a16..9fde837 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -376,9 +376,9 @@ aio_unload(void) rm_at_exit(aio_proc_rundown); rm_at_exec(aio_proc_rundown); kqueue_del_filteropts(EVFILT_AIO); - p31b_setcfg(CTL_P1003_1B_AIO_LISTIO_MAX, 0); - p31b_setcfg(CTL_P1003_1B_AIO_MAX, 0); - p31b_setcfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, 0); + p31b_setcfg(CTL_P1003_1B_AIO_LISTIO_MAX, -1); + p31b_setcfg(CTL_P1003_1B_AIO_MAX, -1); + p31b_setcfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, -1); return (0); } diff --git a/sys/posix4/posix4.h b/sys/posix4/posix4.h index e597370..b17e927 100644 --- a/sys/posix4/posix4.h +++ b/sys/posix4/posix4.h @@ -63,6 +63,7 @@ int p31b_proc(struct proc *, pid_t, struct proc **); void p31b_setcfg(int, int); int p31b_getcfg(int); +int p31b_iscfg(int); #ifdef _KPOSIX_PRIORITY_SCHEDULING diff --git a/sys/posix4/posix4_mib.c b/sys/posix4/posix4_mib.c index 6f1fe46..12d5fec 100644 --- a/sys/posix4/posix4_mib.c +++ b/sys/posix4/posix4_mib.c @@ -40,6 +40,7 @@ #include <posix4/posix4.h> static int facility[CTL_P1003_1B_MAXID - 1]; +static int facility_initialized[CTL_P1003_1B_MAXID - 1]; /* OID_AUTO isn't working with sysconf(3). I guess I'd have to * modify it to do a lookup by name from the index. @@ -92,25 +93,38 @@ P1B_SYSCTL(CTL_P1003_1B_SEM_VALUE_MAX, sem_value_max); P1B_SYSCTL(CTL_P1003_1B_SIGQUEUE_MAX, sigqueue_max); P1B_SYSCTL(CTL_P1003_1B_TIMER_MAX, timer_max); +#define P31B_VALID(num) ((num) >= 1 && (num) < CTL_P1003_1B_MAXID) + /* p31b_setcfg: Set the configuration */ void p31b_setcfg(int num, int value) { - if (num >= 1 && num < CTL_P1003_1B_MAXID) + if (P31B_VALID(num)) { facility[num - 1] = value; + facility_initialized[num - 1] = 1; + } } int p31b_getcfg(int num) { - if (num >= 1 && num < CTL_P1003_1B_MAXID) + if (P31B_VALID(num)) return (facility[num - 1]); return (0); } +int +p31b_iscfg(int num) +{ + + if (P31B_VALID(num)) + return (facility_initialized[num - 1]); + return (0); +} + /* * Turn on indications for standard (non-configurable) kernel features. */ @@ -121,6 +135,12 @@ p31b_set_standard(void *dummy) p31b_setcfg(CTL_P1003_1B_MAPPED_FILES, 1); p31b_setcfg(CTL_P1003_1B_SHARED_MEMORY_OBJECTS, 1); p31b_setcfg(CTL_P1003_1B_PAGESIZE, PAGE_SIZE); + if (!p31b_iscfg(CTL_P1003_1B_AIO_LISTIO_MAX)) + p31b_setcfg(CTL_P1003_1B_AIO_LISTIO_MAX, -1); + if (!p31b_iscfg(CTL_P1003_1B_AIO_MAX)) + p31b_setcfg(CTL_P1003_1B_AIO_MAX, -1); + if (!p31b_iscfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX)) + p31b_setcfg(CTL_P1003_1B_AIO_PRIO_DELTA_MAX, -1); } SYSINIT(p31b_set_standard, SI_SUB_P1003_1B, SI_ORDER_ANY, p31b_set_standard, diff --git a/sys/sys/posix4.h b/sys/sys/posix4.h index e597370..b17e927 100644 --- a/sys/sys/posix4.h +++ b/sys/sys/posix4.h @@ -63,6 +63,7 @@ int p31b_proc(struct proc *, pid_t, struct proc **); void p31b_setcfg(int, int); int p31b_getcfg(int); +int p31b_iscfg(int); #ifdef _KPOSIX_PRIORITY_SCHEDULING |