Descent3/lib/Macros.h

78 lines
2.2 KiB
C
Raw Normal View History

2024-04-16 03:43:29 +00:00
/*
* $Logfile: /DescentIII/Main/Lib/Macros.h $
* $Revision: 11 $
* $Date: 10/21/99 9:28p $
* $Author: Jeff $
*
* Macros.
*
* $Log: /DescentIII/Main/Lib/Macros.h $
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 11 10/21/99 9:28p Jeff
* B.A. Macintosh code merge
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 10 7/28/99 5:18p Kevin
* Mac merge fixes
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 9 7/28/99 3:17p Kevin
* Mac Changes
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 8 12/16/98 1:57p Samir
* Replaced CleanupString2 with CleanupStr
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 7 12/02/98 11:44a Samir
* added CHECK_FLAG macro
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 6 8/10/98 5:53p Samir
* macro to convert KB to bytes.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 5 7/14/98 11:52a Samir
* added cleanup string 'macro'.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 4 5/15/98 3:13p Samir
* added some ushort/byte macros.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 3 3/31/98 7:48p Samir
* fixed horrible makeword macro bug.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 2 12/03/97 7:37p Samir
* Added makeword, hiword and loword macros.
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* $NoKeywords: $
*/
#ifndef _MACROS_H
#define _MACROS_H
2024-04-16 18:56:40 +00:00
#define SWAP(a, b) \
do { \
int _swap_var_ = (a); \
(a) = (b); \
(b) = _swap_var_; \
} while (0)
#define SET_MIN(a, b) (((a) < (b)) ? (a) : (b))
2024-04-16 03:43:29 +00:00
#define CHECK_FLAG(_var, _flag) ((_var) & (_flag))
2024-04-16 18:56:40 +00:00
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define makeword(_h, _l) (((_h) << 16) + ((_l)&0xffff))
#define hiword(_v) ((_v) >> 16)
#define loword(_v) ((_v)&0x0000ffff)
#define makeshort(_h, _l) (((_h) << 8) + ((_l)&0x00ff))
#define hibyte(_w) ((_w) >> 8)
#define lobyte(_w) ((_w)&0x00ff)
#define kb_to_bytes(_kb) ((_kb)*1024)
#define _min(a, b) min(a, b)
#define _max(a, b) max(a, b)
#define ABS(a) ((a < 0) ? (-a) : (a))
2024-04-16 03:43:29 +00:00
#ifndef WIN32
2024-04-16 18:56:40 +00:00
#define __min(a, b) min(a, b)
#define __max(a, b) max(a, b)
2024-04-16 03:43:29 +00:00
#endif
#ifdef LINUX
2024-04-16 18:56:40 +00:00
#define stricmp(a, b) strcasecmp(a, b)
2024-04-16 03:43:29 +00:00
#define _fstat32 fstat
#define _stat stat
#endif
#endif