The Blackfin sim uses this function, but Windows/mingw doesn't provide it.
+2021-05-24 Mike Frysinger <vapier@gentoo.org>
+
+ * update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add ffs.
+ * aclocal.m4, configure, Makefile.in, import/Makefile.am,
+ import/Makefile.in, import/m4/gnulib-cache.m4,
+ import/m4/gnulib-comp.m4: Regenerate.
+ * import/ffs.c, import/m4/ffs.m4, import/m4/strings_h.m4,
+ import/strings.in.h: New files.
+
2021-05-04 Mike Frysinger <vapier@gentoo.org>
* update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add gendocs.
$(top_srcdir)/import/m4/fcntl.m4 \
$(top_srcdir)/import/m4/fcntl_h.m4 \
$(top_srcdir)/import/m4/fdopendir.m4 \
+ $(top_srcdir)/import/m4/ffs.m4 \
$(top_srcdir)/import/m4/filenamecat.m4 \
$(top_srcdir)/import/m4/flexmember.m4 \
$(top_srcdir)/import/m4/float_h.m4 \
$(top_srcdir)/import/m4/strerror.m4 \
$(top_srcdir)/import/m4/strerror_r.m4 \
$(top_srcdir)/import/m4/string_h.m4 \
+ $(top_srcdir)/import/m4/strings_h.m4 \
$(top_srcdir)/import/m4/strnlen.m4 \
$(top_srcdir)/import/m4/strstr.m4 \
$(top_srcdir)/import/m4/strtok_r.m4 \
GNULIB_FDOPEN = @GNULIB_FDOPEN@
GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FFS = @GNULIB_FFS@
GNULIB_FFSL = @GNULIB_FFSL@
GNULIB_FFSLL = @GNULIB_FFSLL@
GNULIB_FGETC = @GNULIB_FGETC@
HAVE_DECL_SQRTL = @HAVE_DECL_SQRTL@
HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNCASECMP = @HAVE_DECL_STRNCASECMP@
HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
HAVE_FDATASYNC = @HAVE_FDATASYNC@
HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FFS = @HAVE_FFS@
HAVE_FFSL = @HAVE_FFSL@
HAVE_FFSLL = @HAVE_FFSLL@
HAVE_FMA = @HAVE_FMA@
HAVE_STDINT_H = @HAVE_STDINT_H@
HAVE_STPCPY = @HAVE_STPCPY@
HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASECMP = @HAVE_STRCASECMP@
HAVE_STRCASESTR = @HAVE_STRCASESTR@
HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
HAVE_STRERRORNAME_NP = @HAVE_STRERRORNAME_NP@
+HAVE_STRINGS_H = @HAVE_STRINGS_H@
HAVE_STRPBRK = @HAVE_STRPBRK@
HAVE_STRPTIME = @HAVE_STRPTIME@
HAVE_STRSEP = @HAVE_STRSEP@
NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRINGS_H = @NEXT_AS_FIRST_DIRECTIVE_STRINGS_H@
NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_RANDOM_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_RANDOM_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@
NEXT_STDINT_H = @NEXT_STDINT_H@
NEXT_STDIO_H = @NEXT_STDIO_H@
NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRINGS_H = @NEXT_STRINGS_H@
NEXT_STRING_H = @NEXT_STRING_H@
NEXT_SYS_RANDOM_H = @NEXT_SYS_RANDOM_H@
NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@
m4_include([import/m4/fcntl.m4])
m4_include([import/m4/fcntl_h.m4])
m4_include([import/m4/fdopendir.m4])
+m4_include([import/m4/ffs.m4])
m4_include([import/m4/filenamecat.m4])
m4_include([import/m4/flexmember.m4])
m4_include([import/m4/float_h.m4])
m4_include([import/m4/strerror.m4])
m4_include([import/m4/strerror_r.m4])
m4_include([import/m4/string_h.m4])
+m4_include([import/m4/strings_h.m4])
m4_include([import/m4/strnlen.m4])
m4_include([import/m4/strstr.m4])
m4_include([import/m4/strtok_r.m4])
HAVE_SYS_RANDOM_H
NEXT_AS_FIRST_DIRECTIVE_SYS_RANDOM_H
NEXT_SYS_RANDOM_H
+HAVE_STRINGS_H
+NEXT_AS_FIRST_DIRECTIVE_STRINGS_H
+NEXT_STRINGS_H
NEXT_AS_FIRST_DIRECTIVE_STRING_H
NEXT_STRING_H
NEXT_AS_FIRST_DIRECTIVE_STDLIB_H
FLOAT_H
NEXT_AS_FIRST_DIRECTIVE_FLOAT_H
NEXT_FLOAT_H
+HAVE_DECL_STRNCASECMP
+HAVE_STRCASECMP
+HAVE_FFS
+GNULIB_FFS
NEXT_AS_FIRST_DIRECTIVE_FCNTL_H
NEXT_FCNTL_H
REPLACE_OPENAT
as_fn_append ac_func_list " __xpg_strerror_r"
as_fn_append ac_func_list " catgets"
as_fn_append ac_func_list " snprintf"
+as_fn_append ac_header_list " strings.h"
as_fn_append ac_header_list " sys/random.h"
as_fn_append ac_header_list " sys/uio.h"
as_fn_append ac_func_list " localtime_r"
# Code from module fd-hook:
# Code from module fd-safer-flag:
# Code from module fdopendir:
+ # Code from module ffs:
# Code from module filename:
# Code from module filenamecat-lgpl:
# Code from module flexmember:
# Code from module strerror-override:
# Code from module strerror_r-posix:
# Code from module string:
+ # Code from module strings:
# Code from module strnlen:
# Code from module strnlen1:
# Code from module strstr:
+ GNULIB_FFS=0;
+ HAVE_FFS=1;
+ HAVE_STRCASECMP=1;
+ HAVE_DECL_STRNCASECMP=1;
+
+
GNULIB_FNMATCH=0;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ if test $gl_cv_have_include_next = yes; then
+ gl_cv_next_strings_h='<'strings.h'>'
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking absolute name of <strings.h>" >&5
+$as_echo_n "checking absolute name of <strings.h>... " >&6; }
+if ${gl_cv_next_strings_h+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ if test $ac_cv_header_strings_h = yes; then
+
+
+
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <strings.h>
+_ACEOF
+ case "$host_os" in
+ aix*) gl_absname_cpp="$ac_cpp -C" ;;
+ *) gl_absname_cpp="$ac_cpp" ;;
+ esac
+
+ case "$host_os" in
+ mingw*)
+ gl_dirsep_regex='[/\\]'
+ ;;
+ *)
+ gl_dirsep_regex='\/'
+ ;;
+ esac
+ gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
+ gl_header_literal_regex=`echo 'strings.h' \
+ | sed -e "$gl_make_literal_regex_sed"`
+ gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
+ s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
+ s|^/[^/]|//&|
+ p
+ q
+ }'
+
+ gl_cv_absolute_strings_h=`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&5 |
+ sed -n "$gl_absolute_header_sed"`
+
+ gl_header=$gl_cv_absolute_strings_h
+ gl_cv_next_strings_h='"'$gl_header'"'
+ else
+ gl_cv_next_strings_h='<'strings.h'>'
+ fi
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_next_strings_h" >&5
+$as_echo "$gl_cv_next_strings_h" >&6; }
+ fi
+ NEXT_STRINGS_H=$gl_cv_next_strings_h
+
+ if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
+ # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
+ gl_next_as_first_directive='<'strings.h'>'
+ else
+ # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
+ gl_next_as_first_directive=$gl_cv_next_strings_h
+ fi
+ NEXT_AS_FIRST_DIRECTIVE_STRINGS_H=$gl_next_as_first_directive
+
+
+
+
+ if test $ac_cv_header_strings_h = yes; then
+ HAVE_STRINGS_H=1
+ else
+ HAVE_STRINGS_H=0
+ fi
+
+
+
+
+
+
ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
if test "x$ac_cv_have_decl_strnlen" = xyes; then :
ac_have_decl=1
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ffs" >&5
+$as_echo_n "checking for ffs... " >&6; }
+if ${gl_cv_func_ffs+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <strings.h>
+ int x;
+
+int
+main ()
+{
+int (*func) (int) = ffs;
+ return func (x);
+
+ ;
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ gl_cv_func_ffs=yes
+else
+ gl_cv_func_ffs=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_func_ffs" >&5
+$as_echo "$gl_cv_func_ffs" >&6; }
+ if test $gl_cv_func_ffs = no; then
+ HAVE_FFS=0
+ fi
+
+ if test $HAVE_FFS = 0; then
+
+
+
+
+
+
+
+
+ gl_LIBOBJS="$gl_LIBOBJS ffs.$ac_objext"
+
+ fi
+
+
+
+
+
+ GNULIB_FFS=1
+
+
+
+
+
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flexible array member" >&5
$as_echo_n "checking for flexible array member... " >&6; }
+
+
+
if test $ac_cv_have_decl_strnlen = no; then
HAVE_DECL_STRNLEN=0
else
# dirent \
# dirfd \
# errno \
+# ffs \
# fnmatch-gnu \
# frexpl \
# gendocs \
## end gnulib module fdopendir
+## begin gnulib module ffs
+
+
+EXTRA_DIST += ffs.c
+
+EXTRA_libgnu_a_SOURCES += ffs.c
+
+## end gnulib module ffs
+
## begin gnulib module filename
## end gnulib module string
+## begin gnulib module strings
+
+BUILT_SOURCES += strings.h
+
+# We need the following in order to create <strings.h> when the system
+# doesn't have one that works with the given compiler.
+strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
+ -e 's/@''GNULIB_FFS''@/$(GNULIB_FFS)/g' \
+ -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
+ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
+ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/strings.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += strings.h strings.h-t
+
+EXTRA_DIST += strings.in.h
+
+## end gnulib module strings
+
## begin gnulib module strnlen
# dirent \
# dirfd \
# errno \
+# ffs \
# fnmatch-gnu \
# frexpl \
# gendocs \
$(top_srcdir)/import/m4/fcntl.m4 \
$(top_srcdir)/import/m4/fcntl_h.m4 \
$(top_srcdir)/import/m4/fdopendir.m4 \
+ $(top_srcdir)/import/m4/ffs.m4 \
$(top_srcdir)/import/m4/filenamecat.m4 \
$(top_srcdir)/import/m4/flexmember.m4 \
$(top_srcdir)/import/m4/float_h.m4 \
$(top_srcdir)/import/m4/strerror.m4 \
$(top_srcdir)/import/m4/strerror_r.m4 \
$(top_srcdir)/import/m4/string_h.m4 \
+ $(top_srcdir)/import/m4/strings_h.m4 \
$(top_srcdir)/import/m4/strnlen.m4 \
$(top_srcdir)/import/m4/strstr.m4 \
$(top_srcdir)/import/m4/strtok_r.m4 \
GNULIB_FDOPEN = @GNULIB_FDOPEN@
GNULIB_FDOPENDIR = @GNULIB_FDOPENDIR@
GNULIB_FFLUSH = @GNULIB_FFLUSH@
+GNULIB_FFS = @GNULIB_FFS@
GNULIB_FFSL = @GNULIB_FFSL@
GNULIB_FFSLL = @GNULIB_FFSLL@
GNULIB_FGETC = @GNULIB_FGETC@
HAVE_DECL_SQRTL = @HAVE_DECL_SQRTL@
HAVE_DECL_STRDUP = @HAVE_DECL_STRDUP@
HAVE_DECL_STRERROR_R = @HAVE_DECL_STRERROR_R@
+HAVE_DECL_STRNCASECMP = @HAVE_DECL_STRNCASECMP@
HAVE_DECL_STRNDUP = @HAVE_DECL_STRNDUP@
HAVE_DECL_STRNLEN = @HAVE_DECL_STRNLEN@
HAVE_DECL_STRSIGNAL = @HAVE_DECL_STRSIGNAL@
HAVE_FDATASYNC = @HAVE_FDATASYNC@
HAVE_FDOPENDIR = @HAVE_FDOPENDIR@
HAVE_FEATURES_H = @HAVE_FEATURES_H@
+HAVE_FFS = @HAVE_FFS@
HAVE_FFSL = @HAVE_FFSL@
HAVE_FFSLL = @HAVE_FFSLL@
HAVE_FMA = @HAVE_FMA@
HAVE_STDINT_H = @HAVE_STDINT_H@
HAVE_STPCPY = @HAVE_STPCPY@
HAVE_STPNCPY = @HAVE_STPNCPY@
+HAVE_STRCASECMP = @HAVE_STRCASECMP@
HAVE_STRCASESTR = @HAVE_STRCASESTR@
HAVE_STRCHRNUL = @HAVE_STRCHRNUL@
HAVE_STRERRORNAME_NP = @HAVE_STRERRORNAME_NP@
+HAVE_STRINGS_H = @HAVE_STRINGS_H@
HAVE_STRPBRK = @HAVE_STRPBRK@
HAVE_STRPTIME = @HAVE_STRPTIME@
HAVE_STRSEP = @HAVE_STRSEP@
NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
+NEXT_AS_FIRST_DIRECTIVE_STRINGS_H = @NEXT_AS_FIRST_DIRECTIVE_STRINGS_H@
NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_RANDOM_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_RANDOM_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SOCKET_H@
NEXT_STDINT_H = @NEXT_STDINT_H@
NEXT_STDIO_H = @NEXT_STDIO_H@
NEXT_STDLIB_H = @NEXT_STDLIB_H@
+NEXT_STRINGS_H = @NEXT_STRINGS_H@
NEXT_STRING_H = @NEXT_STRING_H@
NEXT_SYS_RANDOM_H = @NEXT_SYS_RANDOM_H@
NEXT_SYS_SOCKET_H = @NEXT_SYS_SOCKET_H@
close.c closedir.c dirent-private.h count-one-bits.h \
ctype.in.h dirent.in.h dirfd.c dirname.h dup.c dup2.c \
eloop-threshold.h errno.in.h error.c error.h exitfail.h \
- fchdir.c fcntl.c fcntl.in.h fd-hook.h fdopendir.c filename.h \
- filenamecat.h flexmember.h float.c float.in.h itold.c \
- fnmatch.c fnmatch_loop.c fnmatch.c fnmatch.in.h fpucw.h free.c \
- frexp.c frexp.c frexpl.c fstat.c stat-w32.c stat-w32.h \
- at-func.c fstatat.c $(top_srcdir)/import/extra/gendocs.sh \
- getcwd.c getcwd-lgpl.c getdelim.c getdtablesize.c getline.c \
- getlogin_r.c getrandom.c gettimeofday.c \
- $(top_srcdir)/import/extra/gitlog-to-changelog glob.c \
- glob_internal.h glob_pattern_p.c globfree.c glob-libc.h \
+ fchdir.c fcntl.c fcntl.in.h fd-hook.h fdopendir.c ffs.c \
+ filename.h filenamecat.h flexmember.h float.c float.in.h \
+ itold.c fnmatch.c fnmatch_loop.c fnmatch.c fnmatch.in.h \
+ fpucw.h free.c frexp.c frexp.c frexpl.c fstat.c stat-w32.c \
+ stat-w32.h at-func.c fstatat.c \
+ $(top_srcdir)/import/extra/gendocs.sh getcwd.c getcwd-lgpl.c \
+ getdelim.c getdtablesize.c getline.c getlogin_r.c getrandom.c \
+ gettimeofday.c $(top_srcdir)/import/extra/gitlog-to-changelog \
+ glob.c glob_internal.h glob_pattern_p.c globfree.c glob-libc.h \
glob.in.h hard-locale.h inet_ntop.c intprops.h inttypes.in.h \
isblank.c float+.h isnan.c isnand-nolibm.h isnand.c float+.h \
isnan.c isnanl-nolibm.h isnanl.c cdefs.h libc-config.h \
stat-time.h stdalign.in.h stdbool.in.h stddef.in.h stdint.in.h \
stdio.in.h stdlib.in.h strchrnul.c strchrnul.valgrind strdup.c \
streq.h strerror.c strerror-override.c strerror-override.h \
- strerror_r.c string.in.h strnlen.c strstr.c str-two-way.h \
- strstr.c strtok_r.c sys_random.in.h sys_socket.in.h \
- sys_stat.in.h sys_time.in.h sys_types.in.h sys_uio.in.h \
- tempname.h time.in.h time_r.c unistd.in.h unistd--.h \
- unistd-safer.h unsetenv.c \
+ strerror_r.c string.in.h strings.in.h strnlen.c strstr.c \
+ str-two-way.h strstr.c strtok_r.c sys_random.in.h \
+ sys_socket.in.h sys_stat.in.h sys_time.in.h sys_types.in.h \
+ sys_uio.in.h tempname.h time.in.h time_r.c unistd.in.h \
+ unistd--.h unistd-safer.h unsetenv.c \
$(top_srcdir)/import/extra/update-copyright verify.h \
wchar.in.h wctype.in.h windows-initguard.h windows-mutex.c \
windows-mutex.h windows-once.c windows-once.h \
fcntl.h $(FLOAT_H) $(FNMATCH_H) $(GLOB_H) inttypes.h \
$(LIMITS_H) locale.h math.h $(NETINET_IN_H) signal.h \
$(STDALIGN_H) $(STDBOOL_H) $(STDDEF_H) $(STDINT_H) stdio.h \
- stdlib.h string.h sys/random.h sys/socket.h sys/stat.h \
- sys/time.h sys/types.h sys/uio.h time.h unistd.h wchar.h \
- wctype.h
+ stdlib.h string.h strings.h sys/random.h sys/socket.h \
+ sys/stat.h sys/time.h sys/types.h sys/uio.h time.h unistd.h \
+ wchar.h wctype.h
SUFFIXES =
MOSTLYCLEANFILES = core *.stackdump alloca.h alloca.h-t arpa/inet.h \
arpa/inet.h-t ctype.h ctype.h-t dirent.h dirent.h-t errno.h \
netinet/in.h-t signal.h signal.h-t stdalign.h stdalign.h-t \
stdbool.h stdbool.h-t stddef.h stddef.h-t stdint.h stdint.h-t \
stdio.h stdio.h-t stdlib.h stdlib.h-t string.h string.h-t \
- sys/random.h sys/random.h-t sys/socket.h sys/socket.h-t \
- sys/stat.h sys/stat.h-t sys/time.h sys/time.h-t sys/types.h \
- sys/types.h-t sys/uio.h sys/uio.h-t time.h time.h-t unistd.h \
- unistd.h-t wchar.h wchar.h-t wctype.h wctype.h-t
+ strings.h strings.h-t sys/random.h sys/random.h-t sys/socket.h \
+ sys/socket.h-t sys/stat.h sys/stat.h-t sys/time.h sys/time.h-t \
+ sys/types.h sys/types.h-t sys/uio.h sys/uio.h-t time.h \
+ time.h-t unistd.h unistd.h-t wchar.h wchar.h-t wctype.h \
+ wctype.h-t
MOSTLYCLEANDIRS = arpa netinet sys sys sys sys
CLEANFILES =
DISTCLEANFILES =
libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) @ALLOCA@
EXTRA_libgnu_a_SOURCES = alloca.c btowc.c canonicalize-lgpl.c \
chdir-long.c close.c closedir.c dirfd.c dup.c dup2.c error.c \
- fchdir.c fcntl.c fdopendir.c float.c itold.c fnmatch.c \
+ fchdir.c fcntl.c fdopendir.c ffs.c float.c itold.c fnmatch.c \
fnmatch_loop.c fnmatch.c free.c frexp.c frexp.c frexpl.c \
fstat.c stat-w32.c at-func.c fstatat.c getcwd.c getcwd-lgpl.c \
getdelim.c getdtablesize.c getline.c getlogin_r.c getrandom.c \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer-flag.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fd-safer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdopendir.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffs.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filenamecat-lgpl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/float.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fnmatch.Po@am__quote@
} > $@-t && \
mv $@-t $@
+# We need the following in order to create <strings.h> when the system
+# doesn't have one that works with the given compiler.
+strings.h: strings.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+ sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+ -e 's|@''HAVE_STRINGS_H''@|$(HAVE_STRINGS_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+ -e 's|@''NEXT_STRINGS_H''@|$(NEXT_STRINGS_H)|g' \
+ -e 's/@''GNULIB_FFS''@/$(GNULIB_FFS)/g' \
+ -e 's|@''HAVE_FFS''@|$(HAVE_FFS)|g' \
+ -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
+ -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
+ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+ < $(srcdir)/strings.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+
# We need the following in order to create <sys/random.h> when the system
# doesn't have one.
sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
--- /dev/null
+/* ffs.c -- find the first set bit in a word.
+ Copyright (C) 2011-2021 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+/* Written by Eric Blake. */
+
+#include <config.h>
+
+/* Specification. */
+#include <strings.h>
+
+#include <limits.h>
+
+#if defined _MSC_VER && !(__clang_major__ >= 4)
+# include <intrin.h>
+#endif
+
+int
+ffs (int i)
+{
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__clang_major__ >= 4)
+ return __builtin_ffs (i);
+#elif defined _MSC_VER
+ /* _BitScanForward
+ <https://docs.microsoft.com/en-us/cpp/intrinsics/bitscanforward-bitscanforward64> */
+ unsigned long bit;
+ if (_BitScanForward (&bit, i))
+ return bit + 1;
+ else
+ return 0;
+#else
+ /* <https://github.com/gibsjose/BitHacks>
+ gives this deBruijn constant for a branch-less computation, although
+ that table counted trailing zeros rather than bit position. This
+ requires 32-bit int, we fall back to a naive algorithm on the rare
+ platforms where that assumption is not true. */
+ if (CHAR_BIT * sizeof i == 32)
+ {
+ static unsigned int table[] = {
+ 1, 2, 29, 3, 30, 15, 25, 4, 31, 23, 21, 16, 26, 18, 5, 9,
+ 32, 28, 14, 24, 22, 20, 17, 8, 27, 13, 19, 7, 12, 6, 11, 10
+ };
+ unsigned int u = i;
+ unsigned int bit = u & -u;
+ return table[(bit * 0x077cb531U) >> 27] - !i;
+ }
+ else
+ {
+ unsigned int j;
+ for (j = 0; j < CHAR_BIT * sizeof i; j++)
+ if (i & (1U << j))
+ return j + 1;
+ return 0;
+ }
+#endif
+}
--- /dev/null
+# ffs.m4 serial 4
+dnl Copyright (C) 2011-2021 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_FFS],
+[
+ AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
+
+ dnl We can't use AC_CHECK_FUNC here, because ffs() is defined as a
+ dnl static inline function when compiling for Android 4.2 or older.
+ dnl But require that ffs() is declared; otherwise we may be using
+ dnl the GCC built-in function, which leads to warnings
+ dnl "warning: implicit declaration of function 'ffs'".
+ AC_CACHE_CHECK([for ffs], [gl_cv_func_ffs],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <strings.h>
+ int x;
+ ]],
+ [[int (*func) (int) = ffs;
+ return func (x);
+ ]])
+ ],
+ [gl_cv_func_ffs=yes],
+ [gl_cv_func_ffs=no])
+ ])
+ if test $gl_cv_func_ffs = no; then
+ HAVE_FFS=0
+ fi
+])
# dirent \
# dirfd \
# errno \
+# ffs \
# fnmatch-gnu \
# frexpl \
# gendocs \
dirent
dirfd
errno
+ ffs
fnmatch-gnu
frexpl
gendocs
# Code from module fd-hook:
# Code from module fd-safer-flag:
# Code from module fdopendir:
+ # Code from module ffs:
# Code from module filename:
# Code from module filenamecat-lgpl:
# Code from module flexmember:
# Code from module strerror-override:
# Code from module strerror_r-posix:
# Code from module string:
+ # Code from module strings:
# Code from module strnlen:
# Code from module strnlen1:
# Code from module strstr:
fi
gl_DIRENT_MODULE_INDICATOR([fdopendir])
gl_MODULE_INDICATOR([fdopendir])
+ gl_FUNC_FFS
+ if test $HAVE_FFS = 0; then
+ AC_LIBOBJ([ffs])
+ fi
+ gl_STRINGS_MODULE_INDICATOR([ffs])
gl_FILE_NAME_CONCAT_LGPL
AC_C_FLEXIBLE_ARRAY_MEMBER
gl_FLOAT_H
dnl For the modules argp, error.
gl_MODULE_INDICATOR([strerror_r-posix])
gl_HEADER_STRING_H
+ gl_HEADER_STRINGS_H
gl_FUNC_STRNLEN
if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
AC_LIBOBJ([strnlen])
lib/fd-safer-flag.c
lib/fd-safer.c
lib/fdopendir.c
+ lib/ffs.c
lib/filename.h
lib/filenamecat-lgpl.c
lib/filenamecat.h
lib/strerror.c
lib/strerror_r.c
lib/string.in.h
+ lib/strings.in.h
lib/stripslash.c
lib/strnlen.c
lib/strnlen1.c
m4/fcntl.m4
m4/fcntl_h.m4
m4/fdopendir.m4
+ m4/ffs.m4
m4/filenamecat.m4
m4/flexmember.m4
m4/float_h.m4
m4/strerror.m4
m4/strerror_r.m4
m4/string_h.m4
+ m4/strings_h.m4
m4/strnlen.m4
m4/strstr.m4
m4/strtok_r.m4
--- /dev/null
+# Configure a replacement for <strings.h>.
+# serial 6
+
+# Copyright (C) 2007, 2009-2021 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_HEADER_STRINGS_H],
+[
+ dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+ dnl once only, before all statements that occur in other macros.
+ AC_REQUIRE([gl_HEADER_STRINGS_H_BODY])
+])
+
+AC_DEFUN([gl_HEADER_STRINGS_H_BODY],
+[
+ AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
+
+ gl_CHECK_NEXT_HEADERS([strings.h])
+ if test $ac_cv_header_strings_h = yes; then
+ HAVE_STRINGS_H=1
+ else
+ HAVE_STRINGS_H=0
+ fi
+ AC_SUBST([HAVE_STRINGS_H])
+
+ dnl Check for declarations of anything we want to poison if the
+ dnl corresponding gnulib module is not in use.
+ gl_WARN_ON_USE_PREPARE([[
+ /* Minix 3.1.8 has a bug: <sys/types.h> must be included before
+ <strings.h>. */
+ #include <sys/types.h>
+ #include <strings.h>
+ ]], [ffs strcasecmp strncasecmp])
+])
+
+AC_DEFUN([gl_STRINGS_MODULE_INDICATOR],
+[
+ dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+ AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
+ gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+])
+
+AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS],
+[
+ GNULIB_FFS=0; AC_SUBST([GNULIB_FFS])
+ dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_FFS=1; AC_SUBST([HAVE_FFS])
+ HAVE_STRCASECMP=1; AC_SUBST([HAVE_STRCASECMP])
+ HAVE_DECL_STRNCASECMP=1; AC_SUBST([HAVE_DECL_STRNCASECMP])
+])
--- /dev/null
+/* A substitute <strings.h>.
+
+ Copyright (C) 2007-2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _@GUARD_PREFIX@_STRINGS_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+@PRAGMA_COLUMNS@
+
+/* Minix 3.1.8 has a bug: <sys/types.h> must be included before <strings.h>.
+ But avoid namespace pollution on glibc systems. */
+#if defined __minix && !defined __GLIBC__
+# include <sys/types.h>
+#endif
+
+/* The include_next requires a split double-inclusion guard. */
+#if @HAVE_STRINGS_H@
+# @INCLUDE_NEXT@ @NEXT_STRINGS_H@
+#endif
+
+#ifndef _@GUARD_PREFIX@_STRINGS_H
+#define _@GUARD_PREFIX@_STRINGS_H
+
+#if ! @HAVE_DECL_STRNCASECMP@
+/* Get size_t. */
+# include <stddef.h>
+#endif
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
+
+/* The definition of _GL_ARG_NONNULL is copied here. */
+
+/* The definition of _GL_WARN_ON_USE is copied here. */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ /* Find the index of the least-significant set bit. */
+#if @GNULIB_FFS@
+# if !@HAVE_FFS@
+_GL_FUNCDECL_SYS (ffs, int, (int i));
+# endif
+_GL_CXXALIAS_SYS (ffs, int, (int i));
+_GL_CXXALIASWARN (ffs);
+#elif defined GNULIB_POSIXCHECK
+# undef ffs
+# if HAVE_RAW_DECL_FFS
+_GL_WARN_ON_USE (ffs, "ffs is not portable - use the ffs module");
+# endif
+#endif
+
+/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
+ greater than zero if S1 is lexicographically less than, equal to or greater
+ than S2.
+ Note: This function does not work in multibyte locales. */
+#if ! @HAVE_STRCASECMP@
+extern int strcasecmp (char const *s1, char const *s2)
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+#if defined GNULIB_POSIXCHECK
+/* strcasecmp() does not work with multibyte strings:
+ POSIX says that it operates on "strings", and "string" in POSIX is defined
+ as a sequence of bytes, not of characters. */
+# undef strcasecmp
+# if HAVE_RAW_DECL_STRCASECMP
+_GL_WARN_ON_USE (strcasecmp, "strcasecmp cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbscasecmp if you care about "
+ "internationalization, or use c_strcasecmp , "
+ "gnulib module c-strcase) if you want a locale "
+ "independent function");
+# endif
+#endif
+
+/* Compare no more than N bytes of strings S1 and S2, ignoring case,
+ returning less than, equal to or greater than zero if S1 is
+ lexicographically less than, equal to or greater than S2.
+ Note: This function cannot work correctly in multibyte locales. */
+#if ! @HAVE_DECL_STRNCASECMP@
+extern int strncasecmp (char const *s1, char const *s2, size_t n)
+ _GL_ARG_NONNULL ((1, 2));
+#endif
+#if defined GNULIB_POSIXCHECK
+/* strncasecmp() does not work with multibyte strings:
+ POSIX says that it operates on "strings", and "string" in POSIX is defined
+ as a sequence of bytes, not of characters. */
+# undef strncasecmp
+# if HAVE_RAW_DECL_STRNCASECMP
+_GL_WARN_ON_USE (strncasecmp, "strncasecmp cannot work correctly on character "
+ "strings in multibyte locales - "
+ "use mbsncasecmp or mbspcasecmp if you care about "
+ "internationalization, or use c_strncasecmp , "
+ "gnulib module c-strcase) if you want a locale "
+ "independent function");
+# endif
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _@GUARD_PREFIX@_STRING_H */
+#endif /* _@GUARD_PREFIX@_STRING_H */
dirent \
dirfd \
errno \
+ ffs \
fnmatch-gnu \
frexpl \
gendocs \