1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     util_CLibImpl.h
4 
5   Copyright (C)2009 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law. They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 16709 $
14  *---------------------------------------------------------------------------*/
15 
16 /* Please see man pages for details
17 
18 
19 */
20 
21 #ifndef NN_UTIL_DETAIL_UTIL_CLIBIMPL_H_
22 #define NN_UTIL_DETAIL_UTIL_CLIBIMPL_H_
23 
24 #include <nn/types.h>
25 #include <nn/util/util_StaticAssert.h>
26 #include <nn/util/util_TypeTraits.h>
27 
28 #ifdef __cplusplus
29     /* Please see man pages for details
30 
31     */
32     #define NN_EXTERN_C extern "C"
33     #define NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(cname, cppname, size, alignment_holder_type) \
34         typedef union cname \
35         { \
36             char buf[size]; \
37             alignment_holder_type alignment_holder; \
38             NN_STATIC_ASSERT((size) == sizeof(cppname) && ::nn::util::alignment_of<alignment_holder_type>::value == ::nn::util::alignment_of<cppname>::value); \
39         } cname
40 
41 #else
42     #define NN_EXTERN_C extern
43     #define NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(cname, cppname, size, alignment_holder_type) \
44         typedef union cname \
45         { \
46             char buf[size]; \
47             alignment_holder_type alignment_holder; \
48         } cname
49 #endif
50 
51 #define NN_UTIL_DETAIL_CLIBIMPL_DEFINE_ABSTRACT_BUFFER_CLASS(name) typedef struct { bit8 dummy; } name;
52 
53 #define NN_UTIL_DETAIL_CLIBIMPL_DECLARE_CONVERSION(name, fromC, toC) \
54     NN_EXTERN_C toC* name(fromC*); \
55     NN_EXTERN_C const toC* name##Const(const fromC*)
56 
57 #define NN_UTIL_DETAIL_CLIBIMPL_DEFINE_CONVERSION(name, fromC, toC, fromCpp, toCpp) \
58     NN_EXTERN_C toC* name(fromC* p) { return reinterpret_cast<toC*>(static_cast<toCpp*>(reinterpret_cast<fromCpp*>(p))); } \
59     NN_EXTERN_C const toC* name##Const(const fromC* p) { return reinterpret_cast<const toC*>(static_cast<const toCpp*>(reinterpret_cast<const fromCpp*>(p))); }
60 
61 #endif
62 
63 /*
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 */
100