[PATCH] Misc portability improvements

Robert Millan rmh@aybabtu.com
Mon Aug 22 13:03:00 GMT 2005


Hi!

This patch includes miscellaneous portability improvements.  Although they're
made with GNU/kFreeBSD in mind, these are fairly generic and could apply to
other systems.

ChangeLog entry:

2005-08-22  Robert Millan  <robertmh@gnu.org>

	* manual/errno.texi: Add ENOATTR and EDOOFUS (of BSD origin).
	* sysdeps/gnu/errlist.c: Regenerate.
	* manual/llio.texi (read, write): Document EINVAL on unaligned access.
	* misc/sys/syslog.h: Move _PATH_LOG to /var/run/log (In some devfs
	implementations, creating fifos in /dev is not permitted).
	* include/features.h: #undef __GLIBC__ before attempting to #define it.
	* sysdeps/mach/hurd/nfs/nfs.h: Move to ...
	* sysdeps/generic/nfs/nfs.h: ... here.

	* sysdeps/unix/sysv/linux/sys/soundcard.h: Protect against multiple
	inclusion.
	* sysdeps/unix/sysv/linux/net/ppp-comp.h: Likewise.
	* sysdeps/unix/sysv/linux/nfs/nfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/ultrasound.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/vt.h: Likewise.

	* posix/sys/types.h: Declare vm_*_t types (of BSD origin).
	* sysdeps/generic/bits/types.h: Declare __vm_*_t types.
	* sysdeps/generic/bits/typesizes.h: #define corresponding __VM_*_T_TYPE
	macros.
	* sysdeps/mach/hurd/bits/typesizes.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h: Likewise.

Note: The protection against multiple inclussion is added so that distributors
can check for, say, _SYS_SOUNDCARD_H in <linux/soundcard.h> and issue a warning
recommending not to include this header directly.

Note2: The same change done in the typesizes.h headers is also needed for
LinuxThreads.  It is not included in the patch because linuxthreads is no
longer in CVS (I understand that it is not maintained anymore).

-- 
Robert Millan
-------------- next part --------------

2005-08-21  Robert Millan  <robertmh@gnu.org>

	* manual/errno.texi: Add ENOATTR and EDOOFUS (of BSD origin).
	* sysdeps/gnu/errlist.c: Regenerate.
	* manual/llio.texi (read, write): Document EINVAL on unaligned access.
	* misc/sys/syslog.h: Move _PATH_LOG to /var/run/log (In some devfs
	implementations, creating fifos in /dev is not permitted).
	* include/features.h: #undef __GLIBC__ before attempting to #define it.
	* sysdeps/mach/hurd/nfs/nfs.h: Move to ...
	* sysdeps/generic/nfs/nfs.h: ... here.

	* sysdeps/unix/sysv/linux/sys/soundcard.h: Protect against multiple
	inclusion.
	* sysdeps/unix/sysv/linux/net/ppp-comp.h: Likewise.
	* sysdeps/unix/sysv/linux/nfs/nfs.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/ultrasound.h: Likewise.
	* sysdeps/unix/sysv/linux/sys/vt.h: Likewise.

	* posix/sys/types.h: Declare vm_*_t types (of BSD origin).
	* sysdeps/generic/bits/types.h: Declare __vm_*_t types.
	* sysdeps/generic/bits/typesizes.h: #define corresponding __VM_*_T_TYPE
	macros.
	* sysdeps/mach/hurd/bits/typesizes.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h: Likewise.

diff -ur libc.old/include/features.h libc/include/features.h
--- libc.old/include/features.h	2005-02-17 02:10:58.000000000 +0100
+++ libc/include/features.h	2005-08-21 17:37:15.000000000 +0200
@@ -288,6 +288,7 @@
 
 /* Major and minor version number of the GNU C library package.  Use
    these macros to test for features in specific releases.  */
+#undef	__GLIBC__
 #define	__GLIBC__	2
 #define	__GLIBC_MINOR__	4
 
