This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: errno.h: ESTRPIPE


Ralf Corsepius wrote:
Jeff Johnston wrote:
Ralf Corsepius wrote:
Christopher Faylor wrote:
On Mon, Mar 16, 2009 at 08:29:26AM +0100, Ralf Corsepius wrote:
newlib should stay with well established standards and not be polluted
with underdocumented, proprietary extensions.

Do you have any other irrational prejudices you'd like to share with us?
No, simply point me to an official (POSIX, IEEE, ANSII or similar) standard documenting ESTRPIPE.

Ralf

Hi Ralf,

According to Posix Section 2.4 states:

"Implementations may support additional errors not listed in this clause, but shall not generate a different error number from one required by this part of ISO/IEC 9945 for an error condition described in this part of ISO/IEC 9945...."

Similarly under SUSV:

"Additional implementation-dependent error numbers may be defined in <errno.h>"
Well, this only applies from an OS's POV, i.e. an OS has the liberty to add further errnos.

Newlib is in a special position wrt. this: It is not part of the OS (glibc is), it is used by the OS.

I.e. what you are saying effectively means: Cygwin dictates to newlib what other OS using newlib must support.

Well, actually, the majority of the extensions are Linux and in this matter, I have been Linux-biased based on my local OS and installed glibc header files.

That said, there is a legitimate reason to #ifdef these values as they add to the size of the strerror function which can now be enhanced to include all the extensions. For small platforms, this would be particularly undesirable.

So, I have prepared a patch (attached) that segregates the majority of the extensions under __LINUX_ERRNO_EXTENSIONS__ and have put 3 errno values under __CYGWIN__. There were 4 errnos I couldn't find in the Linux header files: ELBIN, EPROCLIM, EFTYPE, and ENMFILE but I put them under Linux extensions nonetheless. If these are Cygwin-specific, please speak up, otherwise, I'll leave them asis for now.

In sys/config.h I have set __LINUX_ERRNO_EXTENSIONS__ to 1 for Cygwin so Cygwin sees all errnos by default. Linux is already including the local glibc asm/errno.h so it isn't being used by Linux. The extensions aren't being used in the shared code. If it is felt that this should be configurable, I'll add a configuration option.

Comments?

-- Jeff J.
Index: config.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/config.h,v
retrieving revision 1.49
diff -u -p -r1.49 config.h
--- config.h	19 Nov 2008 21:05:31 -0000	1.49
+++ config.h	17 Mar 2009 20:40:07 -0000
@@ -178,6 +178,7 @@
 
 #if defined(__CYGWIN__)
 #include <cygwin/config.h>
+#define __LINUX_ERRNO_EXTENSIONS__ 1
 #endif
 
 #if defined(__rtems__)
Index: errno.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/errno.h,v
retrieving revision 1.14
diff -u -p -r1.14 errno.h
--- errno.h	15 Mar 2009 13:41:46 -0000	1.14
+++ errno.h	17 Mar 2009 20:40:07 -0000
@@ -40,7 +40,9 @@ extern __IMPORT int sys_nerr;
 #define	ENOMEM 12	/* Not enough core */
 #define	EACCES 13	/* Permission denied */
 #define	EFAULT 14	/* Bad address */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define	ENOTBLK 15	/* Block device required */
+#endif
 #define	EBUSY 16	/* Mount device busy */
 #define	EEXIST 17	/* File exists */
 #define	EXDEV 18	/* Cross-device link */
@@ -62,6 +64,7 @@ extern __IMPORT int sys_nerr;
 #define	ERANGE 34	/* Math result not representable */
 #define	ENOMSG 35	/* No message of desired type */
 #define	EIDRM 36	/* Identifier removed */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define	ECHRNG 37	/* Channel number out of range */
 #define	EL2NSYNC 38	/* Level 2 not synchronized */
 #define	EL3HLT 39	/* Level 3 halted */
@@ -70,8 +73,10 @@ extern __IMPORT int sys_nerr;
 #define	EUNATCH 42	/* Protocol driver not attached */
 #define	ENOCSI 43	/* No CSI structure available */
 #define	EL2HLT 44	/* Level 2 halted */
+#endif
 #define	EDEADLK 45	/* Deadlock condition */
 #define	ENOLCK 46	/* No record locks available */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define EBADE 50	/* Invalid exchange */
 #define EBADR 51	/* Invalid request descriptor */
 #define EXFULL 52	/* Exchange full */
@@ -80,22 +85,30 @@ extern __IMPORT int sys_nerr;
 #define EBADSLT 55	/* Invalid slot */
 #define EDEADLOCK 56	/* File locking deadlock error */
 #define EBFONT 57	/* Bad font file fmt */
