📄 cext.h
字号:
/******************************************************************* modified JCD 27 Apr-88 for AMIGA* cext.h -- extensions to c to make it more portable* Copyright 1989 Carnegie Mellon University********************************************************************cext must provide the following definitions:true -- a constantfalse -- a boolean constantprivate -- defined as static, used to declare local functionspublic -- defined as empty string, used to declare exported functionsboolean -- a new typebyte -- unsigned 8-bit quantityushort -- unsigned 16-bit quantityulong -- unsigned 32-bit quantityPointer -- pointer to char, a generic pointerABS() -- absolute value of any type of numberMAX() -- maximum of two numbersMIN() -- minimum of two numbersROUND() -- round a double to long NULL -- pointer to nothing, a constantEOS -- end of string, a constant '\0'MALLOC(x) -- allocates x bytesFREE(x) -- frees something from MALLOCAVAILMEM -- tells how much memory is available. (N.B.: no parens, no args.)EXIT(n) -- calls exit(n) after shutting down/deallocating resources*****************************************************************************//* CHANGE LOG * -------------------------------------------------------------------- * 28Apr03 dm many changes for new conditional compilation switches * 28Apr03 rbd removed macro redefinitions: min, max */#ifndef CEXT_H#ifndef SWITCHES#include "switches.h"#endif#include <stdio.h>#include <string.h>#include <math.h>#if HAS_STDLIB_H#include <stdlib.h>#endif#if HAS_SYS_TYPES_H#include <sys/types.h>#endif#if HAS_MALLOC_H#include <malloc.h>#endif#if NEED_ULONGtypedef unsigned long ulong;#endif#if NEED_USHORTtypedef unsigned long ushort;#endif#if NEED_BYTEtypedef unsigned char byte;#endif/* There's a name conflict between true/false as an enum type in * Apple #includes:Types.h on the Mac, and true/false as #defined below */#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endif#define private static#define public#if NEED_DEFINE_MALLOCpublic void *malloc();#endiftypedef char *Pointer;#ifdef UNIX_MACHtypedef int boolean;#else/* hopefully, unsigned short will save sign extension instructions */typedef unsigned char boolean;#endif#ifndef ABS#define ABS(a) (((a) > 0) ? (a) : -(a))#endif#ifndef MAX#define MAX(a, b) (((a) > (b)) ? (a) : (b))#endif#ifndef MIN#define MIN(a, b) (((a) < (b)) ? (a) : (b))#endif#define MAXULONG 0xffffffff#ifndef NULL#define NULL 0L#endif#ifndef EOS#define EOS '\0'#endif#define SAFETYBUF 10 /* Safety buffer when allocating memory */#define BIGGEST_BLOCK 32765 /* Should find a happy medium for this */#ifdef MACINTOSH /*DMH: gets AVAILMEM in record.c*/#include <stddef.h>#define MALLOC(x) malloc((size_t)(x)) /*DMH: size_t is ulong, for MAC*/#define FREE(x) free((char *)(x))#define AVAILMEM MyMaxMem(NULL)/*???*/#endif#ifdef LATTICE322#define MALLOC malloc#define FREE free#define AVAILMEM MyMaxMem(NULL)#else#ifdef DOS /* was MICROSOFT */#define MALLOC malloc#define FREE free#define AVAILMEM MyMaxMem(NULL)#endif#endif#ifdef UNIX#define MALLOC malloc#define FREE free#define AVAILMEM 10000000 /* since we have virtual memory, assume 10Mb */#endif#ifdef AMIGA#define MALLOC malloc#define FREE free#define AVAILMEM 128000#endifpublic ulong MyMaxMem(ushort *);#ifndef MEM#include "mem.h"#endif#ifndef CLEANUP#include "cleanup.h"#endif#ifdef CMTSTUFF#define EXIT cmt_exitpublic void EXIT(int);/* don't allow anyone to call exit directly */#define exit(n) PLEASE_CALL_EXIT_NOT_exit#else#define EXIT(n) exit(n)#endif#define _cext#ifndef MALLOCMALLOC is not defined!#endif#define ROUND(x) ((long) ((x) + 0.5))/* for compatibility */#ifdef NEED_ROUND#define round ROUND#endif#define CEXT_H#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -