2007-01-26 19:36:29 +03:00
|
|
|
/*
|
2014-06-25 03:25:27 +04:00
|
|
|
* Copyright 2004-2010 Haiku, Inc. All rights reserved.
|
2007-01-26 19:36:29 +03:00
|
|
|
* 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
|
|
|
|
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
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
#include <inttypes.h>
|
2007-01-26 19:36:29 +03:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* fixed-size integer types */
|
|
|
|
typedef __haiku_int8 int8;
|
|
|
|
typedef __haiku_uint8 uint8;
|
|
|
|
typedef __haiku_int16 int16;
|
|
|
|
typedef __haiku_uint16 uint16;
|
|
|
|
typedef __haiku_int32 int32;
|
|
|
|
typedef __haiku_uint32 uint32;
|
|
|
|
typedef __haiku_int64 int64;
|
|
|
|
typedef __haiku_uint64 uint64;
|
|
|
|
|
|
|
|
/* shorthand types */
|
2015-04-04 16:49:19 +03:00
|
|
|
typedef volatile int8 vint8;
|
2009-11-24 22:44:07 +03:00
|
|
|
typedef volatile uint8 vuint8;
|
|
|
|
typedef volatile int16 vint16;
|
|
|
|
typedef volatile uint16 vuint16;
|
|
|
|
typedef volatile int32 vint32;
|
|
|
|
typedef volatile uint32 vuint32;
|
|
|
|
typedef volatile int64 vint64;
|
|
|
|
typedef volatile uint64 vuint64;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
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;
|
2015-04-04 16:49:19 +03:00
|
|
|
typedef unsigned short unichar;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* descriptive types */
|
2002-07-09 16:24:59 +04:00
|
|
|
typedef int32 status_t;
|
|
|
|
typedef int64 bigtime_t;
|
2009-12-08 00:43:19 +03:00
|
|
|
typedef int64 nanotime_t;
|
2002-07-09 16:24:59 +04:00
|
|
|
typedef uint32 type_code;
|
|
|
|
typedef uint32 perform_code;
|
|
|
|
|
2010-05-25 15:18:38 +04:00
|
|
|
typedef __haiku_phys_addr_t phys_addr_t;
|
|
|
|
typedef phys_addr_t phys_size_t;
|
|
|
|
|
2010-06-02 22:22:38 +04:00
|
|
|
typedef __haiku_generic_addr_t generic_addr_t;
|
|
|
|
typedef generic_addr_t generic_size_t;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* printf()/scanf() format strings for [u]int* types */
|
2009-11-24 23:30:01 +03:00
|
|
|
#define B_PRId8 "d"
|
|
|
|
#define B_PRIi8 "i"
|
|
|
|
#define B_PRId16 "d"
|
|
|
|
#define B_PRIi16 "i"
|
|
|
|
#define B_PRId32 __HAIKU_PRI_PREFIX_32 "d"
|
|
|
|
#define B_PRIi32 __HAIKU_PRI_PREFIX_32 "i"
|
|
|
|
#define B_PRId64 __HAIKU_PRI_PREFIX_64 "d"
|
|
|
|
#define B_PRIi64 __HAIKU_PRI_PREFIX_64 "i"
|
|
|
|
#define B_PRIu8 "u"
|
|
|
|
#define B_PRIo8 "o"
|
|
|
|
#define B_PRIx8 "x"
|
|
|
|
#define B_PRIX8 "X"
|
|
|
|
#define B_PRIu16 "u"
|
|
|
|
#define B_PRIo16 "o"
|
|
|
|
#define B_PRIx16 "x"
|
|
|
|
#define B_PRIX16 "X"
|
|
|
|
#define B_PRIu32 __HAIKU_PRI_PREFIX_32 "u"
|
|
|
|
#define B_PRIo32 __HAIKU_PRI_PREFIX_32 "o"
|
|
|
|
#define B_PRIx32 __HAIKU_PRI_PREFIX_32 "x"
|
|
|
|
#define B_PRIX32 __HAIKU_PRI_PREFIX_32 "X"
|
|
|
|
#define B_PRIu64 __HAIKU_PRI_PREFIX_64 "u"
|
|
|
|
#define B_PRIo64 __HAIKU_PRI_PREFIX_64 "o"
|
|
|
|
#define B_PRIx64 __HAIKU_PRI_PREFIX_64 "x"
|
|
|
|
#define B_PRIX64 __HAIKU_PRI_PREFIX_64 "X"
|
2009-11-24 22:44:07 +03:00
|
|
|
|
2015-04-04 16:49:19 +03:00
|
|
|
#define B_SCNd8 "hhd"
|
|
|
|
#define B_SCNi8 "hhi"
|
2009-11-24 23:30:01 +03:00
|
|
|
#define B_SCNd16 "hd"
|
2015-04-04 16:49:19 +03:00
|
|
|
#define B_SCNi16 "hi"
|
|
|
|
#define B_SCNd32 __HAIKU_PRI_PREFIX_32 "d"
|
|
|
|
#define B_SCNi32 __HAIKU_PRI_PREFIX_32 "i"
|
2009-11-24 23:30:01 +03:00
|
|
|
#define B_SCNd64 __HAIKU_PRI_PREFIX_64 "d"
|
2015-04-04 16:49:19 +03:00
|
|
|
#define B_SCNi64 __HAIKU_PRI_PREFIX_64 "i"
|
|
|
|
#define B_SCNu8 "hhu"
|
|
|
|
#define B_SCNo8 "hho"
|
|
|
|
#define B_SCNx8 "hhx"
|
2009-11-24 23:30:01 +03:00
|
|
|
#define B_SCNu16 "hu"
|
|
|
|
#define B_SCNo16 "ho"
|
|
|
|
#define B_SCNx16 "hx"
|
2015-04-04 16:49:19 +03:00
|
|
|
#define B_SCNu32 __HAIKU_PRI_PREFIX_32 "u"
|
|
|
|
#define B_SCNo32 __HAIKU_PRI_PREFIX_32 "o"
|
|
|
|
#define B_SCNx32 __HAIKU_PRI_PREFIX_32 "x"
|
2009-11-24 23:30:01 +03:00
|
|
|
#define B_SCNu64 __HAIKU_PRI_PREFIX_64 "u"
|
|
|
|
#define B_SCNo64 __HAIKU_PRI_PREFIX_64 "o"
|
|
|
|
#define B_SCNx64 __HAIKU_PRI_PREFIX_64 "x"
|
2009-11-24 22:44:07 +03:00
|
|
|
|
2015-04-04 16:54:10 +03:00
|
|
|
/* printf()/scanf() format strings for some standard types */
|
2009-11-24 22:44:07 +03:00
|
|
|
/* size_t */
|
|
|
|
#define B_PRIuSIZE __HAIKU_PRI_PREFIX_ADDR "u"
|
|
|
|
#define B_PRIoSIZE __HAIKU_PRI_PREFIX_ADDR "o"
|
|
|
|
#define B_PRIxSIZE __HAIKU_PRI_PREFIX_ADDR "x"
|
|
|
|
#define B_PRIXSIZE __HAIKU_PRI_PREFIX_ADDR "X"
|
2015-04-04 16:54:10 +03:00
|
|
|
|
|
|
|
#define B_SCNuSIZE __HAIKU_PRI_PREFIX_ADDR "u"
|
|
|
|
#define B_SCNoSIZE __HAIKU_PRI_PREFIX_ADDR "o"
|
|
|
|
#define B_SCNxSIZE __HAIKU_PRI_PREFIX_ADDR "x"
|
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* ssize_t */
|
|
|
|
#define B_PRIdSSIZE __HAIKU_PRI_PREFIX_ADDR "d"
|
|
|
|
#define B_PRIiSSIZE __HAIKU_PRI_PREFIX_ADDR "i"
|
2015-04-04 16:54:10 +03:00
|
|
|
|
|
|
|
#define B_SCNdSSIZE __HAIKU_PRI_PREFIX_ADDR "d"
|
|
|
|
#define B_SCNiSSIZE __HAIKU_PRI_PREFIX_ADDR "i"
|
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* addr_t */
|
|
|
|
#define B_PRIuADDR __HAIKU_PRI_PREFIX_ADDR "u"
|
|
|
|
#define B_PRIoADDR __HAIKU_PRI_PREFIX_ADDR "o"
|
|
|
|
#define B_PRIxADDR __HAIKU_PRI_PREFIX_ADDR "x"
|
|
|
|
#define B_PRIXADDR __HAIKU_PRI_PREFIX_ADDR "X"
|
2015-04-04 16:54:10 +03:00
|
|
|
|
|
|
|
#define B_SCNuADDR __HAIKU_PRI_PREFIX_ADDR "u"
|
|
|
|
#define B_SCNoADDR __HAIKU_PRI_PREFIX_ADDR "o"
|
|
|
|
#define B_SCNxADDR __HAIKU_PRI_PREFIX_ADDR "x"
|
|
|
|
|
* config/{HaikuConfig.h,types.h}:
- Added macro __HAIKU_ARCH_BITS specifying the architecture bitness (32/64)
(might be more convenient to use than __HAIKU_ARCH_{32,64}_BIT).
- Added macros __HAIKU_ARCH_PHYSICAL_BITS, __HAIKU_ARCH_PHYSICAL_{32,64}_BIT,
and the types __haiku_phys_[s]addr_t. The intention is to use separate
macros and types for virtual and physical addresses, since for some
architectures (e.g. x86 with PAE) those actually differ.
* sys/types.h, BeBuild.h, SupportDefs.h:
- Added types phys_[s]addr_t and respective printf() format macros.
- Added public macros B_HAIKU_BITS, B_HAIKU_PHYSICAL_BITS,
B_HAIKU_PHYSICAL_{32,64}_BIT.
Might break the build under older Haiku installations. Will test next.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36926 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-05-24 23:55:38 +04:00
|
|
|
/* phys_addr_t */
|
|
|
|
#define B_PRIuPHYSADDR __HAIKU_PRI_PREFIX_PHYS_ADDR "u"
|
|
|
|
#define B_PRIoPHYSADDR __HAIKU_PRI_PREFIX_PHYS_ADDR "o"
|
|
|
|
#define B_PRIxPHYSADDR __HAIKU_PRI_PREFIX_PHYS_ADDR "x"
|
|
|
|
#define B_PRIXPHYSADDR __HAIKU_PRI_PREFIX_PHYS_ADDR "X"
|
2015-04-04 16:54:10 +03:00
|
|
|
|
|
|
|
#define B_SCNuPHYSADDR __HAIKU_PRI_PREFIX_PHYS_ADDR "u"
|
|
|
|
#define B_SCNoPHYSADDR __HAIKU_PRI_PREFIX_PHYS_ADDR "o"
|
|
|
|
#define B_SCNxPHYSADDR __HAIKU_PRI_PREFIX_PHYS_ADDR "x"
|
|
|
|
|
2010-06-02 22:22:38 +04:00
|
|
|
/* generic_addr_t */
|
|
|
|
#define B_PRIuGENADDR __HAIKU_PRI_PREFIX_GENERIC_ADDR "u"
|
|
|
|
#define B_PRIoGENADDR __HAIKU_PRI_PREFIX_GENERIC_ADDR "o"
|
|
|
|
#define B_PRIxGENADDR __HAIKU_PRI_PREFIX_GENERIC_ADDR "x"
|
|
|
|
#define B_PRIXGENADDR __HAIKU_PRI_PREFIX_GENERIC_ADDR "X"
|
2015-04-04 16:54:10 +03:00
|
|
|
|
|
|
|
#define B_SCNuGENADDR __HAIKU_PRI_PREFIX_GENERIC_ADDR "u"
|
|
|
|
#define B_SCNoGENADDR __HAIKU_PRI_PREFIX_GENERIC_ADDR "o"
|
|
|
|
#define B_SCNxGENADDR __HAIKU_PRI_PREFIX_GENERIC_ADDR "x"
|
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* off_t */
|
|
|
|
#define B_PRIdOFF B_PRId64
|
|
|
|
#define B_PRIiOFF B_PRIi64
|
2013-05-04 15:40:12 +04:00
|
|
|
#define B_PRIxOFF B_PRIx64
|
2015-04-04 16:54:10 +03:00
|
|
|
|
|
|
|
#define B_SCNdOFF B_SCNd64
|
|
|
|
#define B_SCNiOFF B_SCNi64
|
|
|
|
#define B_SCNxOFF B_SCNx64
|
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* dev_t */
|
|
|
|
#define B_PRIdDEV B_PRId32
|
|
|
|
#define B_PRIiDEV B_PRIi32
|
2015-04-04 16:54:10 +03:00
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* ino_t */
|
|
|
|
#define B_PRIdINO B_PRId64
|
|
|
|
#define B_PRIiINO B_PRIi64
|
2015-04-04 16:54:10 +03:00
|
|
|
|
2009-11-25 15:02:20 +03:00
|
|
|
/* time_t */
|
|
|
|
#define B_PRIdTIME B_PRId32
|
|
|
|
#define B_PRIiTIME B_PRIi32
|
2015-04-04 16:54:10 +03:00
|
|
|
|
2013-05-04 13:15:41 +04:00
|
|
|
/* bigtime_t */
|
|
|
|
#define B_PRIdBIGTIME B_PRId64
|
|
|
|
#define B_PRIiBIGTIME B_PRIi64
|
2009-11-24 22:44:07 +03:00
|
|
|
|
|
|
|
|
2012-07-12 14:29:33 +04:00
|
|
|
/* Printed width of a pointer with the %p format (minus 0x prefix). */
|
|
|
|
#ifdef B_HAIKU_64_BIT
|
|
|
|
# define B_PRINTF_POINTER_WIDTH 16
|
|
|
|
#else
|
|
|
|
# define B_PRINTF_POINTER_WIDTH 8
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-11-11 02:50:42 +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
|
|
|
|
|
|
|
|
|
2008-11-11 02:50:42 +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
|
2009-11-24 22:44:07 +03:00
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-11-24 22:44:07 +03:00
|
|
|
/* min() and max() are functions in C++ */
|
2007-01-26 19:36:29 +03:00
|
|
|
#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
|
|
|
|
2008-11-11 02:50:42 +03:00
|
|
|
/* Grandfathering */
|
2005-03-26 21:01:40 +03:00
|
|
|
#ifndef __cplusplus
|
|
|
|
# include <stdbool.h>
|
2009-11-24 22:44:07 +03:00
|
|
|
#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
|
|
|
|
|
2008-11-11 02:50:42 +03:00
|
|
|
/* Other stuff */
|
2007-01-26 19:36:29 +03:00
|
|
|
extern void* get_stack_frame(void);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-09 23:47:39 +03:00
|
|
|
/* Count items in an array, count_of is a common define */
|
|
|
|
#define B_COUNT_OF(a) (sizeof(a) / sizeof(a[0]))
|
|
|
|
|
2008-11-11 02:50:42 +03:00
|
|
|
/* Obsolete or discouraged API */
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-11-11 02:50:42 +03:00
|
|
|
/* use 'true' and 'false' */
|
2002-07-09 16:24:59 +04:00
|
|
|
#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
|
|
|
|
|
2010-01-12 00:38:07 +03:00
|
|
|
|
|
|
|
/* Use the built-in atomic functions, if requested and available. */
|
|
|
|
|
2014-08-25 17:44:12 +04:00
|
|
|
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
|
2014-08-25 16:55:55 +04:00
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ void
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_set(int32* value, int32 newValue)
|
|
|
|
{
|
|
|
|
__atomic_store_n(value, newValue, __ATOMIC_RELEASE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int32
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_get_and_set(int32* value, int32 newValue)
|
|
|
|
{
|
|
|
|
return __atomic_exchange_n(value, newValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int32
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_test_and_set(int32* value, int32 newValue, int32 testAgainst)
|
|
|
|
{
|
|
|
|
__atomic_compare_exchange_n(value, &testAgainst, newValue, 1,
|
|
|
|
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
|
|
|
return testAgainst;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int32
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_add(int32* value, int32 addValue)
|
|
|
|
{
|
|
|
|
return __atomic_fetch_add(value, addValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int32
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_and(int32* value, int32 andValue)
|
|
|
|
{
|
|
|
|
return __atomic_fetch_and(value, andValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int32
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_or(int32* value, int32 orValue)
|
|
|
|
{
|
|
|
|
return __atomic_fetch_or(value, orValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int32
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_get(int32* value)
|
|
|
|
{
|
|
|
|
return __atomic_load_n(value, __ATOMIC_ACQUIRE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ void
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_set64(int64* value, int64 newValue)
|
|
|
|
{
|
|
|
|
__atomic_store_n(value, newValue, __ATOMIC_RELEASE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int64
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_get_and_set64(int64* value, int64 newValue)
|
|
|
|
{
|
|
|
|
return __atomic_exchange_n(value, newValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int64
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_test_and_set64(int64* value, int64 newValue, int64 testAgainst)
|
|
|
|
{
|
|
|
|
__atomic_compare_exchange_n(value, &testAgainst, newValue, 1,
|
|
|
|
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
|
|
|
return testAgainst;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int64
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_add64(int64* value, int64 addValue)
|
|
|
|
{
|
|
|
|
return __atomic_fetch_add(value, addValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int64
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_and64(int64* value, int64 andValue)
|
|
|
|
{
|
|
|
|
return __atomic_fetch_and(value, andValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
2010-01-12 00:38:07 +03:00
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int64
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_or64(int64* value, int64 orValue)
|
|
|
|
{
|
|
|
|
return __atomic_fetch_or(value, orValue, __ATOMIC_SEQ_CST);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
static __inline__ int64
|
2014-08-25 16:55:55 +04:00
|
|
|
atomic_get64(int64* value)
|
|
|
|
{
|
|
|
|
return __atomic_load_n(value, __ATOMIC_ACQUIRE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-19 15:54:18 +03:00
|
|
|
#else /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) */
|
2010-01-12 00:38:07 +03:00
|
|
|
|
2014-08-25 16:55:55 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Atomic functions; previous value is returned */
|
|
|
|
extern void atomic_set(int32* value, int32 newValue);
|
|
|
|
extern int32 atomic_get_and_set(int32* value, int32 newValue);
|
|
|
|
extern int32 atomic_test_and_set(int32 *value, int32 newValue, int32 testAgainst);
|
|
|
|
extern int32 atomic_add(int32 *value, int32 addValue);
|
|
|
|
extern int32 atomic_and(int32 *value, int32 andValue);
|
|
|
|
extern int32 atomic_or(int32 *value, int32 orValue);
|
|
|
|
extern int32 atomic_get(int32 *value);
|
|
|
|
|
|
|
|
extern void atomic_set64(int64* value, int64 newValue);
|
|
|
|
extern int64 atomic_get_and_set64(int64* value, int64 newValue);
|
|
|
|
extern int64 atomic_test_and_set64(int64 *value, int64 newValue, int64 testAgainst);
|
|
|
|
extern int64 atomic_add64(int64 *value, int64 addValue);
|
|
|
|
extern int64 atomic_and64(int64 *value, int64 andValue);
|
|
|
|
extern int64 atomic_or64(int64 *value, int64 orValue);
|
|
|
|
extern int64 atomic_get64(int64 *value);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2010-01-12 00:38:07 +03:00
|
|
|
|
|
|
|
|
2008-11-11 02:50:42 +03:00
|
|
|
#endif /* _SUPPORT_DEFS_H */
|