From owner-freebsd-standards Sun Apr 14 15:20:17 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 DE32F37B419 for ; Sun, 14 Apr 2002 15:20:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3EMK1i16360; Sun, 14 Apr 2002 15:20:01 -0700 (PDT) (envelope-from gnats) Received: from des.thinksec.com (213-145-188-137.dd.nextgentel.com [213.145.188.137]) by hub.freebsd.org (Postfix) with ESMTP id 6469537B400 for ; Sun, 14 Apr 2002 15:14:23 -0700 (PDT) Received: by des.thinksec.com (Postfix, from userid 2602) id B3EAE5604; Mon, 15 Apr 2002 00:13:16 +0200 (CEST) Message-Id: <20020414221316.B3EAE5604@des.thinksec.com> Date: Sun, 14 Apr 2002 19:10:35 +0200 (CEST) From: Dag-Erling Smorgrav Reply-To: Dag-Erling Smorgrav To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/37078: missing prototype for strdup(3) 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: 37078 >Category: standards >Synopsis: missing prototype for strdup(3) >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Apr 14 15:20:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Dag-Erling Smorgrav >Release: FreeBSD 5.0-CURRENT i386 >Organization: ThinkSec AS >Environment: System: FreeBSD des.thinksec.com 5.0-CURRENT FreeBSD 5.0-CURRENT #185: Sat Apr +13 07:20:28 CEST 2002 des@des.thinksec.com:/usr/src/sys/i386/compile/DES i386 >Description: Revision 1.13 of src/include/string.h made the strdup(3) prototype conditional on __POSIX_VISIBLE >= 200112. However, strdup(3) was in SUSv2 long before POSIX 2. Programs that set _XOPEN_SOURCE to 500 should get a prototype for strdup(3). >How-To-Repeat: # cd /usr/src/lib/libpam/modules/pam_passwdqc # make and observe the warnings. >Fix: Unknown. Revision 1.13 of src/include/string.h should be backed out until a satisfactory fix has been found. >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 Sun Apr 14 20:23:27 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 BA30D37B405; Sun, 14 Apr 2002 20:23:26 -0700 (PDT) Received: (from mike@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3F3NQg78763; Sun, 14 Apr 2002 20:23:26 -0700 (PDT) (envelope-from mike) Date: Sun, 14 Apr 2002 20:23:26 -0700 (PDT) From: Message-Id: <200204150323.g3F3NQg78763@freefall.freebsd.org> To: des@ofug.org, mike@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: standards/37078: missing prototype for strdup(3) 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 prototype for strdup(3) State-Changed-From-To: open->feedback State-Changed-By: mike State-Changed-When: Sun Apr 14 20:22:06 PDT 2002 State-Changed-Why: Can you please confirm that revision 1.14 solves this problem. http://www.freebsd.org/cgi/query-pr.cgi?pr=37078 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sun Apr 14 21: 0:11 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 D252937B416 for ; Sun, 14 Apr 2002 21:00:06 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3F406V83228; Sun, 14 Apr 2002 21:00:06 -0700 (PDT) (envelope-from gnats) Date: Sun, 14 Apr 2002 21:00:06 -0700 (PDT) Message-Id: <200204150400.g3F406V83228@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Dag-Erling Smorgrav Subject: Re: standards/37078: missing prototype for strdup(3) Reply-To: Dag-Erling Smorgrav 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/37078; it has been noted by GNATS. From: Dag-Erling Smorgrav To: freebsd-gnats-submit@freebsd.org Cc: Subject: Re: standards/37078: missing prototype for strdup(3) Date: 15 Apr 2002 05:51:29 +0200 writes: > Can you please confirm that revision 1.14 solves this problem. It does, thanks! DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sun Apr 14 22:37:46 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 A567137B400; Sun, 14 Apr 2002 22:37:45 -0700 (PDT) Received: (from mike@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3F5bjJ01679; Sun, 14 Apr 2002 22:37:45 -0700 (PDT) (envelope-from mike) Date: Sun, 14 Apr 2002 22:37:45 -0700 (PDT) From: Message-Id: <200204150537.g3F5bjJ01679@freefall.freebsd.org> To: des@ofug.org, mike@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: standards/37078: missing prototype for strdup(3) 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 prototype for strdup(3) State-Changed-From-To: feedback->closed State-Changed-By: mike State-Changed-When: Sun Apr 14 22:37:17 PDT 2002 State-Changed-Why: Problem resolved. http://www.freebsd.org/cgi/query-pr.cgi?pr=37078 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Apr 15 15:40:13 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 EB9F537B416 for ; Mon, 15 Apr 2002 15:40:09 -0700 (PDT) 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 IAA10393; Tue, 16 Apr 2002 08:36:03 +1000 Date: Tue, 16 Apr 2002 08:36:32 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: "M. Warner Losh" Cc: wollman@lcs.mit.edu, , Subject: Re: standards/36783 In-Reply-To: <20020412.123734.61861702.imp@village.org> Message-ID: <20020416082602.D5869-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, 12 Apr 2002, M. Warner Losh wrote: > In message: <200204121822.g3CIM4491247@khavrinen.lcs.mit.edu> > Garrett Wollman writes: > : < said: > : > : > This is no longer true. Long doubles can and do give better precision > : > than doubles, but at a high performance cost. > : > : Is GCC now emitting code to change the rounding mode from 53-bit to > : 80-bit whenever it works with long doubles? gcc-2.9x doesn't. > I haven't looked at the generated code, but I think so. I've been > able to get better precision from long doubles than doubles in > experimental code. (eg, 1 + epsilon allows me a smaller epsilon with > long double than double). At least on i386's, you would have to change FreeBSD's default rounding mode yourself (or run a Linux binary :-) for (1 + DBL_EPSILON / 2) to be different from 1). Changing the default may cause small errors and library math functions, not to mention printf(), since the library doesn't really support long doubles and may require plain double precision to work precisely. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Apr 17 23:40:26 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 5DFFC37B400; Wed, 17 Apr 2002 23:40:24 -0700 (PDT) Received: (from tjr@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3I6eOJ99204; Wed, 17 Apr 2002 23:40:24 -0700 (PDT) (envelope-from tjr) Date: Wed, 17 Apr 2002 23:40:24 -0700 (PDT) From: Message-Id: <200204180640.g3I6eOJ99204@freefall.freebsd.org> To: tjr@FreeBSD.org, freebsd-bugs@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: bin/11114: make(1) does not work as documented with .POSIX: target 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: make(1) does not work as documented with .POSIX: target Responsible-Changed-From-To: freebsd-bugs->freebsd-standards Responsible-Changed-By: tjr Responsible-Changed-When: Wed Apr 17 23:39:53 PDT 2002 Responsible-Changed-Why: Recategorise http://www.freebsd.org/cgi/query-pr.cgi?pr=11114 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Apr 17 23:50:26 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 0BB2D37B416 for ; Wed, 17 Apr 2002 23:50:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3I6o3A00572; Wed, 17 Apr 2002 23:50:03 -0700 (PDT) (envelope-from gnats) Date: Wed, 17 Apr 2002 23:50:03 -0700 (PDT) Message-Id: <200204180650.g3I6o3A00572@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: bin/11114: make(1) does not work as documented with .POSIX: target 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 bin/11114; it has been noted by GNATS. From: "Tim J. Robbins" To: Jens Schweikhardt Cc: bug-followup@FreeBSD.ORG, cjclark@alum.mit.edu, jmallett@FreeBSD.ORG Subject: Re: bin/11114: make(1) does not work as documented with .POSIX: target Date: Thu, 18 Apr 2002 15:50:09 +1000 Please try this patch & let me know whether it corrects the problems with the special .POSIX target. It is against HEAD, to try it on a 4.x release you will need to edit str.c and remove __DECONST macro usage. I realise it's not a particularly clean solution, and I'd be interested to hear how it could be done better. Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/main.c,v retrieving revision 1.56 diff -u -r1.56 main.c --- main.c 2002/04/13 12:20:51 1.56 +++ main.c 2002/04/18 06:25:35 @@ -113,7 +113,7 @@ GNode *DEFAULT; /* .DEFAULT node */ Boolean allPrecious; /* .PRECIOUS given on line by itself */ -static Boolean noBuiltins; /* -r flag */ +Boolean noBuiltins; /* -r flag */ static Lst makefiles; /* ordered list of makefiles to read */ static Boolean printVars; /* print value of one or more vars */ static Boolean expandVars; /* fully expand printed variables */ @@ -138,7 +138,6 @@ static void MainParseArgs(int, char **); char * chdir_verify_path(char *, char *); -static int ReadMakefile(void *, void *); static void usage(void); static char *curdir; /* startup directory */ @@ -728,22 +727,9 @@ } /* - * Read in the built-in rules first, followed by the specified - * makefile, if it was (makefile != (char *) NULL), or the default - * Makefile and makefile, in that order, if it wasn't. + * Read the specified makefile, if it was (makefile != (char *) NULL), + * or the default Makefile and makefile, in that order, if it wasn't. */ - if (!noBuiltins) { - LstNode ln; - - sysMkPath = Lst_Init (FALSE); - Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath); - if (Lst_IsEmpty(sysMkPath)) - Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); - ln = Lst_Find(sysMkPath, (void *)NULL, ReadMakefile); - if (ln != NULL) - Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); - } - if (!Lst_IsEmpty(makefiles)) { LstNode ln; @@ -899,7 +885,7 @@ * Side Effects: * lots */ -static Boolean +Boolean ReadMakefile(p, q) void *p; void *q; Index: make.h =================================================================== RCS file: /home/ncvs/src/usr.bin/make/make.h,v retrieving revision 1.17 diff -u -r1.17 make.h --- make.h 2002/04/13 10:57:56 1.17 +++ make.h 2002/04/18 06:25:36 @@ -293,6 +293,8 @@ * anything, just see if the targets are out- * of-date */ +extern Boolean noBuiltins; /* TRUE if sys.mk should not be sourced */ + extern Boolean checkEnvFirst; /* TRUE if environment should be searched for * all variables before the global context */ extern Lst envFirstVars; /* List of specific variables for which the @@ -353,5 +355,6 @@ void Make_Update(GNode *); void Make_DoAllVar(GNode *); Boolean Make_Run(Lst); +int ReadMakefile(void *, void *); #endif /* _MAKE_H_ */ Index: parse.c =================================================================== RCS file: /home/ncvs/src/usr.bin/make/parse.c,v retrieving revision 1.32 diff -u -r1.32 parse.c --- parse.c 2002/04/13 10:17:17 1.32 +++ parse.c 2002/04/18 06:25:42 @@ -252,6 +252,7 @@ static char *ParseReadLine(void); static char *ParseSkipLine(int); static void ParseFinishLine(void); +static void ParseSysMk(void); /*- *---------------------------------------------------------------------- @@ -2354,6 +2355,50 @@ } } +/*- + *----------------------------------------------------------------------- + * ParseSysMk -- + * Read and parse the builtin rules file (sys.mk) + * + * Results: + * Nothing. + * + * Side Effects: + * Same as Parse_File(): dependencies added, variables set, etc. + * + *----------------------------------------------------------------------- + */ +void +ParseSysMk(void) +{ + LstNode ln; + Lst sysMkPath; + Boolean old_inLine; + int old_lineno; + char *old_fname; + FILE *old_curFILE; + + /* Save parser globals before Parse_File() clobbers them */ + old_inLine = inLine; + old_lineno = lineno; + old_fname = fname; + old_curFILE = curFILE; + + /* Parse rules from sys.mk */ + sysMkPath = Lst_Init (FALSE); + Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath); + if (Lst_IsEmpty(sysMkPath)) + Fatal("make: no system rules (%s).", _PATH_DEFSYSMK); + ln = Lst_Find(sysMkPath, (void *)NULL, ReadMakefile); + if (ln != NULL) + Fatal("make: cannot open %s.", (char *)Lst_Datum(ln)); + + /* Restore globals */ + inLine = old_inLine; + lineno = old_lineno; + curFILE = old_curFILE; + fname = old_fname; +} /*- *--------------------------------------------------------------------- @@ -2375,6 +2420,7 @@ char *name; /* the name of the file being read */ FILE * stream; /* Stream open to makefile to parse */ { + static int donesysmk; char *cp, /* pointer into the line */ *line; /* the line we're working on */ @@ -2386,6 +2432,20 @@ do { while ((line = ParseReadLine ()) != NULL) { + /* + * Read sys.mk right before we parse the first line that isn't + * either a comment, blank, or .POSIX. The .POSIX pseudo-target + * sets a variable that affects what sys.mk defines. + */ + if (!donesysmk) { + for (cp = line; isspace(*cp); cp++) + ; + if (*cp != '#' && *cp != '\0' && !noBuiltins && + strncmp(line, ".POSIX", 6) != 0) { + donesysmk = 1; + ParseSysMk(); + } + } if (*line == '.') { /* * Lines that begin with the special character are either To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Apr 18 8:50: 8 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 002DB37B416 for ; Thu, 18 Apr 2002 08:50:03 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3IFo3B42847; Thu, 18 Apr 2002 08:50:03 -0700 (PDT) (envelope-from gnats) Date: Thu, 18 Apr 2002 08:50:03 -0700 (PDT) Message-Id: <200204181550.g3IFo3B42847@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "J. Mallett" Subject: Re: bin/11114: make(1) does not work as documented with .POSIX: target Reply-To: "J. Mallett" 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 bin/11114; it has been noted by GNATS. From: "J. Mallett" To: "Tim J. Robbins" Cc: Jens Schweikhardt , bug-followup@FreeBSD.ORG, cjclark@alum.mit.edu, jmallett@FreeBSD.ORG Subject: Re: bin/11114: make(1) does not work as documented with .POSIX: target Date: Thu, 18 Apr 2002 15:50:09 +0000 On Thu, Apr 18, 2002 at 03:50:09PM +1000, Tim J. Robbins wrote: > Please try this patch & let me know whether it corrects the problems > with the special .POSIX target. It is against HEAD, to try it on a 4.x > release you will need to edit str.c and remove __DECONST macro usage. > I realise it's not a particularly clean solution, and I'd be interested > to hear how it could be done better. > I think in the current architecture of make(1), that's probably on the right track to doing it, assuming the Startup()/Cleanup() style thing cannot be done or that it won't work. Does any software include a Makefile that does the .POSIX thing? If so, check and see if this works as expected, and check that it can get through a buildworld (at least as much as normal make(1) - heh), and that there's no significant regression, and I'd say you can pretty much go this way, though you might want to add some DEBUG() stuff, as the codepath is a little obscured, to me anyway. I guess that's all I can think to say right now. -- jmallett@FreeBSD.org | C, MIPS, POSIX, UNIX, BSD, IRC Geek. http://www.FreeBSD.org | The Power to Serve "We all need mirrors to remind ourselves who we are -- I'm no different." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Apr 19 22:18:36 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 7413237B41C for ; Fri, 19 Apr 2002 22:18:27 -0700 (PDT) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g3K5IMf15112 for standards@FreeBSD.org; Sat, 20 Apr 2002 01:18:22 -0400 (EDT) (envelope-from mike) Date: Sat, 20 Apr 2002 01:18:22 -0400 From: Mike Barcroft To: standards@FreeBSD.org Subject: changes for review Message-ID: <20020420011822.L29857@espresso.q9media.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="VrqPEDrXMn8OVzN4" 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 --VrqPEDrXMn8OVzN4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline The attached patch brings up to conformance with SUSv2, and almost with POSIX.1-2001 ( still has too much pollution). Comments appreciated. Best regards, Mike Barcroft --VrqPEDrXMn8OVzN4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="in.diff" in.diff Rearrange so that it is easier to conditionalize sections for various standards. Use standards conforming spelling for types in the sockaddr_in structure. Index: in.h =================================================================== RCS file: /work/repo/src/sys/netinet/in.h,v retrieving revision 1.67 diff -u -r1.67 in.h --- in.h 20 Apr 2002 02:24:35 -0000 1.67 +++ in.h 20 Apr 2002 05:08:18 -0000 @@ -37,8 +37,93 @@ #ifndef _NETINET_IN_H_ #define _NETINET_IN_H_ +#include #include +/* Protocols common to RFC 1700, POSIX, and X/Open. */ +#define IPPROTO_IP 0 /* dummy for IP */ +#define IPPROTO_ICMP 1 /* control message protocol */ +#define IPPROTO_TCP 6 /* tcp */ +#define IPPROTO_UDP 17 /* user datagram protocol */ + +#define INADDR_ANY (u_int32_t)0x00000000 +#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ + +#ifndef _UINT8_T_DECLARED +typedef __uint8_t uint8_t; +#define _UINT8_T_DECLARED +#endif + +#ifndef _UINT16_T_DECLARED +typedef __uint16_t uint16_t; +#define _UINT16_T_DECLARED +#endif + +#ifndef _UINT32_T_DECLARED +typedef __uint32_t uint32_t; +#define _UINT32_T_DECLARED +#endif + +#ifndef _IN_ADDR_T_DECLARED +typedef uint32_t in_addr_t; +#define _IN_ADDR_T_DECLARED +#endif + +#ifndef _IN_PORT_T_DECLARED +typedef uint16_t in_port_t; +#define _IN_PORT_T_DECLARED +#endif + +#ifdef _BSD_SA_FAMILY_T_ +typedef _BSD_SA_FAMILY_T_ sa_family_t; +#undef _BSD_SA_FAMILY_T_ +#endif + +/* Internet address (a structure for historical reasons). */ +#ifndef _STRUCT_IN_ADDR_DECLARED +struct in_addr { + in_addr_t s_addr; +}; +#define _STRUCT_IN_ADDR_DECLARED +#endif + +/* Socket address, internet style. */ +struct sockaddr_in { + uint8_t sin_len; + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +#ifndef _KERNEL + +#ifndef _BYTEORDER_PROTOTYPED +#define _BYTEORDER_PROTOTYPED +__BEGIN_DECLS +uint32_t htonl(uint32_t); +uint16_t htons(uint16_t); +uint32_t ntohl(uint32_t); +uint16_t ntohs(uint16_t); +__END_DECLS +#endif + +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) +#endif + +#endif /* !_KERNEL */ + +#if __POSIX_VISIBLE >= 200112 +#define IPPROTO_RAW 255 /* raw IP packet */ +#define INET_ADDRSTRLEN 16 +#endif + +#if __BSD_VISIBLE /* * Constants and structures defined by the internet system, * Per RFC 790, September 1981, and numerous additions. @@ -47,14 +132,11 @@ /* * Protocols (RFC 1700) */ -#define IPPROTO_IP 0 /* dummy for IP */ #define IPPROTO_HOPOPTS 0 /* IP6 hop-by-hop options */ -#define IPPROTO_ICMP 1 /* control message protocol */ #define IPPROTO_IGMP 2 /* group mgmt protocol */ #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */ #define IPPROTO_IPV4 4 /* IPv4 encapsulation */ #define IPPROTO_IPIP IPPROTO_IPV4 /* for compatibility */ -#define IPPROTO_TCP 6 /* tcp */ #define IPPROTO_ST 7 /* Stream protocol II */ #define IPPROTO_EGP 8 /* exterior gateway protocol */ #define IPPROTO_PIGP 9 /* private interior gateway */ @@ -65,7 +147,6 @@ #define IPPROTO_EMCON 14 /* EMCON */ #define IPPROTO_XNET 15 /* Cross Net Debugger */ #define IPPROTO_CHAOS 16 /* Chaos*/ -#define IPPROTO_UDP 17 /* user datagram protocol */ #define IPPROTO_MUX 18 /* Multiplexing */ #define IPPROTO_MEAS 19 /* DCN Measurement Subsystems */ #define IPPROTO_HMP 20 /* Host Monitoring */ @@ -156,7 +237,6 @@ /* 255: Reserved */ /* BSD Private, local use, namespace incursion */ #define IPPROTO_DIVERT 254 /* divert pseudo-protocol */ -#define IPPROTO_RAW 255 /* raw IP packet */ #define IPPROTO_MAX 256 /* last return value of *_input(), meaning "all job for this pkt is done". */ @@ -302,9 +382,7 @@ #define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) #define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) -#define INADDR_ANY (u_int32_t)0x00000000 #define INADDR_LOOPBACK (u_int32_t)0x7f000001 -#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ #ifndef _KERNEL #define INADDR_NONE 0xffffffff /* -1 return */ #endif @@ -317,19 +395,6 @@ #define IN_LOOPBACKNET 127 /* official! */ /* - * Socket address, internet style. - */ -struct sockaddr_in { - u_char sin_len; - u_char sin_family; - u_short sin_port; - struct in_addr sin_addr; - char sin_zero[8]; -}; - -#define INET_ADDRSTRLEN 16 - -/* * Options for use with [gs]etsockopt at the IP level. * First word of comment is data type; bool is stored in int. */ @@ -496,17 +561,12 @@ { "fastforwarding", CTLTYPE_INT }, \ } -#ifdef _KERNEL -struct ifnet; struct mbuf; /* forward declarations for Standard C */ -#endif - -/* INET6 stuff */ -#define __KAME_NETINET_IN_H_INCLUDED_ -#include -#undef __KAME_NETINET_IN_H_INCLUDED_ +#endif /* __BSD_VISIBLE */ #ifdef _KERNEL +struct ifnet; struct mbuf; /* forward declarations for Standard C */ + int in_broadcast(struct in_addr, struct ifnet *); int in_canforward(struct in_addr); int in_localaddr(struct in_addr); @@ -517,26 +577,13 @@ #define sintosa(sin) ((struct sockaddr *)(sin)) #define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) -#else /* !_KERNEL */ - -#ifndef _BYTEORDER_PROTOTYPED -#define _BYTEORDER_PROTOTYPED -__BEGIN_DECLS -uint32_t htonl(uint32_t); -uint16_t htons(uint16_t); -uint32_t ntohl(uint32_t); -uint16_t ntohs(uint16_t); -__END_DECLS -#endif - -#ifndef _BYTEORDER_FUNC_DEFINED -#define _BYTEORDER_FUNC_DEFINED -#define htonl(x) __htonl(x) -#define htons(x) __htons(x) -#define ntohl(x) __ntohl(x) -#define ntohs(x) __ntohs(x) -#endif - #endif /* _KERNEL */ +/* INET6 stuff */ +#if __POSIX_VISIBLE >= 200112 +#define __KAME_NETINET_IN_H_INCLUDED_ +#include +#undef __KAME_NETINET_IN_H_INCLUDED_ #endif + +#endif /* !_NETINET_IN_H_*/ --VrqPEDrXMn8OVzN4-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Apr 20 12:51:29 2002 Delivered-To: freebsd-standards@freebsd.org Received: from theshell.com (arsenic.theshell.com [63.236.138.5]) by hub.freebsd.org (Postfix) with SMTP id CBF9037B419 for ; Sat, 20 Apr 2002 12:51:00 -0700 (PDT) Received: (qmail 39029 invoked from network); 20 Apr 2002 19:51:00 -0000 Received: from oxygen.theshell.com (pavalos@63.236.138.8) by arsenic.theshell.com with SMTP; 20 Apr 2002 19:51:00 -0000 Received: (from pavalos@localhost) by oxygen.theshell.com (8.12.2/8.12.2/Submit) id g3KJp0vY011732; Sat, 20 Apr 2002 12:51:00 -0700 (PDT) (envelope-from pavalos) Date: Sat, 20 Apr 2002 12:51:00 -0700 From: Peter Avalos To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: standards/36950: Add -n to renice(8) Message-ID: <20020420195059.GB5935@theshell.com> Mail-Followup-To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-standards@FreeBSD.org References: <20020410041602.29265.qmail@theshell.com> <200204100420.g3A4K2L45929@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200204100420.g3A4K2L45929@freefall.freebsd.org> User-Agent: Mutt/1.3.28i 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 think things can be done better than what was changed in the Apr. 10 commit, so I re-did the patch against the newest version. Summary of changes: - Use FBSDID. - Use sysexits. - Change incr to nflag since I think this is better style (originally mike's idea). - Change the usage closer to style(9). Along with this, use nice value since it's less confusing than priority. If I want to raise the priority, I need to lower the nice value. - Move more towards POSIX by only accepting 1 option, and then using that option to determine how the ID is interpreted. - Allow the user to specify usernames and userids. - Remove the prio bounds check. setpriority() does this for us. - Remove the printf that tells the user the old priority and new priority. POSIX says stdout is not used, and the value of this message is questionable. - All numbers should be decimal integers. Index: renice.c =================================================================== RCS file: /cvsroot/fbsd/src/usr.bin/renice/renice.c,v retrieving revision 1.11 diff -u -r1.11 renice.c --- renice.c 10 Apr 2002 13:38:09 -0000 1.11 +++ renice.c 20 Apr 2002 19:23:42 -0000 @@ -35,16 +35,15 @@ static const char copyright[] = "@(#) Copyright (c) 1983, 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ -#ifndef lint #if 0 static char sccsid[] = "@(#)renice.c 8.1 (Berkeley) 6/9/93"; #endif -static const char rcsid[] = - "$FreeBSD: src/usr.bin/renice/renice.c,v 1.11 2002/04/10 13:38:09 maxim Exp $"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -56,6 +55,7 @@ #include #include #include +#include static int donice(int, int, int, int); static int getnum(const char *, const char *, int *); @@ -70,38 +70,48 @@ main(int argc, char *argv[]) { struct passwd *pwd; - int errs, incr, prio, which, who; + char *ep; + int errs, nflag, prio, which, who; errs = 0; - incr = 0; + nflag = 0; which = PRIO_PROCESS; who = 0; argc--, argv++; if (argc < 2) usage(); if (strcmp(*argv, "-n") == 0) { - incr = 1; + nflag = 1; argc--, argv++; if (argc < 2) usage(); } - if (getnum("priority", *argv, &prio)) - return (1); + if (getnum("nice_value", *argv, &prio)) + exit(EX_DATAERR); argc--, argv++; + + /* + * The next argument shall be -g, -p, -u, or an unsigned decimal + * number. If it is a number, default to -p (PRIO_PROCESS). + */ + if (strcmp(*argv, "-g") == 0) { + which = PRIO_PGRP; + argc--, argv++; + } else if (strcmp(*argv, "-u") == 0) { + which = PRIO_USER; + argc--, argv++; + } else if (strcmp(*argv, "-p") == 0) + argc--, argv++; + if (argc < 1) + usage(); + + /* + * From this point on, all non-numeric arguments are invalid unless -u + * (PRIO_USER). Numbers shall be unsigned integers. + */ for (; argc > 0; argc--, argv++) { - if (strcmp(*argv, "-g") == 0) { - which = PRIO_PGRP; - continue; - } - if (strcmp(*argv, "-u") == 0) { - which = PRIO_USER; - continue; - } - if (strcmp(*argv, "-p") == 0) { - which = PRIO_PROCESS; - continue; - } - if (which == PRIO_USER) { + (void)strtol(*argv, &ep, 10); + if (*ep && which == PRIO_USER) { pwd = getpwnam(*argv); if (pwd == NULL) { warnx("%s: unknown user", *argv); @@ -109,20 +119,20 @@ } who = pwd->pw_uid; } else { - if (getnum("pid", *argv, &who)) + if (getnum("ID", *argv, &who)) continue; if (who < 0) { warnx("%s: bad value", *argv); continue; } } - errs += donice(which, who, prio, incr); + errs += donice(which, who, prio, nflag); } exit(errs != 0); } static int -donice(int which, int who, int prio, int incr) +donice(int which, int who, int prio, int nflag) { int oldprio; @@ -132,17 +142,12 @@ warn("%d: getpriority", who); return (1); } - if (incr) - prio = oldprio + prio; - if (prio > PRIO_MAX) - prio = PRIO_MAX; - if (prio < PRIO_MIN) - prio = PRIO_MIN; + if (nflag) + prio = oldprio + prio; /* Possible over/underflow here. */ if (setpriority(which, who, prio) < 0) { warn("%d: setpriority", who); return (1); } - printf("%d: old priority %d, new priority %d\n", who, oldprio, prio); return (0); } @@ -153,7 +158,7 @@ char *ep; errno = 0; - v = strtol(str, &ep, NULL); + v = strtol(str, &ep, 10); if (v < INT_MIN || v > INT_MAX || errno == ERANGE) { warnx("%s argument %s is out of range.", com, str); return (1); @@ -170,8 +175,8 @@ static void usage() { - fprintf(stderr, "%s\n%s\n", -"usage: renice [priority | [-n incr]] [ [ -p ] pids ] [ [ -g ] pgrps ]", -" [ [ -u ] users ]"); - exit(1); + + fprintf(stderr, "usage: renice nice_value [-g | -p | -u] ID ...\n"); + fprintf(stderr, " renice -n increment [-g | -p | -u] ID ...\n"); + exit(EX_USAGE); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Apr 20 13: 0:34 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 E80BF37B41C for ; Sat, 20 Apr 2002 13:00:07 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g3KK07V50494; Sat, 20 Apr 2002 13:00:07 -0700 (PDT) (envelope-from gnats) Date: Sat, 20 Apr 2002 13:00:07 -0700 (PDT) Message-Id: <200204202000.g3KK07V50494@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Peter Avalos Subject: Re: standards/36950: Add -n to renice(8) Reply-To: Peter Avalos 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/36950; it has been noted by GNATS. From: Peter Avalos To: FreeBSD-gnats-submit@FreeBSD.org, freebsd-standards@FreeBSD.org Cc: Subject: Re: standards/36950: Add -n to renice(8) Date: Sat, 20 Apr 2002 12:51:00 -0700 I think things can be done better than what was changed in the Apr. 10 commit, so I re-did the patch against the newest version. Summary of changes: - Use FBSDID. - Use sysexits. - Change incr to nflag since I think this is better style (originally mike's idea). - Change the usage closer to style(9). Along with this, use nice value since it's less confusing than priority. If I want to raise the priority, I need to lower the nice value. - Move more towards POSIX by only accepting 1 option, and then using that option to determine how the ID is interpreted. - Allow the user to specify usernames and userids. - Remove the prio bounds check. setpriority() does this for us. - Remove the printf that tells the user the old priority and new priority. POSIX says stdout is not used, and the value of this message is questionable. - All numbers should be decimal integers. Index: renice.c =================================================================== RCS file: /cvsroot/fbsd/src/usr.bin/renice/renice.c,v retrieving revision 1.11 diff -u -r1.11 renice.c --- renice.c 10 Apr 2002 13:38:09 -0000 1.11 +++ renice.c 20 Apr 2002 19:23:42 -0000 @@ -35,16 +35,15 @@ static const char copyright[] = "@(#) Copyright (c) 1983, 1989, 1993\n\ The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ -#ifndef lint #if 0 static char sccsid[] = "@(#)renice.c 8.1 (Berkeley) 6/9/93"; #endif -static const char rcsid[] = - "$FreeBSD: src/usr.bin/renice/renice.c,v 1.11 2002/04/10 13:38:09 maxim Exp $"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + #include #include #include @@ -56,6 +55,7 @@ #include #include #include +#include static int donice(int, int, int, int); static int getnum(const char *, const char *, int *); @@ -70,38 +70,48 @@ main(int argc, char *argv[]) { struct passwd *pwd; - int errs, incr, prio, which, who; + char *ep; + int errs, nflag, prio, which, who; errs = 0; - incr = 0; + nflag = 0; which = PRIO_PROCESS; who = 0; argc--, argv++; if (argc < 2) usage(); if (strcmp(*argv, "-n") == 0) { - incr = 1; + nflag = 1; argc--, argv++; if (argc < 2) usage(); } - if (getnum("priority", *argv, &prio)) - return (1); + if (getnum("nice_value", *argv, &prio)) + exit(EX_DATAERR); argc--, argv++; + + /* + * The next argument shall be -g, -p, -u, or an unsigned decimal + * number. If it is a number, default to -p (PRIO_PROCESS). + */ + if (strcmp(*argv, "-g") == 0) { + which = PRIO_PGRP; + argc--, argv++; + } else if (strcmp(*argv, "-u") == 0) { + which = PRIO_USER; + argc--, argv++; + } else if (strcmp(*argv, "-p") == 0) + argc--, argv++; + if (argc < 1) + usage(); + + /* + * From this point on, all non-numeric arguments are invalid unless -u + * (PRIO_USER). Numbers shall be unsigned integers. + */ for (; argc > 0; argc--, argv++) { - if (strcmp(*argv, "-g") == 0) { - which = PRIO_PGRP; - continue; - } - if (strcmp(*argv, "-u") == 0) { - which = PRIO_USER; - continue; - } - if (strcmp(*argv, "-p") == 0) { - which = PRIO_PROCESS; - continue; - } - if (which == PRIO_USER) { + (void)strtol(*argv, &ep, 10); + if (*ep && which == PRIO_USER) { pwd = getpwnam(*argv); if (pwd == NULL) { warnx("%s: unknown user", *argv); @@ -109,20 +119,20 @@ } who = pwd->pw_uid; } else { - if (getnum("pid", *argv, &who)) + if (getnum("ID", *argv, &who)) continue; if (who < 0) { warnx("%s: bad value", *argv); continue; } } - errs += donice(which, who, prio, incr); + errs += donice(which, who, prio, nflag); } exit(errs != 0); } static int -donice(int which, int who, int prio, int incr) +donice(int which, int who, int prio, int nflag) { int oldprio; @@ -132,17 +142,12 @@ warn("%d: getpriority", who); return (1); } - if (incr) - prio = oldprio + prio; - if (prio > PRIO_MAX) - prio = PRIO_MAX; - if (prio < PRIO_MIN) - prio = PRIO_MIN; + if (nflag) + prio = oldprio + prio; /* Possible over/underflow here. */ if (setpriority(which, who, prio) < 0) { warn("%d: setpriority", who); return (1); } - printf("%d: old priority %d, new priority %d\n", who, oldprio, prio); return (0); } @@ -153,7 +158,7 @@ char *ep; errno = 0; - v = strtol(str, &ep, NULL); + v = strtol(str, &ep, 10); if (v < INT_MIN || v > INT_MAX || errno == ERANGE) { warnx("%s argument %s is out of range.", com, str); return (1); @@ -170,8 +175,8 @@ static void usage() { - fprintf(stderr, "%s\n%s\n", -"usage: renice [priority | [-n incr]] [ [ -p ] pids ] [ [ -g ] pgrps ]", -" [ [ -u ] users ]"); - exit(1); + + fprintf(stderr, "usage: renice nice_value [-g | -p | -u] ID ...\n"); + fprintf(stderr, " renice -n increment [-g | -p | -u] ID ...\n"); + exit(EX_USAGE); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message