1. petsc
  2. PETSc
  3. petsc

Commits

Jed Brown  committed 0659470

missing.py: fix behavior with feature test macros

PETSc creates prototypes for drand48() when it is not defined in the
headers tested by configure. If configure does not define feature test
macros, this can lead to duplicate definitions when feature test macros
are defined later.

  • Participants
  • Parent commits 07aea91
  • Branches master

Comments (0)

Files changed (3)

File config/PETSc/utilities/missing.py

View file
  • Ignore whitespace
     self.compilers = framework.require('config.compilers', self)
     self.functions = framework.require('config.functions', self)
     self.libraries = framework.require('config.libraries', self)
+    self.petscConf = framework.require('PETSc.Configure', self)
     return
 
+  def featureTestMacros(self):
+    features = ''
+    if self.petscConf.defines.get('_POSIX_C_SOURCE_200112L'):
+      features += '#define _POSIX_C_SOURCE 200112L\n'
+    if self.petscConf.defines.get('_BSD_SOURCE'):
+      features += '#define _BSD_SOURCE\n'
+    if self.petscConf.defines.get('_GNU_SOURCE'):
+      features += '#define _GNU_SOURCE\n'
+    return features
+
 #-------------------------------------------------------
   def configureMissingDefines(self):
     '''Checks for limits'''
 
 
   def configureMissingGetdomainnamePrototype(self):
-    head ='''
+    head = self.featureTestMacros() + '''
 #ifdef PETSC_HAVE_UNISTD_H
 #include <unistd.h>
 #endif
     return
 
   def configureMissingSrandPrototype(self):
-    head ='''
+    head = self.featureTestMacros() + '''
 #ifdef PETSC_HAVE_STDLIB_H
 #include <stdlib.h>
 #endif

File src/sys/classes/random/impls/rand48/rand48.c

View file
  • Ignore whitespace
-
+#define PETSC_DESIRE_FEATURE_TEST_MACROS /* for drand48 with c89 */
 #include <../src/sys/classes/random/randomimpl.h>
 
 #undef __FUNCT__

File src/sys/utils/fhost.c

View file
  • Ignore whitespace
-
+#define PETSC_DESIRE_FEATURE_TEST_MACROS /* for getdomainname */
 /*
       Code for manipulating files.
 */