+#endif
 #define ENOSTR 60	/* Device not a stream */
 #define ENODATA 61	/* No data (for no delay io) */
 #define ETIME 62	/* Timer expired */
 #define ENOSR 63	/* Out of streams resources */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define ENONET 64	/* Machine is not on the network */
 #define ENOPKG 65	/* Package not installed */
 #define EREMOTE 66	/* The object is remote */
+#endif
 #define ENOLINK 67	/* The link has been severed */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define EADV 68		/* Advertise error */
 #define ESRMNT 69	/* Srmount error */
 #define	ECOMM 70	/* Communication error on send */
+#endif
 #define EPROTO 71	/* Protocol error */
 #define	EMULTIHOP 74	/* Multihop attempted */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define	ELBIN 75	/* Inode is remote (not really error) */
 #define	EDOTDOT 76	/* Cross mount point (not really error) */
+#endif
 #define EBADMSG 77	/* Trying to read unreadable message */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define EFTYPE 79	/* Inappropriate file type or format */
 #define ENOTUNIQ 80	/* Given log. name not unique */
 #define EBADFD 81	/* f.d. invalid for this operation */
@@ -105,57 +118,78 @@ extern __IMPORT int sys_nerr;
 #define ELIBSCN 85	/* .lib section in a.out corrupted */
 #define ELIBMAX 86	/* Attempting to link in too many libs */
 #define ELIBEXEC 87	/* Attempting to exec a shared library */
+#endif
 #define ENOSYS 88	/* Function not implemented */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define ENMFILE 89      /* No more files */
+#endif
 #define ENOTEMPTY 90	/* Directory not empty */
 #define ENAMETOOLONG 91	/* File or path name too long */
 #define ELOOP 92	/* Too many symbolic links */
 #define EOPNOTSUPP 95	/* Operation not supported on transport endpoint */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define EPFNOSUPPORT 96 /* Protocol family not supported */
+#endif
 #define ECONNRESET 104  /* Connection reset by peer */
 #define ENOBUFS 105	/* No buffer space available */
 #define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
 #define EPROTOTYPE 107	/* Protocol wrong type for socket */
 #define ENOTSOCK 108	/* Socket operation on non-socket */
 #define ENOPROTOOPT 109	/* Protocol not available */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define ESHUTDOWN 110	/* Can't send after socket shutdown */
+#endif
 #define ECONNREFUSED 111	/* Connection refused */
 #define EADDRINUSE 112		/* Address already in use */
 #define ECONNABORTED 113	/* Connection aborted */
 #define ENETUNREACH 114		/* Network is unreachable */
 #define ENETDOWN 115		/* Network interface is not configured */
 #define ETIMEDOUT 116		/* Connection timed out */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define EHOSTDOWN 117		/* Host is down */
+#endif
 #define EHOSTUNREACH 118	/* Host is unreachable */
 #define EINPROGRESS 119		/* Connection already in progress */
 #define EALREADY 120		/* Socket already connected */
 #define EDESTADDRREQ 121	/* Destination address required */
 #define EMSGSIZE 122		/* Message too long */
 #define EPROTONOSUPPORT 123	/* Unknown protocol */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define ESOCKTNOSUPPORT 124	/* Socket type not supported */
+#endif
 #define EADDRNOTAVAIL 125	/* Address not available */
 #define ENETRESET 126
 #define EISCONN 127		/* Socket is already connected */
 #define ENOTCONN 128		/* Socket is not connected */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define ETOOMANYREFS 129
 #define EPROCLIM 130
 #define EUSERS 131
+#endif
 #define EDQUOT 132
 #define ESTALE 133
 #define ENOTSUP 134		/* Not supported */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define ENOMEDIUM 135   /* No medium (in tape drive) */
+#endif
+#ifdef __CYGWIN__
 #define ENOSHARE 136    /* No such host or network path */
 #define ECASECLASH 137  /* Filename exists with different case */
+#endif
 #define EILSEQ 138
 #define EOVERFLOW 139	/* Value too large for defined data type */
 #define ECANCELED 140	/* Operation canceled */
 #define ENOTRECOVERABLE 141	/* State not recoverable */
 #define EOWNERDEAD 142	/* Previous owner died */
+#ifdef __LINUX_ERRNO_EXTENSIONS__
 #define ESTRPIPE 143	/* Streams pipe error */
+#endif
 
 
 /* From cygwin32.  */
+#ifdef __CYGWIN__
 #define EWOULDBLOCK EAGAIN	/* Operation would block */
+#endif
 
 #define __ELASTERROR 2000	/* Users can add values starting here */
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]