errno breakage fix

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Sat Jul 2 09:21:49 PDT 2005


hey,

this is my proposal for the (not-so) recent errno breakage with popular
software:

Index: sys/sys/errno.h
===================================================================
RCS file: /space/cvs/dragonfly/src/sys/sys/errno.h,v
retrieving revision 1.6
diff -u -r1.6 errno.h
--- sys/sys/errno.h	3 May 2005 07:29:04 -0000	1.6
+++ sys/sys/errno.h	2 Jul 2005 16:08:55 -0000
@@ -45,11 +45,14 @@
 
 #ifndef _KERNEL
 extern __thread int	errno;
-/*
- * A lot of programs want to define errno as normal int, if
- * it isn't a macro. Work around this to prevent even more breakage.
- */
-#define	errno	errno
+
+#include <sys/cdefs.h>
+static inline int *__error(void)
+{
+	return (&errno);
+}
+
+#define	errno		(* __error())
 #endif
 
 #define	EPERM		1		/* Operation not permitted */


it's ABI and API compatible with -Devel. Source code declaring
extern int errno;
now works again.

optimized code (-O and above) will compile this to a no-op, maybe even
nicer code (pushl (%ebx) vs (%esi,%ebx,1))

if nobody objects I'll commit this in two days.

cheers
  simon

-- 
Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low $$$ NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \
Attachment:
pgp00000.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00000.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20050702/aedb32ee/attachment-0018.obj>


More information about the Submit mailing list