This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/4] Add libgomp plugin for Intel MIC


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]