2007-01-26 19:36:29 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2004-2007, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Author:
|
|
|
|
* Erik Jaesler (erik@cgsoftware.com)
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _SUPPORT_DEFS_H
|
|
|
|
#define _SUPPORT_DEFS_H
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
|
|
|
|
/* this must be located before the include of sys/types.h */
|
2004-05-26 20:54:54 +04:00
|
|
|
#if !defined(_SYS_TYPES_H) && !defined(_SYS_TYPES_H_)
|
2002-08-28 21:26:06 +04:00
|
|
|
typedef unsigned long ulong;
|
|
|
|
typedef unsigned int uint;
|
|
|
|
typedef unsigned short ushort;
|
2005-03-26 21:01:40 +03:00
|
|
|
#endif
|
2002-08-28 21:26:06 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <BeBuild.h>
|
2003-05-14 21:21:46 +04:00
|
|
|
#include <Errors.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// Shorthand type formats
|
2002-07-09 16:24:59 +04:00
|
|
|
typedef signed char int8;
|
|
|
|
typedef unsigned char uint8;
|
|
|
|
typedef volatile signed char vint8;
|
|
|
|
typedef volatile unsigned char vuint8;
|
|
|
|
|
|
|
|
typedef short int16;
|
|
|
|
typedef unsigned short uint16;
|
|
|
|
typedef volatile short vint16;
|
|
|
|
typedef volatile unsigned short vuint16;
|
|
|
|
|
|
|
|
typedef long int32;
|
|
|
|
typedef unsigned long uint32;
|
|
|
|
typedef volatile long vint32;
|
|
|
|
typedef volatile unsigned long vuint32;
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
typedef long long int64;
|
|
|
|
typedef unsigned long long uint64;
|
|
|
|
typedef volatile long long vint64;
|
2002-07-09 16:24:59 +04:00
|
|
|
typedef volatile unsigned long long vuint64;
|
|
|
|
|
|
|
|
typedef volatile long vlong;
|
|
|
|
typedef volatile int vint;
|
|
|
|
typedef volatile short vshort;
|
|
|
|
typedef volatile char vchar;
|
|
|
|
|
|
|
|
typedef volatile unsigned long vulong;
|
|
|
|
typedef volatile unsigned int vuint;
|
|
|
|
typedef volatile unsigned short vushort;
|
|
|
|
typedef volatile unsigned char vuchar;
|
|
|
|
|
|
|
|
typedef unsigned char uchar;
|
|
|
|
typedef unsigned short unichar;
|
|
|
|
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// Descriptive formats
|
2002-07-09 16:24:59 +04:00
|
|
|
typedef int32 status_t;
|
|
|
|
typedef int64 bigtime_t;
|
|
|
|
typedef uint32 type_code;
|
|
|
|
typedef uint32 perform_code;
|
|
|
|
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// Empty string ("")
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifdef __cplusplus
|
2007-01-26 19:36:29 +03:00
|
|
|
extern const char *B_EMPTY_STRING;
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// min and max comparisons
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef __cplusplus
|
2005-03-26 21:01:40 +03:00
|
|
|
# ifndef min
|
|
|
|
# define min(a,b) ((a)>(b)?(b):(a))
|
|
|
|
# endif
|
|
|
|
# ifndef max
|
|
|
|
# define max(a,b) ((a)>(b)?(a):(b))
|
|
|
|
# endif
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// min() and max() won't work in C++
|
|
|
|
#define min_c(a,b) ((a)>(b)?(b):(a))
|
|
|
|
#define max_c(a,b) ((a)>(b)?(a):(b))
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// Grandfathering
|
2005-03-26 21:01:40 +03:00
|
|
|
#ifndef __cplusplus
|
|
|
|
# include <stdbool.h>
|
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#ifndef NULL
|
2005-03-26 21:01:40 +03:00
|
|
|
# define NULL (0)
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// Atomic functions; previous value is returned
|
|
|
|
extern int32 atomic_set(vint32 *value, int32 newValue);
|
|
|
|
extern int32 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst);
|
|
|
|
extern int32 atomic_add(vint32 *value, int32 addValue);
|
|
|
|
extern int32 atomic_and(vint32 *value, int32 andValue);
|
|
|
|
extern int32 atomic_or(vint32 *value, int32 orValue);
|
|
|
|
extern int32 atomic_get(vint32 *value);
|
2003-08-20 06:08:13 +04:00
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
extern int64 atomic_set64(vint64 *value, int64 newValue);
|
|
|
|
extern int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst);
|
|
|
|
extern int64 atomic_add64(vint64 *value, int64 addValue);
|
|
|
|
extern int64 atomic_and64(vint64 *value, int64 andValue);
|
|
|
|
extern int64 atomic_or64(vint64 *value, int64 orValue);
|
|
|
|
extern int64 atomic_get64(vint64 *value);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// Other stuff
|
|
|
|
extern void* get_stack_frame(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-01-26 19:36:29 +03:00
|
|
|
// Obsolete or discouraged API
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// use 'true' and 'false'
|
|
|
|
#ifndef FALSE
|
2005-03-26 21:01:40 +03:00
|
|
|
# define FALSE 0
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
#ifndef TRUE
|
2005-03-26 21:01:40 +03:00
|
|
|
# define TRUE 1
|
2002-07-09 16:24:59 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // _SUPPORT_DEFS_H
|