diff -ur libc.old/manual/errno.texi libc/manual/errno.texi
--- libc.old/manual/errno.texi	2004-11-06 00:02:05.000000000 +0100
+++ libc/manual/errno.texi	2005-08-21 17:37:15.000000000 +0200
@@ -991,6 +991,21 @@
 error; @pxref{Cancel AIO Operations}.
 @end deftypevr
 
+@comment errno.h
+@comment BSD: Attribute not found
+@deftypevr Macro int ENOATTR
+@comment errno ???/???
+The specified extended attribute does not exist.
+@end deftypevr
+
+@comment errno.h
+@comment BSD: Programming error
+@deftypevr Macro int EDOOFUS
+@comment errno ???/???
+A function or API is being abused in a way which could only be detected
+at run-time.
+@end deftypevr
+
 
 @emph{The following error codes are defined by the Linux/i386 kernel.
 They are not yet documented.}
diff -ur libc.old/manual/llio.texi libc/manual/llio.texi
--- libc.old/manual/llio.texi	2003-05-10 09:56:51.000000000 +0200
+++ libc/manual/llio.texi	2005-08-21 17:37:15.000000000 +0200
@@ -368,6 +368,11 @@
 the signal is being blocked or ignored, or because the process group is
 orphaned.  @xref{Job Control}, for more information about job control,
 and @ref{Signal Handling}, for information about signals.
+
+@item EINVAL
+In some systems, when reading from a character or block device, position
+and size offsets must be aligned to a particular block size.  This error
+indicates that the offsets were not properly aligned.
 @end table
 
 Please note that there is no function named @code{read64}.  This is not
@@ -515,6 +520,11 @@
 This error is returned when you try to write to a pipe or FIFO that
 isn't open for reading by any process.  When this happens, a @code{SIGPIPE}
 signal is also sent to the process; see @ref{Signal Handling}.
+
+@item EINVAL
+In some systems, when writing to a character or block device, position
+and size offsets must be aligned to a particular block size.  This error
+indicates that the offsets were not properly aligned.
 @end table
 
 Unless you have arranged to prevent @code{EINTR} failures, you should
diff -ur libc.old/misc/sys/syslog.h libc/misc/sys/syslog.h
--- libc.old/misc/sys/syslog.h	2005-07-30 07:59:13.000000000 +0200
+++ libc/misc/sys/syslog.h	2005-08-21 17:37:15.000000000 +0200
@@ -37,7 +37,7 @@
 #include <stdarg.h>
 
 
-#define	_PATH_LOG	"/dev/log"
+#define	_PATH_LOG	"/var/run/log"
 
 /*
  * priorities/facilities are encoded into a single 32-bit quantity, where the
diff -ur libc.old/posix/sys/types.h libc/posix/sys/types.h
--- libc.old/posix/sys/types.h	2002-10-24 01:48:51.000000000 +0200
+++ libc/posix/sys/types.h	2005-08-21 17:37:15.000000000 +0200
@@ -217,6 +217,13 @@
 
 /* BSD defines these symbols, so we follow.  */
 # include <sys/sysmacros.h>
+
+/* These types were copied from FreeBSD.  */
+typedef __vm_offset_t	vm_offset_t;
+typedef __vm_ooffset_t	vm_ooffset_t;
+typedef __vm_paddr_t	vm_paddr_t;
+typedef __vm_pindex_t	vm_pindex_t;
+typedef __vm_size_t	vm_size_t;
 #endif /* Use BSD.  */
 
 
diff -ur libc.old/sysdeps/generic/bits/types.h libc/sysdeps/generic/bits/types.h
--- libc.old/sysdeps/generic/bits/types.h	2005-02-22 00:11:47.000000000 +0100
+++ libc/sysdeps/generic/bits/types.h	2005-08-21 17:37:15.000000000 +0200
@@ -182,6 +182,13 @@
 
 __STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error.  */
 
