1. petsc
  2. PETSc
  3. petsc


Jed Brown  committed c55ef47

missing.py: BSD getdomainname compatibility

Linux and related systems use

int getdomainname(char*, size_t);

while BSD systems (including Apple) prefer

int getdomainname(char*, int);

The test is now precise about types, so we have to try both.

Reported-by: Barry Smith <bsmith@mcs.anl.gov>

  • Participants
  • Parent commits 54a8e6c
  • Branches master

Comments (0)

Files changed (1)

File config/PETSc/utilities/missing.py

View file
  • Ignore whitespace
 #include <netdb.h>
-    code = '''
-int (*getdomainname_ptr)(char*,size_t) = getdomainname;
+    def code(t):
+      """The type of the len parameter is size_t on Linux and int on BSD, so we'll have to try both."""
+      return '''
+int (*getdomainname_ptr)(char*,%s) = getdomainname;
 char test[10];
 if (getdomainname_ptr(test,10)) return 1;
-    if not self.checkCompile(head,code):
+''' % (t,)
+    if not (self.checkCompile(head,code('size_t')) or self.checkCompile(head,code('int'))):
       self.addPrototype('#include <stddef.h>\nint getdomainname(char *, size_t);', 'C')
     if hasattr(self.compilers, 'CXX'):
-      if not self.checkLink(head,code):
+      if not (self.checkLink(head,code('size_t')) or self.checkLink(head,code('int'))):
         self.addPrototype('#include <stddef.h>\nint getdomainname(char *, size_t);', 'extern C')