1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2014 Intel Corporation 3 */ 4 5 #include <errno.h> 6 #include <stdio.h> 7 #include <stdlib.h> 8 #include <stdint.h> 9 #include <unistd.h> 10 #include <sched.h> 11 #include <pthread_np.h> 12 #include <sys/queue.h> 13 #include <sys/thr.h> 14 15 #include <rte_debug.h> 16 #include <rte_atomic.h> 17 #include <rte_launch.h> 18 #include <rte_log.h> 19 #include <rte_memory.h> 20 #include <rte_per_lcore.h> 21 #include <rte_eal.h> 22 #include <rte_lcore.h> 23 24 #include "eal_private.h" 25 #include "eal_thread.h" 26 27 /* require calling thread tid by gettid() */ rte_sys_gettid(void)28int rte_sys_gettid(void) 29 { 30 long lwpid; 31 thr_self(&lwpid); 32 return (int)lwpid; 33 } 34 rte_thread_set_name(rte_thread_t thread_id,const char * thread_name)35void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name) 36 { 37 char truncated[RTE_THREAD_NAME_SIZE]; 38 const size_t truncatedsz = sizeof(truncated); 39 40 if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz) 41 EAL_LOG(DEBUG, "Truncated thread name"); 42 43 pthread_set_name_np((pthread_t)thread_id.opaque_id, truncated); 44 } 45