Update for 2016.11-rc3
[buildroot-gz.git] / package / util-linux / 0001-lib-crc32-prefix-public-functions.patch
blobfa68bd01e7557bf277c29672b3e7e68a65c37b4c
1 From b39b4cac29dcc5d060d8e30344f693462502066a Mon Sep 17 00:00:00 2001
2 From: Gustavo Zacarias <gustavo@zacarias.com.ar>
3 Date: Mon, 10 Oct 2016 17:42:42 -0300
4 Subject: [PATCH] lib/crc32: prefix public functions
6 Make the publicly-visible crc32 library functions prefixed by ul_, such
7 as crc32() -> ul_crc32().
8 This is because it clashes with the crc32() function from zlib.
9 For newer versions of glib (2.50+) zlib and libblkid are required
10 dependencies and otherwise results in build failure when building
11 statically.
13 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
14 ---
15 Status: submitted upstream
17 disk-utils/fsck.cramfs.c | 12 ++++++------
18 disk-utils/mkfs.cramfs.c | 6 +++---
19 include/crc32.h | 4 ++--
20 lib/crc32.c | 4 ++--
21 libblkid/src/partitions/gpt.c | 2 +-
22 libblkid/src/superblocks/nilfs.c | 6 +++---
23 libfdisk/src/gpt.c | 2 +-
24 7 files changed, 18 insertions(+), 18 deletions(-)
26 diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
27 index 12009f2..f34e79f 100644
28 --- a/disk-utils/fsck.cramfs.c
29 +++ b/disk-utils/fsck.cramfs.c
30 @@ -214,7 +214,7 @@ static void test_crc(int start)
31 return;
34 - crc = crc32(0L, Z_NULL, 0);
35 + crc = ul_crc32(0L, Z_NULL, 0);
37 buf =
38 mmap(NULL, super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
39 @@ -231,8 +231,8 @@ static void test_crc(int start)
41 if (buf != MAP_FAILED) {
42 ((struct cramfs_super *)((unsigned char *) buf + start))->fsid.crc =
43 - crc32(0L, Z_NULL, 0);
44 - crc = crc32(crc, (unsigned char *) buf + start, super.size - start);
45 + ul_crc32(0L, Z_NULL, 0);
46 + crc = ul_crc32(crc, (unsigned char *) buf + start, super.size - start);
47 munmap(buf, super.size);
48 } else {
49 int retval;
50 @@ -249,15 +249,15 @@ static void test_crc(int start)
51 break;
52 if (length == 0)
53 ((struct cramfs_super *)buf)->fsid.crc =
54 - crc32(0L, Z_NULL, 0);
55 + ul_crc32(0L, Z_NULL, 0);
56 length += retval;
57 if (length > (super.size - start)) {
58 - crc = crc32(crc, buf,
59 + crc = ul_crc32(crc, buf,
60 retval - (length -
61 (super.size - start)));
62 break;
64 - crc = crc32(crc, buf, retval);
65 + crc = ul_crc32(crc, buf, retval);
67 free(buf);
69 diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
70 index 4e6b3ab..55d6871 100644
71 --- a/disk-utils/mkfs.cramfs.c
72 +++ b/disk-utils/mkfs.cramfs.c
73 @@ -406,7 +406,7 @@ static unsigned int write_superblock(struct entry *root, char *base, int size)
74 super->size = size;
75 memcpy(super->signature, CRAMFS_SIGNATURE, sizeof(super->signature));
77 - super->fsid.crc = crc32(0L, Z_NULL, 0);
78 + super->fsid.crc = ul_crc32(0L, Z_NULL, 0);
79 super->fsid.edition = opt_edition;
80 super->fsid.blocks = total_blocks;
81 super->fsid.files = total_nodes;
82 @@ -700,7 +700,7 @@ int main(int argc, char **argv)
83 loff_t fslen_ub = sizeof(struct cramfs_super);
84 unsigned int fslen_max;
85 char const *dirname, *outfile;
86 - uint32_t crc = crc32(0L, Z_NULL, 0);
87 + uint32_t crc = ul_crc32(0L, Z_NULL, 0);
88 int c;
89 cramfs_is_big_endian = HOST_IS_BIG_ENDIAN; /* default is to use host order */
91 @@ -856,7 +856,7 @@ int main(int argc, char **argv)
92 sizeof(struct cramfs_super));
94 /* Put the checksum in. */
95 - crc = crc32(crc, (unsigned char *) (rom_image+opt_pad), (offset-opt_pad));
96 + crc = ul_crc32(crc, (unsigned char *) (rom_image+opt_pad), (offset-opt_pad));
97 ((struct cramfs_super *) (rom_image+opt_pad))->fsid.crc = u32_toggle_endianness(cramfs_is_big_endian, crc);
98 if (verbose)
99 printf(_("CRC: %x\n"), crc);
100 diff --git a/include/crc32.h b/include/crc32.h
101 index ff2dd99..2551f50 100644
102 --- a/include/crc32.h
103 +++ b/include/crc32.h
104 @@ -4,8 +4,8 @@
105 #include <sys/types.h>
106 #include <stdint.h>
108 -extern uint32_t crc32(uint32_t seed, const unsigned char *buf, size_t len);
109 -extern uint32_t crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
110 +extern uint32_t ul_crc32(uint32_t seed, const unsigned char *buf, size_t len);
111 +extern uint32_t ul_crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
112 size_t exclude_off, size_t exclude_len);
114 #endif
115 diff --git a/lib/crc32.c b/lib/crc32.c
116 index a5e3216..824693d 100644
117 --- a/lib/crc32.c
118 +++ b/lib/crc32.c
119 @@ -108,7 +108,7 @@ static inline uint32_t crc32_add_char(uint32_t crc, unsigned char c)
120 * and does __not__ xor at the end. Then individual users can do
121 * whatever they need.
123 -uint32_t crc32(uint32_t seed, const unsigned char *buf, size_t len)
124 +uint32_t ul_crc32(uint32_t seed, const unsigned char *buf, size_t len)
126 uint32_t crc = seed;
127 const unsigned char *p = buf;
128 @@ -121,7 +121,7 @@ uint32_t crc32(uint32_t seed, const unsigned char *buf, size_t len)
129 return crc;
132 -uint32_t crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
133 +uint32_t ul_crc32_exclude_offset(uint32_t seed, const unsigned char *buf, size_t len,
134 size_t exclude_off, size_t exclude_len)
136 uint32_t crc = seed;
137 diff --git a/libblkid/src/partitions/gpt.c b/libblkid/src/partitions/gpt.c
138 index dcc04e6..e6baa59 100644
139 --- a/libblkid/src/partitions/gpt.c
140 +++ b/libblkid/src/partitions/gpt.c
141 @@ -105,7 +105,7 @@ struct gpt_entry {
142 static inline uint32_t count_crc32(const unsigned char *buf, size_t len,
143 size_t exclude_off, size_t exclude_len)
145 - return (crc32_exclude_offset(~0L, buf, len, exclude_off, exclude_len) ^ ~0L);
146 + return (ul_crc32_exclude_offset(~0L, buf, len, exclude_off, exclude_len) ^ ~0L);
149 static inline unsigned char *get_lba_buffer(blkid_probe pr,
150 diff --git a/libblkid/src/superblocks/nilfs.c b/libblkid/src/superblocks/nilfs.c
151 index ee5c5f9..95538ef 100644
152 --- a/libblkid/src/superblocks/nilfs.c
153 +++ b/libblkid/src/superblocks/nilfs.c
154 @@ -89,9 +89,9 @@ static int nilfs_valid_sb(blkid_probe pr, struct nilfs_super_block *sb, int is_b
155 if (bytes < crc_start || bytes > sizeof(struct nilfs_super_block))
156 return 0;
158 - crc = crc32(le32_to_cpu(sb->s_crc_seed), (unsigned char *)sb, sumoff);
159 - crc = crc32(crc, sum, 4);
160 - crc = crc32(crc, (unsigned char *)sb + crc_start, bytes - crc_start);
161 + crc = ul_crc32(le32_to_cpu(sb->s_crc_seed), (unsigned char *)sb, sumoff);
162 + crc = ul_crc32(crc, sum, 4);
163 + crc = ul_crc32(crc, (unsigned char *)sb + crc_start, bytes - crc_start);
165 return blkid_probe_verify_csum(pr, crc, le32_to_cpu(sb->s_sum));
167 diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
168 index 8377192..208699b 100644
169 --- a/libfdisk/src/gpt.c
170 +++ b/libfdisk/src/gpt.c
171 @@ -850,7 +850,7 @@ fail:
172 static inline uint32_t count_crc32(const unsigned char *buf, size_t len,
173 size_t ex_off, size_t ex_len)
175 - return (crc32_exclude_offset(~0L, buf, len, ex_off, ex_len) ^ ~0L);
176 + return (ul_crc32_exclude_offset(~0L, buf, len, ex_off, ex_len) ^ ~0L);
179 static inline uint32_t gpt_header_count_crc32(struct gpt_header *header)
181 2.7.3