Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xz: remove XZ_EXTERN and extern from functions

XZ_EXTERN was used to make internal functions static in the preboot code.
However, in other decompressors this hasn't been done. On x86-64, this
makes no difference to the kernel image size.

Omit XZ_EXTERN and let some of the internal functions be extern in the
preboot code. Omitting XZ_EXTERN from include/linux/xz.h fixes warnings
in "make htmldocs" and makes the intradocument links to xz_dec functions
work in Documentation/staging/xz.rst. The alternative would have been to
add "XZ_EXTERN" to c_id_attributes in Documentation/conf.py but omitting
XZ_EXTERN seemed cleaner.

Link: https://lore.kernel.org/lkml/20240723205437.3c0664b0@kaneli/
Link: https://lkml.kernel.org/r/20240724110544.16430-1-lasse.collin@tukaani.org
Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Tested-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Sam James <sam@gentoo.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Joel Stanley <joel@jms.id.au>
Cc: Jubin Zhong <zhongjubin@huawei.com>
Cc: Jules Maselbas <jmaselbas@zdiv.net>
Cc: Krzysztof Kozlowski <krzk@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Rui Li <me@lirui.org>
Cc: Simon Glass <sjg@chromium.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lasse Collin and committed by
Andrew Morton
c6f371ba ab4ce983