+/* These types were copied from FreeBSD.  */
+__STD_TYPE __VM_OFFSET_T_TYPE	__vm_offset_t;
+__STD_TYPE __VM_OOFFSET_T_TYPE	__vm_ooffset_t;
+__STD_TYPE __VM_PADDR_T_TYPE	__vm_paddr_t;
+__STD_TYPE __VM_PINDEX_T_TYPE	__vm_pindex_t;
+__STD_TYPE __VM_SIZE_T_TYPE	__vm_size_t;
+
 /* These few don't really vary by system, they always correspond
    to one of the other defined types.  */
 typedef __off64_t __loff_t;	/* Type of file sizes and offsets (LFS).  */
diff -ur libc.old/sysdeps/generic/bits/typesizes.h libc/sysdeps/generic/bits/typesizes.h
--- libc.old/sysdeps/generic/bits/typesizes.h	2003-07-31 21:34:16.000000000 +0200
+++ libc/sysdeps/generic/bits/typesizes.h	2005-08-21 17:37:15.000000000 +0200
@@ -58,6 +58,11 @@
 #define __BLKSIZE_T_TYPE	__SLONGWORD_TYPE
 #define __FSID_T_TYPE		struct { int __val[2]; }
 #define __SSIZE_T_TYPE		__SWORD_TYPE
+#define __VM_OFFSET_T_TYPE	__ULONGWORD_TYPE
+#define __VM_OOFFSET_T_TYPE	__SQUAD_TYPE
+#define __VM_PADDR_T_TYPE	__ULONGWORD_TYPE
+#define __VM_PINDEX_T_TYPE	__UQUAD_TYPE
+#define __VM_SIZE_T_TYPE	__ULONGWORD_TYPE
 
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
diff -ur libc.old/sysdeps/mach/hurd/bits/typesizes.h libc/sysdeps/mach/hurd/bits/typesizes.h
--- libc.old/sysdeps/mach/hurd/bits/typesizes.h	2003-07-31 21:34:16.000000000 +0200
+++ libc/sysdeps/mach/hurd/bits/typesizes.h	2005-08-21 17:37:15.000000000 +0200
@@ -58,6 +58,11 @@
 #define __BLKSIZE_T_TYPE	__SLONGWORD_TYPE
 #define __FSID_T_TYPE		__UQUAD_TYPE
 #define __SSIZE_T_TYPE		__SWORD_TYPE
+#define __VM_OFFSET_T_TYPE	__ULONGWORD_TYPE
+#define __VM_OOFFSET_T_TYPE	__SQUAD_TYPE
+#define __VM_PADDR_T_TYPE	__ULONGWORD_TYPE
+#define __VM_PINDEX_T_TYPE	__UQUAD_TYPE
+#define __VM_SIZE_T_TYPE	__ULONGWORD_TYPE
 
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		256
diff -ur libc.old/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h libc/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
--- libc.old/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h	2003-07-31 21:34:16.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h	2005-08-21 17:37:15.000000000 +0200
@@ -58,6 +58,11 @@
 #define __BLKSIZE_T_TYPE	__U32_TYPE
 #define __FSID_T_TYPE		struct { int __val[2]; }
 #define __SSIZE_T_TYPE		__SWORD_TYPE
+#define __VM_OFFSET_T_TYPE	__ULONGWORD_TYPE
+#define __VM_OOFFSET_T_TYPE	__SQUAD_TYPE
+#define __VM_PADDR_T_TYPE	__ULONGWORD_TYPE
+#define __VM_PINDEX_T_TYPE	__UQUAD_TYPE
+#define __VM_SIZE_T_TYPE	__ULONGWORD_TYPE
 
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
diff -ur libc.old/sysdeps/unix/sysv/linux/net/ppp-comp.h libc/sysdeps/unix/sysv/linux/net/ppp-comp.h
--- libc.old/sysdeps/unix/sysv/linux/net/ppp-comp.h	1996-10-09 01:39:17.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/net/ppp-comp.h	2005-08-21 17:44:33.000000000 +0200
@@ -1 +1,4 @@
+#ifndef _NET_PPP_COMP_H
+#define _NET_PPP_COMP_H 1
 #include <linux/ppp-comp.h>
