Re: __BSD_VISIBLE and u_int
On Wed, 11 Dec 2002, Mike Barcroft wrote: Nate Lawson [EMAIL PROTECTED] writes: What's the proper way to get a typedef for u_int? Is there a doc somewhere on what we expect in terms of #defines for 3rd party application authors? sys/types.h will give you a typedef, provided you aren't writing a POSIX or X/Open application. If you're writing a POSIX or X/Open application (the only time __BSD_VISIBLE is false) you'll have to do the typedef manually in your application. Hmm, which of these defines claims posix src? -D_ANSI_SOURCE ? cc -O -c -O -pipe -mcpu=pentiumpro -mcpu=pentiumpro -I./../include -I./.. -DDIRENT=1 -DDIRENT=1 -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ST_RDEV=1 -DHAVE_TM_ZONE=1 -DHAVE_LONG_FILE_NAMES=1 -DHAVE_RESTARTABLE_SYSCALLS=1 -D_ANSI_SOURCE -DHAVE_DEV_CONSOLE=1 os.c In file included from os.c:25: /usr/include/sys/file.h:130: syntax error before u_int u_int is undocumented and unportable, so it probably shouldn't be used. It's only 3 characters shorter than `unsigned' anyway. It's for ports. -Nate To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: __BSD_VISIBLE and u_int
Hmm, which of these defines claims posix src? -D_ANSI_SOURCE ? cc -O -c -O -pipe -mcpu=pentiumpro -mcpu=pentiumpro -I./../include [...] u_int is undocumented and unportable, so it probably shouldn't be used. It's only 3 characters shorter than `unsigned' anyway. It's for ports. And this is once a again a good example why we _really_ need a define (like Solaris'__EXTENSIONS__ ) that sets __BSD_VISIBLE (no matter what) and could be set in CONFIBURE_ENV. Regards, Marc Premature optimization is the root of all evil. -- Donald E. Knuth msg48683/pgp0.pgp Description: PGP signature
Re: __BSD_VISIBLE and u_int
Nate Lawson [EMAIL PROTECTED] writes: On Wed, 11 Dec 2002, Mike Barcroft wrote: Nate Lawson [EMAIL PROTECTED] writes: What's the proper way to get a typedef for u_int? Is there a doc somewhere on what we expect in terms of #defines for 3rd party application authors? sys/types.h will give you a typedef, provided you aren't writing a POSIX or X/Open application. If you're writing a POSIX or X/Open application (the only time __BSD_VISIBLE is false) you'll have to do the typedef manually in your application. Hmm, which of these defines claims posix src? -D_ANSI_SOURCE ? _ANSI_SOURCE means a strictly conforming C89 application. Everything in sys is off limits for such a program. cc -O -c -O -pipe -mcpu=pentiumpro -mcpu=pentiumpro -I./../include -I./.. -DDIRENT=1 -DDIRENT=1 -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ST_RDEV=1 -DHAVE_TM_ZONE=1 -DHAVE_LONG_FILE_NAMES=1 -DHAVE_RESTARTABLE_SYSCALLS=1 -D_ANSI_SOURCE -DHAVE_DEV_CONSOLE=1 os.c In file included from os.c:25: /usr/include/sys/file.h:130: syntax error before u_int u_int is undocumented and unportable, so it probably shouldn't be used. It's only 3 characters shorter than `unsigned' anyway. It's for ports. I fixed a port like this recently. _ANSI_SOURCE was actually added by the port, not the application vendor, in that case. Best regards, Mike Barcroft To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: __BSD_VISIBLE and u_int
Mike Barcroft [EMAIL PROTECTED] writes: Nate Lawson [EMAIL PROTECTED] writes: cc -O -c -O -pipe -mcpu=pentiumpro -mcpu=pentiumpro -I./../include -I./.. -DDIRENT=1 -DDIRENT=1 -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_ST_RDEV=1 -DHAVE_TM_ZONE=1 -DHAVE_LONG_FILE_NAMES=1 -DHAVE_RESTARTABLE_SYSCALLS=1 -D_ANSI_SOURCE -DHAVE_DEV_CONSOLE=1 os.c In file included from os.c:25: /usr/include/sys/file.h:130: syntax error before u_int u_int is undocumented and unportable, so it probably shouldn't be used. It's only 3 characters shorter than `unsigned' anyway. It's for ports. I fixed a port like this recently. _ANSI_SOURCE was actually added by the port, not the application vendor, in that case. Wait a minute, I think this might be the same port. Is it gnu-finger? If so, try the attached patch. Kris was going to commit it for me. Best regards, Mike Barcroft Index: files/patch-aa === RCS file: /work/repo/ports/net/gnu-finger/files/patch-aa,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 patch-aa --- files/patch-aa 10 Jul 1996 22:33:13 - 1.1.1.1 +++ files/patch-aa 30 Nov 2002 15:55:31 - @@ -1,6 +1,6 @@ configure.orig Fri Oct 16 06:49:05 1992 -+++ configure Mon Jul 8 19:39:32 1996 -@@ -1041,8 +1041,10 @@ +--- configure.orig Thu Oct 15 17:49:05 1992 configure Sat Nov 30 10:55:20 2002 +@@ -1041,8 +1041,8 @@ echo checking for /proc file system @@ -8,12 +8,10 @@ - fi +# if test -r /proc ; then DEFS=$DEFS -DHAVE_PROC_FS=1 +# fi -+ -+ DEFS=$DEFS -D_ANSI_SOURCE -@@ -1071,8 +1073,9 @@ +@@ -1071,8 +1071,9 @@ Index: files/patch-ab === RCS file: /work/repo/ports/net/gnu-finger/files/patch-ab,v retrieving revision 1.3 diff -u -r1.3 patch-ab --- files/patch-ab 6 Jan 1997 14:09:34 - 1.3 +++ files/patch-ab 30 Nov 2002 16:03:57 - @@ -1,7 +1,10 @@ lib/os.c.orig Mon Jan 6 22:09:06 1997 -+++ lib/os.c Mon Jan 6 22:08:34 1997 -@@ -26,6 +26,8 @@ +--- lib/os.c.orig Thu Oct 22 17:01:10 1992 lib/os.c Sat Nov 30 11:03:54 2002 +@@ -24,8 +24,11 @@ + #include sys/stat.h + #include sys/file.h #include sys/acct.h ++#include errno.h #include time.h #include packet.h +#include sys/socket.h @@ -9,7 +12,7 @@ #ifdef HAVE_UTMPX_H #include utmpx.h -@@ -70,8 +72,12 @@ +@@ -70,8 +73,12 @@ /* Where the utmp file is located. */ #ifndef HAVE_GETUTENT @@ -22,7 +25,25 @@ /* A non-null value is the address of the utmp entry which contains the information for the user using the console. */ -@@ -288,6 +294,21 @@ +@@ -210,15 +217,12 @@ + + if (!(hostname = xgethostname ())) + { +- extern int errno; +- extern char *sys_errlist[]; +- + /* Arbitrary limit: we only return the first 128 characters of +an error. This limit would be too complicated to remove. */ + static char hostname_error[128]; + +- strncpy (hostname_error, sys_errlist[errno], +- sizeof hostname_error); ++ if (strerror_r(errno, hostname_error, sizeof hostname_error)) ++strcpy(hostname_error, Unknown error); + hostname = hostname_error; + } + +@@ -288,6 +292,21 @@ { idle = current_time - get_last_access (utmplist[i]-ut_line); @@ -44,7 +65,7 @@ if (idle 0) idle = 0; -@@ -485,6 +506,7 @@ +@@ -485,6 +504,7 @@ UTMP **result; int result_size = 0; @@ -52,7 +73,7 @@ #ifndef HAVE_GETUTENT file = open (UTMP_FILE, O_RDONLY); -@@ -528,6 +550,26 @@ +@@ -528,6 +548,26 @@ if (!UT (entry, ut_name)[0]) continue; #endif /* sun */ Index: files/patch-error.c === RCS file: files/patch-error.c diff -N files/patch-error.c --- /dev/null 1 Jan 1970 00:00:00 - +++ files/patch-error.c 30 Nov 2002 15:52:45 - @@ -0,0 +1,52 @@ +--- lib/error.c.orig Thu Oct 1 14:55:04 1992 lib/error.cSat Nov 30 10:52:14 2002 +@@ -23,6 +23,7 @@ + #include config.h + #include general.h + #include error.h ++#include errno.h + + /* These can be filled in `manually' by callers, but the easiest way +is to call default_error_handling (argv[0]). */ +@@ -50,11 +51,14 @@ + exit (1); + } + ++/* XXX conflicts with system function by the same name. */ ++#if __FreeBSD__ 5 + /* Hack to handle previous bad setjmp (). */ + longjmperror () + { + exit (1); + } ++#endif + + /* Handle some error. */ + void +@@ -92,24 +96,10 @@ + int severity; + char *filename; + { +- extern int errno, sys_nerr; +- extern char *sys_errlist[]; +- +- char *error_text; +- +- if (errno) { +-if (errno sys_nerr) +- error_text = sys_errlist[errno]; +-else +-
Re: __BSD_VISIBLE and u_int
On Fri, Dec 13, 2002 at 11:48:23PM +0100, Marc Recht wrote: Hmm, which of these defines claims posix src? -D_ANSI_SOURCE ? cc -O -c -O -pipe -mcpu=pentiumpro -mcpu=pentiumpro -I./../include [...] u_int is undocumented and unportable, so it probably shouldn't be used. It's only 3 characters shorter than `unsigned' anyway. It's for ports. And this is once a again a good example why we _really_ need a define (like Solaris'__EXTENSIONS__ ) that sets __BSD_VISIBLE (no matter what) and could be set in CONFIBURE_ENV. No, it's a good example of why Linux programmers shouldn't ask for an ANSI C environment then complain when sys/file.h does not work. Tim To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: __BSD_VISIBLE and u_int
On Fri, 13 Dec 2002, Mike Barcroft wrote: I fixed a port like this recently. _ANSI_SOURCE was actually added by the port, not the application vendor, in that case. Wait a minute, I think this might be the same port. Is it gnu-finger? If so, try the attached patch. Kris was going to commit it for me. Yep, that's the one. Thanks. -Nate To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message
Re: __BSD_VISIBLE and u_int
Nate Lawson [EMAIL PROTECTED] writes: What's the proper way to get a typedef for u_int? Is there a doc somewhere on what we expect in terms of #defines for 3rd party application authors? sys/types.h will give you a typedef, provided you aren't writing a POSIX or X/Open application. If you're writing a POSIX or X/Open application (the only time __BSD_VISIBLE is false) you'll have to do the typedef manually in your application. u_int is undocumented and unportable, so it probably shouldn't be used. It's only 3 characters shorter than `unsigned' anyway. Best regards, Mike Barcroft To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-current in the body of the message