xref: /haiku/src/system/libroot/os/arch/x86/compatibility.c (revision be3db2942c0e8dda63cdd226ec3c99309d3eab0c)
1 /*
2  * Copyright 2005-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 // TODO: temporary measurement to fix the build with GCC 4 - in the end, these
7 //	private syscalls shouldn't be used anywhere in the Haiku tree, at the very
8 //	least they should only be used when compiling for GCC 2.95.3, though.
9 #if __GNUC__ < 30
10 
11 // This file includes some known R5 syscalls
12 // ToDo: maybe they should indeed do something...
13 
14 #include <SupportDefs.h>
15 #include <fs_info.h>
16 
17 #include <syscalls.h>
18 
19 #include <errno.h>
20 #include <sys/resource.h>
21 #include <sys/stat.h>
22 
23 
24 int _kset_mon_limit_(int num);
25 int _kset_fd_limit_(int num);
26 int _klock_node_(int fd);
27 int _kget_cpu_state_(int cpuNum);
28 int _kset_cpu_state_(int cpuNum, int state);
29 int _kstatfs_(dev_t device, void *whatever, int fd, const char *path, fs_info *info);
30 
31 
32 int
33 _kset_mon_limit_(int num)
34 {
35 	struct rlimit rl;
36 	if (num < 1)
37 		return EINVAL;
38 	rl.rlim_cur = num;
39 	if (setrlimit(RLIMIT_NOVMON, &rl) < 0)
40 		return errno;
41 	return B_OK;
42 }
43 
44 
45 int
46 _kset_fd_limit_(int num)
47 {
48 	struct rlimit rl;
49 	if (num < 1)
50 		return EINVAL;
51 	rl.rlim_cur = num;
52 	if (setrlimit(RLIMIT_NOFILE, &rl) < 0)
53 		return errno;
54 	return B_OK;
55 }
56 
57 
58 int
59 _klock_node_(int fd)
60 {
61 	return B_ERROR;
62 }
63 
64 
65 int
66 _kget_cpu_state_(int cpuNum)
67 {
68 	return _kern_cpu_enabled(cpuNum);
69 }
70 
71 
72 int
73 _kset_cpu_state_(int cpuNum, int state)
74 {
75 	return _kern_set_cpu_enabled(cpuNum, state != 0);
76 }
77 
78 
79 int
80 _kstatfs_(dev_t device, void *whatever, int fd, const char *path, fs_info *info)
81 {
82 	if (device < 0) {
83 		if (fd >= 0) {
84 			struct stat stat;
85 			if (fstat(fd, &stat) < 0)
86 				return -1;
87 
88 			device = stat.st_dev;
89 		} else if (path != NULL)
90 			device = dev_for_path(path);
91 	}
92 	if (device < 0)
93 		return B_ERROR;
94 
95 	return fs_stat_dev(device, info);
96 }
97 
98 
99 #endif	// __GNUC__ < 3
100