This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 3/4] Add libgomp plugin for Intel MIC
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ilya Verbin <iverbin at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Kirill Yukhin <kirill dot yukhin at gmail dot com>, Andrey Turetskiy <andrey dot turetskiy at gmail dot com>
- Date: Thu, 6 Nov 2014 19:25:36 +0100
- Subject: Re: [PATCH 3/4] Add libgomp plugin for Intel MIC
- Authentication-results: sourceware.org; auth=none
- References: <20141021171323 dot GA47586 at msticlxl57 dot ims dot intel dot com> <20141021172413 dot GD47586 at msticlxl57 dot ims dot intel dot com> <20141022092205 dot GL10376 at tucnak dot redhat dot com> <20141023154112 dot GA65020 at msticlxl57 dot ims dot intel dot com> <20141024143521 dot GF10376 at tucnak dot redhat dot com> <20141024150844 dot GA16821 at msticlxl57 dot ims dot intel dot com> <20141024151858 dot GG10376 at tucnak dot redhat dot com> <20141027121556 dot GB41265 at msticlxl57 dot ims dot intel dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Oct 27, 2014 at 03:15:56PM +0300, Ilya Verbin wrote:
> + bool use_alloca;
> + const char *ld_lib_path = getenv (LD_LIBRARY_PATH_ENV);
> + const char *mic_lib_path = getenv (MIC_LD_LIBRARY_PATH_ENV);
> + char *mic_lib_path_new;
> + size_t len;
> +
> + if (!ld_lib_path)
> + return;
> +
> + len = (mic_lib_path ? strlen (mic_lib_path) : 0) + strlen (ld_lib_path) + 2;
> + use_alloca = len <= 2048;
> +
> + mic_lib_path_new = (char *) (use_alloca ? alloca (len) : malloc (len));
> + if (!mic_lib_path_new)
> + {
> + fprintf (stderr, "%s: Can't allocate memory\n", __FILE__);
> + exit (1);
> + }
> +
> + if (!mic_lib_path)
> + strcpy (mic_lib_path_new, ld_lib_path);
> + else
> + sprintf (mic_lib_path_new, "%s:%s", mic_lib_path, ld_lib_path);
Oh, one more point, if mic_lib_path is NULL, what is the point
to do the alloca/malloc and string copying? Can't you just
setenv (MIC_LD_LIBRARY_PATH_ENV, ld_lib_path, 1);
in that case early?
Otherwise LGTM.
Jakub