Skip to content

Commit bd22c93

Browse files
junjieqifacebook-github-bot
authored andcommitted
Fix swig osx (facebookresearch#3357)
Summary: The osx failed https://app.circleci.com/pipelines/github/facebookresearch/faiss/5698/workflows/4e029c32-8d8b-4db7-99e2-8e802aad6653/jobs/32701 Pull Request resolved: facebookresearch#3357 Reviewed By: kuarora Differential Revision: D56039739 Pulled By: junjieqi fbshipit-source-id: dd434a8817148364797eae39c09e0e1e9edbe858
1 parent 03750f5 commit bd22c93

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

faiss/python/swigfaiss.swig

+5-12
Original file line numberDiff line numberDiff line change
@@ -1022,14 +1022,17 @@ PyObject *swig_ptr (PyObject *a)
10221022
return SWIG_NewPointerObj(data, SWIGTYPE_p_bool, 0);
10231023
}
10241024
if(PyArray_TYPE(ao) == NPY_UINT64) {
1025-
#if (__SIZEOF_LONG__ == 8)
1025+
// Convert npy64 either long or long long and it depends on how compiler define int64_t.
1026+
// In the 64bit machine, typically the int64_t should be long but it is not hold for Apple osx.
1027+
// In this case, we want to convert npy64 to long_Long in osx
1028+
#if __SIZEOF_LONG__ == 8 && !defined(__APPLE__)
10261029
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long, 0);
10271030
#else
10281031
return SWIG_NewPointerObj(data, SWIGTYPE_p_unsigned_long_long, 0);
10291032
#endif
10301033
}
10311034
if(PyArray_TYPE(ao) == NPY_INT64) {
1032-
#if (__SIZEOF_LONG__ == 8)
1035+
#if __SIZEOF_LONG__ == 8 && !defined(__APPLE__)
10331036
return SWIG_NewPointerObj(data, SWIGTYPE_p_long, 0);
10341037
#else
10351038
return SWIG_NewPointerObj(data, SWIGTYPE_p_long_long, 0);
@@ -1054,11 +1057,8 @@ struct PythonInterruptCallback: faiss::InterruptCallback {
10541057
}
10551058

10561059
};
1057-
1058-
10591060
%}
10601061

1061-
10621062
%init %{
10631063
/* needed, else crash at runtime */
10641064
import_array();
@@ -1121,15 +1121,8 @@ int * cast_integer_to_int_ptr (int64_t x) {
11211121
void * cast_integer_to_void_ptr (int64_t x) {
11221122
return (void*)x;
11231123
}
1124-
11251124
%}
11261125

1127-
1128-
1129-
1130-
1131-
1132-
11331126
%inline %{
11341127
void wait() {
11351128
// in gdb, use return to get out of this function

0 commit comments

Comments
 (0)