xref: /haiku/docs/user/support/SupportDefs.dox (revision 362efe0c9f36d3dd38b22d2c24ac02e54b189d7c)
1/*
2 * Copyright 2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Documentation by:
6 *  Niels Sascha Reedijk <niels.reedijk@gmail.com>
7 * Corresponds to:
8 * /trunk/headers/os/support/SupportDefs.h rev 35018
9 */
10
11/*!
12  \file SupportDefs.h
13  \ingroup support
14  \brief Defines basic types and definitions for the Haiku API.
15*/
16
17/*!
18  \name Fixed-Size Integer Types
19*/
20
21//! @{
22
23/*!
24	\typedef typedef __haiku_int8			int8
25*/
26
27/*!
28	\typedef typedef __haiku_uint8			uint8
29*/
30
31/*!
32	\typedef typedef __haiku_int16			int16
33*/
34
35/*!
36	\typedef typedef __haiku_uint16			uint16
37*/
38
39/*!
40	\typedef typedef __haiku_int32			int32
41*/
42
43/*!
44	\typedef typedef __haiku_uint32			uint32
45*/
46
47/*!
48	\typedef typedef __haiku_int64			int64
49*/
50
51/*!
52	\typedef typedef __haiku_uint64			uint64
53*/
54
55//! @}
56
57
58/*!
59	\name Fixed-size Volatile Types
60*/
61
62//! @{
63
64/*!
65	\typedef typedef volatile int8   		vint8
66*/
67
68/*!
69	\typedef typedef volatile uint8			vuint8
70*/
71
72/*!
73	\typedef typedef volatile int16			vint16
74*/
75
76/*!
77	\typedef typedef volatile uint16			vuint16
78*/
79
80/*!
81	\typedef typedef volatile int32			vint32
82*/
83
84/*!
85	\typedef typedef volatile uint32			vuint32
86*/
87
88/*!
89	\typedef typedef volatile int64			vint64
90*/
91
92/*!
93	\typedef typedef volatile uint64			vuint64
94*/
95
96//! @}
97
98
99/*!
100	\name Short-hand Volatile Type Names
101*/
102
103//! @{
104
105/*!
106	\typedef typedef volatile long			vlong
107*/
108
109/*!
110	\typedef typedef volatile int			vint
111*/
112
113/*!
114	\typedef typedef volatile short			vshort
115*/
116
117/*!
118	\typedef typedef volatile char			vchar
119*/
120
121/*!
122	\typedef typedef volatile unsigned long	vulong
123*/
124
125/*!
126	\typedef typedef volatile unsigned int	vuint
127*/
128
129/*!
130	\typedef typedef volatile unsigned short	vushort
131*/
132
133/*!
134	\typedef typedef volatile unsigned char	vuchar
135*/
136
137//! @}
138
139
140/*!	\name Character Type Formats */
141
142//! @{
143
144/*!
145  \typedef typedef unsigned char			uchar
146*/
147
148/*!
149  \typedef typedef unsigned short          unichar
150*/
151
152//! @}
153
154/*!	\name Descriptive Type Formats */
155
156//! @{
157
158/*!
159	\typedef typedef int32					status_t
160	\brief Represents one of the status codes defined in Error.h
161*/
162
163/*!
164	\typedef typedef int64					bigtime_t
165	\brief Represents time. The unit depends on the context of the function.
166*/
167
168/*!
169	\typedef typedef int64					nanotime_t
170	\brief Represents time in nanoseconds.
171*/
172
173/*!
174	\typedef typedef uint32					type_code
175	\brief Represents a certain type of data. See TypeConstants.h for
176		possible values.
177*/
178
179/*!
180	\typedef typedef uint32					perform_code
181	\brief Unused. Defined by Be to support 'hidden' commands or
182		extensions to classes. The Haiku API has none of these.
183*/
184
185//! @}
186
187
188/*!	\name Format strings for printf()/scanf() */
189
190//! @{
191
192/*!
193	\def B_PRId8
194*/
195
196/*!
197	\def B_PRIi8
198*/
199
200/*!
201	\def B_PRId16
202*/
203
204/*!
205	\def B_PRIi16
206*/
207
208/*!
209	\def B_PRId32
210*/
211
212/*!
213	\def B_PRIi32
214*/
215
216/*!
217	\def B_PRId64
218*/
219
220/*!
221	\def B_PRIi64
222*/
223
224/*!
225	\def B_PRIu8
226*/
227
228/*!
229	\def B_PRIo8
230*/
231
232/*!
233	\def B_PRIx8
234*/
235
236/*!
237	\def B_PRIX8
238*/
239
240/*!
241	\def B_PRIu16
242*/
243
244/*!
245	\def B_PRIo16
246*/
247
248/*!
249	\def B_PRIx16
250*/
251
252/*!
253	\def B_PRIX16
254*/
255
256/*!
257	\def B_PRIu32
258*/
259
260/*!
261	\def B_PRIo32
262*/
263
264/*!
265	\def B_PRIx32
266*/
267
268/*!
269	\def B_PRIX32
270*/
271
272/*!
273	\def B_PRIu64
274*/
275
276/*!
277	\def B_PRIo64
278*/
279
280/*!
281	\def B_PRIx64
282*/
283
284/*!
285	\def B_PRIX64
286*/
287
288/*!
289	\def B_SCNd8
290*/
291
292/*!
293	\def B_SCNi8
294*/
295
296/*!
297	\def B_SCNd16
298*/
299
300/*!
301	\def B_SCNi16
302*/
303
304/*!
305	\def B_SCNd32
306*/
307
308/*!
309	\def B_SCNi32
310*/
311
312/*!
313	\def B_SCNd64
314*/
315
316/*!
317	\def B_SCNi64
318*/
319
320/*!
321	\def B_SCNu8
322*/
323
324/*!
325	\def B_SCNo8
326*/
327
328/*!
329	\def B_SCNx8
330*/
331
332/*!
333	\def B_SCNu16
334*/
335
336/*!
337	\def B_SCNo16
338*/
339
340/*!
341	\def B_SCNx16
342*/
343
344/*!
345	\def B_SCNu32
346*/
347
348/*!
349	\def B_SCNo32
350*/
351
352/*!
353	\def B_SCNx32
354*/
355
356/*!
357	\def B_SCNu64
358*/
359
360/*!
361	\def B_SCNo64
362*/
363
364/*!
365	\def B_SCNx64
366*/
367
368//! @}
369
370
371/*!	\name  Format strings for several standard types */
372
373//! @{
374
375/*!
376	\def B_PRIuSIZE
377	\brief size_t
378*/
379
380/*!
381	\def B_PRIoSIZE
382	\brief size_t
383*/
384
385/*!
386	\def B_PRIxSIZE
387	\brief size_t
388*/
389
390/*!
391	\def B_PRIXSIZE
392	\brief size_t
393*/
394
395/*!
396	\def B_PRIdSSIZE
397	\brief ssize_t
398*/
399
400/*!
401	\def B_PRIiSSIZE
402	\brief ssize_t
403*/
404
405/*!
406	\def B_PRIuADDR
407	\brief addr_t
408*/
409
410/*!
411	\def B_PRIoADDR
412	\brief addr_t
413*/
414
415/*!
416	\def B_PRIxADDR
417	\brief addr_t
418*/
419
420/*!
421	\def B_PRIXADDR
422	\brief addr_t
423*/
424
425/*!
426	\def B_PRIdOFF
427	\brief off_t
428*/
429
430/*!
431	\def B_PRIiOFF
432	\brief off_t
433*/
434
435/*!
436	\def B_PRIdDEV
437	\brief dev_t
438*/
439
440/*!
441	\def B_PRIiDEV
442	\brief dev_t
443*/
444
445/*!
446	\def B_PRIdINO
447	\brief ino_t
448*/
449
450/*!
451	\def B_PRIiINO
452	\brief ino_t
453*/
454
455/*!
456	\def B_PRIdTIME
457	\brief time_t
458*/
459
460/*!
461	\def B_PRIiTIME
462	\brief time_t
463*/
464
465//! @}
466
467//////////////// Odds and ends
468
469/*!	\var const char *B_EMPTY_STRING
470	\brief Defines an empty string. Currently defined as the string "".
471*/
472
473/*!	\def min_c(a,b)
474	\brief Returns the minimum of the values a and b.
475
476	\note When including this header in a C file, use the C equivalent called
477		\c min(a,b).
478*/
479
480/*!	\def max_c(a,b)
481	\brief Returns the maximum of values a and b.
482
483	\note When including this header in a C file, use the C equivalent called
484		\c max(a,b).
485*/
486
487/*!	\def NULL
488	\brief Defines the constant \c NULL if it hasn't been defined
489		anywhere before.
490*/
491
492/*!	\addtogroup support_globals */
493
494//! @{
495
496/*!	\fn int32 atomic_set(vint32 *value, int32 newValue)
497	\brief Atomically set the variable \a value to \a newvalue.
498
499	This is a thread-safe way of performing the \c *value \c = \c newValue
500	operation. You should use these function when two or more threads might
501	access the variable simultaneously. You don't have to use a semaphore or a
502	mutex in this case.
503
504	\return The original value of \c value.
505
506	\sa atomic_set64() for a version that works on \c long \c long
507	\sa atomic_test_and_set(), atomic_add(), atomic_and(), atomic_or(),
508		atomic_get()
509*/
510
511/*!	\fn int32 atomic_test_and_set(vint32 *value, int32 newValue,
512		int32 testAgainst)
513	\brief Atomically set the variable \a value to \a newValue if the current
514         value is \a testAgainst.
515
516	This is a thread-safe way of conditionally performing the \c *value \c +=
517	\c newValue operation. You should use these function when two or more
518	threads might access the variable simultaneously. You don't have to use
519	a semaphore or a mutex in this case.
520
521	\return The original value of \c value.
522
523	\sa atomic_test_and_set64() for a version that works on \c long \c long
524	\sa atomic_set(), atomic_add(), atomic_and(), atomic_or(), atomic_get()
525*/
526
527/*!	\fn int32 atomic_add(vint32 *value, int32 addValue)
528	\brief Atomically add the value of \a addValue to \a value.
529
530	This is a thread-safe way of performing the \c *value \c += \c addValue
531	operation. You should use these function when two or more threads might
532	access the variable simultaneously. You don't have to use a semaphore or a
533	mutex in this case.
534
535	\return The original value of \c value.
536
537	\sa atomic_add64() for a version that works on \c long \c long
538	\sa atomic_set(), atomic_test_and_set(), atomic_and(), atomic_or(),
539		atomic_get()
540*/
541
542/*!	\fn int32 atomic_and(vint32 *value, int32 andValue)
543	\brief Atomically perform a bitwise AND operation of \a andValue to the
544         variable \a andValue.
545
546	This is a thread-safe way of performing the \c *value \c &amp;= \c andValue
547	operation. You should use these function when two or more threads might
548	access the variable simultaneously. You don't have to use a semaphore or a
549	mutex in this case.
550
551	\return The original value of \c value.
552
553	\sa atomic_and64() for a version that works on \c long \c long
554	\sa atomic_set(), atomic_test_and_set(), atomic_add(), atomic_or(),
555		atomic_get()
556*/
557
558
559/*!	\fn int32 atomic_or(vint32 *value, int32 orValue)
560	\brief Atomically perform a bitwise OR operation of \a orValue to the
561         variable \a andValue.
562
563	This is a thread-safe way of performing the \c *value \c |= \c orValue
564	operation. You should use these function when two or more threads might
565	access the variable simultaneously. You don't have to use a semaphore or a
566	mutex in this case.
567
568	\return The original value of \c value.
569
570	\sa atomic_or64() for a version that works on \c long \c long
571	\sa atomic_set(), atomic_test_and_set(), atomic_add(), atomic_and(),
572		atomic_get()
573*/
574
575/*!	\fn int32 atomic_get(vint32 *value)
576	\brief Atomically return the value of \c value.
577
578	This is a thread-safe way of reading the contents of the \c value
579	operation. You should use these function when two or more threads might
580	access the variable simultaneously. You don't have to use a semaphore or a
581	mutex in this case.
582
583	\return The original value of \c value.
584
585	\sa atomic_get64() for a version that works on \c long \c long
586	\sa atomic_set(), atomic_test_and_set(), atomic_add(), atomic_and(),
587		atomic_or()
588*/
589
590/*!	\fn int64 atomic_set64(vint64 *value, int64 newValue)
591	\brief Atomically set the variable \a value to \a newvalue.
592
593	This is a thread-safe way of performing the \c *value \c = \c newValue
594	operation. You should use these function when two or more threads might
595	access the variable simultaneously. You don't have to use a semaphore or a
596	mutex in this case.
597
598	\return The original value of \c value.
599
600	\sa atomic_set() for a version that works on an \c int32
601	\sa atomic_test_and_set64(), atomic_add64(), atomic_and64(),
602		atomic_or64(), atomic_get64()
603*/
604
605/*!	\fn int64 atomic_test_and_set64(vint64 *value, int64 newValue,
606		int64 testAgainst)
607	\brief Atomically set the variable \a value to \a newValue if the current
608         value is \a testAgainst.
609
610	This is a thread-safe way of conditionally performing the \c *value
611	\c += \c newValue operation. You should use these function when two
612	or more threads might access the variable simultaneously. You don't
613	have to use a semaphore or a mutex in this case.
614
615	\return The original value of \c value.
616
617	\sa atomic_test_and_set() for a version that works on an \c int32
618	\sa atomic_set64(), atomic_add64(), atomic_and64(),
619		atomic_or64(), atomic_get64()
620*/
621
622/*!	\fn int64 atomic_add64(vint64 *value, int64 addValue)
623	\brief Atomically add the value of \a addValue to \a value.
624
625	This is a thread-safe way of performing the \c *value \c += \c addValue
626	operation. You should use these function when two or more threads might
627	access the variable simultaneously. You don't have to use a semaphore or a
628	mutex in this case.
629
630	\return The original value of \c value.
631
632	\sa atomic_add() for a version that works on an \c int32
633	\sa atomic_set64(), atomic_test_and_set64(), atomic_and64(),
634		atomic_or64(), atomic_get64()
635*/
636
637/*!	\fn int64 atomic_and64(vint64 *value, int64 andValue)
638	\brief Atomically perform a bitwise AND operation of \a andValue to the
639         variable \a andValue.
640
641	This is a thread-safe way of performing the \c *value \c &amp;= \c andValue
642	operation. You should use these function when two or more threads might
643	access the variable simultaneously. You don't have to use a semaphore or a
644	mutex in this case.
645
646	\return The original value of \c value.
647
648	\sa atomic_and() for a version that works on an \c int32
649	\sa atomic_set64(), atomic_test_and_set64(), atomic_add64(),
650		atomic_or64(), atomic_get64()
651*/
652
653/*!	\fn int64 atomic_or64(vint64 *value, int64 orValue)
654	\brief Atomically perform a bitwise OR operation of \a orValue to the
655         variable \a andValue.
656
657	This is a thread-safe way of performing the \c *value \c |= \c orValue
658	operation. You should use these function when two or more threads might
659	access the variable simultaneously. You don't have to use a semaphore or a
660	mutex in this case.
661
662	\return The original value of \c value.
663
664	\sa atomic_or() for a version that works on an \c int32
665	\sa atomic_set64(), atomic_test_and_set64(), atomic_add64(), atomic_and64(),
666		atomic_get64()
667*/
668
669/*!	\fn int64 atomic_get64(vint64 *value)
670	\brief Atomically return the value of \c value.
671
672	This is a thread-safe way of reading the contents of the \c value
673	operation. You should use these function when two or more threads might
674	access the variable simultaneously. You don't have to use a semaphore or a
675	mutex in this case.
676
677	\return The original value of \c value.
678
679	\sa atomic_get() for a version that works on an \c int32
680	\sa atomic_set64(), atomic_test_and_set64(), atomic_add64(),
681		atomic_and64(), atomic_or64()
682*/
683
684//! @}
685
686/*!	\fn void* get_stack_frame(void)
687  \brief Internal function.
688  \internal
689*/
690
691/*!  \name Deprecated defines */
692
693//! @{
694
695/*!	\def FALSE
696	\brief Obsolete. Use \c false.
697*/
698
699/*!	\def TRUE
700	\brief Obsolete. Use \c true.
701*/
702
703//! @}
704
705