This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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 2/4] Initialize tunable list with the GLIBC_TUNABLES environment variable


On Tuesday 27 December 2016 05:11 PM, Florian Weimer wrote:
> See my initial mail.  errno and __getpagesize are not available at this
> point.

Ugh, right.  I'll try to come up with something that does not need an
additional allocation.

>> +static size_t
>> +min_strlen (const char *s)
>> +{
>> +  size_t i = 0;
>> +  while (*s++ != '\0')
>> +    i++;
>> +
>> +  return i;
>> +}
> 
> Is there anything which ensures that GCC does not replace this
> implementation with strlen?

I think I'm missing a gcc flag here to ensure that.  I'll find out and
add it.

>>  /* Disable a tunable if it is set.  */
>>  static void
>>  disable_tunable (tunable_id_t id, char **envp)
>> @@ -216,6 +318,23 @@ disable_tunable (tunable_id_t id, char **envp)
>>
>>    if (env_alias)
>>      tunables_unsetenv (envp, tunable_list[id].env_alias);
>> +
>> +  char *tunable = getenv (GLIBC_TUNABLES);
>> +  const char *cmp = tunable_list[id].name;
>> +  const size_t len = min_strlen (cmp);
>> +
>> +  while (tunable && *tunable != '\0' && *tunable != ':')
>> +    {
>> +      if (is_name (tunable, cmp))
>> +    {
>> +      tunable += len;
>> +      /* Overwrite the = and the value with colons.  */
>> +      while (*tunable != '\0' && *tunable != ':')
>> +        *tunable++ = ':';
>> +      break;
>> +    }
>> +      tunable++;
>> +    }
>>  }
> 
> This assumes that the process environment is not mapped read-only.  I'm
> not sure if this is guaranteed by the ABI.

Barring tunables with string values this might be easy to work around.
Let me give this a shot too.

Siddhesh


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