Blob Blame History Raw
commit 85aed0c60431104446bb904d44066be0bae225d1
Author: Jerry James <loganjerry@gmail.com>
Date:   Tue Nov 22 08:56:51 2022 -0700

    Migrate K&R C in the config scripts to ANSI C

--- api/libbacktrace/src/Clib/bglbacktrace.c.orig	2022-12-29 23:55:22.000000000 -0700
+++ api/libbacktrace/src/Clib/bglbacktrace.c	2023-12-01 10:05:41.064729924 -0700
@@ -191,7 +191,6 @@ bgl_backtrace_foreach(void *proc) {
    if (env) {
       struct backtrace_state *bt_state = libbacktrace_get_state(env);
       backtrace_full(bt_state, 0, backtrace_foreach_cb, cbe, proc);
-      return BUNSPEC;
    }
 }
 
--- api/ssl/src/C/bglssl.c.orig	2022-12-29 23:55:22.000000000 -0700
+++ api/ssl/src/C/bglssl.c	2023-12-01 09:51:44.236639443 -0700
@@ -52,6 +52,11 @@
 #  include <openssl/rand.h>
 #endif
 
+// Avoid GCC 14 errors
+extern int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
+extern void HMAC_CTX_init(HMAC_CTX *ctx);
+extern void HMAC_CTX_cleanup(HMAC_CTX *ctx);
+
 #if( !defined( OPENSSL_NPN_UNSUPPORTED ) )
 #  define OPENSSL_NPN_UNSUPPORTED 0
 #endif
