LCOV - code coverage report
Current view: top level - lib/eal/linux - eal_thread.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 7 9 77.8 %
Date: 2025-03-01 20:23:48 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       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 <unistd.h>
       8                 :            : #include <pthread.h>
       9                 :            : #include <sys/syscall.h>
      10                 :            : 
      11                 :            : #include <rte_eal.h>
      12                 :            : #include <rte_lcore.h>
      13                 :            : #include <rte_log.h>
      14                 :            : #include <rte_string_fns.h>
      15                 :            : 
      16                 :            : #include "eal_private.h"
      17                 :            : 
      18                 :            : /* require calling thread tid by gettid() */
      19                 :        803 : int rte_sys_gettid(void)
      20                 :            : {
      21                 :        803 :         return (int)syscall(SYS_gettid);
      22                 :            : }
      23                 :            : 
      24         [ -  + ]:        493 : void rte_thread_set_name(rte_thread_t thread_id, const char *thread_name)
      25                 :            : {
      26                 :            :         int ret = ENOSYS;
      27                 :            : #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
      28                 :            : #if __GLIBC_PREREQ(2, 12)
      29                 :            :         char truncated[RTE_THREAD_NAME_SIZE];
      30                 :            :         const size_t truncatedsz = sizeof(truncated);
      31                 :            : 
      32         [ -  + ]:        493 :         if (strlcpy(truncated, thread_name, truncatedsz) >= truncatedsz)
      33                 :          0 :                 EAL_LOG(DEBUG, "Truncated thread name");
      34                 :            : 
      35                 :        493 :         ret = pthread_setname_np((pthread_t)thread_id.opaque_id, truncated);
      36                 :            : #endif
      37                 :            : #endif
      38                 :            :         RTE_SET_USED(thread_id);
      39                 :            :         RTE_SET_USED(thread_name);
      40                 :            : 
      41         [ -  + ]:        493 :         if (ret != 0)
      42                 :          0 :                 EAL_LOG(DEBUG, "Failed to set thread name");
      43                 :        493 : }

Generated by: LCOV version 1.14