home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1995, 1996 by Oracle Corporation. All Rights Reserved.
- *
- * ys.h - OMN System Layer
- *
- * DECSRIPTION
- * The Oracle Media Net System Layer (also known as the ys layer)
- * consists of a number of fundamental packages and library routines
- * that together comprise a small, portable virtual operating system
- * and user library. It is not intended to replace the standard C
- * library, nor does it actually implement a virtual operating system.
- * Instead, it provides a portable interface to O/S functions, and a
- * standard library of functions that can be relied upon to present
- * in every program incorporating this system layer.
- *
- * THREAD SAFETY
- * The system layer is designed to be completely thread-safe. In order
- * to use the system layer in a multi-threaded environment, you must
- * initialize the threads package before creating your first thread.
- * See the "THREAD SAFETY" section at the top of each OMN System Layer
- * header file for more information specific to the interface defined
- * there.
- *
- * EXCEPTIONS
- * The system layer provides an exception mechanism designed to emulate
- * the C++ exception model. However, the usage of a non-standard exception
- * mechanism is troublesome, especially across public interfaces that are
- * used in a wide variety of conditions. Therefore, the system layer itself
- * only throws two classes of exceptions:
- *
- * + those that indicate a programming error (such as a bad parameter)
- * + those that indicate a near-fatal condition (such as out of memory)
- *
- * It is rarely possible to recover from these exceptions in any meaningful
- * way other than to simply terminate the running thread or program. Other
- * sorts of errors that are detectable and recoverable are indicated through
- * status codes returned from a function call. This design allows the System
- * Layer to be used essentially unencumbered by its exception model. In the
- * case that an exception does arise, the default behavior is to terminate
- * the program. See yse.h for more information about the exception model.
- */
-
- #ifndef YS_ORACLE
- #define YS_ORACLE
-
- #ifndef SYSX_ORACLE
- #include <sysx.h>
- #endif
- #ifndef YSID_ORACLE
- #include <ysid.h>
- #endif
-
- EXTC_START
-
- /*
- * Type Declarations
- */
- typedef struct ysbv ysbv; /* buffer vector */
- typedef struct yslst yslst; /* list structure */
- typedef struct ysle ysle; /* list element */
- typedef struct yslmtc yslmtc; /* get metrics for a list */
- typedef struct ysfop ysfop; /* fixed-object pool descriptor */
- typedef struct ysmhp ysmhp; /* heap descriptor */
- typedef struct ysque ysque; /* queue descriptor */
- typedef struct ysevt ysevt; /* event descriptor */
-
- typedef dvoid *(*ysmaf)(size_t len); /* allocation function */
- typedef dvoid *(*ysmrf)(dvoid *ptr, size_t len); /* reallocation function */
- typedef void (*ysmff)(dvoid *ptr); /* deallocation function */
-
- /*
- * ysInit, ysTerm - initialization & termination
- *
- * DESCRIPTION
- * ysInit() must be called before using any other routine in the ys layer,
- * or any software that depends on the OMN system layer. osdp is a pointer
- * to memory reserved for operating-system dependent functionality. This
- * memory must be allocated by the caller to last for the lifetime of the
- * program (usually on the stack somewhere near main()). It should be
- * declared as a ub1 array of SYSX_OSDPTR_SIZE bytes. nm is the name of
- * the program being run. This is used when reporting diagnostics, when
- * printing a usage description, and also to generate a name for the
- * process in distributed environments. By convention, it is usually the
- * name of the executable.
- *
- * ysTerm() must be called just prior to program termination to ensure that
- * all resources used by the ys layer are returned to the operation system.
- *
- * The ysInit()/ysTerm() pair may be called more than once in any given
- * process. However, they must not called from within more than one
- * concurrently executing thread at the same time. Additional calls to
- * ysInit() will increment a reference count and return silently leaving
- * the previous initialization intact. Subsequent calls to ysTerm() will
- * decrement the refcnt. YS resources are freed only when the reference
- * count drops to zero.
- */
- void ysInit(dvoid *osdp, CONST char *nm);
- void ysTerm(dvoid *osdp);
-
- /*
- * ysVersion - get version of OMN
- *
- * DESCRIPTION
- * ysVersion() writes a string describing the current version of OMN to
- * buf. A maximum of len bytes will be written. A sufficient maximum
- * length is 80. As a convenience, it returns the pointer to buf that
- * was passed in.
- */
- char *ysVersion(char *buf, size_t len);
-
- /*
- * ysProgName, ysGetOsdPtr, ysGetHostName, ysGetPid, ysGetAffinity,
- * ysGetCpuTime, ysGetUpTime, ysGetMemUsage - get program information
- *
- * SYNOPSIS
- * const char *ysProgName(void);
- * dvoid *ysGetOsdPtr(void);
- * const char *ysGetHostName(void);
- * const char *ysGetPid(void);
- * const char *ysGetAffinity(void);
- * void ysGetCpuTime(sysb8 *cputm);
- * void ysGetUpTime(sysb8 *uptm);
- * ub4 ysGetMemUsage(void);
- *
- * DESCRIPTION
- * These routines return various information about the current process:
- *
- * ysProgName() returns the program name passed to ysInit(). ysGetOsdPtr()
- * returns the OSD pointer passed to ysInit().
- *
- * ysGetHostName() returns the host name for the system, as determined
- * by the operating system. If no host name is defined, the routine will
- * return a null pointer.
- *
- * ysGetPid() returns the proccess ID of the current process, as determined
- * by the operating system. If the operating system has no notion of process
- * identifier, the routine will return a null pointer. ysGetAffinity()
- * returns the affinity of the current process to a particular processor,
- * as determined by the operating system. If the operating system has no
- * notion of affinity, the routine will return a null pointer.
- *
- * ysGetCpuTime() returns the amount of CPU time used by the process, as
- * determined by the operating system. This is returned in units of
- * microseconds. ysGetUpTime() returns the elapsed time since ysInit()
- * was called. This is returned in units of microseconds. ysGetMemUsage()
- * returns the amount of memory currently being consumed by the process,
- * as determined by the operating system. This is returned in units of
- * kilobytes.
- */
- CONST char *ysProgName(void);
- dvoid *ysGetOsdPtr(void);
-
- #define ysGetHostName() ((CONST char *) ysResGetLast("ys.hostname"))
- #define ysGetPid() ((CONST char *) ysResGetLast("ys.pid"))
- #define ysGetAffinity() ((CONST char *) ysResGetLast("ys.affinity"))
-
- void ysGetCpuTime(sysb8 *cputm);
- void ysGetUpTime(sysb8 *uptm);
- ub4 ysGetMemUsage(void);
-
- /*
- * ysFmtVersion - format a version string in a conventional format
- *
- * DESCRIPTION
- * ysFmtVersion() is used by products to consistently format a one-line
- * description of the product, its version and release status, and its
- * build date. The description is written to buf. As a convenience, the
- * pointer to buf is returned by the function. If you do not want a build
- * date to be included, pass in null for the date. The release status
- * may be one of the following:
- */
- #define YSLVL_NONE 0 /* no status */
- #define YSLVL_DEVEL 1 /* Development */
- #define YSLVL_DEVRL 2 /* Developer's Release */
- #define YSLVL_ALPHA 3 /* Alpha */
- #define YSLVL_BETA 4 /* Beta */
- #define YSLVL_LIMIT 5 /* Limited Production */
- #define YSLVL_PROD 6 /* Production */
-
- char *ysFmtVersion(char *buf, size_t buflen, CONST char *prodnm,
- CONST char *vrs, sword sts, CONST char *date);
-
- /* include other public, external headers as a convenience */
- #ifndef YSBV_ORACLE
- #include <ysbv.h>
- #endif
- #ifndef YSFO_ORACLE
- #include <ysfo.h>
- #endif
- #ifndef YSSTR_ORACLE
- #include <ysstr.h>
- #endif
- #ifndef YSLST_ORACLE
- #include <yslst.h>
- #endif
- #ifndef YSHSH_ORACLE
- #include <yshsh.h>
- #endif
- #ifndef YSC_ORACLE
- #include <ysc.h>
- #endif
- #ifndef YSE_ORACLE
- #include <yse.h>
- #endif
- #ifndef YSTM_ORACLE
- #include <ystm.h>
- #endif
- #ifndef YSV_ORACLE
- #include <ysv.h>
- #endif
- #ifndef YSMSC_ORACLE
- #include <ysmsc.h>
- #endif
- #ifndef YSL_ORACLE
- #include <ysl.h>
- #endif
- #ifndef YSR_ORACLE
- #include <ysr.h>
- #endif
- #ifndef YSLOG_ORACLE
- #include <yslog.h>
- #endif
- #ifndef YSTHR_ORACLE
- #include <ysthr.h>
- #endif
-
- EXTC_END
- #endif /* YS_ORACLE */
-