Skip to content

Commit c6f371b

Browse files
Larhzuakpm00
authored andcommitted
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/[email protected] Signed-off-by: Lasse Collin <[email protected]> Tested-by: Michael Ellerman <[email protected]> (powerpc) Cc: Jonathan Corbet <[email protected]> Cc: Sam James <[email protected]> Cc: Albert Ou <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Emil Renner Berthing <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Herbert Xu <[email protected]> Cc: Joel Stanley <[email protected]> Cc: Jubin Zhong <[email protected]> Cc: Jules Maselbas <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Randy Dunlap <[email protected]> Cc: Rui Li <[email protected]> Cc: Simon Glass <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ab4ce98 commit c6f371b

File tree

9 files changed

+34
-59
lines changed

9 files changed

+34
-59
lines changed

Documentation/staging/xz.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,4 @@ xz_dec API
9595

9696
This is available with ``#include <linux/xz.h>``.
9797

98-
``XZ_EXTERN`` is a macro used in the preboot code. Ignore it when
99-
reading this documentation.
100-
10198
.. kernel-doc:: include/linux/xz.h

arch/powerpc/boot/xz_config.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,8 @@ static inline void put_unaligned_be32(u32 val, void *p)
5050
/* prevent the inclusion of the xz-preboot MM headers */
5151
#define DECOMPR_MM_H
5252
#define memmove memmove
53-
#define XZ_EXTERN static
5453

5554
/* xz.h needs to be included directly since we need enum xz_mode */
5655
#include "../../../include/linux/xz.h"
5756

58-
#undef XZ_EXTERN
59-
6057
#endif

include/linux/xz.h

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
# include <stdint.h>
1919
#endif
2020

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-
2621
/**
2722
* enum xz_mode - Operation mode
2823
*
@@ -190,7 +185,7 @@ struct xz_dec;
190185
* ready to be used with xz_dec_run(). If memory allocation fails,
191186
* xz_dec_init() returns NULL.
192187
*/
193-
XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max);
188+
struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max);
194189

195190
/**
196191
* xz_dec_run() - Run the XZ decoder
@@ -210,7 +205,7 @@ XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max);
210205
* get that amount valid data from the beginning of the stream. You must use
211206
* the multi-call decoder if you don't want to uncompress the whole stream.
212207
*/
213-
XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b);
208+
enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b);
214209

215210
/**
216211
* xz_dec_reset() - Reset an already allocated decoder state
@@ -223,14 +218,14 @@ XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b);
223218
* xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in
224219
* multi-call mode.
225220
*/
226-
XZ_EXTERN void xz_dec_reset(struct xz_dec *s);
221+
void xz_dec_reset(struct xz_dec *s);
227222

228223
/**
229224
* xz_dec_end() - Free the memory allocated for the decoder state
230225
* @s: Decoder state allocated using xz_dec_init(). If s is NULL,
231226
* this function does nothing.
232227
*/
233-
XZ_EXTERN void xz_dec_end(struct xz_dec *s);
228+
void xz_dec_end(struct xz_dec *s);
234229

235230
/**
236231
* DOC: MicroLZMA decompressor
@@ -244,10 +239,6 @@ XZ_EXTERN void xz_dec_end(struct xz_dec *s);
244239
* 3/0/2, the first byte is 0xA2. This way the first byte can never be 0x00.
245240
* Just like with LZMA2, lc + lp <= 4 must be true. The LZMA end-of-stream
246241
* marker must not be used. The unused values are reserved for future use.
247-
*
248-
* These functions aren't used or available in preboot code and thus aren't
249-
* marked with XZ_EXTERN. This avoids warnings about static functions that
250-
* are never defined.
251242
*/
252243

253244
/*
@@ -272,8 +263,8 @@ struct xz_dec_microlzma;
272263
* struct xz_dec_microlzma. If memory allocation fails or
273264
* dict_size is invalid, NULL is returned.
274265
*/
275-
extern struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode,
276-
uint32_t dict_size);
266+
struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode,
267+
uint32_t dict_size);
277268

