*
* @return
* On success, zero.
- * On failure, a negative number.
+ * On failure, a negative number and an error number is set in rte_errno.
+ * rte_errno can be: ENOMEM - Memory allocation error.
+ * ENOEXEC - Specific OS error.
*/
__rte_experimental
*
* @return
* On success, zero.
- * On failure, a negative number.
+ * On failure, a negative number and an error number is set in rte_errno.
+ * rte_errno can be: EINVAL - Invalid parameter passed.
+ * ENOEXEC - Specific OS error.
*/
__rte_experimental
int rte_thread_tls_key_delete(rte_tls_key key);
*
* @return
* On success, zero.
- * On failure, a negative number.
+ * On failure, a negative number and an error number is set in rte_errno.
+ * rte_errno can be: EINVAL - Invalid parameter passed.
+ * ENOEXEC - Specific OS error.
*/
__rte_experimental
int rte_thread_tls_value_set(rte_tls_key key, const void *value);
* @return
* On success, value data pointer (can also be NULL).
* On failure, NULL and an error number is set in rte_errno.
+ * rte_errno can be: EINVAL - Invalid parameter passed.
+ * ENOEXEC - Specific OS error.
*/
__rte_experimental
void *rte_thread_tls_value_get(rte_tls_key key);
*key = malloc(sizeof(**key));
if ((*key) == NULL) {
RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n");
+ rte_errno = ENOMEM;
return -1;
}
err = pthread_key_create(&((*key)->thread_index), destructor);
RTE_LOG(DEBUG, EAL, "pthread_key_create failed: %s\n",
strerror(err));
free(*key);
+ rte_errno = ENOEXEC;
return -1;
}
return 0;
if (!key) {
RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n");
+ rte_errno = EINVAL;
return -1;
}
err = pthread_key_delete(key->thread_index);
RTE_LOG(DEBUG, EAL, "pthread_key_delete failed: %s\n",
strerror(err));
free(key);
+ rte_errno = ENOEXEC;
return -1;
}
free(key);
if (!key) {
RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n");
+ rte_errno = EINVAL;
return -1;
}
err = pthread_setspecific(key->thread_index, value);
if (err) {
RTE_LOG(DEBUG, EAL, "pthread_setspecific failed: %s\n",
strerror(err));
+ rte_errno = ENOEXEC;
return -1;
}
return 0;
*key = malloc(sizeof(**key));
if ((*key) == NULL) {
RTE_LOG(DEBUG, EAL, "Cannot allocate TLS key.\n");
+ rte_errno = ENOMEM;
return -1;
}
(*key)->thread_index = TlsAlloc();
if ((*key)->thread_index == TLS_OUT_OF_INDEXES) {
RTE_LOG_WIN32_ERR("TlsAlloc()");
free(*key);
+ rte_errno = ENOEXEC;
return -1;
}
return 0;
{
if (!key) {
RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n");
+ rte_errno = EINVAL;
return -1;
}
if (!TlsFree(key->thread_index)) {
RTE_LOG_WIN32_ERR("TlsFree()");
free(key);
+ rte_errno = ENOEXEC;
return -1;
}
free(key);
if (!key) {
RTE_LOG(DEBUG, EAL, "Invalid TLS key.\n");
+ rte_errno = EINVAL;
return -1;
}
/* discard const qualifier */
p = (char *) (uintptr_t) value;
if (!TlsSetValue(key->thread_index, p)) {
RTE_LOG_WIN32_ERR("TlsSetValue()");
+ rte_errno = ENOEXEC;
return -1;
}
return 0;