Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37048486
en ru br
Репозитории ALT

Группа :: Engineering
Пакет: GMT

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: GMT-c99.patch
Скачать


From 42198756233ea06c38120d290c693a4acfe7bb59 Mon Sep 17 00:00:00 2001
From: Paul Wessel <pwessel@hawaii.edu>
Date: Mon, 24 Apr 2023 15:59:45 +0200
Subject: [PATCH] Ensure mergesort is declared if needed (#7411)
See #7410  for background.  Here I implement it a bit differently.  The mergesort function is used both in a module (gmtspatial) as well as by some gmt_*.c libraries, hence if it is not part of the standard libraries we declare it in gmt_prototypes.h so it is set for both modules and libs.
---
 src/gmt_init.c       | 4 ++++
 src/gmt_prototypes.h | 9 +++++++++
 src/gmtspatial.c     | 9 ---------
 3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/gmt_init.c b/src/gmt_init.c
index d08a07f6229..f1b65f62231 100644
--- a/src/gmt_init.c
+++ b/src/gmt_init.c
@@ -167,6 +167,10 @@
 #	include <mex.h>
 #endif
 
+#ifndef HAVE_MERGESORT
+#include "mergesort.c"
+#endif
+
 /* These are used in gmtinit_init_custom_annot and gmtinit_decode_tinfo only */
 #define GMT_ITEM_ANNOT		0
 #define GMT_ITEM_INTVAL		1
diff --git a/src/gmt_prototypes.h b/src/gmt_prototypes.h
index 4a157d97184..676433a1611 100644
--- a/src/gmt_prototypes.h
+++ b/src/gmt_prototypes.h
@@ -39,6 +39,15 @@ EXTERN_MSC void gmt_grd_dump (struct GMT_GRID_HEADER *header, gmt_grdfloat *grid
 EXTERN_MSC char * gmt_strdup (struct GMT_CTRL *GMT, const char *s);
 #endif
 
+#ifdef __APPLE__
+/* macOX has it built in, so ensure we define this flag */
+#define HAVE_MERGESORT
+#endif
+
+#ifndef HAVE_MERGESORT
+EXTERN_MSC int mergesort (void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *));
+#endif
+
 /* gmt_nc.c: */
 
 EXTERN_MSC bool gmt_nc_is_cube (struct GMTAPI_CTRL *API, char *file);
diff --git a/src/gmtspatial.c b/src/gmtspatial.c
index cfa24ce2e5b..b5a4b1b86a8 100644
--- a/src/gmtspatial.c
+++ b/src/gmtspatial.c
@@ -165,15 +165,6 @@ struct GMTSPATIAL_PAIR {
 	uint64_t pos;
 };
 
-#ifdef __APPLE__
-/* macOX has it built in, so ensure we define this flag */
-#define HAVE_MERGESORT
-#endif
-
-#ifndef HAVE_MERGESORT
-#include "mergesort.c"
-#endif
-
 static void *New_Ctrl (struct GMT_CTRL *GMT) {	/* Allocate and initialize a new control structure */
 	struct GMTSPATIAL_CTRL *C;
 
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin