From f81841857fb895c844bb34a99a16b1c6c96beaf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Mon, 3 Apr 2023 14:58:07 +0200
Subject: [PATCH] MEX: better type definition for BLAS/LAPACK integers in C and
 C++

int64_t on 64-bit machines better expresses the intent than ptrdiff_t. This is
also more consistent with what is done in Fortran.
---
 mex/sources/dynblas.h   | 10 +++++-----
 mex/sources/dynlapack.h | 10 +++++-----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/mex/sources/dynblas.h b/mex/sources/dynblas.h
index be0586b061..c6d62e3d73 100644
--- a/mex/sources/dynblas.h
+++ b/mex/sources/dynblas.h
@@ -8,7 +8,7 @@
  * and MATLAB_VERSION (for version 7.4, define it to 0x0704).
  *
  *
- * Copyright © 2009-2020 Dynare Team
+ * Copyright © 2009-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -29,13 +29,13 @@
 #ifndef _DYNBLAS_H
 #define _DYNBLAS_H
 
-#if defined(MATLAB_MEX_FILE)
+#if defined(MATLAB_MEX_FILE) && __SIZEOF_POINTER__ == 8
 # ifdef __cplusplus
-#  include <cstddef>
+#  include <cstdint>
 # else
-#  include <stddef.h>
+#  include <stdint.h>
 # endif
-typedef ptrdiff_t blas_int;
+typedef int64_t blas_int;
 #else
 typedef int blas_int;
 #endif
diff --git a/mex/sources/dynlapack.h b/mex/sources/dynlapack.h
index 2b95919e0c..59d394241c 100644
--- a/mex/sources/dynlapack.h
+++ b/mex/sources/dynlapack.h
@@ -8,7 +8,7 @@
  * and MATLAB_VERSION (for version 7.4, define it to 0x0704).
  *
  *
- * Copyright © 2009-2020 Dynare Team
+ * Copyright © 2009-2023 Dynare Team
  *
  * This file is part of Dynare.
  *
@@ -29,13 +29,13 @@
 #ifndef _DYNLAPACK_H
 #define _DYNLAPACK_H
 
-#if defined(MATLAB_MEX_FILE)
+#if defined(MATLAB_MEX_FILE) && __SIZEOF_POINTER__ == 8
 # ifdef __cplusplus
-#  include <cstddef>
+#  include <cstdint>
 # else
-#  include <stddef.h>
+#  include <stdint.h>
 # endif
-typedef ptrdiff_t lapack_int;
+typedef int64_t lapack_int;
 #else
 typedef int lapack_int;
 #endif
-- 
GitLab