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]

[PATCH] __compar_fn_t


The attached patch uses the __compar_fn_t typedef for the function pointer types of bsearch, qsort, tsearch and friends, as in glibc. This fixes the build of gedit-code-assistance on Cygwin.


Yaakov
Cygwin/X
2013-08-08  Yaakov Selkowitz  <yselkowitz@...>

	* libc/include/search.h (__compar_fn_t): Add typedef.
	(tdelete, tfind, tsearch): Use it.
	* libc/include/stdlib.h (__compar_fn_t): Add typedef.
	(bsearch, qsort): Use it.

Index: libc/include/search.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/search.h,v
retrieving revision 1.1
diff -u -p -r1.1 search.h
--- libc/include/search.h	20 Jun 2002 19:51:19 -0000	1.1
+++ libc/include/search.h	8 Aug 2013 17:54:36 -0000
@@ -42,6 +42,11 @@ struct hsearch_data
   size_t htablesize;
 };
 
+#ifndef __compar_fn_t_defined
+#define __compar_fn_t_defined
+typedef int (*__compar_fn_t) (const void *, const void *);
+#endif
+
 __BEGIN_DECLS
 int	 hcreate(size_t);
 void	 hdestroy(void);
@@ -49,10 +54,10 @@ ENTRY	*hsearch(ENTRY, ACTION);
 int	 hcreate_r(size_t, struct hsearch_data *);
 void	 hdestroy_r(struct hsearch_data *);
 int	hsearch_r(ENTRY, ACTION, ENTRY **, struct hsearch_data *);
-void	*tdelete(const void *, void **, int (*)(const void *, const void *));
+void	*tdelete(const void *, void **, __compar_fn_t);
 void	tdestroy (void *, void (*)(void *));
-void	*tfind(const void *, void **, int (*)(const void *, const void *));
-void	*tsearch(const void *, void **, int (*)(const void *, const void *));
+void	*tfind(const void *, void **, __compar_fn_t);
+void	*tsearch(const void *, void **, __compar_fn_t);
 void      twalk(const void *, void (*)(const void *, VISIT, int));
 __END_DECLS
 
Index: libc/include/stdlib.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/stdlib.h,v
retrieving revision 1.44
diff -u -p -r1.44 stdlib.h
--- libc/include/stdlib.h	11 Apr 2013 13:01:08 -0000	1.44
+++ libc/include/stdlib.h	8 Aug 2013 17:54:36 -0000
@@ -47,6 +47,11 @@ typedef struct
 } lldiv_t;
 #endif
 
+#ifndef __compar_fn_t_defined
+#define __compar_fn_t_defined
+typedef int (*__compar_fn_t) (const _PTR, const _PTR);
+#endif
+
 #define EXIT_FAILURE 1
 #define EXIT_SUCCESS 0
 
@@ -71,7 +76,7 @@ _PTR	_EXFUN(bsearch,(const _PTR __key,
 		       const _PTR __base,
 		       size_t __nmemb,
 		       size_t __size,
-		       int _EXFNPTR(_compar,(const _PTR, const _PTR))));
+		       __compar_fn_t _compar));
 _PTR	_EXFUN_NOTHROW(calloc,(size_t __nmemb, size_t __size));
 div_t	_EXFUN(div,(int __numer, int __denom));
 _VOID	_EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn)));
@@ -113,7 +118,7 @@ int	_EXFUN(_mkstemp_r, (struct _reent *,
 int	_EXFUN(_mkstemps_r, (struct _reent *, char *, int));
 char *	_EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((__warning__ ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
 #endif
-_VOID	_EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR)));
+_VOID	_EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
 int	_EXFUN(rand,(_VOID));
 _PTR	_EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
 #ifndef __STRICT_ANSI__

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