mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	Move pg_crc.c to src/common, and remove pg_crc_tables.h
To get CRC functionality in a client program, you now need to link with libpgcommon instead of libpgport. The CRC code has nothing to do with portability, so libpgcommon is a better home. (libpgcommon didn't exist when pg_crc.c was originally moved to src/port.) Remove the possibility to get CRC functionality by just #including pg_crc_tables.h. I'm not aware of any extensions that actually did that and couldn't simply link with libpgcommon. This also moves the pg_crc.h header file from src/include/utils to src/include/common, which will require changes to any external programs that currently does #include "utils/pg_crc.h". That seems acceptable, as include/common is clearly the right home for it now, and the change needed to any such programs is trivial.
This commit is contained in:
		
							parent
							
								
									40bede5477
								
							
						
					
					
						commit
						c619c2351f
					
				| @ -6,7 +6,7 @@ | |||||||
| #include "access/gist.h" | #include "access/gist.h" | ||||||
| #include "access/skey.h" | #include "access/skey.h" | ||||||
| #include "catalog/pg_type.h" | #include "catalog/pg_type.h" | ||||||
| #include "utils/pg_crc.h" | #include "common/pg_crc.h" | ||||||
| 
 | 
 | ||||||
| #include "hstore.h" | #include "hstore.h" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ | |||||||
| #define TOLOWER(x)	(x) | #define TOLOWER(x)	(x) | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #include "utils/pg_crc.h" | #include "common/pg_crc.h" | ||||||
| #include "crc32.h" | #include "crc32.h" | ||||||
| 
 | 
 | ||||||
| unsigned int | unsigned int | ||||||
|  | |||||||
| @ -14,6 +14,7 @@ | |||||||
| 
 | 
 | ||||||
| #include "postgres.h" | #include "postgres.h" | ||||||
| 
 | 
 | ||||||
|  | #include "common/pg_crc.h" | ||||||
| #include "libpq/pqformat.h" | #include "libpq/pqformat.h" | ||||||
| #include "miscadmin.h" | #include "miscadmin.h" | ||||||
| #include "tsearch/ts_locale.h" | #include "tsearch/ts_locale.h" | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ include $(top_builddir)/src/Makefile.global | |||||||
| override CPPFLAGS := -DFRONTEND $(CPPFLAGS) | override CPPFLAGS := -DFRONTEND $(CPPFLAGS) | ||||||
| LIBS += $(PTHREAD_LIBS) | LIBS += $(PTHREAD_LIBS) | ||||||
| 
 | 
 | ||||||
| OBJS_COMMON = exec.o pg_lzcompress.o pgfnames.o psprintf.o relpath.o \
 | OBJS_COMMON = exec.o pg_crc.o pg_lzcompress.o pgfnames.o psprintf.o relpath.o \
 | ||||||
| 	rmtree.o string.o username.o wait_error.o | 	rmtree.o string.o username.o wait_error.o | ||||||
| 
 | 
 | ||||||
| OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o | OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o | ||||||
|  | |||||||
| @ -1,32 +1,28 @@ | |||||||
| /*-------------------------------------------------------------------------
 | /*-------------------------------------------------------------------------
 | ||||||
|  * |  * | ||||||
|  * pg_crc_tables.h |  * pg_crc.c | ||||||
|  *	  Polynomial lookup tables for CRC macros |  *	  PostgreSQL CRC support | ||||||
|  * |  | ||||||
|  * 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 |  * See Ross Williams' excellent introduction | ||||||
|  * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from |  * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from | ||||||
|  * http://www.ross.net/crc/download/crc_v3.txt or several other net sites.
 |  * http://www.ross.net/crc/download/crc_v3.txt or several other net sites.
 | ||||||
|  * |  * | ||||||
|  * These lookup tables are for normal, not "reflected", in Williams' terms, |  | ||||||
|  * CRC. |  | ||||||
|  * |  | ||||||
|  * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group |  * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group | ||||||
|  * Portions Copyright (c) 1994, Regents of the University of California |  * Portions Copyright (c) 1994, Regents of the University of California | ||||||
|  * |  * | ||||||
|  * src/include/utils/pg_crc_tables.h |  * | ||||||
|  |  * IDENTIFICATION | ||||||
|  |  *	  src/common/pg_crc.c | ||||||
|  * |  * | ||||||
|  *------------------------------------------------------------------------- |  *------------------------------------------------------------------------- | ||||||
|  */ |  */ | ||||||
| #ifndef PG_CRC_TABLES_H | 
 | ||||||
| #define PG_CRC_TABLES_H | #include "c.h" | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * This table is based on the so-called Castagnoli polynomial (the same |  * This table is based on the so-called Castagnoli polynomial (the same | ||||||
|  * that is used e.g. in iSCSI). |  * that is used e.g. in iSCSI).  It is for normal, not "reflected", in | ||||||
|  |  * Williams' terms, CRC. | ||||||
|  */ |  */ | ||||||
| const uint32 pg_crc32c_table[256] = { | const uint32 pg_crc32c_table[256] = { | ||||||
| 	0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, | 	0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4, | ||||||
| @ -100,6 +96,7 @@ const uint32 pg_crc32c_table[256] = { | |||||||
|  * This table is based on the polynomial |  * This table is based on the polynomial | ||||||
|  *	x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. |  *	x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. | ||||||
|  * (This is the same polynomial used in Ethernet checksums, for instance.) |  * (This is the same polynomial used in Ethernet checksums, for instance.) | ||||||
|  |  * It is for normal, not "reflected", in Williams' terms, CRC. | ||||||
|  */ |  */ | ||||||
| const uint32 pg_crc32_table[256] = { | const uint32 pg_crc32_table[256] = { | ||||||
| 	0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, | 	0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, | ||||||
| @ -167,5 +164,3 @@ const uint32 pg_crc32_table[256] = { | |||||||
| 	0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, | 	0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, | ||||||
| 	0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D | 	0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| #endif   /* PG_CRC_TABLES_H */ |  | ||||||
| @ -13,9 +13,9 @@ | |||||||
| 
 | 
 | ||||||
| #include "access/rmgr.h" | #include "access/rmgr.h" | ||||||
| #include "access/xlogdefs.h" | #include "access/xlogdefs.h" | ||||||
|  | #include "common/pg_crc.h" | ||||||
| #include "storage/block.h" | #include "storage/block.h" | ||||||
| #include "storage/relfilenode.h" | #include "storage/relfilenode.h" | ||||||
| #include "utils/pg_crc.h" |  | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  * The overall layout of an XLOG record is: |  * The overall layout of an XLOG record is: | ||||||
|  | |||||||
| @ -16,8 +16,8 @@ | |||||||
| #define PG_CONTROL_H | #define PG_CONTROL_H | ||||||
| 
 | 
 | ||||||
| #include "access/xlogdefs.h" | #include "access/xlogdefs.h" | ||||||
|  | #include "common/pg_crc.h" | ||||||
| #include "pgtime.h"				/* for pg_time_t */ | #include "pgtime.h"				/* for pg_time_t */ | ||||||
| #include "utils/pg_crc.h" |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /* Version identifier for this pg_control format */ | /* Version identifier for this pg_control format */ | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ | |||||||
|  * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group |  * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group | ||||||
|  * Portions Copyright (c) 1994, Regents of the University of California |  * Portions Copyright (c) 1994, Regents of the University of California | ||||||
|  * |  * | ||||||
|  * src/include/utils/pg_crc.h |  * src/include/common/pg_crc.h | ||||||
|  */ |  */ | ||||||
| #ifndef PG_CRC_H | #ifndef PG_CRC_H | ||||||
| #define PG_CRC_H | #define PG_CRC_H | ||||||
| @ -14,7 +14,6 @@ | |||||||
| 
 | 
 | ||||||
| #include "fmgr.h" | #include "fmgr.h" | ||||||
| #include "utils/memutils.h" | #include "utils/memutils.h" | ||||||
| #include "utils/pg_crc.h" |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  | |||||||
| @ -31,7 +31,7 @@ override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS) | |||||||
| LIBS += $(PTHREAD_LIBS) | LIBS += $(PTHREAD_LIBS) | ||||||
| 
 | 
 | ||||||
| OBJS = $(LIBOBJS) chklocale.o dirmod.o erand48.o fls.o inet_net_ntop.o \
 | OBJS = $(LIBOBJS) chklocale.o dirmod.o erand48.o fls.o inet_net_ntop.o \
 | ||||||
| 	noblock.o path.o pgcheckdir.o pg_crc.o pgmkdirp.o pgsleep.o \
 | 	noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o \
 | ||||||
| 	pgstrcasecmp.o pqsignal.o \
 | 	pgstrcasecmp.o pqsignal.o \
 | ||||||
| 	qsort.o qsort_arg.o quotes.o sprompt.o tar.o thread.o | 	qsort.o qsort_arg.o quotes.o sprompt.o tar.o thread.o | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,21 +0,0 @@ | |||||||
| /*-------------------------------------------------------------------------
 |  | ||||||
|  * |  | ||||||
|  * 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-2015, 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" |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user