user.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  4. */
  5. #ifndef __USER_H__
  6. #define __USER_H__
  7. #include <generated/asm-offsets.h>
  8. /*
  9. * The usual definition - copied here because the kernel provides its own,
  10. * fancier, type-safe, definition. Using that one would require
  11. * copying too much infrastructure for my taste, so userspace files
  12. * get less checking than kernel files.
  13. */
  14. #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  15. /* This is to get size_t and NULL */
  16. #ifndef __UM_HOST__
  17. #include <linux/types.h>
  18. #else
  19. #include <stddef.h>
  20. #include <sys/types.h>
  21. #endif
  22. extern void panic(const char *fmt, ...)
  23. __attribute__ ((format (printf, 1, 2)));
  24. /* Requires preincluding include/linux/kern_levels.h */
  25. #define UM_KERN_EMERG KERN_EMERG
  26. #define UM_KERN_ALERT KERN_ALERT
  27. #define UM_KERN_CRIT KERN_CRIT
  28. #define UM_KERN_ERR KERN_ERR
  29. #define UM_KERN_WARNING KERN_WARNING
  30. #define UM_KERN_NOTICE KERN_NOTICE
  31. #define UM_KERN_INFO KERN_INFO
  32. #define UM_KERN_DEBUG KERN_DEBUG
  33. #define UM_KERN_CONT KERN_CONT
  34. #ifdef UML_CONFIG_PRINTK
  35. #define printk(...) _printk(__VA_ARGS__)
  36. extern int _printk(const char *fmt, ...)
  37. __attribute__ ((format (printf, 1, 2)));
  38. #else
  39. static inline int printk(const char *fmt, ...)
  40. {
  41. return 0;
  42. }
  43. #endif
  44. extern int in_aton(char *str);
  45. extern size_t strlcpy(char *, const char *, size_t);
  46. extern size_t strlcat(char *, const char *, size_t);
  47. /* Copied from linux/compiler-gcc.h since we can't include it directly */
  48. #define barrier() __asm__ __volatile__("": : :"memory")
  49. #endif