Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
macros_impl.h
1 /**
2 * Copyright (c) 2015-present, Facebook, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD+Patents license found in the
6 * LICENSE file in the root directory of this source tree.
7 */
8
9 // Copyright 2004-present Facebook. All Rights Reserved.
10 // -*- c++ -*-
11
12 #ifndef GPU_MACROS_IMPL_H
13 #define GPU_MACROS_IMPL_H
14 #include "../macros_impl.h"
15
16 #undef DEFINE_GETTER
17 #define DEFINE_GETTER(clazz, ty, name) \
18 ty faiss_ ## clazz ## _ ## name (const Faiss ## clazz *obj) { \
19 return static_cast< ty >( \
20 reinterpret_cast< const faiss::gpu::clazz *>(obj)-> name \
21 ); \
22 }
23
24 #undef DEFINE_SETTER
25 #define DEFINE_SETTER(clazz, ty, name) \
26 void faiss_ ## clazz ## _set_ ## name (Faiss ## clazz *obj, ty val) { \
27 reinterpret_cast< faiss::gpu::clazz *>(obj)-> name = val; \
28 }
29
30 #undef DEFINE_SETTER_STATIC
31 #define DEFINE_SETTER_STATIC(clazz, ty_to, ty_from, name) \
32 void faiss_ ## clazz ## _set_ ## name (Faiss ## clazz *obj, ty_from val) { \
33 reinterpret_cast< faiss::gpu::clazz *>(obj)-> name = \
34 static_cast< ty_to >(val); \
35 }
36
37 #undef DEFINE_DESTRUCTOR
38 #define DEFINE_DESTRUCTOR(clazz) \
39 void faiss_ ## clazz ## _free (Faiss ## clazz *obj) { \
40 delete reinterpret_cast<faiss::gpu::clazz *>(obj); \
41 }
42
43 #endif