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