Rename our substitute qsort to pg_qsort at the link-symbol level (but

provide a macro so code can still just say qsort).  Avoids linker warnings
on pickier platforms such as Darwin, and outright failure on MSVC.
This commit is contained in:
Tom Lane 2006-10-19 20:56:22 +00:00
parent 443abd83e5
commit 4887f5f979
2 changed files with 11 additions and 14 deletions

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/port.h,v 1.104 2006/10/04 00:30:06 momjian Exp $ * $PostgreSQL: pgsql/src/include/port.h,v 1.105 2006/10/19 20:56:22 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -363,6 +363,11 @@ extern int pqGethostbyname(const char *name,
struct hostent ** result, struct hostent ** result,
int *herrno); int *herrno);
extern void pg_qsort(void *base, size_t nel, size_t elsize,
int (*cmp) (const void *, const void *));
#define qsort(a,b,c,d) pg_qsort(a,b,c,d)
typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg); typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg);
extern void qsort_arg(void *base, size_t nel, size_t elsize, extern void qsort_arg(void *base, size_t nel, size_t elsize,

View File

@ -9,7 +9,7 @@
* *
* CAUTION: if you change this file, see also qsort_arg.c * CAUTION: if you change this file, see also qsort_arg.c
* *
* $PostgreSQL: pgsql/src/port/qsort.c,v 1.11 2006/10/12 15:04:55 tgl Exp $ * $PostgreSQL: pgsql/src/port/qsort.c,v 1.12 2006/10/19 20:56:22 tgl Exp $
*/ */
/* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */ /* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */
@ -46,8 +46,8 @@
#include "c.h" #include "c.h"
static char *med3(char *, char *, char *, static char *med3(char *a, char *b, char *c,
int (*) (const void *, const void *)); int (*cmp) (const void *, const void *));
static void swapfunc(char *, char *, size_t, int); static void swapfunc(char *, char *, size_t, int);
/* /*
@ -96,11 +96,7 @@ int swaptype;
#define vecswap(a, b, n) if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype) #define vecswap(a, b, n) if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
static char * static char *
med3(a, b, c, cmp) med3(char *a, char *b, char *c, int (*cmp) (const void *, const void *))
char *a,
*b,
*c;
int (*cmp) (const void *, const void *);
{ {
return cmp(a, b) < 0 ? return cmp(a, b) < 0 ?
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a)) (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a))
@ -108,11 +104,7 @@ int (*cmp) (const void *, const void *);
} }
void void
qsort(a, n, es, cmp) pg_qsort(void *a, size_t n, size_t es, int (*cmp) (const void *, const void *))
void *a;
size_t n,
es;
int (*cmp) (const void *, const void *);
{ {
char *pa, char *pa,
*pb, *pb,