Commit 6a5e71b5 authored by Philip Carns's avatar Philip Carns

switch to compile-time test for how to print int64


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@388 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 1856df04
This diff is collapsed.
......@@ -13,9 +13,6 @@ AC_PROG_INSTALL
CHECK_ZLIB
dnl Check byte ordering
AC_C_BIGENDIAN
AC_ARG_WITH(mpi,
[ --with-mpi=<dir> Location of the MPI installation],
if test x$withval = xyes; then
......@@ -78,9 +75,6 @@ AC_ARG_WITH(jobid-env,
fi
)
saveCC="$CC"
CC="$MPICC"
if test x$HAVE_MPICC != "xyes"; then
AC_MSG_ERROR(must provide --with-mpi=<path> argument to configure if mpicc is not in path.)
fi
......@@ -94,6 +88,33 @@ if test x$GOT_JOBID != x1; then
AC_MSG_ERROR(must provide --with-jobid-env=<name> argument to configure.)
fi
# =====================================================================
# all tests executed with CC=MPICC from this point on
saveCC="$CC"
CC="$MPICC"
# redo printf int64 test for mpi compiler
AC_MSG_CHECKING(if int64 can be printed as lld without cast)
old_cflags="$CFLAGS"
CFLAGS="$CFLAGS -Wall -Werror"
AC_TRY_COMPILE(
[
#include <stdio.h>
#include <sys/types.h>
],
[
int64_t test = 0;
printf("%lld\n", test);
],
AC_MSG_RESULT(yes)
,
AC_MSG_RESULT(no)
AC_DEFINE(PRINTF_CAST_INT64_LLD, 1, Define if int64 should be cast to long long for printf)
)
CFLAGS="$old_cflags"
AC_MSG_CHECKING(whether the mpicc compiler works)
AC_TRY_COMPILE([#include <mpi.h>], [int ret = MPI_Init(0, (void*)0)],
AC_MSG_RESULT(yes),
......@@ -101,6 +122,9 @@ AC_TRY_COMPILE([#include <mpi.h>], [int ret = MPI_Init(0, (void*)0)],
AC_MSG_ERROR($CC doesn't appear to be a valid MPI compiler)
)
dnl Check byte ordering
AC_C_BIGENDIAN
dnl temporarily set large file flags just for this test; we don't want
dnl it to propagate to the makefile because of zlib bugs
old_cflags="$CFLAGS"
......@@ -177,7 +201,6 @@ AC_SUBST(__CP_LOG_PATH)
AC_SUBST(__CP_ZLIB_LINK_FLAGS)
AC_SUBST(__CP_ZLIB_INCLUDE_FLAGS)
AC_SUBST(CP_WRAPPERS)
AC_CHECK_SIZEOF([long int])
AC_OUTPUT(Makefile
darshan-mk-log-dirs.pl
darshan-gen-cc.pl
......
......@@ -63,8 +63,8 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `long int', as computed by sizeof. */
#undef SIZEOF_LONG_INT
/* Define if int64 should be cast to long long for printf */
#undef PRINTF_CAST_INT64_LLD
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
......
......@@ -237,16 +237,14 @@ struct darshan_job
int64_t jobid;
};
#if SIZEOF_LONG_INT == 4
# define llu(x) (x)
# define lld(x) (x)
# define SCANF_lld "%lld"
#elif SIZEOF_LONG_INT == 8
#ifdef PRINTF_CAST_INT64_LLD
# define llu(x) (unsigned long long)(x)
# define lld(x) (long long)(x)
# define SCANF_lld "%ld"
#else
# error Unexpected sizeof(long int)
# define llu(x) (x)
# define lld(x) (x)
# define SCANF_lld "%lld"
#endif
#endif /* __DARSHAN_LOG_FORMAT_H */
......@@ -365,14 +365,12 @@ int darshan_log_getmounts(darshan_fd fd, int64_t** devs, char*** mnt_pts, char**
(*fs_types)[array_index] = malloc(CP_EXE_LEN);
assert((*fs_types)[array_index]);
#if SIZEOF_LONG_INT == 4
ret = sscanf(++pos, "%lld\t%s\t%s", &(*devs)[array_index],
(*fs_types)[array_index], (*mnt_pts)[array_index]);
#elif SIZEOF_LONG_INT == 8
#ifdef PRINTF_CAST_INT64_LLD
ret = sscanf(++pos, "%ld\t%s\t%s", &(*devs)[array_index],
(*fs_types)[array_index], (*mnt_pts)[array_index]);
#else
# error Unexpected sizeof(long int)
ret = sscanf(++pos, "%lld\t%s\t%s", &(*devs)[array_index],
(*fs_types)[array_index], (*mnt_pts)[array_index]);
#endif
if(ret != 3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment