1/* 2 * Copyright 2007-2014 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Niels Sascha Reedijk, niels.reedijk@gmail.com 7 * John Scipione, jscipione@gmail.com 8 * 9 * Corresponds to: 10 * headers/os/support/SupportDefs.h hrev51198 11 */ 12 13 14/*! 15 \file SupportDefs.h 16 \ingroup support 17 \ingroup libbe 18 \brief Defines basic types and definitions for the Haiku API. 19*/ 20 21 22/*! 23 \name Fixed-Size Integer Types 24*/ 25 26 27//! @{ 28 29 30/*! 31 \typedef typedef __haiku_int8 int8 32 \brief 1-byte signed integer. 33*/ 34 35 36/*! 37 \typedef typedef __haiku_uint8 uint8 38 \brief 1-byte unsigned integer. 39*/ 40 41 42/*! 43 \typedef typedef __haiku_int16 int16 44 \brief 2-bytes signed integer. 45*/ 46 47 48/*! 49 \typedef typedef __haiku_uint16 uint16 50 \brief 2-bytes unsigned integer. 51*/ 52 53 54/*! 55 \typedef typedef __haiku_int32 int32 56 \brief 4-bytes signed integer. 57*/ 58 59 60/*! 61 \typedef typedef __haiku_uint32 uint32 62 \brief 4-bytes unsigned integer. 63*/ 64 65 66/*! 67 \typedef typedef __haiku_int64 int64 68 \brief 8-bytes signed integer. 69*/ 70 71 72/*! 73 \typedef typedef __haiku_uint64 uint64 74 \brief 8-bytes unsigned integer. 75*/ 76 77 78//! @} 79 80 81/*! 82 \name Fixed-size Volatile Types 83*/ 84 85 86//! @{ 87 88 89/*! 90 \typedef typedef volatile int8 vint8 91 \brief 1-byte volatile signed integer. 92*/ 93 94 95/*! 96 \typedef typedef volatile uint8 vuint8 97 \brief 1-byte volatile unsigned integer. 98*/ 99 100 101/*! 102 \typedef typedef volatile int16 vint16 103 \brief 2-bytes volatile signed integer. 104*/ 105 106 107/*! 108 \typedef typedef volatile uint16 vuint16 109 \brief 2-bytes volatile unsigned integer. 110*/ 111 112 113/*! 114 \typedef typedef volatile int32 vint32 115 \brief 4-bytes volatile signed integer. 116*/ 117 118 119/*! 120 \typedef typedef volatile uint32 vuint32 121 \brief 4-bytes volatile unsigned integer. 122*/ 123 124 125/*! 126 \typedef typedef volatile int64 vint64 127 \brief 8-bytes volatile signed integer. 128*/ 129 130 131/*! 132 \typedef typedef volatile uint64 vuint64 133 \brief 8-bytes volatile unsigned integer. 134*/ 135 136 137//! @} 138 139 140/*! 141 \name Short-hand Volatile Type Names 142*/ 143 144 145//! @{ 146 147 148/*! 149 \typedef typedef volatile long vlong 150 \brief Volatile signed long. 151*/ 152 153 154/*! 155 \typedef typedef volatile int vint 156 \brief Volatile signed int. 157*/ 158 159 160/*! 161 \typedef typedef volatile short vshort 162 \brief Volatile signed short. 163*/ 164 165 166/*! 167 \typedef typedef volatile char vchar 168 \brief Volatile signed char. 169*/ 170 171 172/*! 173 \typedef typedef volatile unsigned long vulong 174 \brief Volatile unsigned long. 175*/ 176 177 178/*! 179 \typedef typedef volatile unsigned int vuint 180 \brief Volatile unsigned int. 181*/ 182 183 184/*! 185 \typedef typedef volatile unsigned short vushort 186 \brief Volatile unsigned short. 187*/ 188 189 190/*! 191 \typedef typedef volatile unsigned char vuchar 192 \brief Volatile unsigned char. 193*/ 194 195 196//! @} 197 198 199/*! 200 \name Character Type Formats 201*/ 202 203 204//! @{ 205 206 207/*! 208 \typedef typedef unsigned char uchar 209 \brief Unsigned 1-byte wide character. 210*/ 211 212 213/*! 214 \typedef typedef unsigned short unichar 215 \brief Unsigned 2-byte wide character. 216*/ 217 218 219//! @} 220 221 222/*! 223 \name Descriptive Type Formats 224*/ 225 226 227//! @{ 228 229 230/*! 231 \typedef typedef int32 status_t 232 \brief Represents one of the status codes defined in Errors.h. 233 234 \since BeOS R3 235*/ 236 237 238/*! 239 \typedef typedef int64 bigtime_t 240 \brief Represents time in microseconds. 241 242 \since BeOS R3 243*/ 244 245 246/*! 247 \typedef typedef int64 nanotime_t 248 \brief Represents time in nanoseconds. 249*/ 250 251 252/*! 253 \typedef typedef uint32 type_code 254 \brief Represents a certain type of data. See TypeConstants.h for 255 possible values. 256 257 \since Haiku R1 258*/ 259 260 261/*! 262 \typedef typedef uint32 perform_code 263 \brief Defined to support 'hidden' commands or extensions to classes. 264 265 The Haiku API has none of these. 266 267 \since Haiku R1 268*/ 269 270 271/*! 272 \typedef typedef __haiku_phys_addr_t phys_addr_t 273 \brief Represents a physical address. 274 275 This has the length of 4 bytes on a 32 bit platform, and 8 bytes on a 64 276 bit platform. 277 278 \since Haiku R1 279*/ 280 281 282/*! 283 \typedef typedef phys_addr_t phys_size_t 284 \brief Represents a size of physical memory. 285 286 This has the length of 4 bytes on a 32 bit platform, and 8 bytes on a 64 287 bit platform. 288 289 \since Haiku R1 290*/ 291 292 293/*! 294 \typedef typedef __haiku_generic_addr_t generic_addr_t 295 \brief Represents a generic address. 296 297 A generic address is wide enough to store both physical and virtual 298 addresses. 299 300 \since Haiku R1 301*/ 302 303 304/*! 305 \typedef typedef generic_addr_t generic_size_t 306 \brief Represents a size of generic memory. 307 308 A generic address is wide enough to store both physical and virtual 309 addresses. 310 311 \since Haiku R1 312*/ 313 314 315//! @} 316 317 318/*! 319 \name Format strings for printf() and scanf() for integer types 320*/ 321 322 323//! @{ 324 325 326/*! 327 \def B_PRId8 328 \brief printf() constant for i8 as decimal 329*/ 330 331 332/*! 333 \def B_PRIi8 334 \brief printf() constant for i8 as decimal 335*/ 336 337 338/*! 339 \def B_PRId16 340 \brief printf() constant for i16 as decimal 341*/ 342 343 344/*! 345 \def B_PRIi16 346 \brief printf() constant for i16 as decimal 347*/ 348 349 350/*! 351 \def B_PRId32 352 \brief printf() constant for i32 as decimal 353*/ 354 355 356/*! 357 \def B_PRIi32 358 \brief printf() constant for i32 as decimal 359*/ 360 361 362/*! 363 \def B_PRId64 364 \brief printf() constant for i64 as decimal 365*/ 366 367 368/*! 369 \def B_PRIi64 370 \brief printf() constant for i64 as decimal 371*/ 372 373 374/*! 375 \def B_PRIu8 376 \brief printf() constant for u8 as decimal 377*/ 378 379 380/*! 381 \def B_PRIo8 382 \brief printf() constant for u8 as octal 383*/ 384 385 386/*! 387 \def B_PRIx8 388 \brief printf() constant for u8 as lowercase hexadecimal 389*/ 390 391 392/*! 393 \def B_PRIX8 394 \brief printf() constant for u8 as uppercase hexadecimal 395*/ 396 397 398/*! 399 \def B_PRIu16 400 \brief printf() constant for u16 as decimal 401*/ 402 403 404/*! 405 \def B_PRIo16 406 \brief printf() constant for u16 as octal 407*/ 408 409 410/*! 411 \def B_PRIx16 412 \brief printf() constant for u16 as lowercase hexadecimal 413*/ 414 415 416/*! 417 \def B_PRIX16 418 \brief printf() constant for u16 as uppercase hexadecimal 419*/ 420 421 422/*! 423 \def B_PRIu32 424 \brief printf() constant for u32 as decimal 425*/ 426 427 428/*! 429 \def B_PRIo32 430 \brief printf() constant for u32 as octal 431*/ 432 433 434/*! 435 \def B_PRIx32 436 \brief printf() constant for u32 as lowercase hexadecimal 437*/ 438 439 440/*! 441 \def B_PRIX32 442 \brief printf() constant for u32 as uppercase hexadecimal 443*/ 444 445 446/*! 447 \def B_PRIu64 448 \brief printf() constant for u64 as decimal 449*/ 450 451 452/*! 453 \def B_PRIo64 454 \brief printf() constant for u64 as octal 455*/ 456 457 458/*! 459 \def B_PRIx64 460 \brief printf() constant for u64 as lowercase hexadecimal 461*/ 462 463 464/*! 465 \def B_PRIX64 466 \brief printf() constant for u64 as uppercase hexadecimal 467*/ 468 469 470/*! 471 \def B_SCNd8 472 \brief scanf() constant for i8 as decimal 473*/ 474 475 476/*! 477 \def B_SCNi8 478 \brief scanf() constant for i8 as decimal, octal or hexadecimal 479*/ 480 481 482/*! 483 \def B_SCNd16 484 \brief scanf() constant for i16 as decimal 485*/ 486 487 488/*! 489 \def B_SCNi16 490 \brief scanf() constant for i16 as decimal, octal or hexadecimal 491*/ 492 493 494/*! 495 \def B_SCNd32 496 \brief scanf() constant for i32 as decimal 497*/ 498 499 500/*! 501 \def B_SCNi32 502 \brief scanf() constant for i32 as decimal, octal or hexadecimal 503*/ 504 505 506/*! 507 \def B_SCNd64 508 \brief scanf() constant for i64 as decimal 509*/ 510 511 512/*! 513 \def B_SCNi64 514 \brief scanf() constant for i64 as decimal, octal or hexadecimal 515*/ 516 517 518/*! 519 \def B_SCNu8 520 \brief scanf() constant for u8 as decimal 521*/ 522 523 524/*! 525 \def B_SCNo8 526 \brief scanf() constant for u8 as decimal, octal or hexadecimal 527*/ 528 529 530/*! 531 \def B_SCNx8 532 \brief scanf() constant for u8 as hexadecimal 533*/ 534 535 536/*! 537 \def B_SCNu16 538 \brief scanf() constant for u16 as decimal 539*/ 540 541 542/*! 543 \def B_SCNo16 544 \brief scanf() constant for u16 as decimal, octal or hexadecimal 545*/ 546 547 548/*! 549 \def B_SCNx16 550 \brief scanf() constant for u16 as hexadecimal 551*/ 552 553 554/*! 555 \def B_SCNu32 556 \brief scanf() constant for u32 as decimal 557*/ 558 559 560/*! 561 \def B_SCNo32 562 \brief scanf() constant for u32 as decimal, octal or hexadecimal 563*/ 564 565 566/*! 567 \def B_SCNx32 568 \brief scanf() constant for u32 as hexadecimal 569*/ 570 571 572/*! 573 \def B_SCNu64 574 \brief scanf() constant for u64 as decimal 575*/ 576 577 578/*! 579 \def B_SCNo64 580 \brief scanf() constant for u64 as decimal, octal or hexadecimal 581*/ 582 583 584/*! 585 \def B_SCNx64 586 \brief scanf() constant for u64 as hexadecimal 587*/ 588 589 590//! @} 591 592 593/*! 594 \name Format strings for several standard types 595*/ 596 597 598//! @{ 599 600 601/*! 602 \def B_PRIuSIZE 603 \brief printf() constant for size_t as decimal 604*/ 605 606 607/*! 608 \def B_PRIoSIZE 609 \brief printf() constant for size_t as octal 610*/ 611 612 613/*! 614 \def B_PRIxSIZE 615 \brief printf() constant for size_t as lowercase hexadecimal 616*/ 617 618 619/*! 620 \def B_PRIXSIZE 621 \brief printf() constant for size_t as uppercase hexadecimal 622*/ 623 624 625/*! 626 \def B_SCNuSIZE 627 \brief scanf() constant for size_t as decimal 628*/ 629 630 631/*! 632 \def B_SCNoSIZE 633 \brief scanf() constant for size_t as decimal, octal or hexadecimal 634 635*/ 636 637 638/*! 639 \def B_SCNxSIZE 640 \brief scanf() constant for size_t as hexadecimal 641*/ 642 643 644/*! 645 \def B_PRIdSSIZE 646 \brief printf() constant for ssize_t as decimal 647*/ 648 649 650/*! 651 \def B_PRIiSSIZE 652 \brief printf() constant for ssize_t as decimal 653*/ 654 655 656/*! 657 \def B_SCNdSSIZE 658 \brief scanf() constant for ssize_t as decimal 659*/ 660 661 662/*! 663 \def B_SCNiSSIZE 664 \brief scanf() constant for ssize_t as decimal, octal or hexadecimal 665*/ 666 667 668/*! 669 \def B_PRIuADDR 670 \brief printf() constant for addr_t as decimal 671*/ 672 673 674/*! 675 \def B_PRIoADDR 676 \brief printf() constant for addr_t as octal 677*/ 678 679 680/*! 681 \def B_PRIxADDR 682 \brief printf() constant for addr_t as lowercase hexadecimal 683*/ 684 685 686/*! 687 \def B_PRIXADDR 688 \brief printf() constant for addr_t as uppercase hexadecimal 689*/ 690 691 692/*! 693 \def B_SCNuADDR 694 \brief scanf() constant for addr_t as decimal 695*/ 696 697 698/*! 699 \def B_SCNoADDR 700 \brief scanf() constant for addr_t as decimal, octal or hexadecimal 701*/ 702 703 704/*! 705 \def B_SCNxADDR 706 \brief scanf() constant for addr_t as hexadecimal 707*/ 708 709 710/*! 711 \def B_PRIuPHYSADDR 712 \brief printf() constant for phys_addr_t as decimal 713*/ 714 715 716/*! 717 \def B_PRIoPHYSADDR 718 \brief printf() constant for phys_addr_t as octal 719*/ 720 721 722/*! 723 \def B_PRIxPHYSADDR 724 \brief printf() constant for phys_addr_t as lowercase hexadecimal 725*/ 726 727 728/*! 729 \def B_PRIXPHYSADDR 730 \brief printf() constant for phys_addr_t as uppercase hexadecimal 731*/ 732 733 734/*! 735 \def B_SCNuPHYSADDR 736 \brief scanf() constant for phys_addr_t as decimal 737*/ 738 739 740/*! 741 \def B_SCNoPHYSADDR 742 \brief scanf() constant for phys_addr_t as decimal, octal or hexadecimal 743*/ 744 745 746/*! 747 \def B_SCNxPHYSADDR 748 \brief scanf() constant for phys_addr_t as hexadecimal 749*/ 750 751 752/*! 753 \def B_PRIuGENADDR 754 \brief printf() constant for generic_addr_t as decimal 755*/ 756 757 758/*! 759 \def B_PRIoGENADDR 760 \brief printf() constant for generic_addr_t as octal 761*/ 762 763 764/*! 765 \def B_PRIxGENADDR 766 \brief printf() constant for generic_addr_t as lowercase hexadecimal 767*/ 768 769 770/*! 771 \def B_PRIXGENADDR 772 \brief printf() constant for generic_addr_t as uppercase hexadecimal 773*/ 774 775 776/*! 777 \def B_SCNuGENADDR 778 \brief scanf() constant for generic_addr_t as decimal 779*/ 780 781 782/*! 783 \def B_SCNoGENADDR 784 \brief scanf() constant for generic_addr_t as decimal, octal or hexadecimal 785*/ 786 787 788/*! 789 \def B_SCNxGENADDR 790 \brief scanf() constant for generic_addr_t as hexadecimal 791*/ 792 793 794/*! 795 \def B_PRIdOFF 796 \brief printf() constant for off_t as decimal 797*/ 798 799 800/*! 801 \def B_PRIiOFF 802 \brief printf() constant for off_t as decimal 803*/ 804 805 806/*! 807 \def B_PRIxOFF 808 \brief printf() constant for off_t as lowercase hexadecimal 809*/ 810 811 812/*! 813 \def B_SCNdOFF 814 \brief scanf() constant for off_t as decimal 815*/ 816 817 818/*! 819 \def B_SCNiOFF 820 \brief scanf() constant for off_t as decimal, octal or hexadecimal 821*/ 822 823 824/*! 825 \def B_SCNxOFF 826 \brief scanf() constant for off_t as octal 827*/ 828 829 830/*! 831 \def B_PRIdDEV 832 \brief printf() constant for dev_t as decimal 833*/ 834 835 836/*! 837 \def B_PRIiDEV 838 \brief printf() constant for dev_t as decimal 839*/ 840 841 842/*! 843 \def B_PRIdINO 844 \brief printf() constant for ino_t as decimal 845*/ 846 847 848/*! 849 \def B_PRIiINO 850 \brief printf() constant for ino_t as decimal 851*/ 852 853 854/*! 855 \def B_PRIdTIME 856 \brief printf() constant for time_t as decimal 857*/ 858 859 860/*! 861 \def B_PRIiTIME 862 \brief printf() constant for time_t as decimal 863*/ 864 865 866/*! 867 \def B_PRIdBIGTIME 868 \brief printf() constant for bigtime_t as decimal 869*/ 870 871 872/*! 873 \def B_PRIiBIGTIME 874 \brief printf() constant for bigtime_t as decimal 875*/ 876 877 878/*! 879 \def B_PRINTF_POINTER_WIDTH 880 \brief printf() argument for printed width of a pointer with the %p format 881 (minus 0x prefix). 882*/ 883 884 885//! @} 886 887 888//////////////// Odds and ends 889 890 891/*! 892 \var const char* B_EMPTY_STRING 893 \brief Defines an empty string. Currently defined as the string "". 894 895 \since BeOS R3 896*/ 897 898 899/*! 900 \def min_c(a,b) 901 \brief Returns the minimum of the values a and b. 902 903 \note When including this header in a C file, use the C equivalent called 904 \c min(a,b). 905 906 \since Haiku R1 907*/ 908 909 910/*! 911 \def max_c(a,b) 912 \brief Returns the maximum of values a and b. 913 914 \note When including this header in a C file, use the C equivalent called 915 \c max(a,b). 916 917 \since Haiku R1 918*/ 919 920 921/*! 922 \def NULL 923 \brief Defines the constant \c NULL if it hasn't already been defined. 924 925 \since BeOS R3 926*/ 927 928 929/*! 930 \def B_COUNT_OF(a) 931 \brief Count items in an array. 932 933 Set to (sizeof(a) / sizeof(a[0])). 934 935 \since Haiku R1 936*/ 937 938 939/*! 940 \addtogroup support_globals 941*/ 942 943 944//! @{ 945 946 947/*! 948 \fn void atomic_set(int32* value, int32 newValue) 949 \brief Atomically set the variable \a value to \a newvalue. 950 951 This is a thread-safe way of performing the \c *value \c = \c newValue 952 operation. You should use these function when two or more threads might 953 access the variable simultaneously. You don't have to use a semaphore or a 954 mutex in this case. The variable must be naturally aligned. 955 956 \sa atomic_set64() for a version that works on \c long \c long. 957 \sa atomic_test_and_set() 958 \sa atomic_add() 959 \sa atomic_and() 960 \sa atomic_or(), 961 \sa atomic_get() 962 963 \since Haiku R1 964*/ 965 966 967/*! \fn int32 atomic_get_and_set(int32* value, int32 newValue) 968 \brief Atomically set the variable \a value to \a newvalue and return the 969 old value. 970 971 This is a thread-safe way of performing the \c *value \c = \c newValue 972 operation. You should use these function when two or more threads might 973 access the variable simultaneously. You don't have to use a semaphore or a 974 mutex in this case. 975 976 \return The original value of \c value. 977 978 \sa atomic_get_and_set64() for a version that works on \c long \c long. 979 \sa atomic_set() 980 \sa atomic_test_and_set() 981 \sa atomic_add() 982 \sa atomic_and() 983 \sa atomic_or(), 984 \sa atomic_get() 985 986 \since Haiku R1 987*/ 988 989 990/*! \fn int32 atomic_test_and_set(int32* value, int32 newValue, 991 int32 testAgainst) 992 \brief Atomically set the variable \a value to \a newValue if the current 993 value is \a testAgainst. 994 995 This is a thread-safe way of conditionally performing the \c *value \c += 996 \c newValue operation. You should use these function when two or more 997 threads might access the variable simultaneously. You don't have to use 998 a semaphore or a mutex in this case. 999 1000 \return The original value of \c value. 1001 1002 \sa atomic_test_and_set64() for a version that works on \c long \c long. 1003 \sa atomic_get_and_set() 1004 \sa atomic_set() 1005 \sa atomic_add() 1006 \sa atomic_and() 1007 \sa atomic_or() 1008 \sa atomic_get() 1009 1010 \since Haiku R1 1011*/ 1012 1013 1014/*! 1015 \fn int32 atomic_add(int32* value, int32 addValue) 1016 \brief Atomically add the value of \a addValue to \a value. 1017 1018 This is a thread-safe way of performing the \c *value \c += \c addValue 1019 operation. You should use these function when two or more threads might 1020 access the variable simultaneously. You don't have to use a semaphore or a 1021 mutex in this case. 1022 1023 \return The original value of \c value. 1024 1025 \sa atomic_add64() for a version that works on \c long \c long. 1026 \sa atomic_get_and_set() 1027 \sa atomic_set() 1028 \sa atomic_test_and_set() 1029 \sa atomic_and() 1030 \sa atomic_or() 1031 \sa atomic_get() 1032 1033 \since BeOS R3 1034*/ 1035 1036 1037/*! \fn int32 atomic_and(int32* value, int32 andValue) 1038 \brief Atomically perform a bitwise AND operation of \a andValue to the 1039 variable \a andValue. 1040 1041 This is a thread-safe way of performing the \c *value \c &= \c andValue 1042 operation. You should use these function when two or more threads might 1043 access the variable simultaneously. You don't have to use a semaphore or a 1044 mutex in this case. 1045 1046 \return The original value of \c value. 1047 1048 \sa atomic_and64() for a version that works on \c long \c long. 1049 \sa atomic_get_and_set() 1050 \sa atomic_set() 1051 \sa atomic_test_and_set() 1052 \sa atomic_add() 1053 \sa atomic_or() 1054 \sa atomic_get() 1055 1056 \since BeOS R3 1057*/ 1058 1059 1060/*! 1061 \fn int32 atomic_or(int32* value, int32 orValue) 1062 \brief Atomically perform a bitwise OR operation of \a orValue to the 1063 variable \a andValue. 1064 1065 This is a thread-safe way of performing the \c *value \c |= \c orValue 1066 operation. You should use these function when two or more threads might 1067 access the variable simultaneously. You don't have to use a semaphore or a 1068 mutex in this case. 1069 1070 \return The original value of \c value. 1071 1072 \sa atomic_or64() for a version that works on \c long \c long. 1073 \sa atomic_get_and_set() 1074 \sa atomic_set() 1075 \sa atomic_test_and_set() 1076 \sa atomic_add() 1077 \sa atomic_and() 1078 \sa atomic_get() 1079 1080 \since BeOS R3 1081*/ 1082 1083 1084/*! 1085 \fn int32 atomic_get(int32* value) 1086 \brief Atomically return the value of \c value. 1087 1088 This is a thread-safe way of reading the contents of the \c value 1089 operation. You should use these function when two or more threads might 1090 access the variable simultaneously. You don't have to use a semaphore or a 1091 mutex in this case. The variable must be naturally aligned. 1092 1093 \return The original value of \c value. 1094 1095 \sa atomic_get64() for a version that works on \c long \c long. 1096 \sa atomic_get_and_set() 1097 \sa atomic_set() 1098 \sa atomic_test_and_set() 1099 \sa atomic_add() 1100 \sa atomic_and() 1101 \sa atomic_or() 1102 1103 \since Haiku R1 1104*/ 1105 1106 1107/*! 1108 \fn void atomic_set64(int64* value, int64 newValue) 1109 \brief Atomically set the variable \a value to \a newvalue. 1110 1111 This is a thread-safe way of performing the \c *value \c = \c newValue 1112 operation. You should use these function when two or more threads might 1113 access the variable simultaneously. You don't have to use a semaphore or a 1114 mutex in this case. The variable must be naturally aligned. 1115 1116 \sa atomic_set() for a version that works on an \c int32. 1117 \sa atomic_get_and_set64() 1118 \sa atomic_test_and_set64() 1119 \sa atomic_add64() 1120 \sa atomic_and64() 1121 \sa atomic_or64() 1122 \sa atomic_get64() 1123 1124 \since Haiku R1 1125*/ 1126 1127 1128/*! 1129 \fn int64 atomic_get_and_set64(int64* value, int64 newValue) 1130 \brief Atomically set the variable \a value to \a newvalue and return 1131 the old value. 1132 1133 This is a thread-safe way of performing the \c *value \c = \c newValue 1134 operation. You should use these function when two or more threads might 1135 access the variable simultaneously. You don't have to use a semaphore or a 1136 mutex in this case. 1137 1138 \return The original value of \c value. 1139 1140 \sa atomic_get_and_set() for a version that works on an \c int32. 1141 \sa atomic_set64() 1142 \sa atomic_test_and_set64() 1143 \sa atomic_add64() 1144 \sa atomic_and64() 1145 \sa atomic_or64() 1146 \sa atomic_get64() 1147 1148 \since Haiku R1 1149*/ 1150 1151 1152/*! 1153 \fn int64 atomic_test_and_set64(int64* value, int64 newValue, 1154 int64 testAgainst) 1155 \brief Atomically set the variable \a value to \a newValue if the current 1156 value is \a testAgainst. 1157 1158 This is a thread-safe way of conditionally performing the \c *value 1159 \c += \c newValue operation. You should use these function when two 1160 or more threads might access the variable simultaneously. You don't 1161 have to use a semaphore or a mutex in this case. 1162 1163 \return The original value of \c value. 1164 1165 \sa atomic_test_and_set() for a version that works on an \c int32. 1166 \sa atomic_get_and_set64() 1167 \sa atomic_set64() 1168 \sa atomic_add64() 1169 \sa atomic_and64() 1170 \sa atomic_or64() 1171 \sa atomic_get64() 1172 1173 \since Haiku R1 1174*/ 1175 1176 1177/*! 1178 \fn int64 atomic_add64(int64* value, int64 addValue) 1179 \brief Atomically add the value of \a addValue to \a value. 1180 1181 This is a thread-safe way of performing the \c *value \c += \c addValue 1182 operation. You should use these function when two or more threads might 1183 access the variable simultaneously. You don't have to use a semaphore or a 1184 mutex in this case. 1185 1186 \return The original value of \c value. 1187 1188 \sa atomic_add() for a version that works on an \c int32. 1189 \sa atomic_get_and_set64() 1190 \sa atomic_set64() 1191 \sa atomic_test_and_set64() 1192 \sa atomic_and64() 1193 \sa atomic_or64() 1194 \sa atomic_get64() 1195 1196 \since Haiku R1 1197*/ 1198 1199 1200/*! 1201 \fn int64 atomic_and64(int64* value, int64 andValue) 1202 \brief Atomically perform a bitwise AND operation of \a andValue to the 1203 variable \a andValue. 1204 1205 This is a thread-safe way of performing the \c *value \c &= \c andValue 1206 operation. You should use these function when two or more threads might 1207 access the variable simultaneously. You don't have to use a semaphore or a 1208 mutex in this case. 1209 1210 \return The original value of \c value. 1211 1212 \sa atomic_and() for a version that works on an \c int32. 1213 \sa atomic_get_and_set64() 1214 \sa atomic_set64() 1215 \sa atomic_test_and_set64() 1216 \sa atomic_add64() 1217 \sa atomic_or64() 1218 \sa atomic_get64() 1219 1220 \since Haiku R1 1221*/ 1222 1223 1224/*! 1225 \fn int64 atomic_or64(int64* value, int64 orValue) 1226 \brief Atomically perform a bitwise OR operation of \a orValue to the 1227 variable \a andValue. 1228 1229 This is a thread-safe way of performing the \c *value \c |= \c orValue 1230 operation. You should use these function when two or more threads might 1231 access the variable simultaneously. You don't have to use a semaphore or a 1232 mutex in this case. 1233 1234 \return The original value of \c value. 1235 1236 \sa atomic_or() for a version that works on an \c int32. 1237 \sa atomic_get_and_set64() 1238 \sa atomic_set64() 1239 \sa atomic_test_and_set64() 1240 \sa atomic_add64() 1241 \sa atomic_and64() 1242 \sa atomic_get64() 1243 1244 \since Haiku R1 1245*/ 1246 1247 1248/*! 1249 \fn int64 atomic_get64(int64* value) 1250 \brief Atomically return the value of \c value. 1251 1252 This is a thread-safe way of reading the contents of the \c value 1253 operation. You should use these function when two or more threads might 1254 access the variable simultaneously. You don't have to use a semaphore or a 1255 mutex in this case. The variable must be naturally aligned. 1256 1257 \return The original value of \c value. 1258 1259 \sa atomic_get() for a version that works on an \c int32. 1260 \sa atomic_get_and_set64() 1261 \sa atomic_set64() 1262 \sa atomic_test_and_set64() 1263 \sa atomic_add64() 1264 \sa atomic_and64() 1265 \sa atomic_or64() 1266 1267 \since Haiku R1 1268*/ 1269 1270 1271//! @} 1272 1273 1274/*! 1275 \fn void* get_stack_frame(void) 1276 \brief Internal function. 1277 \internal 1278*/ 1279 1280 1281/*! 1282 \name Deprecated defines 1283*/ 1284 1285 1286//! @{ 1287 1288 1289/*! 1290 \def FALSE 1291 \brief Obsolete. Use \c false. 1292 1293 \since BeOS R3 1294*/ 1295 1296 1297/*! 1298 \def TRUE 1299 \brief Obsolete. Use \c true. 1300 1301 \since BeOS R3 1302*/ 1303 1304 1305//! @} 1306