openEuler release 22.03 LTS上,编译fio工具时,报错“error: static declaration of ‘gettid’ follows non-static declaration”

openEuler release 22.03 LTS上,编译fio工具时,报错“error: static declaration of ‘gettid’ follows non-static declaration”
怀疑与系统内的库及函数gettid冲突,如下。

请问,该问题是否有解决方式,谢谢!!

[root@test166 fio-fio-3.3]# make
CC crc/crc16.o
CC crc/crc32.o
CC crc/crc32c-arm64.o
CC crc/crc32c-intel.o
CC crc/crc32c.o
CC crc/crc64.o
CC crc/crc7.o
CC crc/fnv.o
CC crc/md5.o
CC crc/murmur3.o
CC crc/sha1.o
CC crc/sha256.o
CC crc/sha3.o
In file included from crc/…/os/os.h:33,
from crc/sha3.c:18:
crc/…/os/os-linux.h:124:19: error: static declaration of ‘gettid’ follows non-static declaration
124 | static inline int gettid(void)
| ^~~~~~
In file included from /usr/include/unistd.h:1204,
from crc/…/os/os.h:8,
from crc/sha3.c:18:
/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here
34 | extern __pid_t gettid (void) __THROW;
| ^~~~~~
make: *** [Makefile:329: crc/sha3.o] Error 1

[root@test166 fio-fio-3.3]# cat /etc/*release
openEuler release 22.03 LTS
NAME=“openEuler”

这个错误可能是由于系统头文件中定义的 gettid 函数的定义与 fio 源代码中的函数定义不一致所致。在系统头文件中,gettid 函数是一个非静态的函数,而在 fio 源代码中也定义了一个名为 gettid 的静态函数,导致重复定义。

解决这个错误的方法是,在 fio 源代码中,将 gettid 函数的函数名改为一个不同的名字,或者在调用 gettid 函数时,使用系统头文件定义的 gettid 函数。具体方法如下:

将 fio 源代码中的 gettid 函数的名称改为其他名称,例如 fio_gettid:

static pid_t fio_gettid(void)
{
return syscall(__NR_gettid);
}
或者,您也可以使用系统头文件中定义的 gettid 函数。在 fio 源代码中,找到所有调用 gettid 函数的地方,并将其更改为调用系统头文件中定义的 gettid 函数。例如,在 fio 源代码中:

#define _GNU_SOURCE
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>

pid_t tid = syscall(SYS_gettid);
可以改为:

#define _GNU_SOURCE
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>

pid_t tid = gettid();
这两种方法都可以解决这个问题,选择哪种方法主要取决于个人偏好和代码的实现方式。