From owner-svn-src-all@freebsd.org Sat Nov 7 18:26:34 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7ADFBA2916B; Sat, 7 Nov 2015 18:26:34 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 353E31FB1; Sat, 7 Nov 2015 18:26:34 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA7IQXep035923; Sat, 7 Nov 2015 18:26:33 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA7IQWNR035920; Sat, 7 Nov 2015 18:26:32 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201511071826.tA7IQWNR035920@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Sat, 7 Nov 2015 18:26:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290505 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Nov 2015 18:26:34 -0000 Author: cem Date: Sat Nov 7 18:26:32 2015 New Revision: 290505 URL: https://svnweb.freebsd.org/changeset/base/290505 Log: Flesh out sysctl types further (follow-up of r290475) Use the right intmax_t type instead of intptr_t in a few remaining places. Add support for CTLFLAG_TUN for the new fixed with types. Bruce will be upset that the new handlers silently truncate tuned quad-sized inputs, but so do all of the existing handlers. Add the new types to debug_dump_node, for whatever use that is. Bump FreeBSD_version again, for good measure. We are changing SYSCTL_HANDLER_ARGS and a member of struct sysctl_oid to intmax_t. Correct the sysctl typed NULL values for the fixed-width types. (Hat tip: hps@.) Suggested by: hps (partial) Sponsored by: EMC / Isilon Storage Division Modified: head/sys/kern/kern_sysctl.c head/sys/sys/param.h head/sys/sys/sysctl.h Modified: head/sys/kern/kern_sysctl.c ============================================================================== --- head/sys/kern/kern_sysctl.c Sat Nov 7 18:26:02 2015 (r290504) +++ head/sys/kern/kern_sysctl.c Sat Nov 7 18:26:32 2015 (r290505) @@ -147,7 +147,7 @@ sysctl_wunlock(void) } static int -sysctl_root_handler_locked(struct sysctl_oid *oid, void *arg1, intptr_t arg2, +sysctl_root_handler_locked(struct sysctl_oid *oid, void *arg1, intmax_t arg2, struct sysctl_req *req, struct rm_priotracker *tracker) { int error; @@ -189,6 +189,9 @@ sysctl_load_tunable_by_oid_locked(struct char path[64]; ssize_t rem = sizeof(path); ssize_t len; + uint8_t val_8; + uint16_t val_16; + uint32_t val_32; int val_int; long val_long; int64_t val_64; @@ -243,6 +246,27 @@ sysctl_load_tunable_by_oid_locked(struct req.newlen = sizeof(val_long); req.newptr = &val_long; break; + case CTLTYPE_S8: + if (getenv_int(path + rem, &val_int) == 0) + return; + val_8 = val_int; + req.newlen = sizeof(val_8); + req.newptr = &val_8; + break; + case CTLTYPE_S16: + if (getenv_int(path + rem, &val_int) == 0) + return; + val_16 = val_int; + req.newlen = sizeof(val_16); + req.newptr = &val_16; + break; + case CTLTYPE_S32: + if (getenv_long(path + rem, &val_long) == 0) + return; + val_32 = val_long; + req.newlen = sizeof(val_32); + req.newptr = &val_32; + break; case CTLTYPE_S64: if (getenv_quad(path + rem, &val_quad) == 0) return; @@ -250,6 +274,27 @@ sysctl_load_tunable_by_oid_locked(struct req.newlen = sizeof(val_64); req.newptr = &val_64; break; + case CTLTYPE_U8: + if (getenv_uint(path + rem, (unsigned int *)&val_int) == 0) + return; + val_8 = val_int; + req.newlen = sizeof(val_8); + req.newptr = &val_8; + break; + case CTLTYPE_U16: + if (getenv_uint(path + rem, (unsigned int *)&val_int) == 0) + return; + val_16 = val_int; + req.newlen = sizeof(val_16); + req.newptr = &val_16; + break; + case CTLTYPE_U32: + if (getenv_ulong(path + rem, (unsigned long *)&val_long) == 0) + return; + val_32 = val_long; + req.newlen = sizeof(val_32); + req.newptr = &val_32; + break; case CTLTYPE_U64: /* XXX there is no getenv_uquad() */ if (getenv_quad(path + rem, &val_quad) == 0) @@ -806,8 +851,14 @@ sysctl_sysctl_debug_dump_node(struct sys case CTLTYPE_LONG: printf(" Long\n"); break; case CTLTYPE_ULONG: printf(" u_long\n"); break; case CTLTYPE_STRING: printf(" String\n"); break; - case CTLTYPE_U64: printf(" uint64_t\n"); break; + case CTLTYPE_S8: printf(" int8_t\n"); break; + case CTLTYPE_S16: printf(" int16_t\n"); break; + case CTLTYPE_S32: printf(" int32_t\n"); break; case CTLTYPE_S64: printf(" int64_t\n"); break; + case CTLTYPE_U8: printf(" uint8_t\n"); break; + case CTLTYPE_U16: printf(" uint16_t\n"); break; + case CTLTYPE_U32: printf(" uint32_t\n"); break; + case CTLTYPE_U64: printf(" uint64_t\n"); break; case CTLTYPE_OPAQUE: printf(" Opaque/struct\n"); break; default: printf("\n"); } Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Sat Nov 7 18:26:02 2015 (r290504) +++ head/sys/sys/param.h Sat Nov 7 18:26:32 2015 (r290505) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100088 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100089 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, Modified: head/sys/sys/sysctl.h ============================================================================== --- head/sys/sys/sysctl.h Sat Nov 7 18:26:02 2015 (r290504) +++ head/sys/sys/sysctl.h Sat Nov 7 18:26:32 2015 (r290505) @@ -137,7 +137,7 @@ struct ctlname { #endif #define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, \ - intptr_t arg2, struct sysctl_req *req + intmax_t arg2, struct sysctl_req *req /* definitions for sysctl_req 'lock' member */ #define REQ_UNWIRED 1 @@ -181,7 +181,7 @@ struct sysctl_oid { int oid_number; u_int oid_kind; void *oid_arg1; - intptr_t oid_arg2; + intmax_t oid_arg2; const char *oid_name; int (*oid_handler)(SYSCTL_HANDLER_ARGS); const char *oid_fmt; @@ -329,7 +329,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for a signed 8-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_S8_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_S8_PTR ((int8_t *)NULL) #define SYSCTL_S8(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_S8 | CTLFLAG_MPSAFE | (access), \ @@ -349,7 +349,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for an unsigned 8-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_U8_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_U8_PTR ((uint8_t *)NULL) #define SYSCTL_U8(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_U8 | CTLFLAG_MPSAFE | (access), \ @@ -369,7 +369,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for a signed 16-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_S16_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_S16_PTR ((int16_t *)NULL) #define SYSCTL_S16(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_S16 | CTLFLAG_MPSAFE | (access), \ @@ -389,7 +389,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for an unsigned 16-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_U16_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_U16_PTR ((uint16_t *)NULL) #define SYSCTL_U16(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_U16 | CTLFLAG_MPSAFE | (access), \ @@ -409,7 +409,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for a signed 32-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_S32_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_S32_PTR ((int32_t *)NULL) #define SYSCTL_S32(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_S32 | CTLFLAG_MPSAFE | (access), \ @@ -429,7 +429,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for an unsigned 32-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_U32_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_U32_PTR ((uint32_t *)NULL) #define SYSCTL_U32(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_U32 | CTLFLAG_MPSAFE | (access), \ @@ -449,7 +449,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for a signed 64-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_S64_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_S64_PTR ((int64_t *)NULL) #define SYSCTL_S64(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_S64 | CTLFLAG_MPSAFE | (access), \ @@ -469,7 +469,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e }) /* Oid for an unsigned 64-bit int. If ptr is NULL, val is returned. */ -#define SYSCTL_NULL_U64_PTR ((unsigned *)NULL) +#define SYSCTL_NULL_U64_PTR ((uint64_t *)NULL) #define SYSCTL_U64(parent, nbr, name, access, ptr, val, descr) \ SYSCTL_OID(parent, nbr, name, \ CTLTYPE_U64 | CTLFLAG_MPSAFE | (access), \