PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/linux-abi/tags/cvs-orig/linux-abi/linux/abi/sysv/sysconf.c

https://github.com/cpc26/abi_linux
C | 197 lines | 114 code | 41 blank | 42 comment | 6 complexity | bca68eb3ee8511fb098f7a2f51331b0e MD5 | raw file
  1. /*
  2. * linux/abi/svr4_common/sysconf.c
  3. *
  4. * Copyright (C) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
  5. *
  6. * $Id$
  7. * $Source$
  8. */
  9. #include <linux/config.h>
  10. #define __NO_VERSION__
  11. #include <linux/module.h>
  12. #include <linux/version.h>
  13. #include <asm/uaccess.h>
  14. #include <linux/errno.h>
  15. #include <linux/sched.h>
  16. #include <linux/kernel.h>
  17. #include <linux/mm.h>
  18. #include <linux/stddef.h>
  19. #include <linux/limits.h>
  20. #include <linux/unistd.h>
  21. #include <linux/ptrace.h>
  22. #include <linux/fcntl.h>
  23. #include <linux/smp.h>
  24. #include <linux/swap.h>
  25. #include <asm/system.h>
  26. #include <linux/fs.h>
  27. #include <linux/sys.h>
  28. #include <abi/abi.h>
  29. #include <abi/svr4.h>
  30. #ifdef CONFIG_ABI_TRACE
  31. #include <abi/trace.h>
  32. #endif
  33. /* The sysconf() call is supposed to give applications access to various
  34. * kernel parameters. According to SCO's man page this a POSIX mandated
  35. * function. Perhaps it should be moved across as a native Linux call?
  36. *
  37. * N.B. SCO only has sysconf in the Xenix group. Therefore this is based
  38. * on the Xenix spec. Is SVR4 the same? Wyse Unix V.3.2.1A doesn't have
  39. * sysconf documented at all.
  40. *
  41. * N.B. 0-7 are required (by who?). Other values may be defined for
  42. * various systems but there appears no guarantee that they match across
  43. * platforms. Thus, unless we can identify what system the executable
  44. * was compiled for, we probably prefer to have extensions fail. Hell,
  45. * nothing important is going to use this obscure stuff anyway...
  46. */
  47. #define _SC_ARG_MAX 0
  48. #define _SC_CHILD_MAX 1
  49. #define _SC_CLK_TCK 2
  50. #define _SC_NGROUPS_MAX 3
  51. #define _SC_OPEN_MAX 4
  52. #define _SC_JOB_CONTROL 5
  53. #define _SC_SAVED_IDS 6
  54. #define _SC_VERSION 7
  55. #define _SC_PAGESIZE 11
  56. #define _SCO_SC_PAGESIZE 34
  57. /* This is an SVR4 system call that is undocumented except for some
  58. * hints in a header file. It appears to be a forerunner to the
  59. * POSIX sysconf() call.
  60. */
  61. int svr4_sysconfig(int name)
  62. {
  63. switch (name) {
  64. case _CONFIG_NGROUPS:
  65. /* From limits.h */
  66. return (NGROUPS_MAX);
  67. case _CONFIG_CHILD_MAX:
  68. /* From limits.h */
  69. return (CHILD_MAX);
  70. case _CONFIG_OPEN_FILES:
  71. /* From limits.h */
  72. return (OPEN_MAX);
  73. case _CONFIG_POSIX_VER:
  74. /* The version of the POSIX standard we conform
  75. * to. SCO defines _POSIX_VERSION as 198808L
  76. * sys/unistd.h. What are we? We are 199009L.
  77. */
  78. return (199009L);
  79. case _CONFIG_PAGESIZE:
  80. return (PAGE_SIZE);
  81. case _CONFIG_CLK_TCK:
  82. return (HZ);
  83. case _CONFIG_XOPEN_VER:
  84. return 4;
  85. case _CONFIG_NACLS_MAX:
  86. return 0;
  87. case _CONFIG_NPROC:
  88. return 4000;
  89. case _CONFIG_NENGINE:
  90. case _CONFIG_NENGINE_ONLN:
  91. return (smp_num_cpus);
  92. case _CONFIG_TOTAL_MEMORY:
  93. return (max_mapnr << (PAGE_SHIFT-10));
  94. case _CONFIG_USEABLE_MEMORY:
  95. case _CONFIG_GENERAL_MEMORY:
  96. return ((unsigned long) (nr_free_pages()) << (PAGE_SHIFT-10));
  97. case _CONFIG_DEDICATED_MEMORY:
  98. return 0;
  99. case _CONFIG_NCGS_CONF:
  100. case _CONFIG_NCGS_ONLN:
  101. case _CONFIG_MAX_ENG_PER_CG:
  102. return 1; /* no NUMA-Q support on Linux yet */
  103. case _CONFIG_CACHE_LINE:
  104. return 32; /* XXX is there a more accurate way? */
  105. case _CONFIG_KERNEL_VM:
  106. return -EINVAL;
  107. case _CONFIG_ARG_MAX:
  108. /* From limits.h */
  109. return (ARG_MAX);
  110. }
  111. #ifdef CONFIG_ABI_TRACE
  112. if ((ibcs_trace & TRACE_API) || ibcs_func_p->trace) {
  113. printk(KERN_DEBUG "iBCS2 unsupported sysconfig call %d\n", name);
  114. }
  115. #endif
  116. return -EINVAL;
  117. }
  118. int ibcs_sysconf(int name)
  119. {
  120. switch (name) {
  121. case _SC_ARG_MAX:
  122. /* From limits.h */
  123. return (ARG_MAX);
  124. case _SC_CHILD_MAX:
  125. /* From limits.h */
  126. return (CHILD_MAX);
  127. case _SC_CLK_TCK:
  128. return (HZ);
  129. case _SC_NGROUPS_MAX:
  130. /* From limits.h */
  131. return (NGROUPS_MAX);
  132. case _SC_OPEN_MAX:
  133. /* From limits.h */
  134. return (OPEN_MAX);
  135. case _SC_JOB_CONTROL:
  136. return (1);
  137. case _SC_SAVED_IDS:
  138. return (1);
  139. case _SC_PAGESIZE:
  140. case _SCO_SC_PAGESIZE:
  141. return PAGE_SIZE;
  142. case _SC_VERSION:
  143. /* The version of the POSIX standard we conform
  144. * to. SCO defines _POSIX_VERSION as 198808L
  145. * sys/unistd.h. What are we?
  146. */
  147. return (198808L);
  148. }
  149. #ifdef CONFIG_ABI_TRACE
  150. if ((ibcs_trace & TRACE_API) || ibcs_func_p->trace) {
  151. printk(KERN_DEBUG "iBCS2 unsupported sysconf call %d\n", name);
  152. }
  153. #endif
  154. return -EINVAL;
  155. }
  156. EXPORT_SYMBOL(svr4_sysconfig);