Subject: emacs does not compile when using uClibc

From: Dan Nicolaescu <[email-masked]>
Date: Sun, 28 Sep 2008 00:15:42 -0700 (PDT)

uClibc is an alternative libc, emacs does not work on such systems at
the moment.
The patch bellow fixes this.  Not sure if this is a bug fix, or it's
adding a new feature, so just record it here in case it's the latter.

Index: src/gmalloc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/gmalloc.c,v
retrieving revision 1.28
diff -u -3 -p -r1.28 gmalloc.c
--- src/gmalloc.c	23 May 2008 04:39:57 -0000	1.28
+++ src/gmalloc.c	28 Sep 2008 07:08:54 -0000
@@ -1706,17 +1706,17 @@ MA 02110-1301, USA.  */
 #include <malloc.h>
 #endif
 
-#ifndef	__GNU_LIBRARY__
+/* uClibc defines __GNU_LIBRARY__, but it is not completely
+   compatible.  */
+#if !defined(__GNU_LIBRARY__) || defined(__UCLIBC__)
 #define	__sbrk	sbrk
-#endif
-
-#ifdef __GNU_LIBRARY__
+#else /* __GNU_LIBRARY__ && ! defined (__UCLIBC__) */
 /* It is best not to declare this and cast its result on foreign operating
    systems with potentially hostile include files.  */
 
 #include <stddef.h>
 extern __ptr_t __sbrk PP ((ptrdiff_t increment));
-#endif
+#endif /* __GNU_LIBRARY__ && ! defined (__UCLIBC__) */
 
 #ifndef NULL
 #define NULL 0
Index: src/s/gnu-linux.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/s/gnu-linux.h,v
retrieving revision 1.113
diff -u -3 -p -r1.113 gnu-linux.h
--- src/s/gnu-linux.h	2 Aug 2008 16:19:03 -0000	1.113
+++ src/s/gnu-linux.h	28 Sep 2008 07:08:54 -0000
@@ -156,11 +156,15 @@ along with GNU Emacs.  If not, see <http
 /* new C libio names */
 #define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \
   ((FILE)->_IO_write_ptr - (FILE)->_IO_write_base)
-#else /* !_IO_STDIO_H */
+#elif defined (__UCLIBC__)
+/* using the uClibc library */
+#define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \
+  ((FILE)->__bufpos - (FILE)->__bufstart)
+#else /* !_IO_STDIO_H && ! __UCLIBC__ */
 /* old C++ iostream names */
 #define GNU_LIBRARY_PENDING_OUTPUT_COUNT(FILE) \
   ((FILE)->_pptr - (FILE)->_pbase)
-#endif /* !_IO_STDIO_H */
+#endif /* !_IO_STDIO_H && ! __UCLIBC__ */
 #endif /* emacs */
 
 /* Ask GCC where to find libgcc.a.  */