278269
/**
279270
* xz_dec_microlzma_reset() - Reset the MicroLZMA decoder state
@@ -289,9 +280,8 @@ extern struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode,
289280
* requiring stdbool.h. This should normally be set to true.
290281
* When this is set to false, error detection is weaker.
291282
*/
292-
extern void xz_dec_microlzma_reset(struct xz_dec_microlzma *s,
293-
uint32_t comp_size, uint32_t uncomp_size,
294-
int uncomp_size_is_exact);
283+
void xz_dec_microlzma_reset(struct xz_dec_microlzma *s, uint32_t comp_size,
284+
uint32_t uncomp_size, int uncomp_size_is_exact);
295285

296286
/**
297287
* xz_dec_microlzma_run() - Run the MicroLZMA decoder
@@ -329,15 +319,14 @@ extern void xz_dec_microlzma_reset(struct xz_dec_microlzma *s,
329319
* may be changed normally like with XZ_PREALLOC. This way input data can be
330320
* provided from non-contiguous memory.
331321
*/
332-
extern enum xz_ret xz_dec_microlzma_run(struct xz_dec_microlzma *s,
333-
struct xz_buf *b);
322+
enum xz_ret xz_dec_microlzma_run(struct xz_dec_microlzma *s, struct xz_buf *b);
334323

335324
/**
336325
* xz_dec_microlzma_end() - Free the memory allocated for the decoder state
337326
* @s: Decoder state allocated using xz_dec_microlzma_alloc().
338327
* If s is NULL, this function does nothing.
339328
*/
340-
extern void xz_dec_microlzma_end(struct xz_dec_microlzma *s);
329+
void xz_dec_microlzma_end(struct xz_dec_microlzma *s);
341330

342331
/*
343332
* Standalone build (userspace build or in-kernel build for boot time use)
@@ -358,13 +347,13 @@ extern void xz_dec_microlzma_end(struct xz_dec_microlzma *s);
358347
* This must be called before any other xz_* function to initialize
359348
* the CRC32 lookup table.
360349
*/
361-
XZ_EXTERN void xz_crc32_init(void);
350+
void xz_crc32_init(void);
362351

363352
/*
364353
* Update CRC32 value using the polynomial from IEEE-802.3. To start a new
365354
* calculation, the third argument must be zero. To continue the calculation,
366355
* the previously returned value is passed as the third argument.
367356
*/
368-
XZ_EXTERN uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc);
357+
uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc);
369358
#endif
370359
#endif

lib/decompress_unxz.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
#ifdef __KERNEL__
108108
# include <linux/decompress/mm.h>
109109
#endif
110-
#define XZ_EXTERN STATIC
111110

112111
#ifndef XZ_PREBOOT
113112
# include <linux/slab.h>

lib/xz/xz_crc32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
STATIC_RW_DATA uint32_t xz_crc32_table[256];
2828

29-
XZ_EXTERN void xz_crc32_init(void)
29+
void xz_crc32_init(void)
3030
{
3131
const uint32_t poly = 0xEDB88320;
3232

@@ -45,7 +45,7 @@ XZ_EXTERN void xz_crc32_init(void)
4545
return;
4646
}
4747

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)
4949
{
5050
crc = ~crc;
5151

lib/xz/xz_dec_bcj.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,8 @@ static void bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b)
572572
* data in chunks of 1-16 bytes. To hide this issue, this function does
573573
* some buffering.
574574
*/
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)
578577
{
579578
size_t out_start;
580579

@@ -682,7 +681,7 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
682681
return s->ret;
683682
}
684683

685-
XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call)
684+
struct xz_dec_bcj *xz_dec_bcj_create(bool single_call)
686685
{
687686
struct xz_dec_bcj *s = kmalloc(sizeof(*s), GFP_KERNEL);
688687
if (s != NULL)
@@ -691,7 +690,7 @@ XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call)
691690
return s;
692691
}
693692

