maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #13293
Re: 6e28a576913: move alloca() definition from all *.h files to one place
Hi, Julius,
this is the combined diff of both commits:
git diff e1ce867e5ab0c^^ e1ce867e5ab0c
On Feb 10, Julius Goryavsky wrote:
> diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
> index a7b98a11050..7d87c4a42b3 100644
> --- a/include/CMakeLists.txt
> +++ b/include/CMakeLists.txt
> @@ -104,6 +105,7 @@ ENDMACRO()
>
> INSTALL_COMPAT_HEADER(my_global.h "")
> INSTALL_COMPAT_HEADER(my_config.h "")
> +INSTALL_COMPAT_HEADER(my_alloca.h "")
I wouldn't use INSTALL_COMPAT_HEADER for my_alloca.h
> INSTALL_COMPAT_HEADER(my_sys.h "")
> INSTALL_COMPAT_HEADER(mysql_version.h "
> #include <mariadb_version.h>
> diff --git a/include/my_alloca.h b/include/my_alloca.h
> new file mode 100644
> index 00000000000..fec0320195e
> --- /dev/null
> +++ b/include/my_alloca.h
> @@ -0,0 +1,37 @@
> +/* Copyright (c) 2023, MariaDB Corporation.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; version 2 of the License.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program; if not, write to the Free Software
> + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
> +
> +#ifndef MY_ALLOCA_INCLUDED
> +#define MY_ALLOCA_INCLUDED
> +
> +#ifdef _WIN32
> +#include <malloc.h> /*for alloca*/
> +#ifndef alloca
When can alloca be defined?
> +#define alloca _alloca
> +#endif
> +#else
> +#include <stdlib.h>
why stdlib.h?
> +#ifdef HAVE_ALLOCA_H
> +#include <alloca.h>
> +#endif
> +#endif
> +
> +#if defined(HAVE_ALLOCA)
> +#if defined(__GNUC__) && !defined(HAVE_ALLOCA_H) && !defined(alloca)
add a comment describing your MinGW use case when this #if is needed
> +#define alloca __builtin_alloca
> +#endif /* GNUC */
> +#endif
> +
> +#endif /* MY_ALLOCA_INCLUDED */
> diff --git a/include/mysql/service_encryption.h b/include/mysql/service_encryption.h
> index 69d205a27e8..cab1418e1d6 100644
> --- a/include/mysql/service_encryption.h
> +++ b/include/mysql/service_encryption.h
> @@ -24,21 +24,19 @@
> *provider* (encryption plugin).
> */
>
> +#ifndef MYSQL_ABI_CHECK
> +#include <my_alloca.h>
> +#endif
> +
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> #ifndef MYSQL_ABI_CHECK
why not to put #include <my_alloca.h> here?
> #ifdef _WIN32
> -#include <malloc.h>
> #ifndef __cplusplus
> #define inline __inline
> #endif
> -#else
> -#include <stdlib.h>
I suspect stdlib.h belongs here, not in my_alloca.h
> -#ifdef HAVE_ALLOCA_H
> -#include <alloca.h>
> -#endif
> #endif
> #endif
Regards,
Sergei
VP of MariaDB Server Engineering
and security@xxxxxxxxxxx