Skip to content

Commit 4887f5f

Browse files
committed
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.
1 parent 443abd8 commit 4887f5f

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/include/port.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.104 2006/10/04 00:30:06 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.105 2006/10/19 20:56:22 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -363,6 +363,11 @@ extern int pqGethostbyname(const char *name,
363363
struct hostent ** result,
364364
int *herrno);
365365

366+
extern void pg_qsort(void *base, size_t nel, size_t elsize,
367+
int (*cmp) (const void *, const void *));
368+
369+
#define qsort(a,b,c,d) pg_qsort(a,b,c,d)
370+
366371
typedef int (*qsort_arg_comparator) (const void *a, const void *b, void *arg);
367372

368373
extern void qsort_arg(void *base, size_t nel, size_t elsize,

src/port/qsort.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* CAUTION: if you change this file, see also qsort_arg.c
1111
*
12-
* $PostgreSQL: pgsql/src/port/qsort.c,v 1.11 2006/10/12 15:04:55 tgl Exp $
12+
* $PostgreSQL: pgsql/src/port/qsort.c,v 1.12 2006/10/19 20:56:22 tgl Exp $
1313
*/
1414

1515
/* $NetBSD: qsort.c,v 1.13 2003/08/07 16:43:42 agc Exp $ */
@@ -46,8 +46,8 @@
4646
#include "c.h"
4747

4848

49-
static char *med3(char *, char *, char *,
50-
int (*) (const void *, const void *));
49+
static char *med3(char *a, char *b, char *c,
50+
int (*cmp) (const void *, const void *));
5151
static void swapfunc(char *, char *, size_t, int);
5252

5353
/*
@@ -96,23 +96,15 @@ int swaptype;
9696
#define vecswap(a, b, n) if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
9797

9898
static char *
99-
med3(a, b, c, cmp)
100-
char *a,
101-
*b,
102-
*c;
103-
int (*cmp) (const void *, const void *);
99+
med3(char *a, char *b, char *c, int (*cmp) (const void *, const void *))
104100
{
105101
return cmp(a, b) < 0 ?
106102
(cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a))
107103
: (cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c));
108104
}
109105

110106
void
111-
qsort(a, n, es, cmp)
112-
void *a;
113-
size_t n,
114-
es;
115-
int (*cmp) (const void *, const void *);
107+
pg_qsort(void *a, size_t n, size_t es, int (*cmp) (const void *, const void *))
116108
{
117109
char *pa,
118110
*pb,

0 commit comments

Comments
 (0)