44 */
55
66#include "../../include/pg_config.h"
7+ #include "../../include/pg_config_os.h"
78
89#include <sys/types.h>
910#include <sys/stat.h>
1415#include <sys/time.h>
1516#include <unistd.h>
1617
18+ #ifdef WIN32
19+ #define FSYNC_FILENAME "./test_fsync.out"
20+ #else
1721#define FSYNC_FILENAME "/var/tmp/test_fsync.out"
22+ #endif
1823
1924/* O_SYNC and O_FSYNC are the same */
2025#if defined(O_SYNC )
2126#define OPEN_SYNC_FLAG O_SYNC
2227#elif defined(O_FSYNC )
2328#define OPEN_SYNC_FLAG O_FSYNC
29+ #elif defined(O_DSYNC )
30+ #define OPEN_DATASYNC_FLAG O_DSYNC
2431#endif
2532
2633#if defined(OPEN_SYNC_FLAG )
@@ -122,6 +129,7 @@ main(int argc, char *argv[])
122129
123130 printf ("\nCompare one o_sync write to two:\n" );
124131
132+ #ifdef OPEN_SYNC_FLAG
125133 /* 16k o_sync write */
126134 if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG )) == -1 )
127135 die ("Cannot open output file." );
@@ -150,6 +158,10 @@ main(int argc, char *argv[])
150158 printf ("\n" );
151159
152160 printf ("\nCompare file sync methods with one 8k write:\n" );
161+ #else
162+ printf ("\t(o_sync unavailable) " );
163+ #endif
164+ printf ("\n" );
153165
154166#ifdef OPEN_DATASYNC_FLAG
155167 /* open_dsync, write */
@@ -162,11 +174,8 @@ main(int argc, char *argv[])
162174 close (tmpfile );
163175 printf ("\topen o_dsync, write " );
164176 print_elapse (start_t , elapse_t );
165- #else
166- printf ("\t(o_dsync unavailable) " );
167- #endif
168177 printf ("\n" );
169-
178+ #ifdef OPEN_SYNC_FLAG
170179 /* open_fsync, write */
171180 if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG )) == -1 )
172181 die ("Cannot open output file." );
@@ -177,6 +186,10 @@ main(int argc, char *argv[])
177186 close (tmpfile );
178187 printf ("\topen o_sync, write " );
179188 print_elapse (start_t , elapse_t );
189+ #endif
190+ #else
191+ printf ("\t(o_dsync unavailable) " );
192+ #endif
180193 printf ("\n" );
181194
182195#ifdef HAVE_FDATASYNC
@@ -234,6 +247,7 @@ main(int argc, char *argv[])
234247#endif
235248 printf ("\n" );
236249
250+ #ifdef OPEN_SYNC_FLAG
237251 /* open_fsync, write */
238252 if ((tmpfile = open (filename , O_RDWR | OPEN_SYNC_FLAG )) == -1 )
239253 die ("Cannot open output file." );
@@ -248,6 +262,7 @@ main(int argc, char *argv[])
248262 printf ("\topen o_sync, write " );
249263 print_elapse (start_t , elapse_t );
250264 printf ("\n" );
265+ #endif
251266
252267#ifdef HAVE_FDATASYNC
253268 /* write, fdatasync */
0 commit comments