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
123130printf ("\nCompare one o_sync write to two:\n" );
124131
132+ #ifdef OPEN_SYNC_FLAG
125133/* 16k o_sync write */
126134if ((tmpfile = open (filename ,O_RDWR |OPEN_SYNC_FLAG ))== -1 )
127135die ("Cannot open output file." );
@@ -150,6 +158,10 @@ main(int argc, char *argv[])
150158printf ("\n" );
151159
152160printf ("\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[])
162174close (tmpfile );
163175printf ("\topen o_dsync, write " );
164176print_elapse (start_t ,elapse_t );
165- #else
166- printf ("\t(o_dsync unavailable) " );
167- #endif
168177printf ("\n" );
169-
178+ #ifdef OPEN_SYNC_FLAG
170179/* open_fsync, write */
171180if ((tmpfile = open (filename ,O_RDWR |OPEN_SYNC_FLAG ))== -1 )
172181die ("Cannot open output file." );
@@ -177,6 +186,10 @@ main(int argc, char *argv[])
177186close (tmpfile );
178187printf ("\topen o_sync, write " );
179188print_elapse (start_t ,elapse_t );
189+ #endif
190+ #else
191+ printf ("\t(o_dsync unavailable) " );
192+ #endif
180193printf ("\n" );
181194
182195#ifdef HAVE_FDATASYNC
@@ -234,6 +247,7 @@ main(int argc, char *argv[])
234247#endif
235248printf ("\n" );
236249
250+ #ifdef OPEN_SYNC_FLAG
237251/* open_fsync, write */
238252if ((tmpfile = open (filename ,O_RDWR |OPEN_SYNC_FLAG ))== -1 )
239253die ("Cannot open output file." );
@@ -248,6 +262,7 @@ main(int argc, char *argv[])
248262printf ("\topen o_sync, write " );
249263print_elapse (start_t ,elapse_t );
250264printf ("\n" );
265+ #endif
251266
252267#ifdef HAVE_FDATASYNC
253268/* write, fdatasync */