Various changes to improve C99 compatibility (#2152303)
Related to: <https://fedoraproject.org/wiki/Changes/PortingToModernC> <https://fedoraproject.org/wiki/Toolchain/PortingToModernC>
This commit is contained in:
parent
c8b4c223a5
commit
f3bdffb458
18
libdb-1.85-c99.patch
Normal file
18
libdb-1.85-c99.patch
Normal file
@ -0,0 +1,18 @@
|
||||
Do not build snprintf. Instead use the one in glibc.
|
||||
This avoids an implicit function declaration of vsprintf.
|
||||
|
||||
snprintf is only called from db.1.85/btree/bt_open.c, and the length
|
||||
checking in the glibc implementation seems harmless there.
|
||||
|
||||
diff -ur db-5.3.28.orig/db.1.85/PORT/linux/Makefile db-5.3.28/db.1.85/PORT/linux/Makefile
|
||||
--- db-5.3.28.orig/db.1.85/PORT/linux/Makefile 2022-12-10 12:29:48.599322424 +0100
|
||||
+++ db-5.3.28/db.1.85/PORT/linux/Makefile 2022-12-10 12:35:08.415288426 +0100
|
||||
@@ -11,7 +11,7 @@
|
||||
OBJ5= rec_close.o rec_delete.o rec_get.o rec_open.o rec_put.o rec_search.o \
|
||||
rec_seq.o rec_utils.o
|
||||
|
||||
-MISC= snprintf.o
|
||||
+MISC=
|
||||
|
||||
${LIBDB}: ${OBJ1} ${OBJ2} ${OBJ3} ${OBJ4} ${OBJ5} ${MISC}
|
||||
rm -f $@
|
26
libdb-c99.patch
Normal file
26
libdb-c99.patch
Normal file
@ -0,0 +1,26 @@
|
||||
Add additional header files to avoid implicit declaration of the flock
|
||||
and usleep functions. Improves C99 compatibility.
|
||||
|
||||
diff -ur db-5.3.28.orig/src/os/os_flock.c db-5.3.28/src/os/os_flock.c
|
||||
--- db-5.3.28.orig/src/os/os_flock.c 2022-12-10 12:29:48.614322281 +0100
|
||||
+++ db-5.3.28/src/os/os_flock.c 2022-12-10 14:33:21.785814691 +0100
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include "db_int.h"
|
||||
|
||||
+#include <sys/file.h>
|
||||
+
|
||||
#if !defined(HAVE_FCNTL) || !defined(HAVE_FLOCK)
|
||||
static int __os_filelocking_notsup __P((ENV *));
|
||||
#endif
|
||||
diff -ur db-5.3.28.orig/util/db_dump185.c db-5.3.28/util/db_dump185.c
|
||||
--- db-5.3.28.orig/util/db_dump185.c 2013-09-09 17:35:12.000000000 +0200
|
||||
+++ db-5.3.28/util/db_dump185.c 2022-12-10 12:35:08.415288426 +0100
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_DB_185_H
|
||||
#include <db_185.h>
|
282
libdb-configure-c99.patch
Normal file
282
libdb-configure-c99.patch
Normal file
@ -0,0 +1,282 @@
|
||||
Port the configure script to C99. Add missing header files, avoid
|
||||
calling the undeclared exit function, and add missing return types
|
||||
main. This improves compatibility with compilers which do not accept
|
||||
language features that were removed from C99.
|
||||
|
||||
diff -ur db-5.3.28.orig/dist/aclocal/clock.m4 db-5.3.28/dist/aclocal/clock.m4
|
||||
--- db-5.3.28.orig/dist/aclocal/clock.m4 2013-09-09 17:35:02.000000000 +0200
|
||||
+++ db-5.3.28/dist/aclocal/clock.m4 2022-12-10 12:35:08.415288426 +0100
|
||||
@@ -21,12 +21,14 @@
|
||||
AC_CACHE_CHECK([for clock_gettime monotonic clock], db_cv_clock_monotonic, [
|
||||
AC_TRY_RUN([
|
||||
#include <sys/time.h>
|
||||
-main() {
|
||||
+#include <time.h>
|
||||
+int main() {
|
||||
struct timespec t;
|
||||
return (clock_gettime(CLOCK_MONOTONIC, &t) != 0);
|
||||
}], db_cv_clock_monotonic=yes, db_cv_clock_monotonic=no,
|
||||
AC_TRY_LINK([
|
||||
-#include <sys/time.h>], [
|
||||
+#include <sys/time.h>
|
||||
+#include <time.h>], [
|
||||
struct timespec t;
|
||||
clock_gettime(CLOCK_MONOTONIC, &t);
|
||||
], db_cv_clock_monotonic=yes, db_cv_clock_monotonic=no))
|
||||
diff -ur db-5.3.28.orig/dist/aclocal/mmap.m4 db-5.3.28/dist/aclocal/mmap.m4
|
||||
--- db-5.3.28.orig/dist/aclocal/mmap.m4 2013-09-09 17:35:02.000000000 +0200
|
||||
+++ db-5.3.28/dist/aclocal/mmap.m4 2022-12-10 12:38:04.520617781 +0100
|
||||
@@ -45,10 +45,10 @@
|
||||
int catch_sig(sig)
|
||||
int sig;
|
||||
{
|
||||
- exit(1);
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
- main() {
|
||||
+ int main() {
|
||||
const char *underlying;
|
||||
unsigned gapsize;
|
||||
char *base;
|
||||
diff -ur db-5.3.28.orig/dist/aclocal/mutex.m4 db-5.3.28/dist/aclocal/mutex.m4
|
||||
--- db-5.3.28.orig/dist/aclocal/mutex.m4 2013-09-09 17:35:02.000000000 +0200
|
||||
+++ db-5.3.28/dist/aclocal/mutex.m4 2022-12-10 12:35:08.415288426 +0100
|
||||
@@ -5,7 +5,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
-main() {
|
||||
+int main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_condattr_t condattr;
|
||||
@@ -49,7 +49,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
-main() {
|
||||
+int main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
pthread_condattr_t condattr;
|
||||
@@ -89,7 +89,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
-main() {
|
||||
+int main() {
|
||||
pthread_cond_t cond;
|
||||
pthread_condattr_t condattr;
|
||||
exit(pthread_condattr_init(&condattr) ||
|
||||
@@ -110,7 +110,7 @@
|
||||
AC_TRY_RUN([
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
-main() {
|
||||
+int main() {
|
||||
pthread_rwlock_t rwlock;
|
||||
pthread_rwlockattr_t rwlockattr;
|
||||
exit(pthread_rwlockattr_init(&rwlockattr) ||
|
||||
@@ -282,7 +282,7 @@
|
||||
# x86/gcc: FreeBSD, NetBSD, BSD/OS, Linux
|
||||
AC_TRY_COMPILE(,[
|
||||
#if (defined(i386) || defined(__i386__)) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -291,7 +291,7 @@
|
||||
# x86_64/gcc: FreeBSD, NetBSD, BSD/OS, Linux
|
||||
AC_TRY_COMPILE(,[
|
||||
#if (defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -314,7 +314,7 @@
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__sparc__) && defined(__GNUC__)
|
||||
asm volatile ("membar #StoreStore|#StoreLoad|#LoadStore");
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -356,7 +356,7 @@
|
||||
msem_init(&x, 0);
|
||||
msem_lock(&x, 0);
|
||||
msem_unlock(&x, 0);
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -373,7 +373,7 @@
|
||||
msem_init(&x, 0);
|
||||
msem_lock(&x, 0);
|
||||
msem_unlock(&x, 0);
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
], [db_cv_mutex=UNIX/msem_init])
|
||||
fi
|
||||
|
||||
@@ -395,7 +395,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__USLC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -452,7 +452,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__alpha) && defined(__DECC)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -463,7 +463,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__alpha) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -474,7 +474,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__arm__) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -485,7 +485,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if (defined(__mips) || defined(__mips__)) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -496,7 +496,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if (defined(__hppa) || defined(__hppa__)) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -507,7 +507,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -518,7 +518,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if (defined(mc68020) || defined(sun3)) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -529,7 +529,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__MVS__) && defined(__IBMC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -540,7 +540,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__s390__) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -551,7 +551,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(__ia64) && defined(__GNUC__)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -562,7 +562,7 @@
|
||||
if test "$db_cv_mutex" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if defined(_UTS)
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
@@ -910,9 +910,9 @@
|
||||
if test "$db_cv_atomic" = no; then
|
||||
AC_TRY_COMPILE(,[
|
||||
#if ((defined(i386) || defined(__i386__)) && defined(__GNUC__))
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#elif ((defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__))
|
||||
- exit(0);
|
||||
+ return 0;
|
||||
#else
|
||||
FAIL TO COMPILE/LINK
|
||||
#endif
|
||||
diff -ur db-5.3.28.orig/dist/aclocal/sequence.m4 db-5.3.28/dist/aclocal/sequence.m4
|
||||
--- db-5.3.28.orig/dist/aclocal/sequence.m4 2022-12-10 12:29:48.598322433 +0100
|
||||
+++ db-5.3.28/dist/aclocal/sequence.m4 2022-12-10 12:35:08.415288426 +0100
|
||||
@@ -43,7 +43,9 @@
|
||||
# test, which won't test for the appropriate printf format strings.
|
||||
if test "$db_cv_build_sequence" = "yes"; then
|
||||
AC_TRY_RUN([
|
||||
- main() {
|
||||
+ #include <stdio.h>
|
||||
+ #include <string.h>
|
||||
+ int main() {
|
||||
$db_cv_seq_type l;
|
||||
unsigned $db_cv_seq_type u;
|
||||
char buf@<:@100@:>@;
|
||||
@@ -59,7 +61,10 @@
|
||||
return (1);
|
||||
return (0);
|
||||
}],, [db_cv_build_sequence="no"],
|
||||
- AC_TRY_LINK(,[
|
||||
+ AC_TRY_LINK([
|
||||
+ #include <stdio.h>
|
||||
+ #include <string.h>
|
||||
+ ],[
|
||||
$db_cv_seq_type l;
|
||||
unsigned $db_cv_seq_type u;
|
||||
char buf@<:@100@:>@;
|
||||
diff -ur db-5.3.28.orig/dist/configure.ac db-5.3.28/dist/configure.ac
|
||||
--- db-5.3.28.orig/dist/configure.ac 2022-12-10 12:29:48.610322320 +0100
|
||||
+++ db-5.3.28/dist/configure.ac 2022-12-10 12:43:38.840398043 +0100
|
||||
@@ -1047,6 +1047,7 @@
|
||||
AC_CACHE_CHECK([for dl_iterate_phdr], db_cv_dl_iterate_phdr, [
|
||||
AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
+#include <link.h>
|
||||
#include <netdb.h>], [
|
||||
dl_iterate_phdr(0, 0);
|
||||
], [db_cv_dl_iterate_phdr=yes], [db_cv_dl_iterate_phdr=no])])
|
20
libdb-sqlite-c99.patch
Normal file
20
libdb-sqlite-c99.patch
Normal file
@ -0,0 +1,20 @@
|
||||
Avoid implicit function declarations due to missing prototypes for
|
||||
internal functions.
|
||||
|
||||
diff -ur db-5.3.28.orig/lang/sql/sqlite/src/test_stat.c db-5.3.28/lang/sql/sqlite/src/test_stat.c
|
||||
--- db-5.3.28.orig/lang/sql/sqlite/src/test_stat.c 2013-09-09 17:35:06.000000000 +0200
|
||||
+++ db-5.3.28/lang/sql/sqlite/src/test_stat.c 2022-12-10 14:40:10.362683745 +0100
|
||||
@@ -136,6 +136,13 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
+** Internal functions used by this test.
|
||||
+*/
|
||||
+int sqlite3PagerGet(Pager *pPager, Pgno pgno, DbPage **ppPage);
|
||||
+void *sqlite3PagerGetData(DbPage *pPg);
|
||||
+void sqlite3PagerUnref(DbPage *pPg);
|
||||
+
|
||||
+/*
|
||||
** Connect to or create a statvfs virtual table.
|
||||
*/
|
||||
static int statConnect(
|
14
libdb.spec
14
libdb.spec
@ -9,7 +9,7 @@
|
||||
Summary: The Berkeley DB database library for C
|
||||
Name: libdb
|
||||
Version: 5.3.28
|
||||
Release: 53%{?dist}
|
||||
Release: 54%{?dist}
|
||||
Source0: http://download.oracle.com/berkeley-db/db-%{version}.tar.gz
|
||||
Source1: http://download.oracle.com/berkeley-db/db.1.85.tar.gz
|
||||
# For mt19937db.c
|
||||
@ -63,6 +63,11 @@ Patch40: db-5.3.28_cve-2019-2708.patch
|
||||
# Prevents high CPU usage
|
||||
Patch41: db-5.3.28-mmap-high-cpu-usage.patch
|
||||
|
||||
Patch42: libdb-1.85-c99.patch
|
||||
Patch43: libdb-c99.patch
|
||||
Patch44: libdb-configure-c99.patch
|
||||
Patch45: libdb-sqlite-c99.patch
|
||||
|
||||
URL: http://www.oracle.com/database/berkeley-db/
|
||||
License: BSD and LGPLv2 and Sleepycat
|
||||
BuildRequires: gcc gcc-c++
|
||||
@ -257,6 +262,10 @@ popd
|
||||
%patch39 -p1
|
||||
%patch40 -p1 -b .cve-2019-2708
|
||||
%patch41 -p1
|
||||
%patch42 -p1
|
||||
%patch43 -p1
|
||||
%patch44 -p1
|
||||
%patch45 -p1
|
||||
|
||||
cd dist
|
||||
./s_config
|
||||
@ -417,6 +426,9 @@ mv man/* ${RPM_BUILD_ROOT}%{_mandir}/man1
|
||||
%{_includedir}/%{name}/dbsql.h
|
||||
|
||||
%changelog
|
||||
* Sat Dec 10 2022 Florian Weimer <fweimer@redhat.com> - 5.3.28-54
|
||||
- Various changes to improve C99 compatibility (#2152303)
|
||||
|
||||
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5.3.28-53
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user