xref: /haiku/docs/user/support/SupportDefs.dox (revision 922e7ba1f3228e6f28db69b0ded8f86eb32dea17)
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/*!
141  \name Character Type Formats
142*/
143
144//! @{
145
146/*!
147  \typedef typedef unsigned char			uchar
148*/
149
150/*!
151  \typedef typedef unsigned short          unichar
152*/
153
154//! @}
155
156/*!
157  \name Descriptive Type Formats
158*/
159
160//! @{
161
162/*!
163  \typedef typedef int32					status_t
164  \brief Represents one of the status codes defined in Error.h
165*/
166
167/*!
168  \typedef typedef int64					bigtime_t
169  \brief Represents time. The unit depends on the context of the function.
170*/
171
172/*!
173	\typedef typedef int64					nanotime_t
174	\brief Represents time in nanoseconds.
175*/
176
177/*!
178  \typedef typedef uint32					type_code
179  \brief Represents a certain type of data. See TypeConstants.h for possible
180    values.
181*/
182
183/*!
184  \typedef typedef uint32					perform_code
185  \brief Unused. Defined by Be to support 'hidden' commands or
186    extensions to classes. The Haiku API has none of these.
187*/
188
189//! @}
190
191
192/*!
193	\name Format strings for printf()/scanf()
194*/
195
196//! @{
197
198/*!
199	\def B_PRId8
200*/
201
202/*!
203	\def B_PRIi8
204*/
205
206/*!
207	\def B_PRId16
208*/
209
210/*!
211	\def B_PRIi16
212*/
213
214/*!
215	\def B_PRId32
216*/
217
218/*!
219	\def B_PRIi32
220*/
221
222/*!
223	\def B_PRId64
224*/
225
226/*!
227	\def B_PRIi64
228*/
229
230/*!
231	\def B_PRIu8
232*/
233
234/*!
235	\def B_PRIo8
236*/
237
238/*!
239	\def B_PRIx8
240*/
241
242/*!
243	\def B_PRIX8
244*/
245
246/*!
247	\def B_PRIu16
248*/
249
250/*!
251	\def B_PRIo16
252*/
253
254/*!
255	\def B_PRIx16
256*/
257
258/*!
259	\def B_PRIX16
260*/
261
262/*!
263	\def B_PRIu32
264*/
265
266/*!
267	\def B_PRIo32
268*/
269
270/*!
271	\def B_PRIx32
272*/
273
274/*!
275	\def B_PRIX32
276*/
277
278/*!
279	\def B_PRIu64
280*/
281
282/*!
283	\def B_PRIo64
284*/
285
286/*!
287	\def B_PRIx64
288*/
289
290/*!
291	\def B_PRIX64
292*/
293
294/*!
295	\def B_SCNd8
296*/
297
298/*!
299	\def B_SCNi8
300*/
301
302/*!
303	\def B_SCNd16
304*/
305
306/*!
307	\def B_SCNi16
308*/
309
310/*!
311	\def B_SCNd32
312*/
313
314/*!
315	\def B_SCNi32
316*/
317
318/*!
319	\def B_SCNd64
320*/
321
322/*!
323	\def B_SCNi64
324*/
325
326/*!
327	\def B_SCNu8
328*/
329
330/*!
331	\def B_SCNo8
332*/
333
334/*!
335	\def B_SCNx8
336*/
337
338/*!
339	\def B_SCNu16
340*/
341
342/*!
343	\def B_SCNo16
344*/
345
346/*!
347	\def B_SCNx16
348*/
349
350/*!
351	\def B_SCNu32
352*/
353
354/*!
355	\def B_SCNo32
356*/
357
358/*!
359	\def B_SCNx32
360*/
361
362/*!
363	\def B_SCNu64
364*/
365
366/*!
367	\def B_SCNo64
368*/
369
370/*!
371	\def B_SCNx64
372*/
373
374//! @}
375
376
377/*!
378	\name  Format strings for several standard types
379*/
380
381//! @{
382
383/*!
384	\def B_PRIuSIZE
385	\brief size_t
386*/
387
388/*!
389	\def B_PRIoSIZE
390	\brief size_t
391*/
392
393/*!
394	\def B_PRIxSIZE
395	\brief size_t
396*/
397
398/*!
399	\def B_PRIXSIZE
400	\brief size_t
401*/
402
403/*!
404	\def B_PRIdSSIZE
405	\brief ssize_t
406*/
407
408/*!
409	\def B_PRIiSSIZE
410	\brief ssize_t
411*/
412
413/*!
414	\def B_PRIuADDR
415	\brief addr_t
416*/
417
418/*!
419	\def B_PRIoADDR
420	\brief addr_t
421*/
422
423/*!
424	\def B_PRIxADDR
425	\brief addr_t
426*/
427
428/*!
429	\def B_PRIXADDR
430	\brief addr_t
431*/
432
433/*!
434	\def B_PRIdOFF
435	\brief off_t
436*/
437
438/*!
439	\def B_PRIiOFF
440	\brief off_t
441*/
442
443/*!
444	\def B_PRIdDEV
445	\brief dev_t
446*/
447
448/*!
449	\def B_PRIiDEV
450	\brief dev_t
451*/
452
453/*!
454	\def B_PRIdINO
455	\brief ino_t
456*/
457
458/*!
459	\def B_PRIiINO
460	\brief ino_t
461*/
462
463/*!
464	\def B_PRIdTIME
465	\brief time_t
466*/
467
468/*!
469	\def B_PRIiTIME
470	\brief time_t
471*/
472
473//! @}
474
475//////////////// Odds and ends
476
477/*!
478  \var const char *B_EMPTY_STRING
479  \brief Defines an empty string. Currently defined as the C-string "".
480*/
481
482/*!
483  \def min_c(a,b)
484  \brief Returns the minimum of the values a and b.
485
486  \note When including this header in a C file, use the C equivalent called
487    \c min(a,b).
488*/
489
490/*!
491  \def max_c(a,b)
492  \brief Returns the maximum of values a and b.
493
494  \note When including this header in a C file, use the C equivalent called
495    \c max(a,b).
496*/
497
498/*!
499  \def NULL
500  \brief Defines the constant \c NULL if it hasn't been defined anywhere before.
501*/
502
503/*!
504  \addtogroup support_globals
505*/
506
507//! @{
508
509/*!
510  \fn int32	atomic_set(vint32 *value, int32 newValue)
511  \brief Atomically set the variable \a value to \a newvalue.
512
513	This is a thread-safe way of performing the \c *value \c = \c newValue
514	operation. You should use these function when two or more threads might
515	access the variable simultaneously. You don't have to use a semaphore or a
516	mutex in this case.
517
518	\return The original value of \c value.
519
520	\sa atomic_set64() for a version that works on \c long \c long
521  \sa atomic_test_and_set(), atomic_add(), atomic_and(),
522    atomic_or(), atomic_get()
523*/
524
525/*!
526  \fn int32	atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst)
527  \brief Atomically set the variable \a value to \a newValue if the current
528         value is \a testAgainst.
529
530	This is a thread-safe way of conditionally performing the \c *value \c +=
531	\c newValue operation. You should use these function when two or more threads
532	might access the variable simultaneously. You don't have to use a semaphore
533	or a mutex in this case.
534
535	\return The original value of \c value.
536  \sa atomic_test_and_set64() for a version that works on \c long \c long
537  \sa atomic_set(), atomic_add(), atomic_and(),
538    atomic_or(), atomic_get()
539*/
540
541/*!
542  \fn int32	atomic_add(vint32 *value, int32 addValue)
543  \brief Atomically add the value of \a addValue to \a value.
544
545	This is a thread-safe way of performing the \c *value \c += \c addValue
546	operation. You should use these function when two or more threads might
547	access the variable simultaneously. You don't have to use a semaphore or a
548	mutex in this case.
549
550	\return The original value of \c value.
551  \sa atomic_add64() for a version that works on \c long \c long
552  \sa atomic_set(), atomic_test_and_set(), atomic_and(),
553    atomic_or(), atomic_get()
554*/
555
556/*!
557  \fn int32	atomic_and(vint32 *value, int32 andValue)
558  \brief Atomically perform a bitwise AND operation of \a andValue to the
559         variable \a andValue.
560
561	This is a thread-safe way of performing the \c *value \c &amp;= \c andValue
562	operation. You should use these function when two or more threads might
563	access the variable simultaneously. You don't have to use a semaphore or a
564	mutex in this case.
565
566	\return The original value of \c value.
567  \sa atomic_and64() for a version that works on \c long \c long
568  \sa atomic_set(), atomic_test_and_set(), atomic_add(),
569    atomic_or(), atomic_get()
570*/
571
572
573/*!
574  \fn int32	atomic_or(vint32 *value, int32 orValue)
575  \brief Atomically perform a bitwise OR operation of \a orValue to the
576         variable \a andValue.
577
578	This is a thread-safe way of performing the \c *value \c |= \c orValue
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  \sa atomic_or64() for a version that works on \c long \c long
585  \sa atomic_set(), atomic_test_and_set(), atomic_add(), atomic_and(),
586    atomic_get()
587*/
588
589/*!
590  \fn int32	atomic_get(vint32 *value)
591  \brief Atomically return the value of \c value.
592
593	This is a thread-safe way of reading the contents of the \c value
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  \sa atomic_get64() for a version that works on \c long \c long
600  \sa atomic_set(), atomic_test_and_set(), atomic_add(), atomic_and(),
601    atomic_or()
602*/
603
604/*!
605  \fn int64	atomic_set64(vint64 *value, int64 newValue)
606  \brief Atomically set the variable \a value to \a newvalue.
607
608	This is a thread-safe way of performing the \c *value \c = \c newValue
609	operation. You should use these function when two or more threads might
610	access the variable simultaneously. You don't have to use a semaphore or a
611	mutex in this case.
612
613	\return The original value of \c value.
614
615  \sa atomic_set() for a version that works on an \c int32
616  \sa atomic_test_and_set64(), atomic_add64(), atomic_and64(),
617    atomic_or64(), atomic_get64()
618*/
619
620/*!
621  \fn int64	atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst)
622  \brief Atomically set the variable \a value to \a newValue if the current
623         value is \a testAgainst.
624
625	This is a thread-safe way of conditionally performing the \c *value \c +=
626	\c newValue operation. You should use these function when two or more threads
627	might access the variable simultaneously. You don't have to use a semaphore
628	or a mutex in this case.
629
630	\return The original value of \c value.
631  \sa atomic_test_and_set() for a version that works on an \c int32
632  \sa atomic_set64(), atomic_add64(), atomic_and64(),
633    atomic_or64(), atomic_get64()
634*/
635
636/*!
637  \fn int64	atomic_add64(vint64 *value, int64 addValue)
638  \brief Atomically add the value of \a addValue to \a value.
639
640	This is a thread-safe way of performing the \c *value \c += \c addValue
641	operation. You should use these function when two or more threads might
642	access the variable simultaneously. You don't have to use a semaphore or a
643	mutex in this case.
644
645	\return The original value of \c value.
646  \sa atomic_add() for a version that works on an \c int32
647  \sa atomic_set64(), atomic_test_and_set64(), atomic_and64(),
648    atomic_or64(), atomic_get64()
649*/
650
651/*!
652  \fn int64	atomic_and64(vint64 *value, int64 andValue)
653  \brief Atomically perform a bitwise AND operation of \a andValue to the
654         variable \a andValue.
655
656	This is a thread-safe way of performing the \c *value \c &amp;= \c andValue
657	operation. You should use these function when two or more threads might
658	access the variable simultaneously. You don't have to use a semaphore or a
659	mutex in this case.
660
661	\return The original value of \c value.
662  \sa atomic_and() for a version that works on an \c int32
663  \sa atomic_set64(), atomic_test_and_set64(), atomic_add64(),
664    atomic_or64(), atomic_get64()
665*/
666
667/*!
668  \fn int64	atomic_or64(vint64 *value, int64 orValue)
669  \brief Atomically perform a bitwise OR operation of \a orValue to the
670         variable \a andValue.
671
672	This is a thread-safe way of performing the \c *value \c |= \c orValue
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  \sa atomic_or() for a version that works on an \c int32
679  \sa atomic_set64(), atomic_test_and_set64(), atomic_add64(), atomic_and64(),
680    atomic_get64()
681*/
682
683/*!
684  \fn int64	atomic_get64(vint64 *value)
685  \brief Atomically return the value of \c value.
686
687	This is a thread-safe way of reading the contents of the \c value
688	operation. You should use these function when two or more threads might
689	access the variable simultaneously. You don't have to use a semaphore or a
690	mutex in this case.
691
692	\return The original value of \c value.
693  \sa atomic_get() for a version that works on an \c int32
694  \sa atomic_set64(), atomic_test_and_set64(), atomic_add64(), atomic_and64(),
695    atomic_or64()
696*/
697
698//! @}
699
700/*!
701  \fn void*	get_stack_frame(void)
702  \brief Internal function.
703  \internal
704*/
705
706/*!
707	\name Deprecated defines
708*/
709
710//! @{
711
712/*!
713  \def FALSE
714  \brief Obsolete. Use \c false.
715*/
716
717/*!
718  \def TRUE
719  \brief Obsolete. Use \c true.
720*/
721
722//! @}
723