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