For the FIPS service indicator API, considering the use cases with threads, a variable storing a context is required.
It is true that we could overload (== extend) the use of errno for that, but it is not cleaner solution.
While libgcrypt tries to support builds with C90 compilers on non-modern OSes too, it would be OK to use C compilers' feature of __thread specifier for thread-local storage.
(For C11/C23, we can use <threads.h> and thread_local.)
If it's OK, let us start with __thread assuming C compiler support.