694-
XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id)
693+
enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id)
695694
{
696695
switch (id) {
697696
#ifdef XZ_DEC_X86

lib/xz/xz_dec_lzma2.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,7 @@ static bool lzma2_lzma(struct xz_dec_lzma2 *s, struct xz_buf *b)
960960
* Take care of the LZMA2 control layer, and forward the job of actual LZMA
961961
* decoding or copying of uncompressed chunks to other functions.
962962
*/
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)
965964
{
966965
uint32_t tmp;
967966

@@ -1137,8 +1136,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
11371136
return XZ_OK;
11381137
}
11391138

1140-
XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
1141-
uint32_t dict_max)
1139+
struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode, uint32_t dict_max)
11421140
{
11431141
struct xz_dec_lzma2 *s = kmalloc(sizeof(*s), GFP_KERNEL);
11441142
if (s == NULL)
@@ -1161,7 +1159,7 @@ XZ_EXTERN struct xz_dec_lzma2 *xz_dec_lzma2_create(enum xz_mode mode,
11611159
return s;
11621160
}
11631161

1164-
XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
1162+
enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
11651163
{
11661164
/* This limits dictionary size to 3 GiB to keep parsing simpler. */
11671165
if (props > 39)
@@ -1197,7 +1195,7 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
11971195
return XZ_OK;
11981196
}
11991197

1200-
XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s)
1198+
void xz_dec_lzma2_end(struct xz_dec_lzma2 *s)
12011199
{
12021200
if (DEC_IS_MULTI(s->dict.mode))
12031201
vfree(s->dict.buf);

lib/xz/xz_dec_stream.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
746746
* actually succeeds (that's the price to pay of using the output buffer as
747747
* the workspace).
748748
*/
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)
750750
{
751751
size_t in_start;
752752
size_t out_start;
@@ -782,7 +782,7 @@ XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b)
782782
return ret;
783783
}
784784

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)
786786
{
787787
struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL);
788788
if (s == NULL)
@@ -812,7 +812,7 @@ XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max)
812812
return NULL;
813813
}
814814

815-
XZ_EXTERN void xz_dec_reset(struct xz_dec *s)
815+
void xz_dec_reset(struct xz_dec *s)
816816
{
817817
s->sequence = SEQ_STREAM_HEADER;
818818
s->allow_buf_error = false;
@@ -824,7 +824,7 @@ XZ_EXTERN void xz_dec_reset(struct xz_dec *s)
824824
s->temp.size = STREAM_HEADER_SIZE;
825825
}
826826

827-
XZ_EXTERN void xz_dec_end(struct xz_dec *s)
827+
void xz_dec_end(struct xz_dec *s)
828828
{
829829
if (s != NULL) {
830830
xz_dec_lzma2_end(s->lzma2);

lib/xz/xz_private.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,48 +115,44 @@
115115
* Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
116116
* before calling xz_dec_lzma2_run().
117117
*/
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);
120119

121120
/*
122121
* Decode the LZMA2 properties (one byte) and reset the decoder. Return
123122
* XZ_OK on success, XZ_MEMLIMIT_ERROR if the preallocated dictionary is not
124123
* big enough, and XZ_OPTIONS_ERROR if props indicates something that this
125124
* decoder doesn't support.
126125
*/
127-
XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s,
128-
uint8_t props);
126+
enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props);
129127

130128
/* Decode raw LZMA2 stream from b->in to b->out. */
131-
XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s,
132-
struct xz_buf *b);
129+
enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, struct xz_buf *b);
133130

134131
/* Free the memory allocated for the LZMA2 decoder. */
135-
XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
132+
void xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
136133

137134
#ifdef XZ_DEC_BCJ
138135
/*
139136
* Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before
140137
* calling xz_dec_bcj_run().
141138
*/
142-
XZ_EXTERN struct xz_dec_bcj *xz_dec_bcj_create(bool single_call);
139+
struct xz_dec_bcj *xz_dec_bcj_create(bool single_call);
143140

144141
/*
145142
* Decode the Filter ID of a BCJ filter. This implementation doesn't
146143
* support custom start offsets, so no decoding of Filter Properties
147144
* is needed. Returns XZ_OK if the given Filter ID is supported.
148145
* Otherwise XZ_OPTIONS_ERROR is returned.
149146
*/
150-
XZ_EXTERN enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id);
147+
enum xz_ret xz_dec_bcj_reset(struct xz_dec_bcj *s, uint8_t id);
151148

152149
/*
153150
* Decode raw BCJ + LZMA2 stream. This must be used only if there actually is
154151
* a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run()
155152
* must be called directly.
156153
*/
157-
XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
158-
struct xz_dec_lzma2 *lzma2,
159-
struct xz_buf *b);
154+
enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s, struct xz_dec_lzma2 *lzma2,
155+
struct xz_buf *b);
160156

161157
/* Free the memory allocated for the BCJ filters. */
162158
#define xz_dec_bcj_end(s) kfree(s)

0 commit comments

Comments
 (0)