File: missing.h

package info (click to toggle)
kmod 26-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,784 kB
  • sloc: ansic: 15,682; xml: 1,879; makefile: 617; sh: 303; python: 7
file content (55 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once

#include <unistd.h>
#include <sys/syscall.h>

#ifdef HAVE_LINUX_MODULE_H
#include <linux/module.h>
#endif

#ifndef MODULE_INIT_IGNORE_MODVERSIONS
# define MODULE_INIT_IGNORE_MODVERSIONS 1
#endif

#ifndef MODULE_INIT_IGNORE_VERMAGIC
# define MODULE_INIT_IGNORE_VERMAGIC 2
#endif

#ifndef __NR_finit_module
# define __NR_finit_module -1
#endif

#ifndef HAVE_FINIT_MODULE
#include <errno.h>

static inline int finit_module(int fd, const char *uargs, int flags)
{
	if (__NR_finit_module == -1) {
		errno = ENOSYS;
		return -1;
	}

	return syscall(__NR_finit_module, fd, uargs, flags);
}
#endif

#if !HAVE_DECL_STRNDUPA
#define strndupa(s, n)							\
	({								\
		const char *__old = (s);				\
		size_t __len = strnlen(__old, (n));			\
		char *__new = alloca(__len + 1);			\
		__new[__len] = '\0';					\
		memcpy(__new, __old, __len);				\
	 })
#endif

#if !HAVE_DECL_BE32TOH
#include <endian.h>
#include <byteswap.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define be32toh(x) bswap_32 (x)
#else
#define be32toh(x) (x)
#endif
#endif