Skip to content

Commit

Permalink
configure: introduce CURL_SIZEOF
Browse files Browse the repository at this point in the history
This is a rewrite of the previously used GPLv3+exception licensed
file. With this change, there is no more reference to GPL so we can
remove that from LICENSES/.

Ref: curl#9220
Closes curl#9291
  • Loading branch information
bagder committed Aug 11, 2022
1 parent d6010c2 commit 9e11c27
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 358 deletions.
232 changes: 0 additions & 232 deletions LICENSES/GPL-3.0-or-later.txt

This file was deleted.

14 changes: 7 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3290,16 +3290,16 @@ AC_TYPE_SIZE_T
CURL_CHECK_STRUCT_TIMEVAL
CURL_VERIFY_RUNTIMELIBS

AX_COMPILE_CHECK_SIZEOF(size_t)
AX_COMPILE_CHECK_SIZEOF(long)
AX_COMPILE_CHECK_SIZEOF(int)
AX_COMPILE_CHECK_SIZEOF(short)
AX_COMPILE_CHECK_SIZEOF(time_t)
AX_COMPILE_CHECK_SIZEOF(off_t)
CURL_SIZEOF(size_t)
CURL_SIZEOF(long)
CURL_SIZEOF(int)
CURL_SIZEOF(short)
CURL_SIZEOF(time_t)
CURL_SIZEOF(off_t)

o=$CPPFLAGS
CPPFLAGS="-I$srcdir/include $CPPFLAGS"
AX_COMPILE_CHECK_SIZEOF(curl_off_t, [
CURL_SIZEOF(curl_off_t, [
#include <curl/system.h>
])
CPPFLAGS=$o
Expand Down
117 changes: 0 additions & 117 deletions m4/ax_compile_check_sizeof.m4

This file was deleted.

59 changes: 59 additions & 0 deletions m4/curl-functions.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5939,3 +5939,62 @@ AC_DEFUN([CURL_ATOMIC],[
])
])
])
# Rewrite inspired by the functionality once provided by
# AX_COMPILE_CHECK_SIZEOF. Uses the switch() "trick" to find the size of the
# given type.
#
# This code fails to compile:
#
# switch() { case 0: case 0: }
#
# By making the second case number a boolean check, it fails to compile the
# test code when the boolean is false and thus creating a zero, making it a
# duplicated case label. If the boolean equals true, it becomes a one, the
# code compiles and we know it was a match.
#
# The check iterates over all possible sizes and stops as soon it compiles
# error-free.
#
# Usage:
#
# CURL_SIZEOF(TYPE, [HEADERS])
#
AC_DEFUN([CURL_SIZEOF], [
dnl The #define name to make autoheader put the name in curl_config.h.in
define(TYPE, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
AC_MSG_CHECKING(size of $1)
r=0
dnl Check the sizes in a reasonable order
for typesize in 8 4 2 16 1; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
$2
]],
[switch(0) {
case 0:
case (sizeof($1) == $typesize):;
}
]) ],
[
r=$typesize],
[
r=0])
dnl get out of the loop once matched
if test $r -gt 0; then
break;
fi
done
if test $r -eq 0; then
AC_MSG_ERROR([Failed to find size of $1])
fi
AC_MSG_RESULT($r)
dnl lowercase and underscore instead of space
tname=$(echo "ac_cv_sizeof_$1" | tr A-Z a-z | tr " " "_")
eval "$tname=$r"
AC_DEFINE_UNQUOTED(TYPE, [$r], [Size of $1 in number of bytes])
])
2 changes: 1 addition & 1 deletion m4/curl-wolfssl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ if test "x$OPT_WOLFSSL" != xno; then
check_for_ca_bundle=1
dnl wolfssl/ctaocrypt/types.h needs SIZEOF_LONG_LONG defined!
AX_COMPILE_CHECK_SIZEOF(long long)
CURL_SIZEOF(long long)
LIBS="$addlib -lm $LIBS"
Expand Down
1 change: 0 additions & 1 deletion scripts/copyright.pl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
# License texts
"LICENSES/BSD-3-Clause.txt" => "<built-in>",
"LICENSES/BSD-4-Clause-UC.txt" => "<built-in>",
"LICENSES/GPL-3.0-or-later.txt" => "<built-in>",
"LICENSES/ISC.txt" => "<built-in>",
"LICENSES/LicenseRef-OpenEvidence.txt" => "<built-in>",
"LICENSES/curl.txt" => "<built-in>",
Expand Down

0 comments on commit 9e11c27

Please sign in to comment.