From owner-freebsd-standards Mon Apr 1 2:29: 4 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 4B83D37B41A for ; Mon, 1 Apr 2002 02:28:54 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g31AMdB98799 for standards@FreeBSD.org; Mon, 1 Apr 2002 05:22:39 -0500 (EST) (envelope-from mike) Date: Mon, 1 Apr 2002 05:22:39 -0500 From: Mike Barcroft To: standards@FreeBSD.org Subject: strings.diff for review Message-ID: <20020401052239.A98094@espresso.q9media.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="zhXaljGHf11kAtnf" Content-Disposition: inline Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --zhXaljGHf11kAtnf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The following is a fairly straightforward implementation of and clean up of . Comments appreciated. Best regards, Mike Barcroft --zhXaljGHf11kAtnf Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="strings.diff" strings.diff o Move some function prototypes from to the newly created , based on POSIX.1-2001's requirements. o Add 'restrict' qualifier (spelled '__restrict') to functions in , as per C99 and POSIX.1-2001. o Properly expose new POSIX.1-2001 functions in . Index: include/string.h =================================================================== RCS file: /work/repo/src/include/string.h,v retrieving revision 1.12 diff -u -r1.12 string.h --- include/string.h 23 Mar 2002 17:24:53 -0000 1.12 +++ include/string.h 1 Apr 2002 10:22:02 -0000 @@ -36,8 +36,18 @@ #ifndef _STRING_H_ #define _STRING_H_ + +#include #include +/* + * Prototype functions which were historically defined in , but + * are required by POSIX to be prototyped in . + */ +#if __BSD_VISIBLE +#include +#endif + #ifdef _BSD_SIZE_T_ typedef _BSD_SIZE_T_ size_t; #undef _BSD_SIZE_T_ @@ -47,53 +57,45 @@ #define NULL 0 #endif -#include - __BEGIN_DECLS void *memchr(const void *, int, size_t); int memcmp(const void *, const void *, size_t); -void *memcpy(void *, const void *, size_t); +void *memcpy(void * __restrict, const void * __restrict, size_t); void *memmove(void *, const void *, size_t); void *memset(void *, int, size_t); -char *strcat(char *, const char *); +char *strcat(char * __restrict, const char * __restrict); char *strchr(const char *, int); int strcmp(const char *, const char *); int strcoll(const char *, const char *); -char *strcpy(char *, const char *); +char *strcpy(char * __restrict, const char * __restrict); size_t strcspn(const char *, const char *); char *strerror(int); size_t strlen(const char *); -char *strncat(char *, const char *, size_t); +char *strncat(char * __restrict, const char * __restrict, size_t); int strncmp(const char *, const char *, size_t); -char *strncpy(char *, const char *, size_t); +char *strncpy(char * __restrict, const char * __restrict, size_t); char *strpbrk(const char *, const char *); char *strrchr(const char *, int); size_t strspn(const char *, const char *); char *strstr(const char *, const char *); -char *strtok(char *, const char *); -size_t strxfrm(char *, const char *, size_t); +char *strtok(char * __restrict, const char * __restrict); +size_t strxfrm(char * __restrict, const char * __restrict, size_t); -/* Nonstandard routines */ -#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) -int bcmp(const void *, const void *, size_t); -void bcopy(const void *, void *, size_t); -void bzero(void *, size_t); -int ffs(int); -char *index(const char *, int); -void *memccpy(void *, const void *, int, size_t); -char *rindex(const char *, int); -int strcasecmp(const char *, const char *); -char *strcasestr(const char *, const char *); +#if __POSIX_VISIBLE >= 200112 +void *memccpy(void * __restrict, const void * __restrict, int, size_t); char *strdup(const char *); int strerror_r(int, char *, size_t); +char *strtok_r(char *, const char *, char **); +#endif + +#if __BSD_VISIBLE +char *strcasestr(const char *, const char *); size_t strlcat(char *, const char *, size_t); size_t strlcpy(char *, const char *, size_t); void strmode(int, char *); -int strncasecmp(const char *, const char *, size_t); char *strnstr(const char *, const char *, size_t); char *strsep(char **, const char *); char *strsignal(int); -char *strtok_r(char *, const char *, char **); void swab(const void *, void *, size_t); #endif __END_DECLS Index: include/strings.h =================================================================== RCS file: /work/repo/src/include/strings.h,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 strings.h --- include/strings.h 24 May 1994 09:57:08 -0000 1.1.1.1 +++ include/strings.h 1 Apr 2002 10:01:40 -0000 @@ -1,6 +1,6 @@ /*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 2002 Mike Barcroft + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,18 +10,11 @@ * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 REGENTS OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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) @@ -30,7 +23,29 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)strings.h 8.1 (Berkeley) 6/2/93 + * $FreeBSD$ */ -#include +#ifndef _STRINGS_H_ +#define _STRINGS_H_ + +#include +#include + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +__BEGIN_DECLS +int bcmp(const void *, const void *, size_t); /* LEGACY */ +void bcopy(const void *, void *, size_t); /* LEGACY */ +void bzero(void *, size_t); /* LEGACY */ +int ffs(int); +char *index(const char *, int); /* LEGACY */ +char *rindex(const char *, int); /* LEGACY */ +int strcasecmp(const char *, const char *); +int strncasecmp(const char *, const char *, size_t); +__END_DECLS + +#endif /* _STRINGS_H_ */ --zhXaljGHf11kAtnf-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Apr 1 20:59:10 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id D84A637B41B for ; Mon, 1 Apr 2002 20:59:08 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.11.4/8.11.6) id g324wv062848; Mon, 1 Apr 2002 23:58:57 -0500 (EST) (envelope-from wollman) Date: Mon, 1 Apr 2002 23:58:57 -0500 (EST) From: Garrett Wollman Message-Id: <200204020458.g324wv062848@khavrinen.lcs.mit.edu> To: "Tim J. Robbins" Cc: freebsd-standards@FreeBSD.ORG Subject: Re: standards/36191: P1003.1-2001 csplit utility In-Reply-To: <200203301100.g2UB0EW11994@freefall.freebsd.org> References: <200203301100.g2UB0EW11994@freefall.freebsd.org> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG < said: > I have now fixed both of these. The manual page for sigaction > doesn't say its safe to call snprintf() from a signal handler, but > it still looks safe to do it. It is not safe to call any stdio function from a signal handler. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Apr 1 21:50:13 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 915A837B423; Mon, 1 Apr 2002 21:50:10 -0800 (PST) Received: (from jmallett@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g325oAe73099; Mon, 1 Apr 2002 21:50:10 -0800 (PST) (envelope-from jmallett) Date: Mon, 1 Apr 2002 21:50:10 -0800 (PST) From: Message-Id: <200204020550.g325oAe73099@freefall.freebsd.org> To: jmallett@FreeBSD.org, freebsd-standards@FreeBSD.org, jmallett@FreeBSD.org Subject: Re: standards/36245: Missing P1003.1-2001 fold -b and -s options Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Synopsis: Missing P1003.1-2001 fold -b and -s options Responsible-Changed-From-To: freebsd-standards->jmallett Responsible-Changed-By: jmallett Responsible-Changed-When: Mon Apr 1 21:49:51 PST 2002 Responsible-Changed-Why: Over to me. http://www.freebsd.org/cgi/query-pr.cgi?pr=36245 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Apr 1 21:53:22 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id EAFEC37B429; Mon, 1 Apr 2002 21:53:08 -0800 (PST) Received: (from jmallett@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g325r8V73691; Mon, 1 Apr 2002 21:53:08 -0800 (PST) (envelope-from jmallett) Date: Mon, 1 Apr 2002 21:53:08 -0800 (PST) From: Message-Id: <200204020553.g325r8V73691@freefall.freebsd.org> To: jmallett@FreeBSD.org, freebsd-standards@FreeBSD.org, jmallett@FreeBSD.org Subject: Re: standards/36075: P1003.1-2001 m4(1) -s option Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Synopsis: P1003.1-2001 m4(1) -s option Responsible-Changed-From-To: freebsd-standards->jmallett Responsible-Changed-By: jmallett Responsible-Changed-When: Mon Apr 1 21:52:55 PST 2002 Responsible-Changed-Why: Over to me. http://www.freebsd.org/cgi/query-pr.cgi?pr=36075 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Apr 5 0: 1: 3 2002 Delivered-To: freebsd-standards@freebsd.org Received: from bazooka.trit.org (bazooka.trit.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 0728337B428 for ; Fri, 5 Apr 2002 00:00:00 -0800 (PST) Received: by bazooka.trit.org (Postfix, from userid 1000) id 754FB3E31; Fri, 5 Apr 2002 08:00:00 +0000 (UTC) Received: from bazooka (localhost [127.0.0.1]) by bazooka.trit.org (Postfix) with ESMTP id 736953C12E for ; Fri, 5 Apr 2002 08:00:00 +0000 (UTC) To: standards@freebsd.org Subject: %j length modifier in kernel printf Date: Fri, 05 Apr 2002 07:59:55 +0000 From: Dima Dorfman Message-Id: <20020405080000.754FB3E31@bazooka.trit.org> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I've implemented the %j and %z (named %Z (for now?), since %z is signed hex) length modifiers in the kernel printf(). The patch below has been tested on i386, and appears to work okay. My primary concern with it is breaking sign extension stuff; I've run tests to check that I didn't break it completely, but it's very possible that I still missed some corner cases. I would appreciate it if someone could review it for such errors and test it on a 64-bit platform; I have no reason to think it will break there, but it can't hurt to check (just apply and see if ddb ps output looks sensible). I'd hate to hose printf() for !i386. Also note that printf now uses intmax_t arithmetic even for shorter types. This has some performance implications, but I don't think kernel printf is used anywhere where such micropessimizations would be noticeable. Thanks in advance. Index: subr_prf.c =================================================================== RCS file: /ref/cvsf/src/sys/kern/subr_prf.c,v retrieving revision 1.80 diff -u -r1.80 subr_prf.c --- subr_prf.c 1 Apr 2002 21:30:49 -0000 1.80 +++ subr_prf.c 4 Apr 2002 02:33:56 -0000 @@ -40,6 +40,7 @@ */ #include +#include #include #include #include @@ -78,6 +79,12 @@ size_t remain; }; +/* Length modifier. */ +enum lenmod { + LM_POINTER, LM_QUAD, LM_UQUAD, LM_LONG, LM_ULONG, + LM_INT, LM_UINT, LM_INTMAX, LM_UINTMAX, LM_SIZET +}; + extern int log_open; struct tty *constty; /* pointer to console "window" tty */ @@ -86,8 +93,9 @@ static void msglogchar(int c, int pri); static void msgaddchar(int c, void *dummy); static void putchar(int ch, void *arg); -static char *ksprintn(char *nbuf, u_long num, int base, int *len); -static char *ksprintqn(char *nbuf, u_quad_t num, int base, int *len); +static char *ksprintn(char *nbuf, uintmax_t num, int base, int *len); +static uintmax_t lm_arg(va_list *app, enum lenmod lm); +static enum lenmod lm_unsigned(enum lenmod in); static void snprintf_func(int ch, void *arg); static int consintr = 1; /* Ok to handle console interrupts? */ @@ -419,9 +427,9 @@ * The buffer pointed to by `nbuf' must have length >= MAXNBUF. */ static char * -ksprintn(nbuf, ul, base, lenp) +ksprintn(nbuf, um, base, lenp) char *nbuf; - u_long ul; + uintmax_t um; int base, *lenp; { char *p; @@ -429,29 +437,92 @@ p = nbuf; *p = '\0'; do { - *++p = hex2ascii(ul % base); - } while (ul /= base); + *++p = hex2ascii(um % base); + } while (um /= base); if (lenp) *lenp = p - nbuf; return (p); } -/* ksprintn, but for a quad_t. */ -static char * -ksprintqn(nbuf, uq, base, lenp) - char *nbuf; - u_quad_t uq; - int base, *lenp; + +/* + * Retrieve the next argument in `app' according to `lm'. + */ +static uintmax_t +lm_arg(va_list *app, enum lenmod lm) { - char *p; + uintmax_t um; - p = nbuf; - *p = '\0'; - do { - *++p = hex2ascii(uq % base); - } while (uq /= base); - if (lenp) - *lenp = p - nbuf; - return (p); + switch (lm) { + case LM_POINTER: + um = (uintptr_t)va_arg(*app, void *); + break; + case LM_QUAD: + um = (quad_t)va_arg(*app, quad_t); + break; + case LM_UQUAD: + um = (u_quad_t)va_arg(*app, u_quad_t); + break; + case LM_LONG: + um = (long)va_arg(*app, long); + break; + case LM_ULONG: + um = (u_long)va_arg(*app, u_long); + break; + case LM_INT: + um = (int)va_arg(*app, int); + break; + case LM_UINT: + um = (u_int)va_arg(*app, u_int); + break; + case LM_INTMAX: + um = (intmax_t)va_arg(*app, intmax_t); + break; + case LM_UINTMAX: + um = (uintmax_t)va_arg(*app, uintmax_t); + break; + case LM_SIZET: + um = (size_t)va_arg(*app, size_t); + break; + default: + panic("lm_arg: unknown lm=%d", lm); + } + return (um); +} + +/* + * Return the unsigned counerpart of the length modifier passed in. + */ +static enum lenmod +lm_unsigned(enum lenmod in) +{ + enum lenmod out; + + switch (in) { + case LM_QUAD: + out = LM_UQUAD; + break; + case LM_LONG: + out = LM_ULONG; + break; + case LM_INT: + out = LM_UINT; + break; + case LM_INTMAX: + out = LM_UINTMAX; + break; + case LM_UQUAD: + case LM_ULONG: + case LM_UINT: + case LM_UINTMAX: + case LM_POINTER: + case LM_SIZET: /* Should we do something special with this? */ + /* These are already unsigned, so just return the input. */ + out = in; + break; + default: + panic("lm_unsigned: unknown lm=%d", in); + } + return (out); } /* @@ -488,15 +559,14 @@ char *p, *q, *d; u_char *up; int ch, n; - u_long ul; - u_quad_t uq; - int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot; + uintmax_t um; + enum lenmod lm; + int base, tmp, width, ladjust, sharpflag, neg, sign, dot; int dwidth; char padc; int retval = 0; - ul = 0; - uq = 0; + um = 0; if (!func) d = (char *) arg; else @@ -516,7 +586,8 @@ return (retval); PCHAR(ch); } - qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0; + lm = LM_INT; + ladjust = 0; sharpflag = 0; neg = 0; sign = 0; dot = 0; dwidth = 0; reswitch: switch (ch = (u_char)*fmt++) { case '.': @@ -564,17 +635,17 @@ width = n; goto reswitch; case 'b': - ul = va_arg(ap, int); + um = va_arg(ap, int); p = va_arg(ap, char *); - for (q = ksprintn(nbuf, ul, *p++, NULL); *q;) + for (q = ksprintn(nbuf, um, *p++, NULL); *q;) PCHAR(*q--); - if (!ul) + if (!um) break; for (tmp = 0; *p;) { n = *p++; - if (ul & (1 << (n - 1))) { + if (um & (1 << (n - 1))) { PCHAR(tmp ? ',' : '<'); for (; (n = *p) > ' '; ++p) PCHAR(n); @@ -604,48 +675,34 @@ } break; case 'd': - if (qflag) - uq = va_arg(ap, quad_t); - else if (lflag) - ul = va_arg(ap, long); - else - ul = va_arg(ap, int); + um = lm_arg(&ap, lm); sign = 1; base = 10; goto number; + case 'j': + lm = LM_INTMAX; + goto reswitch; case 'l': - if (lflag) { - lflag = 0; - qflag = 1; - } else - lflag = 1; + if (lm == LM_LONG) + lm = LM_QUAD; + else + lm = LM_LONG; goto reswitch; case 'o': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = va_arg(ap, u_int); + um = lm_arg(&ap, lm_unsigned(lm)); base = 8; goto nosign; case 'p': - ul = (uintptr_t)va_arg(ap, void *); + um = lm_arg(&ap, LM_POINTER); base = 16; sharpflag = (width == 0); goto nosign; case 'q': - qflag = 1; + lm = LM_QUAD; goto reswitch; case 'n': case 'r': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = sign ? - (u_long)va_arg(ap, int) : va_arg(ap, u_int); + um = lm_arg(&ap, sign ? lm : lm_unsigned(lm)); base = radix; goto number; case 's': @@ -670,50 +727,29 @@ PCHAR(padc); break; case 'u': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = va_arg(ap, u_int); + um = lm_arg(&ap, lm_unsigned(lm)); base = 10; goto nosign; case 'x': case 'X': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = va_arg(ap, u_int); + um = lm_arg(&ap, lm_unsigned(lm)); base = 16; goto nosign; + case 'Z': /* XXX: This should be 'z'. */ + lm = LM_SIZET; + goto reswitch; case 'z': - if (qflag) - uq = va_arg(ap, u_quad_t); - else if (lflag) - ul = va_arg(ap, u_long); - else - ul = sign ? - (u_long)va_arg(ap, int) : va_arg(ap, u_int); + um = lm_arg(&ap, sign ? lm : lm_unsigned(lm)); base = 16; goto number; nosign: sign = 0; number: - if (qflag) { - if (sign && (quad_t)uq < 0) { - neg = 1; - uq = -(quad_t)uq; - } - p = ksprintqn(nbuf, uq, base, &tmp); - } else { - if (sign && (long)ul < 0) { - neg = 1; - ul = -(long)ul; - } - p = ksprintn(nbuf, ul, base, &tmp); + if (sign && (intmax_t)um < 0) { + neg = 1; + um = -(intmax_t)um; } - if (sharpflag && (qflag ? uq != 0 : ul != 0)) { + p = ksprintn(nbuf, um, base, &tmp); + if (sharpflag && um != 0) { if (base == 8) tmp++; else if (base == 16) @@ -727,7 +763,7 @@ PCHAR(padc); if (neg) PCHAR('-'); - if (sharpflag && (qflag ? uq != 0 : ul != 0)) { + if (sharpflag && um != 0) { if (base == 8) { PCHAR('0'); } else if (base == 16) { @@ -746,7 +782,17 @@ break; default: PCHAR('%'); - if (lflag) + /* + * XXX: This is bogus. We can have more flags + * than just `l', and we can even have `l' + * more than once. The old test was + * + * if (lflag) + * + * and we're just imitating that for now. + */ + if (lm == LM_LONG || lm == LM_ULONG || + lm == LM_QUAD || lm == LM_UQUAD) PCHAR('l'); PCHAR(ch); break; @@ -776,7 +822,7 @@ dangling = 0; } msgaddchar('<', NULL); - for (p = ksprintn(nbuf, (u_long)pri, 10, NULL); *p;) + for (p = ksprintn(nbuf, (uintmax_t)pri, 10, NULL); *p;) msgaddchar(*p--, NULL); msgaddchar('>', NULL); lastpri = pri; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Apr 5 1: 1:31 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 8B56A37B416 for ; Fri, 5 Apr 2002 01:01:28 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id TAA20291; Fri, 5 Apr 2002 19:01:19 +1000 Date: Fri, 5 Apr 2002 18:49:19 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dima Dorfman Cc: standards@FreeBSD.ORG Subject: Re: %j length modifier in kernel printf In-Reply-To: <20020405080000.754FB3E31@bazooka.trit.org> Message-ID: <20020405184249.S3947-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 5 Apr 2002, Dima Dorfman wrote: > I've implemented the %j and %z (named %Z (for now?), since %z is > signed hex) length modifiers in the kernel printf(). The patch below > has been tested on i386, and appears to work okay. My primary concern > with it is breaking sign extension stuff; I've run tests to check that > I didn't break it completely, but it's very possible that I still > missed some corner cases. I don't like the restructuring of the code (lm functions). I think the kernel kvprintf should be much like the userland __vfprintf except for not having support for floating point (yet?) or the positional parameters bloat (ever). Are the significant complications for the extra formats in the kernel printf? > Also note that printf now uses intmax_t arithmetic even for shorter > types. This has some performance implications, but I don't think > kernel printf is used anywhere where such micropessimizations would be > noticeable. I agree, but this takes us further from the userland printf. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Apr 5 3:21:30 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D5B7537B41A for ; Fri, 5 Apr 2002 03:20:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g35BK3o49220; Fri, 5 Apr 2002 03:20:03 -0800 (PST) (envelope-from gnats) Received: from treetop.robbins.dropbear.id.au (104.a.010.mel.iprimus.net.au [210.50.200.104]) by hub.freebsd.org (Postfix) with ESMTP id 2A54A37B404 for ; Fri, 5 Apr 2002 03:17:23 -0800 (PST) Received: from treetop.robbins.dropbear.id.au (localhost [127.0.0.1]) by treetop.robbins.dropbear.id.au (8.12.2/8.12.2) with ESMTP id g35BDfSu002186 for ; Fri, 5 Apr 2002 21:13:41 +1000 (EST) (envelope-from tim@treetop.robbins.dropbear.id.au) Received: (from tim@localhost) by treetop.robbins.dropbear.id.au (8.12.2/8.12.2/Submit) id g35BDdRZ002185; Fri, 5 Apr 2002 21:13:39 +1000 (EST) Message-Id: <200204051113.g35BDdRZ002185@treetop.robbins.dropbear.id.au> Date: Fri, 5 Apr 2002 21:13:39 +1000 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36783: P1003.1-2001 -s -A -j -N -t options for od(1) (patch) Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36783 >Category: standards >Synopsis: P1003.1-2001 -s -A -j -N -t options for od(1) (patch) >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Apr 05 03:20:03 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD treetop.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #2: Sat Mar 30 20:10:51 EST 2002 tim@treetop.robbins.dropbear.id.au:/usr/obj/usr/src/sys/GENERIC i386 >Description: 4.4BSD's (and FreeBSD's) hexdump utility is missing the -s, -A, -j, -N, and -t options in its od compatibility mode. Here is a patch to add them. >How-To-Repeat: od -Ax -tx1 /dev/null >Fix: I've renamed the `deprecated' variable to `odmode' and removed everything to do with deprecation from the program and manual pages, added the -t option then rewritten all the other output-format options in terms of that. I've also written a manual page that is much more complete than the old one. long double output (-t fL) is not supported. This bug is documented in the new manual page. Adding support for long double would require changes all over the place, I thought it would be best to get it pretty close, then add long double support for hexdump, then od. Index: conv.c =================================================================== RCS file: /home/ncvs/src/usr.bin/hexdump/conv.c,v retrieving revision 1.3 diff -u -r1.3 conv.c --- conv.c 2002/03/07 23:00:27 1.3 +++ conv.c 2002/04/05 11:04:18 @@ -48,7 +48,6 @@ PR *pr; u_char *p; { - extern int deprecated; char buf[10]; char const *str; @@ -58,7 +57,7 @@ goto strpr; /* case '\a': */ case '\007': - if (deprecated) /* od didn't know about \a */ + if (odmode) /* od didn't know about \a */ break; str = "\\a"; goto strpr; @@ -78,7 +77,7 @@ str = "\\t"; goto strpr; case '\v': - if (deprecated) + if (odmode) break; str = "\\v"; goto strpr; @@ -101,7 +100,6 @@ PR *pr; u_char *p; { - extern int deprecated; static char const * list[] = { "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel", "bs", "ht", "lf", "vt", "ff", "cr", "so", "si", @@ -112,14 +110,14 @@ /* od used nl, not lf */ if (*p <= 0x1f) { *pr->cchar = 's'; - if (deprecated && *p == 0x0a) + if (odmode && *p == 0x0a) (void)printf(pr->fmt, "nl"); else (void)printf(pr->fmt, list[*p]); } else if (*p == 0x7f) { *pr->cchar = 's'; (void)printf(pr->fmt, "del"); - } else if (deprecated && *p == 0x20) { /* od replaced space with sp */ + } else if (odmode && *p == 0x20) { /* od replaced space with sp */ *pr->cchar = 's'; (void)printf(pr->fmt, " sp"); } else if (isprint(*p)) { Index: display.c =================================================================== RCS file: /home/ncvs/src/usr.bin/hexdump/display.c,v retrieving revision 1.11 diff -u -r1.11 display.c --- display.c 2002/03/22 01:22:45 1.11 +++ display.c 2002/04/05 11:04:18 @@ -228,7 +228,6 @@ u_char * get() { - extern int length; static int ateof = 1; static u_char *curp, *savp; register int n; @@ -255,6 +254,8 @@ * block and set the end flag. */ if (!length || (ateof && !next((char **)NULL))) { + if (odmode && address < skip) + errx(1, "cannot skip past end of input"); if (need == blocksize) return((u_char *)NULL); if (vflag != ALL && @@ -298,8 +299,6 @@ nread += n; } } - -extern off_t skip; /* bytes to skip */ int next(argv) Index: hexdump.h =================================================================== RCS file: /home/ncvs/src/usr.bin/hexdump/hexdump.h,v retrieving revision 1.5 diff -u -r1.5 hexdump.h --- hexdump.h 2002/03/22 01:22:45 1.5 +++ hexdump.h 2002/04/05 11:04:19 @@ -73,6 +73,9 @@ extern FS *fshead; /* head of format strings list */ extern int blocksize; /* data block size */ +extern int odmode; /* are we acting as od(1)? */ +extern int length; /* amount of data to read */ +extern off_t skip; /* amount of data to skip at start */ enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */ void add(const char *); Index: hexsyntax.c =================================================================== RCS file: /home/ncvs/src/usr.bin/hexdump/hexsyntax.c,v retrieving revision 1.9 diff -u -r1.9 hexsyntax.c --- hexsyntax.c 2001/09/01 22:42:46 1.9 +++ hexsyntax.c 2002/04/05 11:04:19 @@ -58,7 +58,6 @@ { extern enum _vflag vflag; extern FS *fshead; - extern int length; int ch; char *p, **argv; Index: od.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/hexdump/od.1,v retrieving revision 1.10 diff -u -r1.10 od.1 --- od.1 2000/12/27 16:52:29 1.10 +++ od.1 2002/04/05 11:04:19 @@ -40,7 +40,11 @@ .Nd octal, decimal, hex, ASCII dump .Sh SYNOPSIS .Nm -.Op Fl aBbcDdeFfHhIiLlOovXx +.Op Fl aBbcDdeFfHhIiLlOosvXx +.Op Fl A Ar base +.Op Fl j Ar skip +.Op Fl N Ar length +.Op Fl t Ar type .Sm off .Oo .Op Cm \&+ @@ -51,33 +55,141 @@ .Sm on .Ar file .Sh DESCRIPTION -.Nm Od -has been deprecated in favor of -.Xr hexdump 1 . -.Pp -.Nm Hexdump , -if called as -.Nm , -provides compatibility for the options listed above. +The +.Nm +utility is a filter which displays the specified files, or standard +input if no files are specified, in a user specified format. .Pp -It does not provide compatibility for the -.Fl s -option (see -.Xr strings 1 ) -or the -.Fl P , -.Fl p , +The options are as follows: +.Bl -tag -width Fl +.It Fl A Ar base +Specify the input address base. +.Ar base +may be one of +.Ql d , +.Ql o , +.Ql x +or +.Ql n , +which specify decimal, octal, hexadecimal +addresses or no address, respectively. +.It Fl a +Equivalent to +.Fl t Ar a . +.It Fl B , Fl o +Equivalent to +.Fl t Ar o2 . +.It Fl b +Equivalent to +.Fl t Ar o1 . +.It Fl c +Equivalent to +.Fl t Ar c . +.It Fl D +Equivalent to +.Fl t Ar u4 . +.It Fl e , Fl F +Equivalent to +.Fl t Ar fD . +.It Fl f +Equivalent to +.Fl t Ar fF . +.It Fl H , Fl X +Equivalent to +.Fl t Ar x4 . +.It Fl h , Fl x +Equivalent to +.Fl t Ar x2 . +.It Fl I , Fl L , Fl l +Equivalent to +.Fl t Ar dL . +.It Fl i +Equivalent to +.Fl t Ar dI . +.It Fl j Ar skip +Skip +.Ar skip +bytes of the combined input before dumping. The number may be followed by one +of +.Ql b , +.Ql k +or +.Ql m +which specify the units of the number as blocks (512 bytes), kilobytes and +megabytes, respectively. +.It Fl N Ar length +Dump at most +.Ar length +bytes of input. +.It Fl O +Equivalent to +.Fl t Ar o4 . +.It Fl s +Equivalent to +.Fl t Ar d2 . +.It Fl t Ar type +Specify the output format. +.Ar type +is a string containing one or more of the following kinds of type specifiers: +.Bl -tag -width indent +.It Cm a +Named characters +.Pq Sq ASCII . +.It Cm c +Characters. +.It Cm [d|o|u|x][C|S|I|L| Ns Ar n Ns ] +Signed decimal +.Pq Ql d , +octal +.Pq Ql o , +unsigned decimal +.Pq Ql u +or +hexadecimal +.Pq Ql x . +Followed by an optional size specifier, which may be either +.Ql C Pq "char" , +.Ql S Pq "short" , +.Ql I Pq "int" , +.Ql L Pq "long" , +or a byte count as a decimal integer. +.It Cm f[F|D|L| Ns Ar n Ns ] +Floating-point number. +Followed by an optional size specifier, which may be either +.Ql F Pq "float" , +.Ql D Pq "double" or -.Fl w -options, nor is compatibility provided for the ``label'' component -of the offset syntax. +.Ql L Pq "long double" . +.El +.It Fl v +Write all input data, instead of replacing lines of duplicate values with a +.Ql * . +.El +.Pp +Multiple options that specify output format may be used; the output will +contain one line for each format. +.Pp +If no output format is specified, +.Fl t Ar oS +is assumed. +.Sh DIAGNOSTICS +.Ex -std .Sh SEE ALSO .Xr hexdump 1 , .Xr strings 1 -.Sh BUGS -Quite a few. +.Sh STANDARDS +The +.Nm +utility is expected to conform to +.St -p1003.1-2001 . .Sh HISTORY A .Nm command appeared in .At v1 . +.Sh BUGS +The +.Sq "long double" +data type, +.Fl t Ar fL , +is not supported. Index: odsyntax.c =================================================================== RCS file: /home/ncvs/src/usr.bin/hexdump/odsyntax.c,v retrieving revision 1.10 diff -u -r1.10 odsyntax.c --- odsyntax.c 2002/03/22 01:22:45 1.10 +++ odsyntax.c 2002/04/05 11:04:20 @@ -43,16 +43,20 @@ #include #include +#include #include #include #include #include "hexdump.h" -int deprecated; +#define PADDING " " +int odmode; + +static void odadd(const char *); +static void odformat(const char *); static void odoffset(int, char ***); -static void odprecede(void); void oldsyntax(argc, argvp) @@ -62,91 +66,110 @@ extern enum _vflag vflag; extern FS *fshead; int ch; - char **argv; + char **argv, *end; + + /* Add initial (default) address format. -A may change it later. */ +#define TYPE_OFFSET 7 + add("\"%07.7_Ao\n\""); + add("\"%07.7_ao \""); - deprecated = 1; + odmode = 1; argv = *argvp; - while ((ch = getopt(argc, argv, "aBbcDdeFfHhIiLlOoPpswvXx")) != -1) + while ((ch = getopt(argc, argv, "A:aBbcDdeFfHhIij:LlN:Oost:vXx")) != -1) switch (ch) { + case 'A': + switch (*optarg) { + case 'd': + case 'o': + case 'x': + fshead->nextfu->fmt[TYPE_OFFSET] = *optarg; + fshead->nextfs->nextfu->fmt[TYPE_OFFSET] = *optarg; + break; + case 'n': + fshead->nextfu->fmt = ""; + fshead->nextfs->nextfu->fmt = PADDING; + break; + default: + errx(1, "%s: invalid address base", optarg); + } + break; case 'a': - odprecede(); - add("16/1 \"%3_u \" \"\\n\""); + odformat("a"); break; case 'B': case 'o': - odprecede(); - add("8/2 \" %06o \" \"\\n\""); + odformat("o2"); break; case 'b': - odprecede(); - add("16/1 \"%03o \" \"\\n\""); + odformat("o1"); break; case 'c': - odprecede(); - add("16/1 \"%3_c \" \"\\n\""); + odformat("c"); break; case 'd': - odprecede(); - add("8/2 \" %05u \" \"\\n\""); + odformat("u2"); break; case 'D': - odprecede(); - add("4/4 \" %010u \" \"\\n\""); + odformat("u4"); break; case 'e': /* undocumented in od */ case 'F': - odprecede(); - add("2/8 \" %21.14e \" \"\\n\""); + odformat("fD"); break; - case 'f': - odprecede(); - add("4/4 \" %14.7e \" \"\\n\""); + odformat("fF"); break; case 'H': case 'X': - odprecede(); - add("4/4 \" %08x \" \"\\n\""); + odformat("x4"); break; case 'h': case 'x': - odprecede(); - add("8/2 \" %04x \" \"\\n\""); + odformat("x2"); break; case 'I': case 'L': case 'l': - odprecede(); - add("4/4 \" %11d \" \"\\n\""); + odformat("dL"); break; case 'i': - odprecede(); - add("8/2 \" %6d \" \"\\n\""); + odformat("dI"); + break; + case 'j': + errno = 0; + skip = (off_t)strtoul(optarg, &end, 0); + if (*end == 'b') + skip *= 512; + else if (*end == 'k') + skip *= 1024; + else if (*end == 'm') + skip *= 1048576L; + if (errno != 0 || strlen(end) > 1) + errx(1, "%s: invalid skip amount", optarg); + break; + case 'N': + if ((length = atoi(optarg)) <= 0) + errx(1, "%s: invalid length", optarg); break; case 'O': - odprecede(); - add("4/4 \" %011o \" \"\\n\""); + odformat("o4"); + break; + case 's': + odformat("d2"); break; + case 't': + odformat(optarg); + break; case 'v': vflag = ALL; break; - case 'P': - case 'p': - case 's': - case 'w': case '?': default: - warnx("od(1) has been deprecated for hexdump(1)"); - if (ch != '?') - warnx("hexdump(1) compatibility doesn't support the -%c option%s", - ch, ch == 's' ? "; see strings(1)" : ""); usage(); } - if (!fshead) { - add("\"%07.7_Ao\n\""); - add("\"%07.7_ao \" 8/2 \"%06o \" \"\\n\""); - } + if (fshead->nextfs->nextfs == NULL) + odformat("oS"); argc -= optind; *argvp += optind; @@ -160,7 +183,6 @@ int argc; char ***argvp; { - extern off_t skip; unsigned char *p, *num, *end; int base; @@ -241,7 +263,6 @@ * If the offset uses a non-octal base, the base of the offset * is changed as well. This isn't pretty, but it's easy. */ -#define TYPE_OFFSET 7 if (base == 16) { fshead->nextfu->fmt[TYPE_OFFSET] = 'x'; fshead->nextfs->nextfu->fmt[TYPE_OFFSET] = 'x'; @@ -254,15 +275,127 @@ (*argvp)[1] = NULL; } +static void +odformat(const char *fmt) +{ + size_t size; + unsigned long long n; + int digits; + char *hdfmt, fchar, *end; + + while (*fmt != '\0') { + switch ((fchar = *fmt++)) { + case 'a': + odadd("16/1 \"%3_u \" \"\\n\""); + break; + case 'c': + odadd("16/1 \"%3_c \" \"\\n\""); + break; + case 'o': + case 'u': + case 'd': + case 'x': + size = sizeof(int); + switch (*fmt) { + case 'C': + size = sizeof(char); + fmt++; + break; + case 'I': + size = sizeof(int); + fmt++; + break; + case 'L': + size = sizeof(long); + fmt++; + break; + case 'S': + size = sizeof(short); + fmt++; + break; + default: + if (isdigit(*fmt)) { + errno = 0; + size = strtol(fmt, &end, 10); + if (errno != 0 || size <= 0) + errx(1, "bad size"); + if (size != sizeof(char) && + size != sizeof(short) && + size != sizeof(int) && + size != sizeof(long)) + errx(1, + "unsupported int size %ld", + size); + fmt = (const char *)end; + } + } + n = (1ULL << (8 * size)) - 1; + digits = 0; + while (n != 0) { + digits++; + n >>= (fchar == 'o' || fchar == 'd') ? 3 : 4; + } + asprintf(&hdfmt, "%d/%d \"%%%s%d%c \" \"\\n\"", + 16 / size, size, fchar == 'd' ? "" : "0", + digits, fchar); + if (hdfmt == NULL) + err(1, NULL); + odadd(hdfmt); + free(hdfmt); + break; + case 'f': + size = sizeof(double); + switch (*fmt) { + case 'F': + size = sizeof(float); + fmt++; + break; + case 'D': + size = sizeof(double); + fmt++; + break; + case 'L': + size = sizeof(long double); + fmt++; + break; + default: + if (isdigit(*fmt)) { + errno = 0; + size = strtol(fmt, &end, 10); + if (errno != 0 || size <= 0) + errx(1, "bad size"); + fmt = (const char *)end; + } + } + switch (size) { + case sizeof(float): + odadd("4/4 \" %14.7e \" \"\\n\""); + break; + case sizeof(double): + odadd("2/8 \" %21.14e \" \"\\n\""); + break; + case sizeof(long double): +#ifdef notyet + odadd("1/16 \" %21.14Le \" \"\\n\""); + break; +#endif + default: + errx(1, "unsupported FP size %ld", size); + } + break; + default: + errx(1, "%s: bad format", fmt); + } + } +} + static void -odprecede() +odadd(const char *fmt) { - static int first = 1; + static int needpad; - if (first) { - first = 0; - add("\"%07.7_Ao\n\""); - add("\"%07.7_ao \""); - } else - add("\" \""); + if (needpad) + add("\""PADDING"\""); + add(fmt); + needpad = 1; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Apr 5 3:50:25 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A0DAD37B404 for ; Fri, 5 Apr 2002 03:50:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g35Bo3955377; Fri, 5 Apr 2002 03:50:03 -0800 (PST) (envelope-from gnats) Date: Fri, 5 Apr 2002 03:50:03 -0800 (PST) Message-Id: <200204051150.g35Bo3955377@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: standards/36783: P1003.1-2001 -s -A -j -N -t options for od(1) (patch) Reply-To: "Tim J. Robbins" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36783; it has been noted by GNATS. From: "Tim J. Robbins" To: freebsd-gnats-submit@FreeBSD.ORG Cc: Subject: Re: standards/36783: P1003.1-2001 -s -A -j -N -t options for od(1) (patch) Date: Fri, 5 Apr 2002 21:42:09 +1000 On Fri, Apr 05, 2002 at 09:13:39PM +1000, Tim J. Robbins wrote: > + n = (1ULL << (8 * size)) - 1; > + digits = 0; > + while (n != 0) { > + digits++; > + n >>= (fchar == 'o' || fchar == 'd') ? 3 : 4; > + } Oops. There is a little problem here with output of unsigned decimal numbers. --- odsyntax.c.old Fri Apr 5 21:37:47 2002 +++ odsyntax.c Fri Apr 5 21:41:07 2002 @@ -333,10 +333,11 @@ digits = 0; while (n != 0) { digits++; - n >>= (fchar == 'o' || fchar == 'd') ? 3 : 4; + n >>= (fchar == 'x') ? 4 : 3; } asprintf(&hdfmt, "%d/%d \"%%%s%d%c \" \"\\n\"", - 16 / size, size, fchar == 'd' ? "" : "0", + 16 / size, size, + (fchar == 'd' || fchar == 'u') ? "" : "0", digits, fchar); if (hdfmt == NULL) err(1, NULL); Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Apr 5 9:24:53 2002 Delivered-To: freebsd-standards@freebsd.org Received: from Awfulhak.org (gw.Awfulhak.org [217.204.245.18]) by hub.freebsd.org (Postfix) with ESMTP id 408F437B41A for ; Fri, 5 Apr 2002 09:24:50 -0800 (PST) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [IPv6:fec0::1:12]) by Awfulhak.org (8.12.2/8.11.6) with ESMTP id g35HOkCu004869; Fri, 5 Apr 2002 18:24:46 +0100 (BST) (envelope-from brian@freebsd-services.com) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.12.2/8.12.2) with ESMTP id g35HOeq7045079; Fri, 5 Apr 2002 18:24:40 +0100 (BST) (envelope-from brian@freebsd-services.com) Message-Id: <200204051724.g35HOeq7045079@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.5 07/13/2001 with nmh-1.0.4 To: utsl@quic.net Cc: freebsd-standards@FreeBSD.ORG, Brian Somers Subject: Re: utmpx implementation In-Reply-To: Message from utsl@quic.net of "Thu, 21 Mar 2002 19:10:31 EST." <20020322001031.GA21735@quic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 05 Apr 2002 18:24:40 +0100 From: Brian Somers Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > I have written a utmpx implementation. It is written from scratch from > the SUSv2 spec (also in POSIX, I believe), and is under BSD license. I > have also examined other systems, and included what made sense to me. > > I have partially implemented reentrant functions, but haven't finished yet. > Suggestions and patches are welcome. [.....] Hi, This is just a comfort message to say that you haven't been ignored. I'm very interested in this implementation and will get around to trying it out RSN. -- Brian http://www.freebsd-services.com/ Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Apr 5 11:11:28 2002 Delivered-To: freebsd-standards@freebsd.org Received: from quic.net (romulus.quic.net [216.23.27.8]) by hub.freebsd.org (Postfix) with SMTP id E378337B419 for ; Fri, 5 Apr 2002 11:11:24 -0800 (PST) Received: (qmail 3093 invoked by uid 1032); 5 Apr 2002 19:11:31 -0000 From: utsl@quic.net Date: Fri, 5 Apr 2002 14:11:31 -0500 To: Brian Somers Cc: freebsd-standards@FreeBSD.ORG Subject: Re: utmpx implementation Message-ID: <20020405191131.GA2287@quic.net> References: <20020322001031.GA21735@quic.net> <200204051724.g35HOeq7045079@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200204051724.g35HOeq7045079@hak.lan.Awfulhak.org> User-Agent: Mutt/1.3.27i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Apr 05, 2002 at 06:24:40PM +0100, Brian Somers wrote: > > I have written a utmpx implementation. It is written from scratch from > > the SUSv2 spec (also in POSIX, I believe), and is under BSD license. I > > have also examined other systems, and included what made sense to me. > > > > I have partially implemented reentrant functions, but haven't finished yet. > > Suggestions and patches are welcome. > [.....] > > Hi, > > This is just a comfort message to say that you haven't been ignored. > I'm very interested in this implementation and will get around to > trying it out RSN. Thank you. I'm using it for a project I'm working on, and it was a huge help with source compatibility. I am also looking writing an implemention of libshadow, which would provide getspent and related functions, but work with /etc/master.passwd. Reading will be easy, but I'm still thinking about how to do writing. ---Nathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Apr 6 3:39:20 2002 Delivered-To: freebsd-standards@freebsd.org Received: from bazooka.trit.org (bazooka.trit.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id D40A937B400 for ; Sat, 6 Apr 2002 03:39:18 -0800 (PST) Received: by bazooka.trit.org (Postfix, from userid 1000) id 03E623E2F; Sat, 6 Apr 2002 11:39:14 +0000 (UTC) Received: from bazooka (localhost [127.0.0.1]) by bazooka.trit.org (Postfix) with ESMTP id 026053C12E; Sat, 6 Apr 2002 11:39:14 +0000 (UTC) To: Bruce Evans Cc: standards@FreeBSD.ORG Subject: Re: %j length modifier in kernel printf In-Reply-To: <20020405184249.S3947-100000@gamplex.bde.org>; from bde@zeta.org.au on "Fri, 5 Apr 2002 18:49:19 +1000 (EST)" Date: Sat, 06 Apr 2002 11:39:08 +0000 From: Dima Dorfman Message-Id: <20020406113914.03E623E2F@bazooka.trit.org> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bruce Evans wrote: > On Fri, 5 Apr 2002, Dima Dorfman wrote: > > > I've implemented the %j and %z (named %Z (for now?), since %z is > > signed hex) length modifiers in the kernel printf(). The patch below > > has been tested on i386, and appears to work okay. My primary concern > > with it is breaking sign extension stuff; I've run tests to check that > > I didn't break it completely, but it's very possible that I still > > missed some corner cases. > > I don't like the restructuring of the code (lm functions). I think > the kernel kvprintf should be much like the userland __vfprintf except > for not having support for floating point (yet?) or the positional > parameters bloat (ever). Are the significant complications for the > extra formats in the kernel printf? I didn't see any particular reason to model it on __vfprintf (besides that it might have been less work, but it didn't appear to be so to me). The latter needs to be concerned with things that the kernel printf doesn't care about (you mentioned floating point stuff and positional parameters), so is likely to be more complicated than the kernel printf needs to be. Therefore, keeping them in sync won't buy is much since they'll always be significantly different. What didn't you like about the lm functions? I admit they aren't pretty, but the *ARG() macros in __vfprintf are hardly better. Is this the only part that you thought was unlike __vfprintf? Thanks. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message