2 * Copyright 2007-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Niels Sascha Reedijk, niels.reedijk@gmail.com
7 * John Scipione, jscipione@gmail.com
10 * headers/os/support/SupportDefs.h rev 35018
18 \brief Defines basic types and definitions for the Haiku API.
23 \name Fixed-Size Integer Types
31 \typedef typedef __haiku_int8 int8
36 \typedef typedef __haiku_uint8 uint8
41 \typedef typedef __haiku_int16 int16
46 \typedef typedef __haiku_uint16 uint16
51 \typedef typedef __haiku_int32 int32
56 \typedef typedef __haiku_uint32 uint32
61 \typedef typedef __haiku_int64 int64
66 \typedef typedef __haiku_uint64 uint64
74 \name Fixed-size Volatile Types
82 \typedef typedef volatile int8 vint8
87 \typedef typedef volatile uint8 vuint8
92 \typedef typedef volatile int16 vint16
97 \typedef typedef volatile uint16 vuint16
102 \typedef typedef volatile int32 vint32
107 \typedef typedef volatile uint32 vuint32
112 \typedef typedef volatile int64 vint64
117 \typedef typedef volatile uint64 vuint64
125 \name Short-hand Volatile Type Names
133 \typedef typedef volatile long vlong
138 \typedef typedef volatile int vint
143 \typedef typedef volatile short vshort
148 \typedef typedef volatile char vchar
153 \typedef typedef volatile unsigned long vulong
158 \typedef typedef volatile unsigned int vuint
163 \typedef typedef volatile unsigned short vushort
168 \typedef typedef volatile unsigned char vuchar
176 \name Character Type Formats
184 \typedef typedef unsigned char uchar
189 \typedef typedef unsigned short unichar
197 \name Descriptive Type Formats
205 \typedef typedef int32 status_t
206 \brief Represents one of the status codes defined in Errors.h.
213 \typedef typedef int64 bigtime_t
214 \brief Represents time. The unit depends on the context of the function.
221 \typedef typedef int64 nanotime_t
222 \brief Represents time in nanoseconds.
227 \typedef typedef uint32 type_code
228 \brief Represents a certain type of data. See TypeConstants.h for
236 \typedef typedef uint32 perform_code
237 \brief Defined to support 'hidden' commands or extensions to classes.
239 The Haiku API has none of these.
249 \name Format strings for printf() and scanf()
480 \name Format strings for several standard types
598 //////////////// Odds and ends
602 \var const char* B_EMPTY_STRING
603 \brief Defines an empty string. Currently defined as the string "".
611 \brief Returns the minimum of the values a and b.
613 \note When including this header in a C file, use the C equivalent called
622 \brief Returns the maximum of values a and b.
624 \note When including this header in a C file, use the C equivalent called
633 \brief Defines the constant \c NULL if it hasn't already been defined.
640 \addtogroup support_globals
648 \fn void atomic_set(int32* value, int32 newValue)
649 \brief Atomically set the variable \a value to \a newvalue.
651 This is a thread-safe way of performing the \c *value \c = \c newValue
652 operation. You should use these function when two or more threads might
653 access the variable simultaneously. You don't have to use a semaphore or a
654 mutex in this case. The variable must be naturally aligned.
656 \sa atomic_set64() for a version that works on \c long \c long.
657 \sa atomic_test_and_set()
667 /*! \fn int32 atomic_get_and_set(int32* value, int32 newValue)
668 \brief Atomically set the variable \a value to \a newvalue and return the
671 This is a thread-safe way of performing the \c *value \c = \c newValue
672 operation. You should use these function when two or more threads might
673 access the variable simultaneously. You don't have to use a semaphore or a
676 \return The original value of \c value.
678 \sa atomic_get_and_set64() for a version that works on \c long \c long.
680 \sa atomic_test_and_set()
690 /*! \fn int32 atomic_test_and_set(int32* value, int32 newValue,
692 \brief Atomically set the variable \a value to \a newValue if the current
693 value is \a testAgainst.
695 This is a thread-safe way of conditionally performing the \c *value \c +=
696 \c newValue operation. You should use these function when two or more
697 threads might access the variable simultaneously. You don't have to use
698 a semaphore or a mutex in this case.
700 \return The original value of \c value.
702 \sa atomic_test_and_set64() for a version that works on \c long \c long.
703 \sa atomic_get_and_set()
715 \fn int32 atomic_add(int32* value, int32 addValue)
716 \brief Atomically add the value of \a addValue to \a value.
718 This is a thread-safe way of performing the \c *value \c += \c addValue
719 operation. You should use these function when two or more threads might
720 access the variable simultaneously. You don't have to use a semaphore or a
723 \return The original value of \c value.
725 \sa atomic_add64() for a version that works on \c long \c long.
726 \sa atomic_get_and_set()
728 \sa atomic_test_and_set()
737 /*! \fn int32 atomic_and(int32* value, int32 andValue)
738 \brief Atomically perform a bitwise AND operation of \a andValue to the
739 variable \a andValue.
741 This is a thread-safe way of performing the \c *value \c &= \c andValue
742 operation. You should use these function when two or more threads might
743 access the variable simultaneously. You don't have to use a semaphore or a
746 \return The original value of \c value.
748 \sa atomic_and64() for a version that works on \c long \c long.
749 \sa atomic_get_and_set()
751 \sa atomic_test_and_set()
761 \fn int32 atomic_or(int32* value, int32 orValue)
762 \brief Atomically perform a bitwise OR operation of \a orValue to the
763 variable \a andValue.
765 This is a thread-safe way of performing the \c *value \c |= \c orValue
766 operation. You should use these function when two or more threads might
767 access the variable simultaneously. You don't have to use a semaphore or a
770 \return The original value of \c value.
772 \sa atomic_or64() for a version that works on \c long \c long.
773 \sa atomic_get_and_set()
775 \sa atomic_test_and_set()
785 \fn int32 atomic_get(int32* value)
786 \brief Atomically return the value of \c value.
788 This is a thread-safe way of reading the contents of the \c value
789 operation. You should use these function when two or more threads might
790 access the variable simultaneously. You don't have to use a semaphore or a
791 mutex in this case. The variable must be naturally aligned.
793 \return The original value of \c value.
795 \sa atomic_get64() for a version that works on \c long \c long.
796 \sa atomic_get_and_set()
798 \sa atomic_test_and_set()
808 \fn void atomic_set64(int64* value, int64 newValue)
809 \brief Atomically set the variable \a value to \a newvalue.
811 This is a thread-safe way of performing the \c *value \c = \c newValue
812 operation. You should use these function when two or more threads might
813 access the variable simultaneously. You don't have to use a semaphore or a
814 mutex in this case. The variable must be naturally aligned.
816 \sa atomic_set() for a version that works on an \c int32.
817 \sa atomic_get_and_set64()
818 \sa atomic_test_and_set64()
829 \fn int64 atomic_get_and_set64(int64* value, int64 newValue)
830 \brief Atomically set the variable \a value to \a newvalue and return
833 This is a thread-safe way of performing the \c *value \c = \c newValue
834 operation. You should use these function when two or more threads might
835 access the variable simultaneously. You don't have to use a semaphore or a
838 \return The original value of \c value.
840 \sa atomic_get_and_set() for a version that works on an \c int32.
842 \sa atomic_test_and_set64()
853 \fn int64 atomic_test_and_set64(int64* value, int64 newValue,
855 \brief Atomically set the variable \a value to \a newValue if the current
856 value is \a testAgainst.
858 This is a thread-safe way of conditionally performing the \c *value
859 \c += \c newValue operation. You should use these function when two
860 or more threads might access the variable simultaneously. You don't
861 have to use a semaphore or a mutex in this case.
863 \return The original value of \c value.
865 \sa atomic_test_and_set() for a version that works on an \c int32.
866 \sa atomic_get_and_set64()
878 \fn int64 atomic_add64(int64* value, int64 addValue)
879 \brief Atomically add the value of \a addValue to \a value.
881 This is a thread-safe way of performing the \c *value \c += \c addValue
882 operation. You should use these function when two or more threads might
883 access the variable simultaneously. You don't have to use a semaphore or a
886 \return The original value of \c value.
888 \sa atomic_add() for a version that works on an \c int32.
889 \sa atomic_get_and_set64()
891 \sa atomic_test_and_set64()
901 \fn int64 atomic_and64(int64* value, int64 andValue)
902 \brief Atomically perform a bitwise AND operation of \a andValue to the
903 variable \a andValue.
905 This is a thread-safe way of performing the \c *value \c &= \c andValue
906 operation. You should use these function when two or more threads might
907 access the variable simultaneously. You don't have to use a semaphore or a
910 \return The original value of \c value.
912 \sa atomic_and() for a version that works on an \c int32.
913 \sa atomic_get_and_set64()
915 \sa atomic_test_and_set64()
925 \fn int64 atomic_or64(int64* value, int64 orValue)
926 \brief Atomically perform a bitwise OR operation of \a orValue to the
927 variable \a andValue.
929 This is a thread-safe way of performing the \c *value \c |= \c orValue
930 operation. You should use these function when two or more threads might
931 access the variable simultaneously. You don't have to use a semaphore or a
934 \return The original value of \c value.
936 \sa atomic_or() for a version that works on an \c int32.
937 \sa atomic_get_and_set64()
939 \sa atomic_test_and_set64()
949 \fn int64 atomic_get64(int64* value)
950 \brief Atomically return the value of \c value.
952 This is a thread-safe way of reading the contents of the \c value
953 operation. You should use these function when two or more threads might
954 access the variable simultaneously. You don't have to use a semaphore or a
955 mutex in this case. The variable must be naturally aligned.
957 \return The original value of \c value.
959 \sa atomic_get() for a version that works on an \c int32.
960 \sa atomic_get_and_set64()
962 \sa atomic_test_and_set64()
975 \fn void* get_stack_frame(void)
976 \brief Internal function.
982 \name Deprecated defines
991 \brief Obsolete. Use \c false.
999 \brief Obsolete. Use \c true.