docs/69428: [patch] Wrong symbolic constant in getrusage(2) on 4.10-STABLE

Sascha Schneider suntsu at suntsu.org
Thu Jul 22 11:50:26 UTC 2004


>Number:         69428
>Category:       docs
>Synopsis:       [patch] Wrong symbolic constant in getrusage(2) on 4.10-STABLE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 22 11:50:25 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Sascha Schneider
>Release:        FreeBSD 4.10-STABLE i386
>Organization:
>Environment:
System: FreeBSD ws111.noc.celox.de 4.10-STABLE FreeBSD 4.10-STABLE #0: Mon Jul 5 15:45:06 CEST 2004 root at ws111.noc.celox.de:/usr/obj/usr/src/sys/WS111 i386
	$FreeBSD: src/lib/libc/sys/getrusage.2,v 1.10.2.5 2001/12/14 18:34:00 ru Exp $
	$FreeBSD: src/lib/libc/gen/sysconf.3,v 1.8.2.6 2001/12/14 18:33:51 ru Exp $
	$FreeBSD: src/sys/sys/unistd.h,v 1.22.2.3 2003/11/11 07:26:33 das Exp $

>Description:
	getrusage(2) states that sysconf(_SC_CLOCK_TCK) would return the
	frequency of the statistic clock. According to sysconf(3) and
	/usr/include/sys/unistd.h this is wrong: 
	sysconf(_SC_CLK_TCK) is the way to do it.
>How-To-Repeat:
	[user at ws111] [~]$ zgrep TCK /usr/share/man/man2/getrusage.2.gz
	.Fn sysconf _SC_CLOCK_TCK
	[user at ws111] [~]$ zgrep TCK /usr/share/man/man3/sysconf.3.gz
	.It Li _SC_CLK_TCK
	[user at ws111] [~]$ zgrep TCK /usr/include/sys/unistd.h
	#define _SC_CLK_TCK
	[user at ws111] [~dc/stuff]$ cat getrusage-wrong.c
	#include <stdio.h>
	#include <unistd.h>

	int main(void)
	{
		printf("Frequency: %d\n", sysconf(_SC_CLOCK_TCK));
	}
	[user at ws111] [~dc/stuff]$ make getrusage-wrong
	cc -O -pipe -march=pentium  getrusage-wrong.c  -o getrusage-wrong
	getrusage-wrong.c: In function `main':
	getrusage-wrong.c:6: `_SC_CLOCK_TCK' undeclared (first use in this function)
	getrusage-wrong.c:6: (Each undeclared identifier is reported only once
	getrusage-wrong.c:6: for each function it appears in.)
	*** Error code 1

	Stop in /home/user/development/c/stuff.
	[user at ws111] [~dc/stuff]$ cat getrusage-right.c
	#include <stdio.h>
	#include <unistd.h>

	int main(void)
	{
		printf("Frequency: %d\n", sysconf(_SC_CLK_TCK));
	}
	[user at ws111] [~dc/stuff]$ make getrusage-right
	cc -O -pipe -march=pentium  getrusage-right.c  -o getrusage-right
	[user at ws111] [~dc/stuff]$ ./getrusage-right
	Frequency: 128


>Fix:
patch patch-getrusage.2 attached.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-doc mailing list