loadavg.h
来自「wu-ftpd类unix下的ftp服务器,可用于嵌入式系统」· C头文件 代码 · 共 897 行 · 第 1/2 页
H
897 行
/**************************************************************************** Copyright (c) 1999,2000 WU-FTPD Development Group. All rights reserved. Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994 The Regents of the University of California. Portions Copyright (c) 1993, 1994 Washington University in Saint Louis. Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc. Portions Copyright (c) 1989 Massachusetts Institute of Technology. Portions Copyright (c) 1998 Sendmail, Inc. Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman. Portions Copyright (c) 1997 by Stan Barber. Portions Copyright (c) 1997 by Kent Landfield. Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. Use and distribution of this software and its source code are governed by the terms and conditions of the WU-FTPD Software License ("LICENSE"). If you did not receive a copy of the license, it may be obtained online at http://www.wu-ftpd.org/license.html. $Id: loadavg.h,v 1.7 2000/07/01 18:17:39 wuftpd Exp $ ****************************************************************************/#include <unistd.h>#include <stddef.h>#include <stdlib.h>#include <stdio.h>#include <ctype.h>#include <setjmp.h>#include <string.h>#ifdef TIME_WITH_SYS_TIME#include <time.h>#include <sys/time.h>#else#ifdef HAVE_SYS_TIME_H#include <sys/time.h>#else#include <time.h>#endif#endif#include <errno.h>#include <sysexits.h>#include <sys/param.h>#include <sys/types.h>#include <sys/stat.h>#ifndef __QNX__/* in QNX this grabs bogus LOCK_* manifests */#include <sys/file.h>#endif#include <sys/wait.h>#include <limits.h>#include <fcntl.h>#include <signal.h>#include <netdb.h>#include <pwd.h>/************************************************************************ Operating system configuration.**** Unless you are porting to a new OS, you shouldn't have to** change these.**********************************************************************//* ** HP-UX -- tested for 8.07, 9.00, and 9.01. ** ** If V4FS is defined, compile for HP-UX 10.0. ** 11.x support from Richard Allen <ra@hp.is>. */#ifdef __hpux#define SYSTEM5 1 /* include all the System V defines */#define LA_TYPE LA_HPUX#ifdef V4FS /* HP-UX 10.x */#define _PATH_UNIX "/stand/vmunix"#else /* HP-UX 9.x */#define _PATH_UNIX "/hp-ux"#endif#endif/* ** IBM AIX 4.x */#ifdef _AIX4#define _AIX3 1 /* pull in AIX3 stuff */#endif/* ** IBM AIX 3.x -- actually tested for 3.2.3 */#ifdef _AIX3#include <paths.h>#include <sys/machine.h> /* to get byte order */#include <sys/select.h>#define LA_TYPE LA_INT#define FSHIFT 16#define LA_AVENRUN "avenrun"#endif/* ** IBM AIX 2.2.1 -- actually tested for osupdate level 2706+1773 ** ** From Mark Whetzel <markw@wg.waii.com>. */#ifdef AIX#include <paths.h>#define LA_TYPE LA_SUBR /* use our ported loadavgd daemon */#endif/* ** Silicon Graphics IRIX ** ** Compiles on 4.0.1. ** ** Use IRIX64 instead of IRIX for 64-bit IRIX (6.0). ** Use IRIX5 instead of IRIX for IRIX 5.x. ** ** This version tries to be adaptive using _MIPS_SIM: ** _MIPS_SIM == _ABIO32 (= 1) Abi: -32 on IRIX 6.2 ** _MIPS_SIM == _ABIN32 (= 2) Abi: -n32 on IRIX 6.2 ** _MIPS_SIM == _ABI64 (= 3) Abi: -64 on IRIX 6.2 ** ** _MIPS_SIM is 1 also on IRIX 5.3 ** ** IRIX64 changes from Mark R. Levinson <ml@cvdev.rochester.edu>. ** IRIX5 changes from Kari E. Hurtta <Kari.Hurtta@fmi.fi>. ** Adaptive changes from Kari E. Hurtta <Kari.Hurtta@fmi.fi>. */#if defined(__sgi)#ifndef IRIX#define IRIX#endif#if _MIPS_SIM > 0 && !defined(IRIX5)#define IRIX5 /* IRIX5 or IRIX6 */#endif#if _MIPS_SIM > 1 && !defined(IRIX6) && !defined(IRIX64)#define IRIX6 /* IRIX6 */#endif#endif#ifdef IRIX#define SYSTEM5 1 /* this is a System-V derived system */#ifdef IRIX6#define LA_TYPE LA_IRIX6 /* figure out at run time */#else#define LA_TYPE LA_INT#endif#if defined(IRIX64) || defined(IRIX5) || defined(IRIX6)#include <sys/cdefs.h>#include <paths.h>#endif#endif/* ** SunOS and Solaris ** ** Tested on SunOS 4.1.x (a.k.a. Solaris 1.1.x) and ** Solaris 2.4 (a.k.a. SunOS 5.4). */#if defined(sun) && !defined(BSD)#ifdef SOLARIS_2_3#define SOLARIS 20300 /* for back compat only -- use -DSOLARIS=20300 */#endif#if !defined(SOLARIS) && defined(sun) && (defined(__svr4__) || defined(__SVR4))#define SOLARIS 1 /* unknown Solaris version */#endif#ifdef SOLARIS /* Solaris 2.x (a.k.a. SunOS 5.x) */#ifndef __svr4__#define __svr4__ /* use all System V Releae 4 defines below */#endif#ifndef _PATH_UNIX#define _PATH_UNIX "/dev/ksyms"#endif#if SOLARIS >= 20500 || (SOLARIS < 10000 && SOLARIS >= 205)#if SOLARIS < 207 || (SOLARIS > 10000 && SOLARIS < 20700)#ifndef LA_TYPE#define LA_TYPE LA_KSTAT /* use kstat(3k) -- may work in < 2.5 */#endif#endif#endif#if SOLARIS >= 20700 || (SOLARIS < 10000 && SOLARIS >= 207)#ifndef LA_TYPE#define LA_TYPE LA_SUBR /* getloadavg(3c) appears in 2.7 */#endif#endif#else /* SunOS 4.0.3 or 4.1.x */#include <memory.h>#include <vfork.h>#ifdef SUNOS403 /* special tweaking for SunOS 4.0.3 */#include <malloc.h>#define BSD4_3 1 /* 4.3 BSD-based */#endif#endif#ifndef LA_TYPE#define LA_TYPE LA_INT#endif#endif /* sun && !BSD *//* ** DG/UX ** ** Tested on 5.4.2 and 5.4.3. Use DGUX_5_4_2 to get the ** older support. ** 5.4.3 changes from Mark T. Robinson <mtr@ornl.gov>. */#ifdef DGUX_5_4_2#define DGUX 1#endif#ifdef DGUX#define SYSTEM5 1#define LA_TYPE LA_DGUX/* these include files must be included early on DG/UX */#include <netinet/in.h>#include <arpa/inet.h>/* compiler doesn't understand const? */#define const#endif/* ** Digital Ultrix 4.2A or 4.3 ** ** Apparently, fcntl locking is broken on 4.2A, in that locks are ** not dropped when the process exits. This causes major problems, ** so flock is the only alternative. */#ifdef ultrix#ifdef vax#define LA_TYPE LA_FLOAT#else#define LA_TYPE LA_INT#define LA_AVENRUN "avenrun"#endif#endif/* ** OSF/1 for KSR. ** ** Contributed by Todd C. Miller <Todd.Miller@cs.colorado.edu> */#ifdef __ksr__#define __osf__ 1 /* get OSF/1 defines below */#endif/* ** OSF/1 for Intel Paragon. ** ** Contributed by Jeff A. Earickson <jeff@ssd.intel.com> ** of Intel Scalable Systems Divison. */#ifdef __PARAGON__#define __osf__ 1 /* get OSF/1 defines below */#endif/* ** OSF/1 (tested on Alpha) -- now known as Digital UNIX. ** ** Tested for 3.2 and 4.0. */#ifdef __osf__#define LA_TYPE LA_ALPHAOSF#endif/* ** NeXTstep */#ifdef NeXT#ifndef LA_TYPE#define LA_TYPE LA_MACH#endif#endif/* ** 4.4 BSD ** ** See also BSD defines. */#if defined(BSD4_4) && !defined(__bsdi__) && !defined(__GNU__)#include <paths.h>#include <sys/cdefs.h>#ifndef LA_TYPE#define LA_TYPE LA_SUBR#endif#endif/* ** BSD/OS (was BSD/386) (all versions) ** From Tony Sanders, BSDI */#ifdef __bsdi__#include <paths.h>#include <sys/cdefs.h>#ifndef LA_TYPE#define LA_TYPE LA_SUBR#endif#endif/* ** QNX 4.2x ** Contributed by Glen McCready <glen@qnx.com>. ** ** Should work with all versions of QNX. */#if defined(__QNX__)#include <unix.h>#include <sys/select.h>#define LA_TYPE LA_ZERO#endif/* ** FreeBSD / NetBSD / OpenBSD (all architectures, all versions) ** ** 4.3BSD clone, closer to 4.4BSD for FreeBSD 1.x and NetBSD 0.9x ** 4.4BSD-Lite based for FreeBSD 2.x and NetBSD 1.x ** ** See also BSD defines. */#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)#include <paths.h>#include <sys/cdefs.h>#ifndef LA_TYPE#define LA_TYPE LA_SUBR#endif#if defined(__FreeBSD__)#if __FreeBSD__ == 2#include <osreldate.h> /* and this works */#if __FreeBSD_version >= 199512 /* 2.2-current right now */#include <libutil.h>#endif#endif#endif#endif/* ** Mach386 ** ** For mt Xinu's Mach386 system. */#if defined(MACH) && defined(i386) && !defined(__GNU__)#define MACH386 1#ifndef LA_TYPE#define LA_TYPE LA_FLOAT#endif#endif/* ** GNU OS (hurd) ** Largely BSD & posix compatible. ** Port contributed by Miles Bader <miles@gnu.ai.mit.edu>. */#ifdef __GNU_HURD__#define LA_TYPE LA_MACH#endif /* GNU *//* ** 4.3 BSD -- this is for very old systems ** ** Should work for mt Xinu MORE/BSD and Mips UMIPS-BSD 2.1. ** ** You'll also have to install a new resolver library. ** I don't guarantee that support for this environment is complete. */#if defined(oldBSD43) || defined(MORE_BSD) || defined(umipsbsd)#ifndef LA_TYPE#define LA_TYPE LA_FLOAT#endif#endif/* ** SCO Unix ** ** This includes three parts: ** ** The first is for SCO OpenServer 5. ** (Contributed by Keith Reynolds <keithr@sco.COM>). ** ** SCO OpenServer 5 has a compiler version number macro, ** which we can use to figure out what version we're on. ** This may have to change in future releases. ** ** The second is for SCO UNIX 3.2v4.2/Open Desktop 3.0. ** (Contributed by Philippe Brand <phb@colombo.telesys-innov.fr>). ** ** The third is for SCO UNIX 3.2v4.0/Open Desktop 2.0 and earlier. *//* SCO OpenServer 5 */#if _SCO_DS >= 1#include <paths.h>#ifndef LA_TYPE#define LA_TYPE LA_DEVSHORT#endif#define _PATH_AVENRUN "/dev/table/avenrun"#ifndef _SCO_unix_4_2#define _SCO_unix_4_2#endif#endif/* SCO UNIX 3.2v4.2/Open Desktop 3.0 */#ifdef _SCO_unix_4_2#define _SCO_unix_#endif/* SCO UNIX 3.2v4.0 Open Desktop 2.0 and earlier */#ifdef _SCO_unix_#include <sys/stream.h> /* needed for IP_SRCROUTE */#define SYSTEM5 1 /* include all the System V defines */#define _PATH_UNIX "/unix"#ifndef _SCO_DS#define LA_TYPE LA_SHORT#endif#endif/* ** ISC (SunSoft) Unix. ** ** Contributed by J.J. Bailey <jjb@jagware.bcc.com> */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?