[m-rev.] diff: Fix missing declarations of symbols for thread-pinning.

Peter Wang novalazy at gmail.com
Sat Mar 26 19:10:50 AEDT 2016


runtime/mercury_context.c:
	Define _GNU_SOURCE at top of file, otherwise including <sched.h>
	does not declare the glibc/Linux-specific symbols we use for
	thread pinning: sched_getaffinity, sched_setaffinity,
	sched_getcpu, and the cpu_set_t CPU_* macros.

diff --git a/runtime/mercury_context.c b/runtime/mercury_context.c
index 3bd98fb..49dfcd2 100644
--- a/runtime/mercury_context.c
+++ b/runtime/mercury_context.c
@@ -7,13 +7,21 @@ ENDINIT
 */
 /*
 ** Copyright (C) 1995-2007, 2009-2011 The University of Melbourne.
-** Copyright (C) 2014 The Mercury team.
+** Copyright (C) 2014, 2016 The Mercury team.
 ** This file may only be copied under the terms of the GNU Library General
 ** Public License - see the file COPYING.LIB in the Mercury distribution.
 */
 
 /* mercury_context.c - handles multithreading stuff. */
 
+#ifndef _GNU_SOURCE
+  /*
+  ** This must be defined prior to including <sched.h> for sched_setaffinity,
+  ** etc.
+  */
+  #define _GNU_SOURCE
+#endif
+
 #include "mercury_imp.h"
 
 #include <stdio.h>
@@ -36,7 +44,7 @@ ENDINIT
 #endif
 
 #ifdef MR_HAVE_SCHED_H
-#include <sched.h>
+  #include <sched.h>
 #endif
 
 #ifdef MR_MINGW
-- 
2.7.4



More information about the reviews mailing list