diff --git a/src/backend/utils/hash/Makefile b/src/backend/utils/hash/Makefile index 64eebd1d996c42ede260726021303b7c029901ac..05d347c85630176a7414f336ba6cb3d72cba4e4d 100644 --- a/src/backend/utils/hash/Makefile +++ b/src/backend/utils/hash/Makefile @@ -12,6 +12,6 @@ subdir = src/backend/utils/hash top_builddir = ../../../.. include $(top_builddir)/src/Makefile.global -OBJS = dynahash.o hashfn.o pg_crc.o +OBJS = dynahash.o hashfn.o include $(top_srcdir)/src/backend/common.mk diff --git a/src/bin/pg_controldata/.gitignore b/src/bin/pg_controldata/.gitignore index 32ea40181f5b404b2d48dd4a52c19026b5d8ccac..eab0c28a8bb3f3c5524da4be86c53163a44d819f 100644 --- a/src/bin/pg_controldata/.gitignore +++ b/src/bin/pg_controldata/.gitignore @@ -1,3 +1 @@ -/pg_crc.c - /pg_controldata diff --git a/src/bin/pg_controldata/Makefile b/src/bin/pg_controldata/Makefile index 0eff84666da0ba91b8b4e24dc2640336d894c64a..b8a39dc1cdba8214b55a91e25a0aefe5c33658d4 100644 --- a/src/bin/pg_controldata/Makefile +++ b/src/bin/pg_controldata/Makefile @@ -15,16 +15,13 @@ subdir = src/bin/pg_controldata top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -OBJS= pg_controldata.o pg_crc.o $(WIN32RES) +OBJS= pg_controldata.o $(WIN32RES) all: pg_controldata pg_controldata: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) -pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c - rm -f $@ && $(LN_S) $< . - install: all installdirs $(INSTALL_PROGRAM) pg_controldata$(X) '$(DESTDIR)$(bindir)/pg_controldata$(X)' @@ -35,4 +32,4 @@ uninstall: rm -f '$(DESTDIR)$(bindir)/pg_controldata$(X)' clean distclean maintainer-clean: - rm -f pg_controldata$(X) $(OBJS) pg_crc.c + rm -f pg_controldata$(X) $(OBJS) diff --git a/src/bin/pg_resetxlog/.gitignore b/src/bin/pg_resetxlog/.gitignore index 584590951fc6f84bd9f7a88a6892cc441c227dd2..6b84208ee0c22dd61210d9e43b3ff52eb1a227ed 100644 --- a/src/bin/pg_resetxlog/.gitignore +++ b/src/bin/pg_resetxlog/.gitignore @@ -1,3 +1 @@ -/pg_crc.c - /pg_resetxlog diff --git a/src/bin/pg_resetxlog/Makefile b/src/bin/pg_resetxlog/Makefile index eb03b8a0b91988fc03c0ad80294ec4db131e734f..0e2603558699eb8ee41dbe66c2496f110f199af0 100644 --- a/src/bin/pg_resetxlog/Makefile +++ b/src/bin/pg_resetxlog/Makefile @@ -15,16 +15,13 @@ subdir = src/bin/pg_resetxlog top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -OBJS= pg_resetxlog.o pg_crc.o $(WIN32RES) +OBJS= pg_resetxlog.o $(WIN32RES) all: pg_resetxlog pg_resetxlog: $(OBJS) | submake-libpgport $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) -pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c - rm -f $@ && $(LN_S) $< . - install: all installdirs $(INSTALL_PROGRAM) pg_resetxlog$(X) '$(DESTDIR)$(bindir)/pg_resetxlog$(X)' @@ -35,4 +32,4 @@ uninstall: rm -f '$(DESTDIR)$(bindir)/pg_resetxlog$(X)' clean distclean maintainer-clean: - rm -f pg_resetxlog$(X) $(OBJS) pg_crc.c + rm -f pg_resetxlog$(X) $(OBJS) diff --git a/src/backend/utils/hash/pg_crc.c b/src/include/utils/pg_crc_tables.h similarity index 98% rename from src/backend/utils/hash/pg_crc.c rename to src/include/utils/pg_crc_tables.h index 596184b59af8582405ee85bed8384c2c13d82ab2..524410fffdfb64fe1ca89211ce8fe2f037acee00 100644 --- a/src/backend/utils/hash/pg_crc.c +++ b/src/include/utils/pg_crc_tables.h @@ -1,7 +1,11 @@ /*------------------------------------------------------------------------- * - * pg_crc.c - * PostgreSQL CRC support + * pg_crc_tables.h + * Polynomial lookup tables for CRC macros + * + * We make these tables available as a .h file so that programs not linked + * with libpgport can still use the macros in pg_crc.h. They just need + * to #include this header as well. * * See Ross Williams' excellent introduction * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from @@ -17,16 +21,12 @@ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * - * IDENTIFICATION - * src/backend/utils/hash/pg_crc.c + * src/include/utils/pg_crc_tables.h * *------------------------------------------------------------------------- */ - -/* Use c.h so that this file can be built in either frontend or backend */ -#include "c.h" - +#ifndef PG_CRC_TABLES_H +#define PG_CRC_TABLES_H /* * This table is based on the polynomial @@ -513,3 +513,5 @@ const uint64 pg_crc64_table[256] = { #endif /* SIZEOF_VOID_P < 8 */ #endif /* PROVIDE_64BIT_CRC */ + +#endif /* PG_CRC_TABLES_H */ diff --git a/src/port/Makefile b/src/port/Makefile index 1bf0963ba7888c6ce92fd0d58a72a4015f60cb33..4e3a8edd3a151253a6cc65509d98f4b620277bee 100644 --- a/src/port/Makefile +++ b/src/port/Makefile @@ -31,8 +31,8 @@ override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS) LIBS += $(PTHREAD_LIBS) OBJS = $(LIBOBJS) chklocale.o dirmod.o erand48.o exec.o fls.o inet_net_ntop.o \ - noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o pgstrcasecmp.o \ - qsort.o qsort_arg.o sprompt.o thread.o + noblock.o path.o pgcheckdir.o pg_crc.o pgmkdirp.o pgsleep.o \ + pgstrcasecmp.o qsort.o qsort_arg.o sprompt.o thread.o # foo_srv.o and foo.o are both built from foo.c, but only foo.o has -DFRONTEND OBJS_SRV = $(OBJS:%.o=%_srv.o) diff --git a/src/port/pg_crc.c b/src/port/pg_crc.c new file mode 100644 index 0000000000000000000000000000000000000000..ebf4f3a61a75883ea0312a9d0e50559fd47ec21f --- /dev/null +++ b/src/port/pg_crc.c @@ -0,0 +1,21 @@ +/*------------------------------------------------------------------------- + * + * pg_crc.c + * PostgreSQL CRC support + * + * This file simply #includes the CRC table definitions so that they are + * available to programs linked with libpgport. + * + * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * + * IDENTIFICATION + * src/port/pg_crc.c + * + *------------------------------------------------------------------------- + */ + +#include "c.h" + +#include "utils/pg_crc_tables.h" diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm index 9db664a190e33d33b372eb3fa5a8874ae5ed724d..98db076e58c78333d36ca72ad6a471243ee13a06 100644 --- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -261,8 +261,8 @@ sub AddDir $mf =~ s{OBJS[^=]*=\s*(.*)$}{}m; } - # Match rules that pull in source files from different directories - # example: pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c + # Match rules that pull in source files from different directories, eg + # pgstrcasecmp.c rint.c snprintf.c: % : $(top_srcdir)/src/port/% my $replace_re = qr{^([^:\n\$]+\.c)\s*:\s*(?:%\s*: )?\$(\([^\)]+\))\/(.*)\/[^\/]+$}m; while ($mf =~ m{$replace_re}m) {