@@ -1743,7 +1748,7 @@ bgl_ssl_connection_clear_pending( ssl_co
 /*    bgl_get_session_callback ...                                     */
 /*---------------------------------------------------------------------*/
 static SSL_SESSION *
-bgl_get_session_callback( SSL *ssl, unsigned char *key, int len, int *copy ) {
+bgl_get_session_callback( SSL *ssl, const unsigned char *key, int len, int *copy ) {
    ssl_connection c = (ssl_connection)(SSL_get_app_data( ssl ));
    SSL_SESSION *sess = CCON( c )->BgL_z42nextzd2sessionz90;
    
@@ -2310,7 +2315,7 @@ bgl_ssl_connection_get_peer_certificate(
       }
 
       STACK_OF(ASN1_OBJECT) *eku =
-	 (ASN1_OBJECT *)X509_get_ext_d2i( peer_cert, NID_ext_key_usage, NULL, NULL );
+	 (STACK_OF(ASN1_OBJECT) *)X509_get_ext_d2i( peer_cert, NID_ext_key_usage, NULL, NULL );
       if( eku != NULL ) {
 	 char buf[ 256 ];
 	 int len = sk_ASN1_OBJECT_num( eku );
diff --git autoconf/alsa autoconf/alsa
index 028a1979..3d354afb 100755
--- autoconf/alsa
+++ autoconf/alsa
@@ -72,6 +72,7 @@ cat > $file.c <<EOF
  *  This extra small demo sends a random samples to your speakers.
  */
 
+#include <stdio.h>
 #include <alsa/asoundlib.h>
 
 static char *device = "default";                        /* playback device */
diff --git autoconf/ccoptim autoconf/ccoptim
index 297fafdc..117bbb39 100755
--- autoconf/ccoptim
+++ autoconf/ccoptim
@@ -85,6 +85,8 @@ fi
 #*    allocations. We try to detect this in the Bigloo configuration.  */
 #*---------------------------------------------------------------------*/
 cat > $file2.c <<EOF
+extern int failure_then_exit(int);
+extern int foo(int);
 int gcc3xxx_bug( int x ) {
    /* This function is badly compiled, the value of x is not restored */
    /* after the call to foo. This is supposed to be fixed             */
diff --git autoconf/environ autoconf/environ
index a6ec506c..dc2adbe6 100755
--- autoconf/environ
+++ autoconf/environ
@@ -52,9 +52,7 @@ fi
 cat > $file.c <<EOF
 #include <unistd.h>
 
-main( argc, argv )
-int   argc;
-char *argv[];
+int main( int argc, char *argv[] )
 {
    extern char **environ;
    return (environ != 0) && (&execv != 0);
diff --git autoconf/gccattrs autoconf/gccattrs
index 592b525d..1b2a56d0 100755
--- autoconf/gccattrs
+++ autoconf/gccattrs
@@ -73,7 +73,7 @@ __malloc void *foo() {
   return malloc( 10 );
 }
 
-__noreturn stop() {
+__noreturn void stop() {
   exit( 0 );
 }
 
diff --git autoconf/gchavedoblocking autoconf/gchavedoblocking
index 111ff9c7..6374a0fe 100755
--- autoconf/gchavedoblocking
+++ autoconf/gchavedoblocking
@@ -74,7 +74,7 @@ int check_addr( long a1, long a2 ) {
     return a1 > a2;
 }
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    GC_init();
    if( check_addr( &GC_do_blocking, &main ) ) puts( "yes" ); else puts( "yes" );
    return 0;
diff --git autoconf/gchavestartblocking autoconf/gchavestartblocking
index f85f16c8..1c9bc0b0 100755
--- autoconf/gchavestartblocking
+++ autoconf/gchavestartblocking
@@ -70,7 +70,7 @@ cat > $file.c <<EOF
 #include <stdio.h>
 extern GC_start_blocking();
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    GC_init();
    if( GC_start_blocking() ) puts( "yes" ); else puts( "yes" );
    return 0;
diff --git autoconf/getaddrinfo autoconf/getaddrinfo
index bf035e71..130e0c29 100755
--- autoconf/getaddrinfo
+++ autoconf/getaddrinfo
@@ -75,8 +75,9 @@ cat > $file.c <<EOF
 #ifdef BGL_ANDROID
 #  include <linux/in.h>
 #endif
+#include <arpa/inet.h>
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    int status;
    struct addrinfo hints;
    struct addrinfo *res, *rp;       
diff --git autoconf/gethwaddrs autoconf/gethwaddrs
index 7ecd0330..94f8fa11 100755
--- autoconf/gethwaddrs
+++ autoconf/gethwaddrs
@@ -58,6 +58,8 @@ fi
 #*---------------------------------------------------------------------*/
 cat > $file.c <<EOF
 #include <stdio.h>
+#include <string.h>
+#include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>    
 #include <sys/socket.h>
diff --git autoconf/inet_aton autoconf/inet_aton
index 6b4abb92..d9758957 100755
--- autoconf/inet_aton
+++ autoconf/inet_aton
@@ -72,8 +72,9 @@ cat > $file.c <<EOF
 #endif
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#include <arpa/inet.h>
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    return (inet_aton( "127.0.0.1", (void *)argv ) > 0);
 }
 EOF
diff --git autoconf/inet_pton autoconf/inet_pton
index 47d71f3c..a101968b 100755
--- autoconf/inet_pton
+++ autoconf/inet_pton
@@ -81,8 +81,9 @@ cat > $file.c <<EOF
 #endif
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#include <arpa/inet.h>
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    return (inet_pton( AF_INET, "127.0.0.1", (void *)argv ) > 0);
 }
 EOF
diff --git autoconf/jartest autoconf/jartest
index 2ba133ca..ec8469c0 100755
--- autoconf/jartest
+++ autoconf/jartest
@@ -61,9 +61,8 @@ fi
 #*    Test                                                             */
 #*---------------------------------------------------------------------*/
 cat > $file.txt <<EOF
-main( argc, argv )
-int   argc;
-char *argv[];
+#include <stdlib.h>
+int main( int argc, char *argv[] )
 {
    exit( 0 );
 }
--- autoconf/openssl-getter.orig
+++ autoconf/openssl-getter
@@ -73,7 +73,7 @@ int main( int argc, char *argv[] ) {
     DH *dh;
     const BIGNUM *key;
     DH_get0_key( dh, &key, 0 );
-    return SSL_CTX_get_ssl_method( ctx );
+    return (SSL_CTX_get_ssl_method( ctx ) == NULL) ? 1 : 0;
 }
 EOF
 
diff --git autoconf/openssl-tls13 autoconf/openssl-tls13
index 0981d682..c3a781ea 100755
--- autoconf/openssl-tls13
+++ autoconf/openssl-tls13
@@ -68,6 +68,7 @@ cat > $file.c <<EOF
 #include <openssl/bio.h>
 
 static SSL_CTX *ctx;
+extern const SSL_METHOD *TLSv1_3_client_method(void);
 
 int main( int argc, char *argv[] ) {
     BIO *sbio;
diff --git autoconf/openssl-v2 autoconf/openssl-v2
index 5e065cc3..9dbaa243 100755
--- autoconf/openssl-v2
+++ autoconf/openssl-v2
@@ -68,6 +68,7 @@ cat > $file.c <<EOF
 #include <openssl/bio.h>
 
 static SSL_CTX *ctx;
+const SSL_METHOD *SSLv2_server_method(void);
 
 int main( int argc, char *argv[] ) {
     BIO *sbio;
diff --git autoconf/openssl-v3 autoconf/openssl-v3
index ab4a6a34..bb6f1678 100755
--- autoconf/openssl-v3
+++ autoconf/openssl-v3
@@ -68,6 +68,7 @@ cat > $file.c <<EOF
 #include <openssl/bio.h>
 
 static SSL_CTX *ctx;
+const SSL_METHOD *SSLv3_server_method(void);
 
 int main( int argc, char *argv[] ) {
     BIO *sbio;
diff --git autoconf/ptrsize autoconf/ptrsize
index da2ff8c2..06354f4b 100755
--- autoconf/ptrsize
+++ autoconf/ptrsize
@@ -50,7 +50,8 @@ fi
 #*    Test                                                             */
 #*---------------------------------------------------------------------*/
 cat > $file.c <<EOF
-int main () { printf( "%d\n", sizeof( int * ) ); }
+#include <stdio.h>
+int main () { printf( "%zu\n", sizeof( int * ) ); }
 EOF
 
 #*---------------------------------------------------------------------*/
diff --git autoconf/sendfile autoconf/sendfile
index 5ab5e0ca..11209262 100755
--- autoconf/sendfile
+++ autoconf/sendfile
@@ -104,9 +104,7 @@ cat > $file.c <<EOF
 #include <sys/socket.h>
 #include <sys/uio.h>
 
-main( argc, argv )
-int   argc;
-char *argv[];
+int main( int argc, char *argv[] )
 {
    char buffer [50];
    FILE *fd = fopen( "/etc/hosts", "r" );
diff --git autoconf/setsockopt autoconf/setsockopt
index 7c48286f..4cc152b1 100755
--- autoconf/setsockopt
+++ autoconf/setsockopt
@@ -77,7 +77,7 @@ cat > $file.c <<EOF
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    int s = socket( AF_INET, SOCK_STREAM, 0 );
    int sock_opt = 1;
 
diff --git autoconf/socket autoconf/socket
index 5bf55d71..8eb188aa 100755
--- autoconf/socket
+++ autoconf/socket
@@ -68,10 +68,12 @@ cat > $file.c <<EOF
 #ifdef _MINGW_VER
 #include <winsock2.h>
 #endif
+#include <stdio.h>
+extern int gethostbyname(const char *);
+extern int getsockname(long, long, long);
+extern int accept(long, long, long);
 
-main( argc, argv )
-int   argc;
-char *argv[];
+int main( int argc, char *argv[] )
 {
    printf( "%d\n", gethostbyname( "toto" ) );
    printf( "%8x\n", getsockname( 0L, 0L, 0L ) );
diff --git autoconf/socklen autoconf/socklen
index 775b11b5..bec90627 100755
--- autoconf/socklen
+++ autoconf/socklen
@@ -72,7 +72,7 @@ cat > $file.c <<EOF
 #include <winsock2.h>
 #endif
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    printf( "%d\n", (socklen_t)argc );
    return 0;
 }
diff --git autoconf/unixsocket autoconf/unixsocket
index 231dc5bf..973409c6 100755
--- autoconf/unixsocket
+++ autoconf/unixsocket
@@ -77,7 +77,7 @@ cat > $file.c <<EOF
 #include <stdlib.h>
 #include <string.h>
 
-main( int argc, char *argv[] ) {
+int main( int argc, char *argv[] ) {
    int s;
    struct sockaddr_un saddr;
 
@@ -85,6 +85,7 @@ main( int argc, char *argv[] ) {
 
    strcpy( saddr.sun_path, "/tmp/foo" );
    connect( s, (struct sockaddr *)&saddr, sizeof( saddr ) );
+   return 0;
 }
 EOF
 
diff --git autoconf/ziptest autoconf/ziptest
index 02cc1893..bd7af72d 100755
--- autoconf/ziptest
+++ autoconf/ziptest
@@ -61,9 +61,8 @@ fi
 #*    Test                                                             */
 #*---------------------------------------------------------------------*/
 cat > $file.txt <<EOF
-main( argc, argv )
-int   argc;
-char *argv[];
+#include <stdlib.h>
+int main( int argc, char *argv[] )
 {
    exit( 0 );
 }
--- gc/gc-8.2.2.patch.orig	2022-12-29 23:55:22.000000000 -0700
+++ gc/gc-8.2.2.patch	2023-11-30 15:36:16.039764489 -0700
@@ -189,3 +189,48 @@ diff -Naur gc-8.2.2.orig/Makefile.in gc-
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backgraph.Plo@am__quote@ # am--include-marker
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blacklst.Plo@am__quote@ # am--include-marker
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checksums.Plo@am__quote@ # am--include-marker
+diff -Naur gc-8.2.2.orig/configure.ac gc-8.2.2/configure.ac
+--- gc-8.2.2.orig/configure.ac	2022-08-26 12:44:49.000000000 -0600
++++ gc-8.2.2/configure.ac	2023-11-30 15:32:49.187695181 -0700
+@@ -833,13 +833,15 @@
+ AS_IF([test "$THREADS" = posix],
+   [AC_MSG_CHECKING(for pthread_setname_np)
+    old_CFLAGS="$CFLAGS"
+-   CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror"
+-   AC_TRY_COMPILE([#include <pthread.h>],
++   CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror -pthread"
++   AC_TRY_COMPILE([#define _GNU_SOURCE
++                   #include <pthread.h>],
+                   [pthread_setname_np("thread-name")],
+      [AC_MSG_RESULT([yes (w/o tid)])
+       AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID], [1],
+                 [Define to use 'pthread_setname_np(const char*)' function.])],
+-     [AC_TRY_COMPILE([#include <pthread.h>],
++     [AC_TRY_COMPILE([#define _GNU_SOURCE
++                      #include <pthread.h>],
+                      [pthread_setname_np(pthread_self(), "thread-name-%u", 0)],
+        [AC_MSG_RESULT([yes (with tid and arg)])
+         AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG], [1],
+diff -Naur gc-8.2.2.orig/configure.ac gc-8.2.2/configure.ac
+--- gc-8.2.2.orig/configure	2022-08-26 12:45:05.000000000 -0600
++++ gc-8.2.2/configure	2023-11-30 15:34:02.851651485 -0700
+@@ -17565,9 +17565,10 @@
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_setname_np" >&5
+ $as_echo_n "checking for pthread_setname_np... " >&6; }
+    old_CFLAGS="$CFLAGS"
+-   CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror"
++   CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror -pthread"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
++#define _GNU_SOURCE
+ #include <pthread.h>
+ int
+ main ()
+@@ -17586,6 +17587,7 @@
+ else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
++#define _GNU_SOURCE
+ #include <pthread.h>
+ int
+ main ()