DragonFly BSD
DragonFly submit List (threaded) for 2005-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

errno breakage fix


From: "Simon 'corecode' Schubert" <corecode@xxxxxxxxxxxx>
Date: Sat, 2 Jul 2005 18:20:10 +0200

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
Description: PGP signature



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]