2019-08-25 10:49:19 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2007-11-14 17:00:31 -08:00
|
|
|
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-16 15:20:36 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __USER_H__
|
|
|
|
|
#define __USER_H__
|
|
|
|
|
|
2011-08-18 20:01:49 +01:00
|
|
|
#include <generated/asm-offsets.h>
|
2007-11-14 17:00:31 -08:00
|
|
|
|
2007-05-06 14:51:09 -07:00
|
|
|
/*
|
|
|
|
|
* The usual definition - copied here because the kernel provides its own,
|
|
|
|
|
* fancier, type-safe, definition. Using that one would require
|
|
|
|
|
* copying too much infrastructure for my taste, so userspace files
|
|
|
|
|
* get less checking than kernel files.
|
|
|
|
|
*/
|
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
|
|
2022-07-17 10:53:46 +02:00
|
|
|
/* This is to get size_t and NULL */
|
2015-05-31 19:50:57 +02:00
|
|
|
#ifndef __UM_HOST__
|
2007-05-06 14:51:52 -07:00
|
|
|
#include <linux/types.h>
|
2007-10-16 01:26:47 -07:00
|
|
|
#else
|
|
|
|
|
#include <stddef.h>
|
2022-07-17 10:53:46 +02:00
|
|
|
#include <sys/types.h>
|
2007-10-16 01:26:47 -07:00
|
|
|
#endif
|
2007-05-06 14:51:52 -07:00
|
|
|
|
2006-04-10 22:53:31 -07:00
|
|
|
extern void panic(const char *fmt, ...)
|
|
|
|
|
__attribute__ ((format (printf, 1, 2)));
|
2007-11-14 17:00:31 -08:00
|
|
|
|
2012-08-16 20:15:05 +02:00
|
|
|
/* Requires preincluding include/linux/kern_levels.h */
|
|
|
|
|
#define UM_KERN_EMERG KERN_EMERG
|
|
|
|
|
#define UM_KERN_ALERT KERN_ALERT
|
|
|
|
|
#define UM_KERN_CRIT KERN_CRIT
|
|
|
|
|
#define UM_KERN_ERR KERN_ERR
|
|
|
|
|
#define UM_KERN_WARNING KERN_WARNING
|
|
|
|
|
#define UM_KERN_NOTICE KERN_NOTICE
|
|
|
|
|
#define UM_KERN_INFO KERN_INFO
|
|
|
|
|
#define UM_KERN_DEBUG KERN_DEBUG
|
|
|
|
|
#define UM_KERN_CONT KERN_CONT
|
|
|
|
|
|
2024-11-03 16:05:03 +01:00
|
|
|
#if IS_ENABLED(CONFIG_PRINTK)
|
2021-06-15 17:52:53 +01:00
|
|
|
#define printk(...) _printk(__VA_ARGS__)
|
|
|
|
|
extern int _printk(const char *fmt, ...)
|
2006-04-10 22:53:31 -07:00
|
|
|
__attribute__ ((format (printf, 1, 2)));
|
2024-07-03 15:45:28 +02:00
|
|
|
extern void print_hex_dump(const char *level, const char *prefix_str,
|
|
|
|
|
int prefix_type, int rowsize, int groupsize,
|
|
|
|
|
const void *buf, size_t len, _Bool ascii);
|
2007-11-14 17:00:31 -08:00
|
|
|
#else
|
|
|
|
|
static inline int printk(const char *fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2024-07-03 15:45:28 +02:00
|
|
|
static inline void print_hex_dump(const char *level, const char *prefix_str,
|
|
|
|
|
int prefix_type, int rowsize, int groupsize,
|
|
|
|
|
const void *buf, size_t len, _Bool ascii)
|
|
|
|
|
{
|
|
|
|
|
}
|
2007-11-14 17:00:31 -08:00
|
|
|
#endif
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
extern int in_aton(char *str);
|
2007-05-06 14:51:52 -07:00
|
|
|
extern size_t strlcat(char *, const char *, size_t);
|
2023-09-20 12:38:14 -07:00
|
|
|
extern size_t sized_strscpy(char *, const char *, size_t);
|
2024-02-02 03:55:00 -08:00
|
|
|
#define strscpy(dst, src) sized_strscpy(dst, src, sizeof(dst))
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2011-08-18 20:04:59 +01:00
|
|
|
/* Copied from linux/compiler-gcc.h since we can't include it directly */
|
|
|
|
|
#define barrier() __asm__ __volatile__("": : :"memory")
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
#endif
|