errno breakage fix
Matthew Dillon
dillon at apollo.backplane.com
Sat Jul 2 10:25:49 PDT 2005
:hey,
:
:this is my proposal for the (not-so) recent errno breakage with popular
:software:
:
:Index: sys/sys/errno.h
:=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
:=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
:=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
: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 @@
:=20
: #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
:=20
: #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
Well, I guess we may have no choice. As hacks go, it isn't too shabby.
I say we go with it.
-Matt
More information about the Submit
mailing list