8000 Move pg_crc.c to src/common, and remove pg_crc_tables.h · postgrespro/postgres@c619c23 · GitHub
[go: up one dir, main page]

Skip to content
  • Commit c619c23

    Browse files
    committed
    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.
    1 parent 40bede5 commit c619c23

    File tree

    11 files changed

    +18
    -44
    lines changed

    11 files changed

    +18
    -44
    lines changed

    contrib/hstore/hstore_gist.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -6,7 +6,7 @@
    66
    #include "access/gist.h"
    77
    #include "access/skey.h"
    88
    #include "catalog/pg_type.h"
    9-
    #include "utils/pg_crc.h"
    9+
    #include "common/pg_crc.h"
    1010

    1111
    #include "hstore.h"
    1212

    contrib/ltree/crc32.c

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -20,7 +20,7 @@
    2020
    #define TOLOWER(x) (x)
    2121
    #endif
    2222

    23-
    #include "utils/pg_crc.h"
    23+
    #include "common/pg_crc.h"
    2424
    #include "crc32.h"
    2525

    2626
    unsigned int

    src/backend/utils/adt/tsquery.c

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -14,6 +14,7 @@
    1414

    1515
    #include "postgres.h"
    1616

    17+
    #include "common/pg_crc.h"
    1718
    #include "libpq/pqformat.h"
    1819
    #include "miscadmin.h"
    1920
    #include "tsearch/ts_locale.h"

    src/common/Makefile

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -23,7 +23,7 @@ include $(top_builddir)/src/Makefile.global
    2323
    override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
    2424
    LIBS += $(PTHREAD_LIBS)
    2525

    26-
    OBJS_COMMON = exec.o pg_lzcompress.o pgfnames.o psprintf.o relpath.o \
    26+
    OBJS_COMMON = exec.o pg_crc.o pg_lzcompress.o pgfnames.o psprintf.o relpath.o \
    2727
    rmtree.o string.o username.o wait_error.o
    2828

    2929
    OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o

    src/include/utils/pg_crc_tables.h renamed to src/common/pg_crc.c

    Lines changed: 10 additions & 15 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,32 +1,28 @@
    11
    /*-------------------------------------------------------------------------
    22
    *
    3-
    * pg_crc_tables.h
    4-
    * Polynomial lookup tables for CRC macros
    5-
    *
    6-
    * We make these tables available as a .h file so that programs not linked
    7-
    * with libpgport can still use the macros in pg_crc.h. They just need
    8-
    * to #include this header as well.
    3+
    * pg_crc.c
    4+
    * PostgreSQL CRC support
    95
    *
    106
    * See Ross Williams' excellent introduction
    117
    * A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS, available from
    128
    * http://www.ross.net/crc/download/crc_v3.txt or several other net sites.
    139
    *
    14-
    * These lookup tables are for normal, not "reflected", in Williams' terms,
    15-
    * CRC.
    16-
    *
    1710
    * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
    1811
    * Portions Copyright (c) 1994, Regents of the University of California
    1912
    *
    20-
    * src/include/utils/pg_crc_tables.h
    13+
    *
    14+
    * IDENTIFICATION
    15+
    * src/common/pg_crc.c
    2116
    *
    2217
    *-------------------------------------------------------------------------
    2318
    */
    24-
    #ifndef PG_CRC_TABLES_H
    25-
    #define PG_CRC_TABLES_H
    19+
    20+
    #include "c.h"
    2621

    2722
    /*
    2823
    * This table is based on the so-called Castagnoli polynomial (the same
    29-
    * that is used e.g. in iSCSI).
    24+
    * that is used e.g. in iSCSI). It is for normal, not "reflected", in
    25+
    * Williams' terms, CRC.
    3026
    */
    3127
    const uint32 pg_crc32c_table[256] = {
    3228
    0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
    @@ -100,6 +96,7 @@ const uint32 pg_crc32c_table[256] = {
    10096
    * This table is based on the polynomial
    10197
    * 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.
    10298
    * (This is the same polynomial used in Ethernet checksums, for instance.)
    99+
    * It is for normal, not "reflected", in Williams' terms, CRC.
    103100
    */
    104101
    const uint32 pg_crc32_table[256] = {
    105102
    0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
    @@ -167,5 +164,3 @@ const uint32 pg_crc32_table[256] = {
    167164
    0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
    168165
    0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
    169166
    };
    170-
    171-
    #endif /* PG_CRC_TABLES_H */

    src/include/access/xlogrecord.h

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -13,9 +13,9 @@
    1313

    1414
    #include "access/rmgr.h"
    1515
    #include "access/xlogdefs.h"
    16+
    #include "common/pg_crc.h"
    1617
    #include "storage/block.h"
    1718
    #include "storage/relfilenode.h"
    18-
    #include "utils/pg_crc.h"
    1919

    2020
    /*
    2121
    * The overall layout of an XLOG record is:

    src/include/catalog/pg_control.h

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -16,8 +16,8 @@
    1616
    #define PG_CONTROL_H
    1717

    1818
    #include "access/xlogdefs.h"
    19+
    #include "common/pg_crc.h"
    1920
    #include "pgtime.h" /* for pg_time_t */
    20-
    #include "utils/pg_crc.h"
    2121

    2222

    2323
    /* Version identifier for this pg_control format */

    src/include/utils/pg_crc.h renamed to src/include/common/pg_crc.h

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -27,7 +27,7 @@
    2727
    * Portions Copyright (c) 1996-2015, PostgreSQL Global Development Group
    2828
    * Portions Copyright (c) 1994, Regents of the University of California
    2929
    *
    30-
    * src/include/utils/pg_crc.h
    30+
    * src/include/common/pg_crc.h
    3131
    */
    3232
    #ifndef PG_CRC_H
    3333
    #define PG_CRC_H

    src/include/tsearch/ts_type.h

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -14,7 +14,6 @@
    1414

    1515
    #include "fmgr.h"
    1616
    #include "utils/memutils.h"
    17-
    #include "utils/pg_crc.h"
    1817

    1918

    2019
    /*

    src/port/Makefile

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -31,7 +31,7 @@ override CPPFLAGS := -I$(top_builddir)/src/port -DFRONTEND $(CPPFLAGS)
    3131
    LIBS += $(PTHREAD_LIBS)
    3232

    3333
    OBJS = $(LIBOBJS) chklocale.o dirmod.o erand48.o fls.o inet_net_ntop.o \
    34-
    noblock.o path.o pgcheckdir.o pg_crc.o pgmkdirp.o pgsleep.o \
    34+
    noblock.o path.o pgcheckdir.o pgmkdirp.o pgsleep.o \
    3535
    pgstrcasecmp.o pqsignal.o \
    3636
    qsort.o qsort_arg.o quotes.o sprompt.o tar.o thread.o
    3737

    0 commit comments

    Comments
     (0)
    0