check glibc version to avoid redefine gettid()

This commit is contained in:
lingsheng 2020-07-28 09:52:53 +08:00
parent 3f5e018ccc
commit eceadb918a
2 changed files with 46 additions and 2 deletions

View File

@ -0,0 +1,38 @@
From 04f80ac2c822543f130c30942560e4a3300f8481 Mon Sep 17 00:00:00 2001
From: lingsheng <lingsheng@huawei.com>
Date: Tue, 28 Jul 2020 09:41:05 +0800
Subject: [PATCH] Don't redefine gettid if glibc provides it
glibc 2.30+ include a definition for gettid() so that users don't have
to manually define gettid() with syscall().
Old code don't check this, this will redefine gettid() on the latest
versions of glibc, causing build fail.
Signed-off-by: lingsheng <lingsheng@huawei.com>
---
KAE/utils/engine_utils.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/KAE/utils/engine_utils.h b/KAE/utils/engine_utils.h
index 160e449..12a587e 100644
--- a/KAE/utils/engine_utils.h
+++ b/KAE/utils/engine_utils.h
@@ -28,7 +28,15 @@
#include <sys/types.h>
#include <sys/syscall.h>
+#if __GLIBC_PREREQ(2, 30)
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <unistd.h>
+#else
#define gettid() syscall(SYS_gettid)
+#endif
+
#define PRINTPID \
US_DEBUG("pid=%d, ptid=%lu, tid=%d", getpid(), pthread_self(), gettid())
--
2.23.0

View File

@ -3,7 +3,7 @@
Name: libkae
Summary: Huawei Kunpeng Accelerator Engine
Version: 1.2.10
Release: 3
Release: 4
License: Apache-2.0
Source: %{name}-%{version}.tar.gz
Vendor: Huawei Corporation
@ -16,11 +16,14 @@ Provides: %{name} = %{version}-%{release}
BuildRequires: libwd >= %{version} openssl-devel sed
Requires: openssl
ExclusiveArch: aarch64
Patch0001: 0001-Don-t-redefine-gettid-if-glibc-provides-it.patch
%description
This package contains the Huawei Kunpeng Accelerator Engine
%prep
%setup -c -n %{name}-%{version}
%autosetup -c -n %{name}-%{version} -p1
%build
cd KAE
@ -64,6 +67,9 @@ fi
/sbin/ldconfig
%changelog
* Tue Jul 28 2020 lingsheng <lingsheng@huawei.com> 1.2.10-4
- Check glibc version to avoid redefine gettid()
* Sun Mar 15 2020 zhangtao <zhangtao221@huawei.com> 1.2.10-3
- Specify aarch64 compilation