[rtems commit] sysconf: Simplify
Sebastian Huber
sebh at rtems.org
Mon Mar 9 14:25:59 UTC 2015
Module: rtems
Branch: master
Commit: 8552df6514e2c28ac3d1fdbc377e4f55fa8bb32e
Changeset: http://git.rtems.org/rtems/commit/?id=8552df6514e2c28ac3d1fdbc377e4f55fa8bb32e
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Mar 9 15:23:12 2015 +0100
sysconf: Simplify
---
cpukit/posix/src/sysconf.c | 39 +++++++++++++++++----------------------
1 file changed, 17 insertions(+), 22 deletions(-)
diff --git a/cpukit/posix/src/sysconf.c b/cpukit/posix/src/sysconf.c
index 05158a2..7bbf865 100644
--- a/cpukit/posix/src/sysconf.c
+++ b/cpukit/posix/src/sysconf.c
@@ -22,8 +22,7 @@
#include <unistd.h>
#include <errno.h>
-#include <rtems/score/todimpl.h>
-#include <rtems/system.h>
+#include <rtems.h>
#include <rtems/seterr.h>
#include <rtems/libio_.h>
@@ -37,26 +36,22 @@ long sysconf(
int name
)
{
- if ( name == _SC_CLK_TCK )
- return (TOD_MICROSECONDS_PER_SECOND /
- rtems_configuration_get_microseconds_per_tick());
-
- if ( name == _SC_OPEN_MAX )
- return rtems_libio_number_iops;
-
- if ( name == _SC_GETPW_R_SIZE_MAX )
- return 1024;
-
- if ( name == _SC_PAGESIZE )
- return PAGE_SIZE;
-
- if ( name == _SC_SYMLOOP_MAX )
- return RTEMS_FILESYSTEM_SYMLOOP_MAX;
-
+ switch ( name ) {
+ case _SC_CLK_TCK:
+ return (long) rtems_clock_get_ticks_per_second();
+ case _SC_OPEN_MAX:
+ return rtems_libio_number_iops;
+ case _SC_GETPW_R_SIZE_MAX:
+ return 1024;
+ case _SC_PAGESIZE:
+ return PAGE_SIZE;
+ case _SC_SYMLOOP_MAX:
+ return RTEMS_FILESYSTEM_SYMLOOP_MAX;
#if defined(__sparc__)
- if ( name == 515 ) /* Solaris _SC_STACK_PROT */
- return 0;
+ case 515: /* Solaris _SC_STACK_PROT */
+ return 0;
#endif
-
- rtems_set_errno_and_return_minus_one( EINVAL );
+ default:
+ rtems_set_errno_and_return_minus_one( EINVAL );
+ }
}
More information about the vc
mailing list