"Fossies" - the Fresh Open Source Software Archive

Member "scalasca-2.6/vendor/cubew/build-config/m4/ac_cube_posix_functions.m4" (19 Apr 2021, 5042 Bytes) of package /linux/misc/scalasca-2.6.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ##*************************************************************************##
    2 ##  CUBE        http://www.scalasca.org/                                   ##
    3 ##*************************************************************************##
    4 ##  Copyright (c) 1998-2016                                                ##
    5 ##  Forschungszentrum Juelich GmbH, Juelich Supercomputing Centre          ##
    6 ##                                                                         ##
    7 ##  Copyright (c) 2009-2015                                                ##
    8 ##  German Research School for Simulation Sciences GmbH,                   ##
    9 ##  Laboratory for Parallel Programming                                    ##
   10 ##                                                                         ##
   11 ##  This software may be modified and distributed under the terms of       ##
   12 ##  a BSD-style license.  See the COPYING file in the package base         ##
   13 ##  directory for details.                                                 ##
   14 ##*************************************************************************##
   15 
   16 
   17 
   18 ## file       ac_cube_posix_functions.m4
   19 
   20 AC_DEFUN([AC_CUBE_POSIX_FUNCTIONS], [
   21 
   22     ##
   23     ## check function declarations
   24     ##
   25 
   26     AC_LANG_PUSH(C)
   27 
   28     ## check whether functions are declared and set HAVE_DECL_* appropriately
   29     AC_CHECK_DECLS([gethostid, gethostname, fseeko, fseeko64, getcwd], [], [], [[
   30       #include <unistd.h>
   31       #include <stdio.h>
   32     ]])
   33 
   34     ##
   35     ## try to link
   36     ##
   37 
   38     has_gethostid_func="yes"
   39     AC_MSG_CHECKING([for gethostid])
   40     AC_LINK_IFELSE([
   41         AC_LANG_SOURCE([
   42             #include <stddef.h>
   43 
   44             #if !HAVE_DECL_GETHOSTID
   45             long gethostid(void);
   46             #endif
   47 
   48             int main()
   49             {
   50                 long host_id = gethostid();
   51                 return 0;
   52             }
   53             ])],
   54         [AC_MSG_RESULT(yes);
   55          AC_DEFINE(HAVE_GETHOSTID, 1, [Can link a gethostid function])],
   56         [AC_MSG_RESULT(no)
   57          has_gethostid_func="no"]
   58     ) # AC_LINK_IF_ELSE
   59 
   60     has_gethostname_func="yes"
   61     AC_MSG_CHECKING([for gethostname])
   62     AC_LINK_IFELSE([
   63         AC_LANG_SOURCE([
   64             #include <stddef.h>
   65 
   66             #if !HAVE_DECL_GETHOSTNAME
   67             int gethostname(char *name, size_t namelen);
   68             #endif
   69 
   70             int main()
   71             {
   72                 char* name;
   73                 return gethostname(name, 256);
   74             }
   75             ])],
   76         [AC_MSG_RESULT(yes);
   77          AC_DEFINE(HAVE_GETHOSTNAME, 1, [Can link a gethostname function])],
   78         [AC_MSG_RESULT(no)
   79          has_gethostname_func="no"]
   80     ) # AC_LINK_IF_ELSE
   81 
   82     has_fseeko_func="yes"
   83     AC_MSG_CHECKING([for fseeko])
   84     AC_LINK_IFELSE([
   85         AC_LANG_SOURCE([
   86             #include <stdio.h>
   87             #include <fcntl.h>
   88 
   89             #if !HAVE_DECL_FSEEKO
   90             int fseeko(FILE *stream, off_t offset, int whence);
   91             #endif
   92 
   93             int main()
   94             {
   95                 FILE* stream;
   96                 return fseeko(stream, 256, 0);
   97             }
   98             ])],
   99         [AC_MSG_RESULT(yes);
  100          AC_DEFINE(HAVE_FSEEKO, 1, [Can link a fseeko function])],
  101         [AC_MSG_RESULT(no)
  102          has_fseeko_func="no"]
  103     ) # AC_LINK_IF_ELSE
  104 
  105     has_fseeko64_func="yes"
  106     AC_MSG_CHECKING([for fseeko64])
  107     AC_LINK_IFELSE([
  108         AC_LANG_SOURCE([
  109             #include <stdio.h>
  110             #include <unistd.h>
  111             #include <fcntl.h>
  112 
  113             #if !HAVE_DECL_FSEEKO64
  114             int fseeko64(FILE *stream, off64_t offset, int whence);
  115             #endif
  116 
  117             int main()
  118             {
  119                 FILE* stream;
  120                 return fseeko64(stream, 256lu, 0);
  121             }
  122             ])],
  123         [AC_MSG_RESULT(yes);
  124          AC_DEFINE(HAVE_FSEEKO64, 1, [Can link a fseeko64 function])],
  125         [AC_MSG_RESULT(no)
  126          has_fseeko64_func="no"]
  127     ) # AC_LINK_IF_ELSE
  128 
  129     has_getcwd_func="yes"
  130     AC_MSG_CHECKING([for getcwd])
  131     AC_LINK_IFELSE([
  132         AC_LANG_SOURCE([
  133             #include <stdio.h>
  134             #include <unistd.h>
  135             #include <stdlib.h>
  136 
  137             #if !HAVE_DECL_GETCWD
  138             char* getcwd(char* buf, size_t size);
  139             #endif
  140 
  141             int main()
  142             {
  143                 char* cwd = getcwd(NULL, 0);
  144                 return (cwd == NULL ? EXIT_FAILURE : EXIT_SUCCESS);
  145             }
  146             ])],
  147         [AC_MSG_RESULT(yes);
  148          AC_DEFINE(HAVE_GETCWD, 1, [Can link a getcwd function])],
  149         [AC_MSG_RESULT(no)
  150          has_getcwd_func="no"]
  151     ) # AC_LINK_IF_ELSE
  152 
  153     AC_LANG_POP(C)
  154 
  155     ##
  156     ## result
  157     ##
  158 
  159     AM_CONDITIONAL([HAVE_GETHOSTID], [test "x${has_gethostid_func}" = "xyes"])
  160     AM_CONDITIONAL([HAVE_GETHOSTNAME], [test "x${has_gethostname_func}" = "xyes"])
  161     AM_CONDITIONAL([HAVE_FSEEKO], [test "x${has_fseeko_func}" = "xyes"])
  162     AM_CONDITIONAL([HAVE_FSEEKO64], [test "x${has_fseeko64_func}" = "xyes"])
  163     AM_CONDITIONAL([HAVE_GETCWD], [test "x${has_getcwd_func}" = "xyes"])
  164 ])