Code:
$ cat mysrc/sysinf.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/systeminfo.h>
#include <unistd.h>
#include <errno.h>
static void p_sysinfo( int name, char *cname ){
char buf[65536];
if ( 0 > sysinfo( name, buf, sizeof buf ) ) {
fputs( "sysinfo(): ", stderr );
perror( cname );
} else {
printf( "%s:\t%s\n", cname, buf );
}
}
static void p_sysconf( int name, char *cname ){
long l ;
errno = 0 ;
if ( -1 == ( l = sysconf( name ) ) ) {
if ( errno ) {
perror( cname );
} else {
fputs( cname, stderr );
fputs( ": Not supported\n", stderr );
}
} else {
printf( "%s: %ld\n", cname, l );
}
}
int main( int argc, char **argv ){
p_sysinfo( SI_ARCHITECTURE, "SI_ARCHITECTURE" );
p_sysinfo( SI_ARCHITECTURE_32, "SI_ARCHITECTURE_32" );
p_sysinfo( SI_ARCHITECTURE_64, "SI_ARCHITECTURE_64" );
p_sysinfo( SI_ARCHITECTURE_K, "SI_ARCHITECTURE_K" );
p_sysinfo( SI_ARCHITECTURE_NATIVE, "SI_ARCHITECTURE_NATIVE" );
p_sysinfo( SI_DHCP_CACHE, "SI_DHCP_CACHE" );
p_sysinfo( SI_HOSTNAME, "SI_HOSTNAME" );
p_sysinfo( SI_HW_PROVIDER, "SI_HW_PROVIDER" );
p_sysinfo( SI_HW_SERIAL, "SI_HW_SERIAL" );
p_sysinfo( SI_ISALIST, "SI_ISALIST" );
p_sysinfo( SI_MACHINE, "SI_MACHINE" );
p_sysinfo( SI_PLATFORM, "SI_PLATFORM" );
p_sysinfo( SI_RELEASE, "SI_RELEASE" );
/* p_sysinfo( SI_SET_HOSTNAME, "SI_SET_HOSTNAME" ); */
/* p_sysinfo( SI_SET_SRPC_DOMAIN, "SI_SET_SRPC_DOMAIN" ); */
p_sysinfo( SI_SRPC_DOMAIN, "SI_SRPC_DOMAIN" );
p_sysinfo( SI_SYSNAME, "SI_SYSNAME" );
p_sysinfo( SI_VERSION, "SI_VERSION" );
p_sysconf( _SC_2_CHAR_TERM, "_SC_2_CHAR_TERM" );
p_sysconf( _SC_2_C_BIND, "_SC_2_C_BIND" );
p_sysconf( _SC_2_C_DEV, "_SC_2_C_DEV" );
p_sysconf( _SC_2_C_VERSION, "_SC_2_C_VERSION" );
p_sysconf( _SC_2_FORT_DEV, "_SC_2_FORT_DEV" );
p_sysconf( _SC_2_FORT_RUN, "_SC_2_FORT_RUN" );
p_sysconf( _SC_2_LOCALEDEF, "_SC_2_LOCALEDEF" );
p_sysconf( _SC_2_PBS, "_SC_2_PBS" );
p_sysconf( _SC_2_PBS_ACCOUNTING, "_SC_2_PBS_ACCOUNTING" );
p_sysconf( _SC_2_PBS_CHECKPOINT, "_SC_2_PBS_CHECKPOINT" );
p_sysconf( _SC_2_PBS_LOCATE, "_SC_2_PBS_LOCATE" );
p_sysconf( _SC_2_PBS_MESSAGE, "_SC_2_PBS_MESSAGE" );
p_sysconf( _SC_2_PBS_TRACK, "_SC_2_PBS_TRACK" );
p_sysconf( _SC_2_SW_DEV, "_SC_2_SW_DEV" );
p_sysconf( _SC_2_UPE, "_SC_2_UPE" );
p_sysconf( _SC_2_VERSION, "_SC_2_VERSION" );
p_sysconf( _SC_ADVISORY_INFO, "_SC_ADVISORY_INFO" );
p_sysconf( _SC_AIO_LISTIO_MAX, "_SC_AIO_LISTIO_MAX" );
p_sysconf( _SC_AIO_MAX, "_SC_AIO_MAX" );
p_sysconf( _SC_AIO_PRIO_DELTA_MAX, "_SC_AIO_PRIO_DELTA_MAX" );
p_sysconf( _SC_ARG_MAX, "_SC_ARG_MAX" );
p_sysconf( _SC_ASYNCHRONOUS_IO, "_SC_ASYNCHRONOUS_IO" );
p_sysconf( _SC_ATEXIT_MAX, "_SC_ATEXIT_MAX" );
p_sysconf( _SC_AVPHYS_PAGES, "_SC_AVPHYS_PAGES" );
p_sysconf( _SC_BARRIERS, "_SC_BARRIERS" );
p_sysconf( _SC_BC_BASE_MAX, "_SC_BC_BASE_MAX" );
p_sysconf( _SC_BC_DIM_MAX, "_SC_BC_DIM_MAX" );
p_sysconf( _SC_BC_SCALE_MAX, "_SC_BC_SCALE_MAX" );
p_sysconf( _SC_BC_STRING_MAX, "_SC_BC_STRING_MAX" );
p_sysconf( _SC_CHILD_MAX, "_SC_CHILD_MAX" );
p_sysconf( _SC_CLK_TCK, "_SC_CLK_TCK" );
p_sysconf( _SC_CLOCK_SELECTION, "_SC_CLOCK_SELECTION" );
p_sysconf( _SC_COHER_BLKSZ, "_SC_COHER_BLKSZ" );
p_sysconf( _SC_COLL_WEIGHTS_MAX, "_SC_COLL_WEIGHTS_MAX" );
p_sysconf( _SC_CPUID_MAX, "_SC_CPUID_MAX" );
p_sysconf( _SC_CPUTIME, "_SC_CPUTIME" );
p_sysconf( _SC_DCACHE_ASSOC, "_SC_DCACHE_ASSOC" );
p_sysconf( _SC_DCACHE_BLKSZ, "_SC_DCACHE_BLKSZ" );
p_sysconf( _SC_DCACHE_LINESZ, "_SC_DCACHE_LINESZ" );
p_sysconf( _SC_DCACHE_SZ, "_SC_DCACHE_SZ" );
p_sysconf( _SC_DCACHE_TBLKSZ, "_SC_DCACHE_TBLKSZ" );
p_sysconf( _SC_DELAYTIMER_MAX, "_SC_DELAYTIMER_MAX" );
p_sysconf( _SC_EXPR_NEST_MAX, "_SC_EXPR_NEST_MAX" );
p_sysconf( _SC_FSYNC, "_SC_FSYNC" );
p_sysconf( _SC_GETGR_R_SIZE_MAX, "_SC_GETGR_R_SIZE_MAX" );
p_sysconf( _SC_GETPW_R_SIZE_MAX, "_SC_GETPW_R_SIZE_MAX" );
p_sysconf( _SC_HOST_NAME_MAX, "_SC_HOST_NAME_MAX" );
p_sysconf( _SC_ICACHE_ASSOC, "_SC_ICACHE_ASSOC" );
p_sysconf( _SC_ICACHE_BLKSZ, "_SC_ICACHE_BLKSZ" );
p_sysconf( _SC_ICACHE_LINESZ, "_SC_ICACHE_LINESZ" );
p_sysconf( _SC_ICACHE_SZ, "_SC_ICACHE_SZ" );
p_sysconf( _SC_IOV_MAX, "_SC_IOV_MAX" );
p_sysconf( _SC_IPV6, "_SC_IPV6" );
p_sysconf( _SC_JOB_CONTROL, "_SC_JOB_CONTROL" );
p_sysconf( _SC_LINE_MAX, "_SC_LINE_MAX" );
p_sysconf( _SC_LOGIN_NAME_MAX, "_SC_LOGIN_NAME_MAX" );
p_sysconf( _SC_LOGNAME_MAX, "_SC_LOGNAME_MAX" );
p_sysconf( _SC_MAPPED_FILES, "_SC_MAPPED_FILES" );
p_sysconf( _SC_MAXPID, "_SC_MAXPID" );
p_sysconf( _SC_MEMLOCK, "_SC_MEMLOCK" );
p_sysconf( _SC_MEMLOCK_RANGE, "_SC_MEMLOCK_RANGE" );
p_sysconf( _SC_MEMORY_PROTECTION, "_SC_MEMORY_PROTECTION" );
p_sysconf( _SC_MESSAGE_PASSING, "_SC_MESSAGE_PASSING" );
p_sysconf( _SC_MONOTONIC_CLOCK, "_SC_MONOTONIC_CLOCK" );
p_sysconf( _SC_MQ_OPEN_MAX, "_SC_MQ_OPEN_MAX" );
p_sysconf( _SC_MQ_PRIO_MAX, "_SC_MQ_PRIO_MAX" );
p_sysconf( _SC_NGROUPS_MAX, "_SC_NGROUPS_MAX" );
p_sysconf( _SC_NPROCESSORS_CONF, "_SC_NPROCESSORS_CONF" );
p_sysconf( _SC_NPROCESSORS_MAX, "_SC_NPROCESSORS_MAX" );
p_sysconf( _SC_NPROCESSORS_ONLN, "_SC_NPROCESSORS_ONLN" );
p_sysconf( _SC_OPEN_MAX, "_SC_OPEN_MAX" );
p_sysconf( _SC_PAGESIZE, "_SC_PAGESIZE" );
p_sysconf( _SC_PASS_MAX, "_SC_PASS_MAX" );
p_sysconf( _SC_PHYS_PAGES, "_SC_PHYS_PAGES" );
p_sysconf( _SC_PRIORITIZED_IO, "_SC_PRIORITIZED_IO" );
p_sysconf( _SC_PRIORITY_SCHEDULING, "_SC_PRIORITY_SCHEDULING" );
p_sysconf( _SC_RAW_SOCKETS, "_SC_RAW_SOCKETS" );
p_sysconf( _SC_READER_WRITER_LOCKS, "_SC_READER_WRITER_LOCKS" );
p_sysconf( _SC_REALTIME_SIGNALS, "_SC_REALTIME_SIGNALS" );
p_sysconf( _SC_REGEXP, "_SC_REGEXP" );
p_sysconf( _SC_RE_DUP_MAX, "_SC_RE_DUP_MAX" );
p_sysconf( _SC_RTSIG_MAX, "_SC_RTSIG_MAX" );
p_sysconf( _SC_SAVED_IDS, "_SC_SAVED_IDS" );
p_sysconf( _SC_SEMAPHORES, "_SC_SEMAPHORES" );
p_sysconf( _SC_SEM_NSEMS_MAX, "_SC_SEM_NSEMS_MAX" );
p_sysconf( _SC_SEM_VALUE_MAX, "_SC_SEM_VALUE_MAX" );
p_sysconf( _SC_SHARED_MEMORY_OBJECTS, "_SC_SHARED_MEMORY_OBJECTS" );
p_sysconf( _SC_SHELL, "_SC_SHELL" );
p_sysconf( _SC_SIGQUEUE_MAX, "_SC_SIGQUEUE_MAX" );
p_sysconf( _SC_SIGRT_MAX, "_SC_SIGRT_MAX" );
p_sysconf( _SC_SIGRT_MIN, "_SC_SIGRT_MIN" );
p_sysconf( _SC_SPAWN, "_SC_SPAWN" );
p_sysconf( _SC_SPIN_LOCKS, "_SC_SPIN_LOCKS" );
p_sysconf( _SC_SPLIT_CACHE, "_SC_SPLIT_CACHE" );
p_sysconf( _SC_SPORADIC_SERVER, "_SC_SPORADIC_SERVER" );
p_sysconf( _SC_SS_REPL_MAX, "_SC_SS_REPL_MAX" );
p_sysconf( _SC_STACK_PROT, "_SC_STACK_PROT" );
p_sysconf( _SC_STREAM_MAX, "_SC_STREAM_MAX" );
p_sysconf( _SC_SYMLOOP_MAX, "_SC_SYMLOOP_MAX" );
p_sysconf( _SC_SYNCHRONIZED_IO, "_SC_SYNCHRONIZED_IO" );
p_sysconf( _SC_THREADS, "_SC_THREADS" );
p_sysconf( _SC_THREAD_ATTR_STACKADDR, "_SC_THREAD_ATTR_STACKADDR" );
p_sysconf( _SC_THREAD_ATTR_STACKSIZE, "_SC_THREAD_ATTR_STACKSIZE" );
p_sysconf( _SC_THREAD_CPUTIME, "_SC_THREAD_CPUTIME" );
p_sysconf( _SC_THREAD_DESTRUCTOR_ITERATIONS, "_SC_THREAD_DESTRUCTOR_ITERATIONS" );
p_sysconf( _SC_THREAD_KEYS_MAX, "_SC_THREAD_KEYS_MAX" );
p_sysconf( _SC_THREAD_PRIORITY_SCHEDULING, "_SC_THREAD_PRIORITY_SCHEDULING" );
p_sysconf( _SC_THREAD_PRIO_INHERIT, "_SC_THREAD_PRIO_INHERIT" );
p_sysconf( _SC_THREAD_PRIO_PROTECT, "_SC_THREAD_PRIO_PROTECT" );
p_sysconf( _SC_THREAD_PROCESS_SHARED, "_SC_THREAD_PROCESS_SHARED" );
p_sysconf( _SC_THREAD_SAFE_FUNCTIONS, "_SC_THREAD_SAFE_FUNCTIONS" );
p_sysconf( _SC_THREAD_SPORADIC_SERVER, "_SC_THREAD_SPORADIC_SERVER" );
p_sysconf( _SC_THREAD_STACK_MIN, "_SC_THREAD_STACK_MIN" );
p_sysconf( _SC_THREAD_THREADS_MAX, "_SC_THREAD_THREADS_MAX" );
p_sysconf( _SC_TIMEOUTS, "_SC_TIMEOUTS" );
p_sysconf( _SC_TIMERS, "_SC_TIMERS" );
p_sysconf( _SC_TIMER_MAX, "_SC_TIMER_MAX" );
p_sysconf( _SC_TRACE, "_SC_TRACE" );
p_sysconf( _SC_TRACE_EVENT_FILTER, "_SC_TRACE_EVENT_FILTER" );
p_sysconf( _SC_TRACE_EVENT_NAME_MAX, "_SC_TRACE_EVENT_NAME_MAX" );
p_sysconf( _SC_TRACE_INHERIT, "_SC_TRACE_INHERIT" );
p_sysconf( _SC_TRACE_LOG, "_SC_TRACE_LOG" );
p_sysconf( _SC_TRACE_NAME_MAX, "_SC_TRACE_NAME_MAX" );
p_sysconf( _SC_TRACE_SYS_MAX, "_SC_TRACE_SYS_MAX" );
p_sysconf( _SC_TRACE_USER_EVENT_MAX, "_SC_TRACE_USER_EVENT_MAX" );
p_sysconf( _SC_TTY_NAME_MAX, "_SC_TTY_NAME_MAX" );
p_sysconf( _SC_TYPED_MEMORY_OBJECTS, "_SC_TYPED_MEMORY_OBJECTS" );
p_sysconf( _SC_TZNAME_MAX, "_SC_TZNAME_MAX" );
p_sysconf( _SC_T_IOV_MAX, "_SC_T_IOV_MAX" );
p_sysconf( _SC_V6_ILP32_OFF32, "_SC_V6_ILP32_OFF32" );
p_sysconf( _SC_V6_ILP32_OFFBIG, "_SC_V6_ILP32_OFFBIG" );
p_sysconf( _SC_V6_LP64_OFF64, "_SC_V6_LP64_OFF64" );
p_sysconf( _SC_V6_LPBIG_OFFBIG, "_SC_V6_LPBIG_OFFBIG" );
p_sysconf( _SC_VERSION, "_SC_VERSION" );
p_sysconf( _SC_XBS5_ILP32_OFF32, "_SC_XBS5_ILP32_OFF32" );
p_sysconf( _SC_XBS5_ILP32_OFFBIG, "_SC_XBS5_ILP32_OFFBIG" );
p_sysconf( _SC_XBS5_LP64_OFF64, "_SC_XBS5_LP64_OFF64" );
p_sysconf( _SC_XBS5_LPBIG_OFFBIG, "_SC_XBS5_LPBIG_OFFBIG" );
p_sysconf( _SC_XOPEN_CRYPT, "_SC_XOPEN_CRYPT" );
p_sysconf( _SC_XOPEN_ENH_I18N, "_SC_XOPEN_ENH_I18N" );
p_sysconf( _SC_XOPEN_LEGACY, "_SC_XOPEN_LEGACY" );
p_sysconf( _SC_XOPEN_REALTIME, "_SC_XOPEN_REALTIME" );
p_sysconf( _SC_XOPEN_REALTIME_THREADS, "_SC_XOPEN_REALTIME_THREADS" );
p_sysconf( _SC_XOPEN_SHM, "_SC_XOPEN_SHM" );
p_sysconf( _SC_XOPEN_STREAMS, "_SC_XOPEN_STREAMS" );
p_sysconf( _SC_XOPEN_UNIX, "_SC_XOPEN_UNIX" );
p_sysconf( _SC_XOPEN_VERSION, "_SC_XOPEN_VERSION" );
p_sysconf( _SC_XOPEN_XCU_VERSION, "_SC_XOPEN_XCU_VERSION" );
exit( 0 );
}
$