mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	Fix test_fsync compile on MinGW(win32)
Hiroshi Saito
This commit is contained in:
		| @@ -1,22 +1,25 @@ | |||||||
|  | #------------------------------------------------------------------------- | ||||||
| # | # | ||||||
| # Makefile | # Makefile for src/tools/fsync | ||||||
| # | # | ||||||
|  | # Copyright (c) 2003-2006, PostgreSQL Global Development Group | ||||||
| # | # | ||||||
| TARGET = test_fsync | # $PostgreSQL: pgsql/src/tools/fsync/Makefile,v 1.3 2006/10/13 14:19:29 momjian Exp $ | ||||||
| XFLAGS =  | # | ||||||
| CFLAGS = -O | #------------------------------------------------------------------------- | ||||||
| LIBS =  |  | ||||||
|  |  | ||||||
| $(TARGET) : test_fsync.o | subdir = src/tools/fsync | ||||||
| 	$(CC) -o $(TARGET) $(XFLAGS) $(CFLAGS) test_fsync.o $(LIBS) | top_builddir = ../../.. | ||||||
|  | include $(top_builddir)/src/Makefile.global | ||||||
|  |  | ||||||
| test_fsync.o	: test_fsync.c  | override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) $(CPPFLAGS) | ||||||
| 	$(CC) -c $(XFLAGS) $(CFLAGS) test_fsync.c |  | ||||||
|  |  | ||||||
| clean: | OBJS= test_fsync.o | ||||||
| 	rm -f *.o $(TARGET) log core |  | ||||||
|  |  | ||||||
| install: | all: submake-libpq submake-libpgport test_fsync | ||||||
| 	make clean |  | ||||||
| 	make CFLAGS=-O | test_fsync: test_fsync.o $(libpq_builddir)/libpq.a | ||||||
| 	install -s -o bin -g bin $(TARGET) /usr/local/bin | 	$(CC) $(CFLAGS) test_fsync.o $(libpq_pgport) $(LDFLAGS) $(LIBS) -o $@$(X) | ||||||
|  |  | ||||||
|  | clean distclean maintainer-clean: | ||||||
|  | 	rm -f test_fsync$(X) $(OBJS) | ||||||
|   | |||||||
| @@ -4,6 +4,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "../../include/pg_config.h" | #include "../../include/pg_config.h" | ||||||
|  | #include "../../include/pg_config_os.h" | ||||||
|  |  | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| @@ -14,13 +15,19 @@ | |||||||
| #include <sys/time.h> | #include <sys/time.h> | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  |  | ||||||
|  | #ifdef WIN32 | ||||||
|  | #define FSYNC_FILENAME	"./test_fsync.out" | ||||||
|  | #else | ||||||
| #define FSYNC_FILENAME	"/var/tmp/test_fsync.out" | #define FSYNC_FILENAME	"/var/tmp/test_fsync.out" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* O_SYNC and O_FSYNC are the same */ | /* O_SYNC and O_FSYNC are the same */ | ||||||
| #if defined(O_SYNC) | #if defined(O_SYNC) | ||||||
| #define OPEN_SYNC_FLAG		O_SYNC | #define OPEN_SYNC_FLAG		O_SYNC | ||||||
| #elif defined(O_FSYNC) | #elif defined(O_FSYNC) | ||||||
| #define OPEN_SYNC_FLAG		O_FSYNC | #define OPEN_SYNC_FLAG		O_FSYNC | ||||||
|  | #elif defined(O_DSYNC) | ||||||
|  | #define OPEN_DATASYNC_FLAG	O_DSYNC | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(OPEN_SYNC_FLAG) | #if defined(OPEN_SYNC_FLAG) | ||||||
| @@ -122,6 +129,7 @@ main(int argc, char *argv[]) | |||||||
|  |  | ||||||
| 	printf("\nCompare one o_sync write to two:\n"); | 	printf("\nCompare one o_sync write to two:\n"); | ||||||
|  |  | ||||||
|  | #ifdef OPEN_SYNC_FLAG | ||||||
| 	/* 16k o_sync write */ | 	/* 16k o_sync write */ | ||||||
| 	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1) | 	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1) | ||||||
| 		die("Cannot open output file."); | 		die("Cannot open output file."); | ||||||
| @@ -150,6 +158,10 @@ main(int argc, char *argv[]) | |||||||
| 	printf("\n"); | 	printf("\n"); | ||||||
|  |  | ||||||
| 	printf("\nCompare file sync methods with one 8k write:\n"); | 	printf("\nCompare file sync methods with one 8k write:\n"); | ||||||
|  | #else | ||||||
|  | 	printf("\t(o_sync unavailable)  "); | ||||||
|  | #endif | ||||||
|  | 	printf("\n"); | ||||||
|  |  | ||||||
| #ifdef OPEN_DATASYNC_FLAG | #ifdef OPEN_DATASYNC_FLAG | ||||||
| 	/* open_dsync, write */ | 	/* open_dsync, write */ | ||||||
| @@ -162,11 +174,8 @@ main(int argc, char *argv[]) | |||||||
| 	close(tmpfile); | 	close(tmpfile); | ||||||
| 	printf("\topen o_dsync, write    "); | 	printf("\topen o_dsync, write    "); | ||||||
| 	print_elapse(start_t, elapse_t); | 	print_elapse(start_t, elapse_t); | ||||||
| #else |  | ||||||
| 	printf("\t(o_dsync unavailable)  "); |  | ||||||
| #endif |  | ||||||
| 	printf("\n"); | 	printf("\n"); | ||||||
|  | #ifdef OPEN_SYNC_FLAG | ||||||
| 	/* open_fsync, write */ | 	/* open_fsync, write */ | ||||||
| 	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1) | 	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1) | ||||||
| 		die("Cannot open output file."); | 		die("Cannot open output file."); | ||||||
| @@ -177,6 +186,10 @@ main(int argc, char *argv[]) | |||||||
| 	close(tmpfile); | 	close(tmpfile); | ||||||
| 	printf("\topen o_sync, write     "); | 	printf("\topen o_sync, write     "); | ||||||
| 	print_elapse(start_t, elapse_t); | 	print_elapse(start_t, elapse_t); | ||||||
|  | #endif | ||||||
|  | #else | ||||||
|  | 	printf("\t(o_dsync unavailable)  "); | ||||||
|  | #endif | ||||||
| 	printf("\n"); | 	printf("\n"); | ||||||
|  |  | ||||||
| #ifdef HAVE_FDATASYNC | #ifdef HAVE_FDATASYNC | ||||||
| @@ -234,6 +247,7 @@ main(int argc, char *argv[]) | |||||||
| #endif | #endif | ||||||
| 	printf("\n"); | 	printf("\n"); | ||||||
|  |  | ||||||
|  | #ifdef OPEN_SYNC_FLAG | ||||||
| 	/* open_fsync, write */ | 	/* open_fsync, write */ | ||||||
| 	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1) | 	if ((tmpfile = open(filename, O_RDWR | OPEN_SYNC_FLAG)) == -1) | ||||||
| 		die("Cannot open output file."); | 		die("Cannot open output file."); | ||||||
| @@ -248,6 +262,7 @@ main(int argc, char *argv[]) | |||||||
| 	printf("\topen o_sync, write     "); | 	printf("\topen o_sync, write     "); | ||||||
| 	print_elapse(start_t, elapse_t); | 	print_elapse(start_t, elapse_t); | ||||||
| 	printf("\n"); | 	printf("\n"); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef HAVE_FDATASYNC | #ifdef HAVE_FDATASYNC | ||||||
| 	/* write, fdatasync */ | 	/* write, fdatasync */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user