home *** CD-ROM | disk | FTP | other *** search
- /*
- nextstd.h
- Application Kit, Release 2.0
- Copyright (c) 1988, 1989, 1990, NeXT, Inc. All rights reserved.
- */
-
- /* This file has some standard macros useful in any program. */
-
- @class NSString;
-
- #ifndef NEXTSTD_H
- #define NEXTSTD_H
-
- #import <math.h>
- #import <stdio.h>
- #import <libc.h>
-
- #ifndef MAX
- #define MAX(A,B) ((A) > (B) ? (A) : (B))
- #endif
- #ifndef MIN
- #define MIN(A,B) ((A) < (B) ? (A) : (B))
- #endif
- #ifndef ABS
- #define ABS(A) ((A) < 0 ? (-(A)) : (A))
- #endif
-
- #define NX_MALLOC( VAR, TYPE, NUM ) \
- ((VAR) = (TYPE *) malloc((unsigned)(NUM)*sizeof(TYPE)))
-
- #define NX_REALLOC( VAR, TYPE, NUM ) \
- ((VAR) = (TYPE *) realloc((VAR), (unsigned)(NUM)*sizeof(TYPE)))
-
- #define NX_FREE( PTR ) free((PTR))
-
- #define NX_ZONEMALLOC( Z, VAR, TYPE, NUM ) \
- ((VAR) = (TYPE *) NSZoneMalloc((Z), (unsigned)(NUM)*sizeof(TYPE)))
-
- #define NX_ZONEREALLOC( Z, VAR, TYPE, NUM ) \
- ((VAR) = (TYPE *) NSZoneRealloc ((Z), (char *)(VAR), \
- (unsigned)(NUM)*sizeof(TYPE)))
-
- #ifndef NBITSCHAR
- #define NBITSCHAR 8
- #endif NBITSCHAR
-
- #ifndef NBITSINT
- #define NBITSINT (sizeof(int)*NBITSCHAR)
- #endif NBITSINT
-
- #ifndef TRUE
- #define TRUE 1
- #endif TRUE
- #ifndef FALSE
- #define FALSE 0
- #endif FALSE
-
- /*
- * compile with -DNX_BLOCKASSERTS to turn off asserts in your code
- */
-
- #ifndef NX_BLOCKASSERTS
- extern void NSLog(NSString *format, ...);
- #define NX_ASSERT(exp,str) {if(!(exp)) NSLog(@"Assertion failed: %s\n", str);}
- #else NX_BLOCKASSERTS
- #define NX_ASSERT(exp,str) {}
- #endif NX_BLOCKASSERTS
-
- /*
- * Used to insert messages in showps output. If you use this macro, you can
- * compile with -DNX_BLOCKPSDEBUG to turn it off. Note that it only writes
- * its messages when showps is on.
- */
-
- #ifndef NX_BLOCKPSDEBUG
- #define NX_PSDEBUG() {if ((DPSGetCurrentContext())->chainChild && (DPSGetCurrentContext())->chainChild->programEncoding == dps_ascii) DPSPrintf( DPSGetCurrentContext(),"\n%% *** Debug *** Object:%d Class:%s Method:%s\n", ((int)self), ([[self class] description]), SELNAME(_cmd));}
- #else NX_BLOCKPSDEBUG
- #define NX_PSDEBUG() {}
- #endif NX_BLOCKPSDEBUG
-
- #endif
-