+34 -59
-3
Documentation/staging/xz.rst
··· 95 95 96 96 This is available with ``#include <linux/xz.h>``. 97 97 98 - ``XZ_EXTERN`` is a macro used in the preboot code. Ignore it when 99 - reading this documentation. 100 - 101 98 .. kernel-doc:: include/linux/xz.h
-3
arch/powerpc/boot/xz_config.h
··· 50 50 /* prevent the inclusion of the xz-preboot MM headers */ 51 51 #define DECOMPR_MM_H 52 52 #define memmove memmove 53 - #define XZ_EXTERN static 54 53 55 54 /* xz.h needs to be included directly since we need enum xz_mode */ 56 55 #include "../../../include/linux/xz.h" 57 - 58 - #undef XZ_EXTERN 59 56 60 57 #endif
+12 -23
include/linux/xz.h
··· 18 18 # include <stdint.h> 19 19 #endif 20 20 21 - /* In Linux, this is used to make extern functions static when needed. */ 22 - #ifndef XZ_EXTERN 23 - # define XZ_EXTERN extern 24 - #endif 25 - 26 21 /** 27 22 * enum xz_mode - Operation mode 28 23 * ··· 185 190 * ready to be used with xz_dec_run(). If memory allocation fails, 186 191 * xz_dec_init() returns NULL. 187 192 */ 188 - XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max); 193 + struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max); 189 194 190 195 /** 191 196 * xz_dec_run() - Run the XZ decoder ··· 205 210 * get that amount valid data from the beginning of the stream. You must use 206 211 * the multi-call decoder if you don't want to uncompress the whole stream. 207 212 */ 208 - XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b); 213 + enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b); 209 214 210 215 /** 211 216 * xz_dec_reset() - Reset an already allocated decoder state ··· 218 223 * xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in 219 224 * multi-call mode. 220 225 */ 221 - XZ_EXTERN void xz_dec_reset(struct xz_dec *s); 226 + void xz_dec_reset(struct xz_dec *s); 222 227 223 228 /** 224 229 * xz_dec_end() - Free the memory allocated for the decoder state 225 230 * @s: Decoder state allocated using xz_dec_init(). If s is NULL, 226 231 * this function does nothing. 227 232 */ 228 - XZ_EXTERN void xz_dec_end(struct xz_dec *s); 233 + void xz_dec_end(struct xz_dec *s); 229 234 230 235 /** 231 236 * DOC: MicroLZMA decompressor ··· 239 244 * 3/0/2, the first byte is 0xA2. This way the first byte can never be 0x00. 240 245 * Just like with LZMA2, lc + lp <= 4 must be true. The LZMA end-of-stream 241 246 * marker must not be used. The unused values are reserved for future use. 242 - * 243 - * These functions aren't used or available in preboot code and thus aren't 244 - * marked with XZ_EXTERN. This avoids warnings about static functions that 245 - * are never defined. 246 247 */ 247 248 248 249 /* ··· 263 272 * struct xz_dec_microlzma. If memory allocation fails or 264 273 * dict_size is invalid, NULL is returned. 265 274 */ 266 - extern struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode, 267 - uint32_t dict_size); 275 + struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode, 276 + uint32_t dict_size); 268 277 269 278 /** 270 279 * xz_dec_microlzma_reset() - Reset the MicroLZMA decoder state ··· 280 289 * requiring stdbool.h. This should normally be set to true. 281 290 * When this is set to false, error detection is weaker. 282 291 */ 283 - extern void xz_dec_microlzma_reset(struct xz_dec_microlzma *s, 284 - uint32_t comp_size, uint32_t uncomp_size, 285 - int uncomp_size_is_exact); 292 + void xz_dec_microlzma_reset(struct xz_dec_microlzma *s, uint32_t comp_size, 293 + uint32_t uncomp_size, int uncomp_size_is_exact); 286 294 287 295 /** 288 296 * xz_dec_microlzma_run() - Run the MicroLZMA decoder ··· 319 329 * may be changed normally like with XZ_PREALLOC. This way input data can be 320 330 * provided from non-contiguous memory. 321 331 */ 322 - extern enum xz_ret xz_dec_microlzma_run(struct xz_dec_microlzma *s, 323 - struct xz_buf *b); 332 + enum xz_ret xz_dec_microlzma_run(struct xz_dec_microlzma *s, struct xz_buf *b); 324 333 325 334 /** 326 335 * xz_dec_microlzma_end() - Free the memory allocated for the decoder state 327 336 * @s: Decoder state allocated using xz_dec_microlzma_alloc(). 328 337 * If s is NULL, this function does nothing. 329 338 */ 330 - extern void xz_dec_microlzma_end(struct xz_dec_microlzma *s); 339 + void xz_dec_microlzma_end(struct xz_dec_microlzma *s); 331 340 332 341 /* 333 342 * Standalone build (userspace build or in-kernel build for boot time use) ··· 347 358 * This must be called before any other xz_* function to initialize 348 359 * the CRC32 lookup table. 349 360 */ 350 - XZ_EXTERN void xz_crc32_init(void); 361 + void xz_crc32_init(void); 351 362 352 363 /* 353 364 * Update CRC32 value using the polynomial from IEEE-802.3. To start a new 354 365 * calculation, the third argument must be zero. To continue the calculation, 355 366 * the previously returned value is passed as the third argument. 356 367 */ 357 - XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); 368 + uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc); 358 369 #endif 359 370 #endif
-1
lib/decompress_unxz.c
··· 107 107 #ifdef __KERNEL__ 108 108 # include <linux/decompress/mm.h> 109 109 #endif 110 - #define XZ_EXTERN STATIC 111 110 112 111 #ifndef XZ_PREBOOT 113 112 # include <linux/slab.h>
+2 -2
lib/xz/xz_crc32.c
··· 26 26 27 27 STATIC_RW_DATA uint32_t xz_crc32_table[256]; 28 28 29 - XZ_EXTERN void xz_crc32_init(void) 29 + void xz_crc32_init(void) 30 30 { 31 31 const uint32_t poly = 0xEDB88320; 32 32 ··· 45 45 return; 46 46 } 47 47 48 - XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) 48 + uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc) 49 49 { 50 50 crc = ~crc; 51 51
+4 -5
lib/xz/xz_dec_bcj.c
··· 572 572 * data in chunks of 1-16 bytes. To hide this issue, this function does 573 573 * some buffering. 574 574 */ 575 - XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, 576 - struct xz_dec_lzma2 *lzma2, 577 - struct xz_buf *b) 575 + enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2, 576 + struct xz_buf *b) 578 577 { 579 578 size_t out_start; 580 579 ··· 681 682 return s->ret; 682 683 } 683 684 684 - XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call) 685 + struct xz_dec_bcj *xz_dec_bcj_create(bool single_call) 685 686 { 686 687 struct xz_dec_bcj *s = kmalloc(sizeof(*s), GFP_KERNEL); 687 688 if (s != NULL) ··· 690 691 return s; 691 692 } 692 693 693 - XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id) 694 + enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id) 694 695 { 695 696 switch (id) { 696 697 #ifdef XZ_DEC_X86
+4 -6
lib/xz/xz_dec_lzma2.c
··· 960 960 * Take care of the LZMA2 control layer, and forward the job of actual LZMA 961 961 * decoding or copying of uncompressed chunks to other functions. 962 962 */ 963 - XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, 964 - struct xz_buf *b) 963 + enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b) 965 964 { 966 965 uint32_t tmp; 967 966 ··· 1136 1137 return XZ_OK; 1137 1138 } 1138 1139 1139 - XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, 1140 - uint32_t dict_max) 1140 + struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max) 1141 1141 { 1142 1142 struct xz_dec_lzma2 *s = kmalloc(sizeof(*s), GFP_KERNEL); 1143 1143 if (s == NULL) ··· 1159 1161 return s; 1160 1162 } 1161 1163 1162 - XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) 1164 + enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props) 1163 1165 { 1164 1166 /* This limits dictionary size to 3 GiB to keep parsing simpler. */ 1165 1167 if (props > 39) ··· 1195 1197 return XZ_OK; 1196 1198 } 1197 1199 1198 - XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s) 1200 + void xz_dec_lzma2_end(struct xz_dec_lzma2 *s) 1199 1201 { 1200 1202 if (DEC_IS_MULTI(s->dict.mode)) 1201 1203 vfree(s->dict.buf);
+4 -4
lib/xz/xz_dec_stream.c
··· 746 746 * actually succeeds (that's the price to pay of using the output buffer as 747 747 * the workspace). 748 748 */ 749 - XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b) 749 + enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b) 750 750 { 751 751 size_t in_start; 752 752 size_t out_start; ··· 782 782 return ret; 783 783 } 784 784 785 - XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max) 785 + struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max) 786 786 { 787 787 struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL); 788 788 if (s == NULL) ··· 812 812 return NULL; 813 813 } 814 814 815 - XZ_EXTERN void xz_dec_reset(struct xz_dec *s) 815 + void xz_dec_reset(struct xz_dec *s) 816 816 { 817 817 s->sequence = SEQ_STREAM_HEADER; 818 818 s->allow_buf_error = false; ··· 824 824 s->temp.size = STREAM_HEADER_SIZE; 825 825 } 826 826 827 - XZ_EXTERN void xz_dec_end(struct xz_dec *s) 827 + void xz_dec_end(struct xz_dec *s) 828 828 { 829 829 if (s != NULL) { 830 830 xz_dec_lzma2_end(s->lzma2);
+8 -12
lib/xz/xz_private.h
··· 115 115 * Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used 116 116 * before calling xz_dec_lzma2_run(). 117 117 */ 118 - XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, 119 - uint32_t dict_max); 118 + struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max); 120 119 121 120 /* 122 121 * Decode the LZMA2 properties (one byte) and reset the decoder. Return ··· 123 124 * big enough, and XZ_OPTIONS_ERROR if props indicates something that this 124 125 * decoder doesn't support. 125 126 */ 126 - XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, 127 - uint8_t props); 127 + enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props); 128 128 129 129 /* Decode raw LZMA2 stream from b->in to b->out. */ 130 - XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, 131 - struct xz_buf *b); 130 + enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b); 132 131 133 132 /* Free the memory allocated for the LZMA2 decoder. */ 134 - XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s); 133 + void xz_dec_lzma2_end(struct xz_dec_lzma2 *s); 135 134 136 135 #ifdef XZ_DEC_BCJ 137 136 /* 138 137 * Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before 139 138 * calling xz_dec_bcj_run(). 140 139 */ 141 - XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call); 140 + struct xz_dec_bcj *xz_dec_bcj_create(bool single_call); 142 141 143 142 /* 144 143 * Decode the Filter ID of a BCJ filter. This implementation doesn't ··· 144 147 * is needed. Returns XZ_OK if the given Filter ID is supported. 145 148 * Otherwise XZ_OPTIONS_ERROR is returned. 146 149 */ 147 - XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id); 150 + enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id); 148 151 149 152 /* 150 153 * Decode raw BCJ + LZMA2 stream. This must be used only if there actually is 151 154 * a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run() 152 155 * must be called directly. 153 156 */ 154 - XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, 155 - struct xz_dec_lzma2 *lzma2, 156 - struct xz_buf *b); 157 + enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2, 158 + struct xz_buf *b); 157 159 158 160 /* Free the memory allocated for the BCJ filters. */ 159 161 #define xz_dec_bcj_end(s) kfree(s)