Skip to content

Commit

Permalink
isystem: ship and use stdarg.h
Browse files Browse the repository at this point in the history
Ship minimal stdarg.h (1 type, 4 macros) as <linux/stdarg.h>.
stdarg.h is the only userspace header commonly used in the kernel.

GPL 2 version of <stdarg.h> can be extracted from
http://archive.debian.org/debian/pool/main/g/gcc-4.2/gcc-4.2_4.2.4.orig.tar.gz

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Alexey Dobriyan authored and masahir0y committed Aug 19, 2021
1 parent 39f75da commit c0891ac
Show file tree
Hide file tree
Showing 31 changed files with 41 additions and 31 deletions.
2 changes: 1 addition & 1 deletion arch/parisc/kernel/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* prumpf 991016
*/

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/delay.h>
#include <linux/init.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/prom_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* we cannot use FORTIFY as it brings in new symbols */
#define __NO_FORTIFY

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/init.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/rtas.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Copyright (C) 2001 IBM.
*/

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/spinlock.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/udbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* c 2001 PPC 64 Team, IBM Corp
*/

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/console.h>
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/boot/pgm_check_info.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/stdarg.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <asm/stacktrace.h>
Expand All @@ -8,7 +9,6 @@
#include <asm/setup.h>
#include <asm/sclp.h>
#include <asm/uv.h>
#include <stdarg.h>
#include "boot.h"

const char hex_asc[] = "0123456789abcdef";
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/boot/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#ifndef __ASSEMBLY__

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/types.h>
#include <linux/edd.h>
#include <asm/setup.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/efi/libstub/efi-stub-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Copyright 2011 Intel Corporation; author Matt Fleming
*/

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/ctype.h>
#include <linux/efi.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/firmware/efi/libstub/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Oh, it's a waste of space, but oh-so-yummy for debugging.
*/

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/compiler.h>
#include <linux/ctype.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/display/dc/dc_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
*/

#include <linux/delay.h>
#include <linux/stdarg.h>

#include "dm_services.h"
#include <stdarg.h>

#include "dc.h"
#include "dc_dmub_srv.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/drm_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#define DEBUG /* for pr_debug() */

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/io.h>
#include <linux/moduleparam.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/isdn/capi/capiutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ static char *pnames[] =
/*2f */ "Useruserdata"
};

#include <stdarg.h>
#include <linux/stdarg.h>

/*-------------------------------------------------------*/
static _cdebbuf *bufprint(_cdebbuf *cdb, char *fmt, ...)
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/via-cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Copyright (C) 1996 Paul Mackerras.
*/
#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/kernel.h>
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/via-pmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* a sleep or a freq. switch
*
*/
#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/mutex.h>
#include <linux/types.h>
#include <linux/errno.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef __PRINT_SUPPORT_H_INCLUDED__
#define __PRINT_SUPPORT_H_INCLUDED__

#include <stdarg.h>
#include <linux/stdarg.h>

extern int (*sh_css_printf)(const char *fmt, va_list args);
/* depends on host supplied print function in ia_css_init() */
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/media/atomisp/pci/ia_css_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#define __IA_CSS_ENV_H

#include <type_support.h>
#include <stdarg.h> /* va_list */
#include <linux/stdarg.h> /* va_list */
#include "ia_css_types.h"
#include "ia_css_acc_types.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/*! \file */

#include <type_support.h>
#include <stdarg.h>
#include <linux/stdarg.h>
#include "ia_css_types.h"
#include "ia_css_binary.h"
#include "ia_css_frame_public.h"
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/media/atomisp/pci/sh_css_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <math_support.h>
#include <type_support.h>
#include <platform_support.h>
#include <stdarg.h>
#include <linux/stdarg.h>

#if !defined(ISP2401)
#include "input_formatter.h"
Expand Down
2 changes: 1 addition & 1 deletion fs/befs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#ifdef __KERNEL__

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/string.h>
#include <linux/spinlock.h>
#include <linux/kernel.h>
Expand Down
2 changes: 1 addition & 1 deletion fs/reiserfs/prints.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <linux/string.h>
#include <linux/buffer_head.h>

#include <stdarg.h>
#include <linux/stdarg.h>

static char error_buf[1024];
static char fmt_buf[1024];
Expand Down
2 changes: 1 addition & 1 deletion fs/ufs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#include <linux/module.h>
#include <linux/bitops.h>

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/uaccess.h>

Expand Down
2 changes: 1 addition & 1 deletion include/acpi/platform/acgcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef __builtin_va_list va_list;
#define va_arg(v, l) __builtin_va_arg(v, l)
#define va_copy(d, s) __builtin_va_copy(d, s)
#else
#include <stdarg.h>
#include <linux/stdarg.h>
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef _LINUX_KERNEL_H
#define _LINUX_KERNEL_H

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/align.h>
#include <linux/limits.h>
#include <linux/linkage.h>
Expand Down
2 changes: 1 addition & 1 deletion include/linux/printk.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef __KERNEL_PRINTK__
#define __KERNEL_PRINTK__

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/init.h>
#include <linux/kern_levels.h>
#include <linux/linkage.h>
Expand Down
11 changes: 11 additions & 0 deletions include/linux/stdarg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef _LINUX_STDARG_H
#define _LINUX_STDARG_H

typedef __builtin_va_list va_list;
#define va_start(v, l) __builtin_va_start(v, l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v, T) __builtin_va_arg(v, T)
#define va_copy(d, s) __builtin_va_copy(d, s)

#endif
2 changes: 1 addition & 1 deletion include/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <linux/types.h> /* for size_t */
#include <linux/stddef.h> /* for NULL */
#include <linux/errno.h> /* for E2BIG */
#include <stdarg.h>
#include <linux/stdarg.h>
#include <uapi/linux/string.h>

extern char *strndup_user(const char __user *, long);
Expand Down
3 changes: 1 addition & 2 deletions lib/debug_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* CONFIG_DEBUG_INFO_REDUCED. Please do not add actual code. However,
* adding appropriate #includes is fine.
*/
#include <stdarg.h>

#include <linux/cred.h>
#include <linux/crypto.h>
#include <linux/dcache.h>
Expand All @@ -22,6 +20,7 @@
#include <linux/net.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/stdarg.h>
#include <linux/types.h>
#include <net/addrconf.h>
#include <net/sock.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/kasprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 1991, 1992 Linus Torvalds
*/

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/export.h>
#include <linux/slab.h>
#include <linux/types.h>
Expand Down
2 changes: 1 addition & 1 deletion lib/kunit/string-stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <linux/spinlock.h>
#include <linux/types.h>
#include <stdarg.h>
#include <linux/stdarg.h>

struct string_stream_fragment {
struct kunit *test;
Expand Down
2 changes: 1 addition & 1 deletion lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* - scnprintf and vscnprintf
*/

#include <stdarg.h>
#include <linux/stdarg.h>
#include <linux/build_bug.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
Expand Down
2 changes: 1 addition & 1 deletion mm/kfence/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2020, Google LLC.
*/

#include <stdarg.h>
#include <linux/stdarg.h>

#include <linux/kernel.h>
#include <linux/lockdep.h>
Expand Down
2 changes: 1 addition & 1 deletion net/batman-adv/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "log.h"
#include "main.h"

#include <stdarg.h>
#include <linux/stdarg.h>

#include "trace.h"

Expand Down

0 comments on commit c0891ac

Please sign in to comment.