| 1 | /* |
| 2 | * Copyright (C) by Argonne National Laboratory |
| 3 | * See COPYRIGHT in top-level directory |
| 4 | */ |
| 5 | |
| 6 | /* Include stdio.h first to see if the MPI implementation can handle the |
| 7 | conflicting definitions in stdio.h for the SEEK_SET, SEEK_CUR, and |
| 8 | SEEK_END */ |
| 9 | #include "mpitestconf.h" |
| 10 | |
| 11 | #include <stdio.h> |
| 12 | #ifdef HAVE_IOSTREAM |
| 13 | // Not all C++ compilers have iostream instead of iostream.h |
| 14 | #include <iostream> |
| 15 | #ifdef HAVE_NAMESPACE_STD |
| 16 | // Those that do often need the std namespace; otherwise, a bare "cout" |
| 17 | // is likely to fail to compile |
| 18 | using namespace std; |
| 19 | #endif |
| 20 | #else |
| 21 | #include <iostream.h> |
| 22 | #endif |
| 23 | #ifdef HAVE_STRING_H |
| 24 | #include <string.h> |
| 25 | #endif |
| 26 | |
| 27 | #include "mpi.h" |
| 28 | #include "mpitestcxx.h" |
| 29 | |
| 30 | static char MTEST_Descrip[] = "Test availability of MPI::SEEK_SET and SEEK_SET from stdio.h"; |
| 31 | |
| 32 | int main(int argc, char *argv[]) |
| 33 | { |
| 34 | int errs = 0, err; |
| 35 | int rank; |
| 36 | MPI::Intracomm comm; |
| 37 | MPI::Status status; |
| 38 | int seekValues; |
| 39 | |
| 40 | MTest_Init(); |
| 41 | comm = MPI::COMM_WORLD; |
| 42 | |
| 43 | // Make sure that we can access each value |
| 44 | // First, the MPI C++ values |
| 45 | seekValues = MPI::SEEK_SET; |
| 46 | if (MPI::SEEK_CUR == seekValues) { |
| 47 | errs++; |
| 48 | } |
| 49 | if (MPI::SEEK_END == seekValues) { |
| 50 | errs++; |
| 51 | } |
| 52 | // Second, the stdio values |
| 53 | seekValues = SEEK_SET; |
| 54 | if (SEEK_CUR == seekValues) { |
| 55 | errs++; |
| 56 | } |
| 57 | if (SEEK_END == seekValues) { |
| 58 | errs++; |
| 59 | } |
| 60 | |
| 61 | /* some workarounds for the SEEK_SET problem prevent its |
| 62 | * use as a case label */ |
| 63 | seekValues = SEEK_SET; |
| 64 | switch (seekValues) { |
| 65 | case SEEK_SET: |
| 66 | break; |
| 67 | case SEEK_CUR: |
| 68 | case SEEK_END: |
| 69 | default: |
| 70 | errs++; |
| 71 | break; |
| 72 | } |
| 73 | |
| 74 | MTest_Finalize(errs); |
| 75 | return 0; |
| 76 | } |