+#endif
diff -ur libc.old/sysdeps/unix/sysv/linux/nfs/nfs.h libc/sysdeps/unix/sysv/linux/nfs/nfs.h
--- libc.old/sysdeps/unix/sysv/linux/nfs/nfs.h	1995-10-16 02:37:46.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/nfs/nfs.h	2005-08-21 17:37:15.000000000 +0200
@@ -1 +1,4 @@
+#ifndef _NFS_NFS_H
+#define _NFS_NFS_H 1
 #include <linux/nfs.h>
+#endif
diff -ur libc.old/sysdeps/unix/sysv/linux/s390/bits/typesizes.h libc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h
--- libc.old/sysdeps/unix/sysv/linux/s390/bits/typesizes.h	2003-09-14 10:01:45.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h	2005-08-21 17:37:15.000000000 +0200
@@ -64,6 +64,11 @@
 /* size_t is unsigned long int on s390 -m31.  */
 #define __SSIZE_T_TYPE		__SLONGWORD_TYPE
 #endif
+#define __VM_OFFSET_T_TYPE	__ULONGWORD_TYPE
+#define __VM_OOFFSET_T_TYPE	__SQUAD_TYPE
+#define __VM_PADDR_T_TYPE	__ULONGWORD_TYPE
+#define __VM_PINDEX_T_TYPE	__UQUAD_TYPE
+#define __VM_SIZE_T_TYPE	__ULONGWORD_TYPE
 
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
diff -ur libc.old/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h libc/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
--- libc.old/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h	2003-07-31 21:34:16.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h	2005-08-21 17:37:15.000000000 +0200
@@ -58,6 +58,11 @@
 #define __BLKSIZE_T_TYPE	__SLONGWORD_TYPE
 #define __FSID_T_TYPE		struct { int __val[2]; }
 #define __SSIZE_T_TYPE		__SWORD_TYPE
+#define __VM_OFFSET_T_TYPE	__ULONGWORD_TYPE
+#define __VM_OOFFSET_T_TYPE	__SQUAD_TYPE
+#define __VM_PADDR_T_TYPE	__ULONGWORD_TYPE
+#define __VM_PINDEX_T_TYPE	__UQUAD_TYPE
+#define __VM_SIZE_T_TYPE	__ULONGWORD_TYPE
 
 /* Number of descriptors that can fit in an `fd_set'.  */
 #define	__FD_SETSIZE		1024
diff -ur libc.old/sysdeps/unix/sysv/linux/sys/soundcard.h libc/sysdeps/unix/sysv/linux/sys/soundcard.h
--- libc.old/sysdeps/unix/sysv/linux/sys/soundcard.h	1996-10-09 01:39:20.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/sys/soundcard.h	2005-08-21 17:37:15.000000000 +0200
@@ -1 +1,4 @@
+#ifndef _SYS_SOUNDCARD_H
+#define _SYS_SOUNDCARD_H 1
 #include <linux/soundcard.h>
+#endif
diff -ur libc.old/sysdeps/unix/sysv/linux/sys/ultrasound.h libc/sysdeps/unix/sysv/linux/sys/ultrasound.h
--- libc.old/sysdeps/unix/sysv/linux/sys/ultrasound.h	1997-12-04 01:10:44.000000000 +0100
+++ libc/sysdeps/unix/sysv/linux/sys/ultrasound.h	2005-08-21 17:37:15.000000000 +0200
@@ -1 +1,4 @@
+#ifndef _SYS_ULTRASOUND_H
+#define _SYS_ULTRASOUND_H 1
 #include <linux/ultrasound.h>
+#endif
diff -ur libc.old/sysdeps/unix/sysv/linux/sys/vt.h libc/sysdeps/unix/sysv/linux/sys/vt.h
--- libc.old/sysdeps/unix/sysv/linux/sys/vt.h	1996-09-27 05:44:24.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/sys/vt.h	2005-08-21 17:37:15.000000000 +0200
@@ -1 +1,4 @@
+#ifndef _SYS_VT_H
+#define _SYS_VT_H 1
 #include <linux/vt.h>
+#endif


More information about the Libc-alpha mailing list