This source file includes following definitions.
- MPI_File_seek
1
2
3
4
5
6
7
8 #include "mpioimpl.h"
9 #include "adioi.h"
10
11 #ifdef HAVE_WEAK_SYMBOLS
12
13 #if defined(HAVE_PRAGMA_WEAK)
14 #pragma weak MPI_File_seek = PMPI_File_seek
15 #elif defined(HAVE_PRAGMA_HP_SEC_DEF)
16 #pragma _HP_SECONDARY_DEF PMPI_File_seek MPI_File_seek
17 #elif defined(HAVE_PRAGMA_CRI_DUP)
18 #pragma _CRI duplicate MPI_File_seek as PMPI_File_seek
19
20 #elif defined(HAVE_WEAK_ATTRIBUTE)
21 int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence) __attribute__((weak,alias("PMPI_File_seek")));
22 #endif
23
24
25 #define MPIO_BUILD_PROFILING
26 #include "mpioprof.h"
27 #endif
28
29
30
31
32
33
34
35
36
37
38
39 int MPI_File_seek(MPI_File fh, MPI_Offset offset, int whence)
40 {
41 int error_code;
42 ADIO_File adio_fh;
43 static char myname[] = "MPI_FILE_SEEK";
44 MPI_Offset curr_offset, eof_offset;
45
46 #ifdef MPI_hpux
47 int fl_xmpi;
48
49 HPMP_IO_START(fl_xmpi, BLKMPIFILESEEK, TRDTBLOCK, adio_fh, MPI_DATATYPE_NULL, -1);
50 #endif
51
52 ROMIO_THREAD_CS_ENTER();
53
54 adio_fh = MPIO_File_resolve(fh);
55
56
57 MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
58 MPIO_CHECK_NOT_SEQUENTIAL_MODE(adio_fh, myname, error_code);
59
60
61 switch(whence) {
62 case MPI_SEEK_SET:
63
64 if (offset < 0) {
65 error_code = MPIO_Err_create_code(MPI_SUCCESS,
66 MPIR_ERR_RECOVERABLE, myname,
67 __LINE__, MPI_ERR_ARG,
68 "**iobadoffset", 0);
69 error_code = MPIO_Err_return_file(adio_fh, error_code);
70 goto fn_exit;
71 }
72
73 break;
74 case MPI_SEEK_CUR:
75
76 ADIOI_Get_position(adio_fh, &curr_offset);
77 offset += curr_offset;
78
79
80 if (offset < 0) {
81 error_code = MPIO_Err_create_code(MPI_SUCCESS,
82 MPIR_ERR_RECOVERABLE, myname,
83 __LINE__, MPI_ERR_ARG,
84 "**ionegoffset", 0);
85 error_code = MPIO_Err_return_file(adio_fh, error_code);
86 goto fn_exit;
87 }
88
89
90 break;
91 case MPI_SEEK_END:
92
93
94 ADIOI_TEST_DEFERRED(adio_fh, "MPI_File_seek", &error_code);
95
96
97 ADIOI_Get_eof_offset(adio_fh, &eof_offset);
98 offset += eof_offset;
99
100
101 if (offset < 0) {
102 error_code = MPIO_Err_create_code(MPI_SUCCESS,
103 MPIR_ERR_RECOVERABLE, myname,
104 __LINE__, MPI_ERR_ARG,
105 "**ionegoffset", 0);
106 error_code = MPIO_Err_return_file(adio_fh, error_code);
107 goto fn_exit;
108 }
109
110
111 break;
112 default:
113
114 error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
115 myname, __LINE__, MPI_ERR_ARG,
116 "**iobadwhence", 0);
117 error_code = MPIO_Err_return_file(adio_fh, error_code);
118 goto fn_exit;
119
120 }
121
122 ADIO_SeekIndividual(adio_fh, offset, ADIO_SEEK_SET, &error_code);
123
124
125
126 if (error_code != MPI_SUCCESS)
127 error_code = MPIO_Err_return_file(adio_fh, error_code);
128
129
130 #ifdef MPI_hpux
131 HPMP_IO_END(fl_xmpi, adio_fh, MPI_DATATYPE_NULL, -1);
132 #endif
133
134 error_code = MPI_SUCCESS;
135
136 fn_exit:
137 ROMIO_THREAD_CS_EXIT();
138 return error_code;
139 }