• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_C_C_API_MACROS_H_
17 #define TENSORFLOW_C_C_API_MACROS_H_
18 
19 #ifdef SWIG
20 #define TF_CAPI_EXPORT
21 #else
22 #if defined(_WIN32)
23 #ifdef TF_COMPILE_LIBRARY
24 #define TF_CAPI_EXPORT __declspec(dllexport)
25 #else
26 #define TF_CAPI_EXPORT __declspec(dllimport)
27 #endif  // TF_COMPILE_LIBRARY
28 #else
29 #define TF_CAPI_EXPORT __attribute__((visibility("default")))
30 #endif  // _WIN32
31 #endif  // SWIG
32 
33 // TF_Bool is the C API typedef for unsigned char, while TF_BOOL is
34 // the datatype for boolean tensors.
35 #ifndef TF_Bool
36 #define TF_Bool unsigned char
37 #endif  // TF_Bool
38 
39 // Macro used to calculate struct size for maintaining ABI stability across
40 // different struct implementations.
41 #ifndef TF_OFFSET_OF_END
42 #define TF_OFFSET_OF_END(TYPE, MEMBER) \
43   (offsetof(TYPE, MEMBER) + sizeof(((TYPE *)0)->MEMBER))
44 #endif  // TF_OFFSET_OF_END
45 
46 #endif  // TENSORFLOW_C_C_API_MACROS_H_
47