Compare commits

..
2 Commits
32 changed files with 8011 additions and 2492 deletions
+4 -1
View File
@@ -1,7 +1,10 @@
AUTOMAKE_OPTION = foreign
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = go.mod t t/test-bi.hak
gosrcdir = $(datadir)/hak/go
gosrc_DATA = go.mod hak.go hak-inst.go hak-cb.go
EXTRA_DIST = t t/test-bi.hak
SUBDIRS =
+67 -11
View File
@@ -13,6 +13,7 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
@@ -135,6 +136,34 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
am__install_max = 40
am__nobase_strip_setup = \
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
am__nobase_strip = \
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
am__nobase_list = $(am__nobase_strip_setup); \
for p in $$list; do echo "$$p $$p"; done | \
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
if (++n[$$2] == $(am__install_max)) \
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
END { for (dir in files) print dir, files[dir] }'
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
am__uninstall_files_from_dir = { \
{ test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \
}
am__installdirs = "$(DESTDIR)$(gosrcdir)"
DATA = $(gosrc_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
@@ -355,7 +384,9 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTION = foreign
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = go.mod t t/test-bi.hak
gosrcdir = $(datadir)/hak/go
gosrc_DATA = go.mod hak.go hak-inst.go hak-cb.go
EXTRA_DIST = t t/test-bi.hak
SUBDIRS = $(am__append_1) $(am__append_2)
DIST_SUBDIRS = $(SUBDIRS) pas
all: all-recursive
@@ -403,6 +434,27 @@ clean-libtool:
distclean-libtool:
-rm -f libtool config.lt
install-gosrcDATA: $(gosrc_DATA)
@$(NORMAL_INSTALL)
@list='$(gosrc_DATA)'; test -n "$(gosrcdir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(gosrcdir)'"; \
$(MKDIR_P) "$(DESTDIR)$(gosrcdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(gosrcdir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(gosrcdir)" || exit $$?; \
done
uninstall-gosrcDATA:
@$(NORMAL_UNINSTALL)
@list='$(gosrc_DATA)'; test -n "$(gosrcdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(gosrcdir)'; $(am__uninstall_files_from_dir)
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
@@ -715,9 +767,12 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile
all-am: Makefile $(DATA)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(gosrcdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
@@ -770,7 +825,7 @@ info: info-recursive
info-am:
install-data-am:
install-data-am: install-gosrcDATA
install-dvi: install-dvi-recursive
@@ -816,7 +871,7 @@ ps: ps-recursive
ps-am:
uninstall-am:
uninstall-am: uninstall-gosrcDATA
.MAKE: $(am__recursive_targets) install-am install-strip
@@ -829,13 +884,14 @@ uninstall-am:
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-info install-info-am install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am
install-exec install-exec-am install-gosrcDATA install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags tags-am uninstall uninstall-am \
uninstall-gosrcDATA
.PRECIOUS: Makefile
+90 -101
View File
@@ -1,4 +1,4 @@
#! /bin/sh
#!/bin/sh
# Attempt to guess a canonical system name.
# Copyright 1992-2024 Free Software Foundation, Inc.
@@ -194,17 +194,6 @@ Linux|GNU|GNU/*)
;;
esac
case "${UNAME_MACHINE}" in
i?86)
test -z "$VENDOR" && VENDOR=pc
;;
*)
test -z "$VENDOR" && VENDOR=unknown
;;
esac
test -f /etc/SuSE-release -o -f /.buildenv && VENDOR=suse
test -f /etc/os-release && grep -q suse /etc/os-release && VENDOR=suse
# Note: order is significant - the case branches are not exclusive.
case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
@@ -286,46 +275,46 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-bitrig$UNAME_RELEASE
GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-openbsd$UNAME_RELEASE
GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
;;
*:SecBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-secbsd$UNAME_RELEASE
GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
GUESS=$UNAME_MACHINE_ARCH-${VENDOR}-libertybsd$UNAME_RELEASE
GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
;;
*:MidnightBSD:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-midnightbsd$UNAME_RELEASE
GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
;;
*:ekkoBSD:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-ekkobsd$UNAME_RELEASE
GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
;;
*:SolidBSD:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-solidbsd$UNAME_RELEASE
GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
;;
*:OS108:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-os108_$UNAME_RELEASE
GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
;;
macppc:MirBSD:*:*)
GUESS=powerpc-${VENDOR}-mirbsd$UNAME_RELEASE
GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
;;
*:MirBSD:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-mirbsd$UNAME_RELEASE
GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
;;
*:Sortix:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-sortix
GUESS=$UNAME_MACHINE-unknown-sortix
;;
*:Twizzler:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-twizzler
GUESS=$UNAME_MACHINE-unknown-twizzler
;;
*:Redox:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-redox
GUESS=$UNAME_MACHINE-unknown-redox
;;
mips:OSF1:*.*)
GUESS=mips-dec-osf1
@@ -387,13 +376,13 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
;;
Amiga*:UNIX_System_V:4.0:*)
GUESS=m68k-${VENDOR}-sysv4
GUESS=m68k-unknown-sysv4
;;
*:[Aa]miga[Oo][Ss]:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-amigaos
GUESS=$UNAME_MACHINE-unknown-amigaos
;;
*:[Mm]orph[Oo][Ss]:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-morphos
GUESS=$UNAME_MACHINE-unknown-morphos
;;
*:OS/390:*:*)
GUESS=i370-ibm-openedition
@@ -408,7 +397,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
GUESS=arm-acorn-riscix$UNAME_RELEASE
;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
GUESS=arm-${VENDOR}-riscos
GUESS=arm-unknown-riscos
;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
GUESS=hppa1.1-hitachi-hiuxmpp
@@ -522,7 +511,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
GUESS=m68k-hades-mint$UNAME_RELEASE
;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
GUESS=m68k-${VENDOR}-mint$UNAME_RELEASE
GUESS=m68k-unknown-mint$UNAME_RELEASE
;;
m68k:machten:*:*)
GUESS=m68k-apple-machten$UNAME_RELEASE
@@ -837,9 +826,9 @@ EOF
;;
i*86:OSF1:*:*)
if test -x /usr/sbin/sysversion ; then
GUESS=$UNAME_MACHINE-${VENDOR}-osf1mk
GUESS=$UNAME_MACHINE-unknown-osf1mk
else
GUESS=$UNAME_MACHINE-${VENDOR}-osf1
GUESS=$UNAME_MACHINE-unknown-osf1
fi
;;
parisc*:Lites*:*:*)
@@ -904,10 +893,10 @@ EOF
GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
;;
sparc*:BSD/OS:*:*)
GUESS=sparc-${VENDOR}-bsdi$UNAME_RELEASE
GUESS=sparc-unknown-bsdi$UNAME_RELEASE
;;
*:BSD/OS:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-bsdi$UNAME_RELEASE
GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
;;
arm:FreeBSD:*:*)
UNAME_PROCESSOR=`uname -p`
@@ -916,10 +905,10 @@ EOF
| grep -q __ARM_PCS_VFP
then
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-${VENDOR}-freebsd$FREEBSD_REL-gnueabi
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
else
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-${VENDOR}-freebsd$FREEBSD_REL-gnueabihf
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
fi
;;
*:FreeBSD:*:*)
@@ -931,7 +920,7 @@ EOF
UNAME_PROCESSOR=i586 ;;
esac
FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_PROCESSOR-${VENDOR}-freebsd$FREEBSD_REL
GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
;;
i*:CYGWIN*:*)
GUESS=$UNAME_MACHINE-pc-cygwin
@@ -957,10 +946,10 @@ EOF
GUESS=i586-pc-interix$UNAME_RELEASE
;;
authenticamd | genuineintel | EM64T)
GUESS=x86_64-${VENDOR}-interix$UNAME_RELEASE
GUESS=x86_64-unknown-interix$UNAME_RELEASE
;;
IA64)
GUESS=ia64-${VENDOR}-interix$UNAME_RELEASE
GUESS=ia64-unknown-interix$UNAME_RELEASE
;;
esac ;;
i*:UWIN*:*)
@@ -971,7 +960,7 @@ EOF
;;
prep*:SunOS:5.*:*)
SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
GUESS=powerpcle-${VENDOR}-solaris2$SUN_REL
GUESS=powerpcle-unknown-solaris2$SUN_REL
;;
*:GNU:*:*)
# the GNU system
@@ -989,10 +978,10 @@ EOF
GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
;;
*:[Mm]anagarm:*:*)
GUESS="$UNAME_MACHINE-${VENDOR}-managarm-mlibc"
GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
;;
*:Minix:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-minix
GUESS=$UNAME_MACHINE-unknown-minix
;;
aarch64:Linux:*:*)
set_cc_for_build
@@ -1015,11 +1004,11 @@ EOF
eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
esac
fi
GUESS=$CPU-${VENDOR}-linux-$LIBCABI
GUESS=$CPU-unknown-linux-$LIBCABI
;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
@@ -1033,29 +1022,29 @@ EOF
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
arm*:Linux:*:*)
set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
GUESS=$UNAME_MACHINE-${VENDOR}-linux-${LIBC}eabi
GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
else
GUESS=$UNAME_MACHINE-${VENDOR}-linux-${LIBC}eabihf
GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
fi
fi
;;
avr32*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
cris:Linux:*:*)
GUESS=$UNAME_MACHINE-axis-linux-$LIBC
@@ -1064,40 +1053,40 @@ EOF
GUESS=$UNAME_MACHINE-axis-linux-$LIBC
;;
e2k:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
frv:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
hexagon:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
i*86:Linux:*:*)
GUESS=$UNAME_MACHINE-pc-linux-$LIBC
;;
ia64:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
k1om:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
kvx:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
kvx:cos:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-cos
GUESS=$UNAME_MACHINE-unknown-cos
;;
kvx:mbr:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-mbr
GUESS=$UNAME_MACHINE-unknown-mbr
;;
loongarch32:Linux:*:* | loongarch64:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
m32r*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
m68*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
mips:Linux:*:* | mips64:Linux:*:*)
set_cc_for_build
@@ -1148,57 +1137,57 @@ EOF
test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
;;
mips64el:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
openrisc*:Linux:*:*)
GUESS=or1k-${VENDOR}-linux-$LIBC
GUESS=or1k-unknown-linux-$LIBC
;;
or32:Linux:*:* | or1k*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
padre:Linux:*:*)
GUESS=sparc-${VENDOR}-linux-$LIBC
GUESS=sparc-unknown-linux-$LIBC
;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
GUESS=hppa64-${VENDOR}-linux-$LIBC
GUESS=hppa64-unknown-linux-$LIBC
;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
PA7*) GUESS=hppa1.1-${VENDOR}-linux-$LIBC ;;
PA8*) GUESS=hppa2.0-${VENDOR}-linux-$LIBC ;;
*) GUESS=hppa-${VENDOR}-linux-$LIBC ;;
PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
*) GUESS=hppa-unknown-linux-$LIBC ;;
esac
;;
ppc64:Linux:*:*)
GUESS=powerpc64-${VENDOR}-linux-$LIBC
GUESS=powerpc64-unknown-linux-$LIBC
;;
ppc:Linux:*:*)
GUESS=powerpc-${VENDOR}-linux-$LIBC
GUESS=powerpc-unknown-linux-$LIBC
;;
ppc64le:Linux:*:*)
GUESS=powerpc64le-${VENDOR}-linux-$LIBC
GUESS=powerpc64le-unknown-linux-$LIBC
;;
ppcle:Linux:*:*)
GUESS=powerpcle-${VENDOR}-linux-$LIBC
GUESS=powerpcle-unknown-linux-$LIBC
;;
riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
s390:Linux:*:* | s390x:Linux:*:*)
GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
;;
sh64*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
sh*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
sparc:Linux:*:* | sparc64:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
tile*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
vax:Linux:*:*)
GUESS=$UNAME_MACHINE-dec-linux-$LIBC
@@ -1228,7 +1217,7 @@ EOF
GUESS=$CPU-pc-linux-$LIBCABI
;;
xtensa*:Linux:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-linux-$LIBC
GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1250,16 +1239,16 @@ EOF
GUESS=$UNAME_MACHINE-pc-os2-emx
;;
i*86:XTS-300:*:STOP)
GUESS=$UNAME_MACHINE-${VENDOR}-stop
GUESS=$UNAME_MACHINE-unknown-stop
;;
i*86:atheos:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-atheos
GUESS=$UNAME_MACHINE-unknown-atheos
;;
i*86:syllable:*:*)
GUESS=$UNAME_MACHINE-pc-syllable
;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
GUESS=i386-${VENDOR}-lynxos$UNAME_RELEASE
GUESS=i386-unknown-lynxos$UNAME_RELEASE
;;
i*86:*DOS:*:*)
GUESS=$UNAME_MACHINE-pc-msdosdjgpp
@@ -1279,7 +1268,7 @@ EOF
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
GUESS=$UNAME_MACHINE-${VENDOR}-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
@@ -1318,7 +1307,7 @@ EOF
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
GUESS=i860-${VENDOR}-sysv$UNAME_RELEASE # Unknown i860-SVR4
GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4
fi
;;
mini*:CTIX:SYS*5:*)
@@ -1355,19 +1344,19 @@ EOF
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
GUESS=m68k-${VENDOR}-lynxos$UNAME_RELEASE
GUESS=m68k-unknown-lynxos$UNAME_RELEASE
;;
mc68030:UNIX_System_V:4.*:*)
GUESS=m68k-atari-sysv4
;;
TSUNAMI:LynxOS:2.*:*)
GUESS=sparc-${VENDOR}-lynxos$UNAME_RELEASE
GUESS=sparc-unknown-lynxos$UNAME_RELEASE
;;
rs6000:LynxOS:2.*:*)
GUESS=rs6000-${VENDOR}-lynxos$UNAME_RELEASE
GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
GUESS=powerpc-${VENDOR}-lynxos$UNAME_RELEASE
GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
;;
SM[BE]S:UNIX_SV:*:*)
GUESS=mips-dde-sysv$UNAME_RELEASE
@@ -1417,7 +1406,7 @@ EOF
if test -d /usr/nec; then
GUESS=mips-nec-sysv$UNAME_RELEASE
else
GUESS=mips-${VENDOR}-sysv$UNAME_RELEASE
GUESS=mips-unknown-sysv$UNAME_RELEASE
fi
;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
@@ -1436,7 +1425,7 @@ EOF
GUESS=powerpc-apple-haiku
;;
*:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
GUESS=$UNAME_MACHINE-${VENDOR}-haiku
GUESS=$UNAME_MACHINE-unknown-haiku
;;
SX-4:SUPER-UX:*:*)
GUESS=sx4-nec-superux$UNAME_RELEASE
@@ -1549,13 +1538,13 @@ EOF
elif test "x${cputype-}" != x; then
UNAME_MACHINE=$cputype
fi
GUESS=$UNAME_MACHINE-${VENDOR}-plan9
GUESS=$UNAME_MACHINE-unknown-plan9
;;
*:TOPS-10:*:*)
GUESS=pdp10-${VENDOR}-tops10
GUESS=pdp10-unknown-tops10
;;
*:TENEX:*:*)
GUESS=pdp10-${VENDOR}-tenex
GUESS=pdp10-unknown-tenex
;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
GUESS=pdp10-dec-tops20
@@ -1564,17 +1553,17 @@ EOF
GUESS=pdp10-xkl-tops20
;;
*:TOPS-20:*:*)
GUESS=pdp10-${VENDOR}-tops20
GUESS=pdp10-unknown-tops20
;;
*:ITS:*:*)
GUESS=pdp10-${VENDOR}-its
GUESS=pdp10-unknown-its
;;
SEI:*:*:SEIUX)
GUESS=mips-sei-seiux$UNAME_RELEASE
;;
*:DragonFly:*:*)
DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
GUESS=$UNAME_MACHINE-${VENDOR}-dragonfly$DRAGONFLY_REL
GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
@@ -1597,19 +1586,19 @@ EOF
GUESS=$UNAME_MACHINE-pc-fiwix
;;
*:AROS:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-aros
GUESS=$UNAME_MACHINE-unknown-aros
;;
x86_64:VMkernel:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-esx
GUESS=$UNAME_MACHINE-unknown-esx
;;
amd64:Isilon\ OneFS:*:*)
GUESS=x86_64-${VENDOR}-onefs
GUESS=x86_64-unknown-onefs
;;
*:Unleashed:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-unleashed$UNAME_RELEASE
GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
;;
*:Ironclad:*:*)
GUESS=$UNAME_MACHINE-${VENDOR}-ironclad
GUESS=$UNAME_MACHINE-unknown-ironclad
;;
esac
+1 -1
View File
@@ -1,4 +1,4 @@
#! /bin/sh
#!/bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2024 Free Software Foundation, Inc.
Executable → Regular
+414 -333
View File
File diff suppressed because it is too large Load Diff
Vendored
+2 -2
View File
@@ -14,8 +14,8 @@
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
[m4_warning([this file was generated for autoconf 2.71.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.72],,
[m4_warning([this file was generated for autoconf 2.72.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
Vendored
+3054 -1652
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -113,6 +113,7 @@ AC_CHECK_HEADERS([dlfcn.h ltdl.h sys/mman.h sys/uio.h])
AC_CHECK_HEADERS([sys/devpoll.h sys/epoll.h poll.h])
AC_CHECK_HEADERS([libunwind.h quadmath.h])
AC_CHECK_HEADERS([sys/ioctl.h net/if.h])
AC_CHECK_HEADERS([sys/wait.h sys/resource.h])
dnl check data types
dnl AC_CHECK_TYPE([wchar_t],
@@ -131,6 +132,9 @@ AC_CHECK_FUNCS([sigaction signal])
AC_CHECK_FUNCS([snprintf _vsnprintf _vsnwprintf strerror_r])
AC_CHECK_FUNCS([accept4 pipe2 epoll_create epoll_create1 kqueue kqueue1])
AC_CHECK_FUNCS([isatty mmap munmap])
AC_CHECK_FUNCS([posix_spawn getrlimit sysconf dirfd])
dnl dirfd may be provided as a macro rather than a function
AC_CHECK_DECLS([dirfd],[],[],[[#include <dirent.h>]])
save_LIBS="$LIBS"
AC_SEARCH_LIBS([dlopen], [dl dld], [
+4
View File
@@ -52,8 +52,10 @@ pkginclude_HEADERS = \
hak-cmgr.h \
hak-cmn.h \
hak-fmt.h \
hak-htb.h \
hak-opt.h \
hak-pac1.h \
hak-pio.h \
hak-rbt.h \
hak-str.h \
hak-upac.h \
@@ -78,11 +80,13 @@ libhak_la_SOURCES = \
gc.c \
hak.c \
heap.c \
htb.c \
mb8.c \
number.c \
obj.c \
opt-impl.h \
opt.c \
pio.c \
prim.c \
print.c \
rbt.c \
+36 -12
View File
@@ -155,12 +155,12 @@ am_libhak_la_OBJECTS = libhak_la-bigint.lo libhak_la-chr.lo \
libhak_la-debug.lo libhak_la-decode.lo libhak_la-dic.lo \
libhak_la-err.lo libhak_la-exec.lo libhak_la-fmt.lo \
libhak_la-gc.lo libhak_la-hak.lo libhak_la-heap.lo \
libhak_la-mb8.lo libhak_la-number.lo libhak_la-obj.lo \
libhak_la-opt.lo libhak_la-prim.lo libhak_la-print.lo \
libhak_la-rbt.lo libhak_la-read.lo libhak_la-std.lo \
libhak_la-str.lo libhak_la-sym.lo libhak_la-utf16.lo \
libhak_la-utf8.lo libhak_la-utl.lo libhak_la-xchg.lo \
libhak_la-xma.lo
libhak_la-htb.lo libhak_la-mb8.lo libhak_la-number.lo \
libhak_la-obj.lo libhak_la-opt.lo libhak_la-pio.lo \
libhak_la-prim.lo libhak_la-print.lo libhak_la-rbt.lo \
libhak_la-read.lo libhak_la-std.lo libhak_la-str.lo \
libhak_la-sym.lo libhak_la-utf16.lo libhak_la-utf8.lo \
libhak_la-utl.lo libhak_la-xchg.lo libhak_la-xma.lo
libhak_la_OBJECTS = $(am_libhak_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -206,8 +206,9 @@ am__depfiles_remade = ./$(DEPDIR)/libhak_la-bigint.Plo \
./$(DEPDIR)/libhak_la-err.Plo ./$(DEPDIR)/libhak_la-exec.Plo \
./$(DEPDIR)/libhak_la-fmt.Plo ./$(DEPDIR)/libhak_la-gc.Plo \
./$(DEPDIR)/libhak_la-hak.Plo ./$(DEPDIR)/libhak_la-heap.Plo \
./$(DEPDIR)/libhak_la-mb8.Plo ./$(DEPDIR)/libhak_la-number.Plo \
./$(DEPDIR)/libhak_la-obj.Plo ./$(DEPDIR)/libhak_la-opt.Plo \
./$(DEPDIR)/libhak_la-htb.Plo ./$(DEPDIR)/libhak_la-mb8.Plo \
./$(DEPDIR)/libhak_la-number.Plo ./$(DEPDIR)/libhak_la-obj.Plo \
./$(DEPDIR)/libhak_la-opt.Plo ./$(DEPDIR)/libhak_la-pio.Plo \
./$(DEPDIR)/libhak_la-prim.Plo ./$(DEPDIR)/libhak_la-print.Plo \
./$(DEPDIR)/libhak_la-rbt.Plo ./$(DEPDIR)/libhak_la-read.Plo \
./$(DEPDIR)/libhak_la-std.Plo ./$(DEPDIR)/libhak_la-str.Plo \
@@ -247,8 +248,9 @@ am__can_run_installinfo = \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__pkginclude_HEADERS_DIST = hak.h hak-chr.h hak-cmgr.h hak-cmn.h \
hak-fmt.h hak-opt.h hak-pac1.h hak-rbt.h hak-str.h hak-upac.h \
hak-utl.h hak-xma.h hak-x.h hak-tmr.h hak-json.h
hak-fmt.h hak-htb.h hak-opt.h hak-pac1.h hak-pio.h hak-rbt.h \
hak-str.h hak-upac.h hak-utl.h hak-xma.h hak-x.h hak-tmr.h \
hak-json.h
HEADERS = $(pkginclude_HEADERS)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
hak-cfg.h.in
@@ -440,8 +442,8 @@ LIBADD_LIB_COMMON = $(LIBM) $(am__append_1) $(am__append_2) \
@WIN32_TRUE@ -DHAK_DEFAULT_PFMODPOSTFIX=\"-1.dll\" \
@WIN32_TRUE@ $(am__append_4) $(am__append_5)
pkginclude_HEADERS = hak.h hak-chr.h hak-cmgr.h hak-cmn.h hak-fmt.h \
hak-opt.h hak-pac1.h hak-rbt.h hak-str.h hak-upac.h hak-utl.h \
hak-xma.h $(am__append_8)
hak-htb.h hak-opt.h hak-pac1.h hak-pio.h hak-rbt.h hak-str.h \
hak-upac.h hak-utl.h hak-xma.h $(am__append_8)
pkglib_LTLIBRARIES = libhak.la $(am__append_7)
libhak_la_SOURCES = \
hak-prv.h \
@@ -460,11 +462,13 @@ libhak_la_SOURCES = \
gc.c \
hak.c \
heap.c \
htb.c \
mb8.c \
number.c \
obj.c \
opt-impl.h \
opt.c \
pio.c \
prim.c \
print.c \
rbt.c \
@@ -608,10 +612,12 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-gc.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-hak.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-heap.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-htb.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-mb8.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-number.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-obj.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-opt.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-pio.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-prim.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-print.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhak_la-rbt.Plo@am__quote@ # am--include-marker
@@ -760,6 +766,13 @@ libhak_la-heap.lo: heap.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhak_la-heap.lo `test -f 'heap.c' || echo '$(srcdir)/'`heap.c
libhak_la-htb.lo: htb.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhak_la-htb.lo -MD -MP -MF $(DEPDIR)/libhak_la-htb.Tpo -c -o libhak_la-htb.lo `test -f 'htb.c' || echo '$(srcdir)/'`htb.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhak_la-htb.Tpo $(DEPDIR)/libhak_la-htb.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='htb.c' object='libhak_la-htb.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhak_la-htb.lo `test -f 'htb.c' || echo '$(srcdir)/'`htb.c
libhak_la-mb8.lo: mb8.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhak_la-mb8.lo -MD -MP -MF $(DEPDIR)/libhak_la-mb8.Tpo -c -o libhak_la-mb8.lo `test -f 'mb8.c' || echo '$(srcdir)/'`mb8.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhak_la-mb8.Tpo $(DEPDIR)/libhak_la-mb8.Plo
@@ -788,6 +801,13 @@ libhak_la-opt.lo: opt.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhak_la-opt.lo `test -f 'opt.c' || echo '$(srcdir)/'`opt.c
libhak_la-pio.lo: pio.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhak_la-pio.lo -MD -MP -MF $(DEPDIR)/libhak_la-pio.Tpo -c -o libhak_la-pio.lo `test -f 'pio.c' || echo '$(srcdir)/'`pio.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhak_la-pio.Tpo $(DEPDIR)/libhak_la-pio.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pio.c' object='libhak_la-pio.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhak_la-pio.lo `test -f 'pio.c' || echo '$(srcdir)/'`pio.c
libhak_la-prim.lo: prim.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhak_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhak_la-prim.lo -MD -MP -MF $(DEPDIR)/libhak_la-prim.Tpo -c -o libhak_la-prim.lo `test -f 'prim.c' || echo '$(srcdir)/'`prim.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhak_la-prim.Tpo $(DEPDIR)/libhak_la-prim.Plo
@@ -1090,10 +1110,12 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/libhak_la-gc.Plo
-rm -f ./$(DEPDIR)/libhak_la-hak.Plo
-rm -f ./$(DEPDIR)/libhak_la-heap.Plo
-rm -f ./$(DEPDIR)/libhak_la-htb.Plo
-rm -f ./$(DEPDIR)/libhak_la-mb8.Plo
-rm -f ./$(DEPDIR)/libhak_la-number.Plo
-rm -f ./$(DEPDIR)/libhak_la-obj.Plo
-rm -f ./$(DEPDIR)/libhak_la-opt.Plo
-rm -f ./$(DEPDIR)/libhak_la-pio.Plo
-rm -f ./$(DEPDIR)/libhak_la-prim.Plo
-rm -f ./$(DEPDIR)/libhak_la-print.Plo
-rm -f ./$(DEPDIR)/libhak_la-rbt.Plo
@@ -1173,10 +1195,12 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libhak_la-gc.Plo
-rm -f ./$(DEPDIR)/libhak_la-hak.Plo
-rm -f ./$(DEPDIR)/libhak_la-heap.Plo
-rm -f ./$(DEPDIR)/libhak_la-htb.Plo
-rm -f ./$(DEPDIR)/libhak_la-mb8.Plo
-rm -f ./$(DEPDIR)/libhak_la-number.Plo
-rm -f ./$(DEPDIR)/libhak_la-obj.Plo
-rm -f ./$(DEPDIR)/libhak_la-opt.Plo
-rm -f ./$(DEPDIR)/libhak_la-pio.Plo
-rm -f ./$(DEPDIR)/libhak_la-prim.Plo
-rm -f ./$(DEPDIR)/libhak_la-print.Plo
-rm -f ./$(DEPDIR)/libhak_la-rbt.Plo
+82 -1
View File
@@ -4882,6 +4882,74 @@ static int compile_cons_alist_expression (hak_t* hak, hak_cnode_t* cmd)
return 0;
}
static int compile_cons_plist_expression (hak_t* hak, hak_cnode_t* obj, int nrets)
{
hak_cframe_t* cf;
hak_cnode_t* c1, * c2, * c3;
hak_var_info_t vi;
int x;
HAK_ASSERT(hak, HAK_CNODE_IS_CONS_CONCODED(obj, HAK_CONCODE_PLIST));
c1 = HAK_CNODE_CONS_CAR(obj);
obj = HAK_CNODE_CONS_CDR(obj);
/*
ret := (input -> @{ls -laF} -> output)
-> transform?
[ret, output] := (sys.run "ls -laF" input)
input -> @{ls -laF} -> output
-> transform
out := (sys.run_noret "ls -laF" input)
input -> @{ls -laF}
-> transform
sys.run_noret "ls -laF" input
@{ls -laF} -> output
-> transform
out := (sys.run_noret "ls -laF")
*/
// HAK_ASSERT(hak, HAK_CNODE_IS_SYMBOL(var) || HAK_CNODE_IS_DSYMBOL_CLA(var) || HAK_CNODE_IS_CONS_CONCODED(var, HAK_CONCODE_TUPLE));
HAK_ASSERT(hak, obj && HAK_CNODE_IS_CONS(obj)); /* reader guaranteed */
c2 = HAK_CNODE_CONS_CAR(obj);
obj = HAK_CNODE_CONS_CDR(obj);
c3 = HAK_NULL;
if (obj)
{
HAK_ASSERT(hak, HAK_CNODE_IS_CONS(obj)); /* reader guaranteed */
c3 = HAK_CNODE_CONS_CAR(obj);
}
HAK_ASSERT(hak, HAK_CNODE_CONS_CDR(obj) == HAK_NULL); /* reader guaranteed */
if (c3)
{
SWITCH_TOP_CFRAME(hak, COP_COMPILE_OBJECT, c1); /* 1 */
if (obj) PUSH_SUBCFRAME(hak, COP_COMPILE_AND_P1, obj); /* 2 */
}
else
{
}
/*
if (HAK_CNODE_IS_CONS_CONCODED(c1, HAK_CONCODE_TUPLE))
{
}
else if (HAK_CNODE_IS_CONS_CONCODED(c1, HCK_CNODE_DLIST))
{
}
*/
hak_setsynerrbfmt(hak, HAK_SYNERR_INTERN, HAK_CNODE_GET_LOC(obj), "internal error - piping expression not implemented");
return -1;
}
static int compile_cons_xlist_expression (hak_t* hak, hak_cnode_t* obj, int nrets);
static int compile_cons_dlist_expression (hak_t* hak, hak_cnode_t* obj, int nrets)
@@ -5007,6 +5075,7 @@ static int compile_cons_xlist_expression (hak_t* hak, hak_cnode_t* obj, int nret
HAK_CNODE_IS_SYMLIT(car) || /* this condition to represent an external program TODO: change this to a dedicated cnode */
HAK_CNODE_IS_CONS_CONCODED(car, HAK_CONCODE_XLIST) || /* () is nested */
HAK_CNODE_IS_CONS_CONCODED(car, HAK_CONCODE_DLIST) || /* $() is nested */
HAK_CNODE_IS_CONS_CONCODED(car, HAK_CONCODE_PLIST) ||
HAK_CNODE_IS_CONS_CONCODED(car, HAK_CONCODE_MLIST) ||
HAK_CNODE_IS_CONS_CONCODED(car, HAK_CONCODE_BLIST) ||
HAK_CNODE_IS_CONS_CONCODED(car, HAK_CONCODE_ALIST))
@@ -5746,6 +5815,10 @@ redo:
if (compile_cons_mlist_expression(hak, oprnd, 0) <= -1) return -1;
break;
case HAK_CONCODE_PLIST: /* piping expression: in -> @{} -> out */
if (compile_cons_plist_expression(hak, oprnd, 0) <= -1) return -1;
break;
case HAK_CONCODE_BLOCK:
if (compile_cons_block_expression(hak, oprnd) <= -1) return -1;
break;
@@ -5798,7 +5871,7 @@ redo:
return -1;
case HAK_CONCODE_BLIST:
/* this must not happend as the reader prevents it */
/* this must not happen as the reader prevents it */
hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, HAK_CNODE_GET_LOC(oprnd), "empty binop list");
return -1;
@@ -5806,6 +5879,11 @@ redo:
hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, HAK_CNODE_GET_LOC(oprnd), "empty message send list");
return -1;
case HAK_CONCODE_PLIST:
/* this must not happen as the reader prevents it */
hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, HAK_CNODE_GET_LOC(oprnd), "empty piping expression list");
return -1;
case HAK_CONCODE_BLOCK:
if (compile_cons_block_expression(hak, oprnd) <= -1) return -1;
break;
@@ -5899,6 +5977,9 @@ static int compile_object_r (hak_t* hak)
case HAK_CONCODE_DLIST:
return compile_cons_dlist_expression(hak, oprnd, cf->u.obj_r.nrets);
case HAK_CONCODE_PLIST:
return compile_cons_plist_expression(hak, oprnd, cf->u.obj_r.nrets);
case HAK_CONCODE_BLIST:
case HAK_CONCODE_MLIST:
return compile_cons_mlist_expression(hak, oprnd, cf->u.obj_r.nrets);
+112 -90
View File
@@ -165,55 +165,62 @@
/* Wide-character type size */
#undef HAK_WIDE_CHAR_SIZE
/* Define to 1 if you have the `accept4' function. */
/* Define to 1 if you have the 'accept4' function. */
#undef HAVE_ACCEPT4
/* Define to 1 if you have the `acosq' function. */
/* Define to 1 if you have the 'acosq' function. */
#undef HAVE_ACOSQ
/* Define to 1 if you have the `asinq' function. */
/* Define to 1 if you have the 'asinq' function. */
#undef HAVE_ASINQ
/* Define to 1 if you have the `atan2q' function. */
/* Define to 1 if you have the 'atan2q' function. */
#undef HAVE_ATAN2Q
/* Define to 1 if you have the `atanq' function. */
/* Define to 1 if you have the 'atanq' function. */
#undef HAVE_ATANQ
/* Define to 1 if you have the `backtrace' function. */
/* Define to 1 if you have the 'backtrace' function. */
#undef HAVE_BACKTRACE
/* Define to 1 if you have the `backtrace_symbols' function. */
/* Define to 1 if you have the 'backtrace_symbols' function. */
#undef HAVE_BACKTRACE_SYMBOLS
/* Define to 1 if you have the `ceilq' function. */
/* Define to 1 if you have the 'ceilq' function. */
#undef HAVE_CEILQ
/* Define to 1 if you have the `clock_gettime' function. */
/* Define to 1 if you have the 'clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
/* Define to 1 if you have the `clock_nanosleep' function. */
/* Define to 1 if you have the 'clock_nanosleep' function. */
#undef HAVE_CLOCK_NANOSLEEP
/* Define to 1 if you have the `clock_settime' function. */
/* Define to 1 if you have the 'clock_settime' function. */
#undef HAVE_CLOCK_SETTIME
/* Define to 1 if you have the `coshq' function. */
/* Define to 1 if you have the 'coshq' function. */
#undef HAVE_COSHQ
/* Define to 1 if you have the `cosq' function. */
/* Define to 1 if you have the 'cosq' function. */
#undef HAVE_COSQ
/* Define to 1 if you have the declaration of 'dirfd', and to 0 if you don't.
*/
#undef HAVE_DECL_DIRFD
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define to 1 if you have the 'dirfd' function. */
#undef HAVE_DIRFD
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the `epoll_create' function. */
/* Define to 1 if you have the 'epoll_create' function. */
#undef HAVE_EPOLL_CREATE
/* Define to 1 if you have the `epoll_create1' function. */
/* Define to 1 if you have the 'epoll_create1' function. */
#undef HAVE_EPOLL_CREATE1
/* Define to 1 if you have the <errno.h> header file. */
@@ -222,79 +229,85 @@
/* Define to 1 if you have the <execinfo.h> header file. */
#undef HAVE_EXECINFO_H
/* Define to 1 if you have the `expq' function. */
/* Define to 1 if you have the 'expq' function. */
#undef HAVE_EXPQ
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `floorq' function. */
/* Define to 1 if you have the 'floorq' function. */
#undef HAVE_FLOORQ
/* Define to 1 if you have the `fmodq' function. */
/* Define to 1 if you have the 'fmodq' function. */
#undef HAVE_FMODQ
/* Define to 1 if you have the `getcontext' function. */
/* Define to 1 if you have the 'getcontext' function. */
#undef HAVE_GETCONTEXT
/* Define to 1 if you have the `getitimer' function. */
/* Define to 1 if you have the 'getitimer' function. */
#undef HAVE_GETITIMER
/* Define to 1 if you have the `gettimeofday' function. */
/* Define to 1 if you have the 'getrlimit' function. */
#undef HAVE_GETRLIMIT
/* Define to 1 if you have the 'gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `gmtime_r' function. */
/* Define to 1 if you have the 'gmtime_r' function. */
#undef HAVE_GMTIME_R
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `isatty' function. */
/* Define to 1 if you have the 'isatty' function. */
#undef HAVE_ISATTY
/* Define to 1 if you have the `kqueue' function. */
/* Define to 1 if you have the 'kqueue' function. */
#undef HAVE_KQUEUE
/* Define to 1 if you have the `kqueue1' function. */
/* Define to 1 if you have the 'kqueue1' function. */
#undef HAVE_KQUEUE1
/* Define to 1 if you have the <libunwind.h> header file. */
#undef HAVE_LIBUNWIND_H
/* Define to 1 if you have the `localtime_r' function. */
/* Define to 1 if you have the 'localtime_r' function. */
#undef HAVE_LOCALTIME_R
/* Define to 1 if you have the `log10q' function. */
/* Define to 1 if you have the 'log10q' function. */
#undef HAVE_LOG10Q
/* Define to 1 if you have the `logq' function. */
/* Define to 1 if you have the 'logq' function. */
#undef HAVE_LOGQ
/* Define to 1 if you have the <ltdl.h> header file. */
#undef HAVE_LTDL_H
/* Define to 1 if you have the `makecontext' function. */
/* Define to 1 if you have the 'makecontext' function. */
#undef HAVE_MAKECONTEXT
/* Define to 1 if you have the `mmap' function. */
/* Define to 1 if you have the 'mmap' function. */
#undef HAVE_MMAP
/* Define to 1 if you have the `munmap' function. */
/* Define to 1 if you have the 'munmap' function. */
#undef HAVE_MUNMAP
/* Define to 1 if you have the `nanosleep' function. */
/* Define to 1 if you have the 'nanosleep' function. */
#undef HAVE_NANOSLEEP
/* Define to 1 if you have the <net/if.h> header file. */
#undef HAVE_NET_IF_H
/* Define to 1 if you have the `pipe2' function. */
/* Define to 1 if you have the 'pipe2' function. */
#undef HAVE_PIPE2
/* Define to 1 if you have the <poll.h> header file. */
#undef HAVE_POLL_H
/* Define to 1 if you have the `powq' function. */
/* Define to 1 if you have the 'posix_spawn' function. */
#undef HAVE_POSIX_SPAWN
/* Define to 1 if you have the 'powq' function. */
#undef HAVE_POWQ
/* Define if you have POSIX threads libraries and header files. */
@@ -306,43 +319,43 @@
/* Define to 1 if you have the <quadmath.h> header file. */
#undef HAVE_QUADMATH_H
/* Define to 1 if you have the `quadmath_snprintf' function. */
/* Define to 1 if you have the 'quadmath_snprintf' function. */
#undef HAVE_QUADMATH_SNPRINTF
/* Define to 1 if you have the `roundq' function. */
/* Define to 1 if you have the 'roundq' function. */
#undef HAVE_ROUNDQ
/* Define to 1 if you have the `setcontext' function. */
/* Define to 1 if you have the 'setcontext' function. */
#undef HAVE_SETCONTEXT
/* Define to 1 if you have the `setitimer' function. */
/* Define to 1 if you have the 'setitimer' function. */
#undef HAVE_SETITIMER
/* Define to 1 if you have the `settimeofday' function. */
/* Define to 1 if you have the 'settimeofday' function. */
#undef HAVE_SETTIMEOFDAY
/* Define to 1 if you have the `sigaction' function. */
/* Define to 1 if you have the 'sigaction' function. */
#undef HAVE_SIGACTION
/* Define to 1 if you have the `signal' function. */
/* Define to 1 if you have the 'signal' function. */
#undef HAVE_SIGNAL
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define to 1 if you have the `sinhq' function. */
/* Define to 1 if you have the 'sinhq' function. */
#undef HAVE_SINHQ
/* Define to 1 if you have the `sinq' function. */
/* Define to 1 if you have the 'sinq' function. */
#undef HAVE_SINQ
/* Define to 1 if you have the `snprintf' function. */
/* Define to 1 if you have the 'snprintf' function. */
#undef HAVE_SNPRINTF
/* Define to 1 if you have the <spawn.h> header file. */
#undef HAVE_SPAWN_H
/* Define to 1 if you have the `sqrtq' function. */
/* Define to 1 if you have the 'sqrtq' function. */
#undef HAVE_SQRTQ
/* Define to 1 if you have the <stddef.h> header file. */
@@ -357,7 +370,7 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror_r' function. */
/* Define to 1 if you have the 'strerror_r' function. */
#undef HAVE_STRERROR_R
/* strftime supports %z */
@@ -369,18 +382,21 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoflt128' function. */
/* Define to 1 if you have the 'strtoflt128' function. */
#undef HAVE_STRTOFLT128
/* Define to 1 if `ifr_ifindex' is a member of `struct ifreq'. */
/* Define to 1 if 'ifr_ifindex' is a member of 'struct ifreq'. */
#undef HAVE_STRUCT_IFREQ_IFR_IFINDEX
/* Define to 1 if `ifr_mtu' is a member of `struct ifreq'. */
/* Define to 1 if 'ifr_mtu' is a member of 'struct ifreq'. */
#undef HAVE_STRUCT_IFREQ_IFR_MTU
/* Define to 1 if you have the `swapcontext' function. */
/* Define to 1 if you have the 'swapcontext' function. */
#undef HAVE_SWAPCONTEXT
/* Define to 1 if you have the 'sysconf' function. */
#undef HAVE_SYSCONF
/* Define to 1 if you have the <sys/devpoll.h> header file. */
#undef HAVE_SYS_DEVPOLL_H
@@ -393,6 +409,9 @@
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
@@ -405,10 +424,13 @@
/* Define to 1 if you have the <sys/uio.h> header file. */
#undef HAVE_SYS_UIO_H
/* Define to 1 if you have the `tanhq' function. */
/* Define to 1 if you have the <sys/wait.h> header file. */
#undef HAVE_SYS_WAIT_H
/* Define to 1 if you have the 'tanhq' function. */
#undef HAVE_TANHQ
/* Define to 1 if you have the `tanq' function. */
/* Define to 1 if you have the 'tanq' function. */
#undef HAVE_TANQ
/* Define to 1 if you have the <time.h> header file. */
@@ -423,7 +445,7 @@
/* libunwind is available */
#undef HAVE_UNWIND_LIB
/* Define to 1 if you have the `usleep' function. */
/* Define to 1 if you have the 'usleep' function. */
#undef HAVE_USLEEP
/* Define to 1 if you have the <utime.h> header file. */
@@ -438,10 +460,10 @@
/* Define to 1 if you have the <wctype.h> header file. */
#undef HAVE_WCTYPE_H
/* Define to 1 if you have the `_vsnprintf' function. */
/* Define to 1 if you have the '_vsnprintf' function. */
#undef HAVE__VSNPRINTF
/* Define to 1 if you have the `_vsnwprintf' function. */
/* Define to 1 if you have the '_vsnwprintf' function. */
#undef HAVE__VSNWPRINTF
/* __builtin_memcmp */
@@ -493,109 +515,109 @@
your system. */
#undef PTHREAD_CREATE_JOINABLE
/* The size of `char', as computed by sizeof. */
/* The size of 'char', as computed by sizeof. */
#undef SIZEOF_CHAR
/* The size of `char16_t', as computed by sizeof. */
/* The size of 'char16_t', as computed by sizeof. */
#undef SIZEOF_CHAR16_T
/* The size of `char32_t', as computed by sizeof. */
/* The size of 'char32_t', as computed by sizeof. */
#undef SIZEOF_CHAR32_T
/* The size of `double', as computed by sizeof. */
/* The size of 'double', as computed by sizeof. */
#undef SIZEOF_DOUBLE
/* The size of `float', as computed by sizeof. */
/* The size of 'float', as computed by sizeof. */
#undef SIZEOF_FLOAT
/* The size of `int', as computed by sizeof. */
/* The size of 'int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of `long', as computed by sizeof. */
/* The size of 'long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `long double', as computed by sizeof. */
/* The size of 'long double', as computed by sizeof. */
#undef SIZEOF_LONG_DOUBLE
/* The size of `long long', as computed by sizeof. */
/* The size of 'long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* The size of `mbstate_t', as computed by sizeof. */
/* The size of 'mbstate_t', as computed by sizeof. */
#undef SIZEOF_MBSTATE_T
/* The size of `off64_t', as computed by sizeof. */
/* The size of 'off64_t', as computed by sizeof. */
#undef SIZEOF_OFF64_T
/* The size of `off_t', as computed by sizeof. */
/* The size of 'off_t', as computed by sizeof. */
#undef SIZEOF_OFF_T
/* The size of `sa_family_t', as computed by sizeof. */
/* The size of 'sa_family_t', as computed by sizeof. */
#undef SIZEOF_SA_FAMILY_T
/* The size of `short', as computed by sizeof. */
/* The size of 'short', as computed by sizeof. */
#undef SIZEOF_SHORT
/* The size of `socklen_t', as computed by sizeof. */
/* The size of 'socklen_t', as computed by sizeof. */
#undef SIZEOF_SOCKLEN_T
/* The size of `struct sockaddr_dl', as computed by sizeof. */
/* The size of 'struct sockaddr_dl', as computed by sizeof. */
#undef SIZEOF_STRUCT_SOCKADDR_DL
/* The size of `struct sockaddr_in', as computed by sizeof. */
/* The size of 'struct sockaddr_in', as computed by sizeof. */
#undef SIZEOF_STRUCT_SOCKADDR_IN
/* The size of `struct sockaddr_in6', as computed by sizeof. */
/* The size of 'struct sockaddr_in6', as computed by sizeof. */
#undef SIZEOF_STRUCT_SOCKADDR_IN6
/* The size of `struct sockaddr_ll', as computed by sizeof. */
/* The size of 'struct sockaddr_ll', as computed by sizeof. */
#undef SIZEOF_STRUCT_SOCKADDR_LL
/* The size of `struct sockaddr_un', as computed by sizeof. */
/* The size of 'struct sockaddr_un', as computed by sizeof. */
#undef SIZEOF_STRUCT_SOCKADDR_UN
/* The size of `void *', as computed by sizeof. */
/* The size of 'void *', as computed by sizeof. */
#undef SIZEOF_VOID_P
/* The size of `wchar_t', as computed by sizeof. */
/* The size of 'wchar_t', as computed by sizeof. */
#undef SIZEOF_WCHAR_T
/* The size of `__float128', as computed by sizeof. */
/* The size of '__float128', as computed by sizeof. */
#undef SIZEOF___FLOAT128
/* The size of `__int128', as computed by sizeof. */
/* The size of '__int128', as computed by sizeof. */
#undef SIZEOF___INT128
/* The size of `__int128_t', as computed by sizeof. */
/* The size of '__int128_t', as computed by sizeof. */
#undef SIZEOF___INT128_T
/* The size of `__int16', as computed by sizeof. */
/* The size of '__int16', as computed by sizeof. */
#undef SIZEOF___INT16
/* The size of `__int16_t', as computed by sizeof. */
/* The size of '__int16_t', as computed by sizeof. */
#undef SIZEOF___INT16_T
/* The size of `__int32', as computed by sizeof. */
/* The size of '__int32', as computed by sizeof. */
#undef SIZEOF___INT32
/* The size of `__int32_t', as computed by sizeof. */
/* The size of '__int32_t', as computed by sizeof. */
#undef SIZEOF___INT32_T
/* The size of `__int64', as computed by sizeof. */
/* The size of '__int64', as computed by sizeof. */
#undef SIZEOF___INT64
/* The size of `__int64_t', as computed by sizeof. */
/* The size of '__int64_t', as computed by sizeof. */
#undef SIZEOF___INT64_T
/* The size of `__int8', as computed by sizeof. */
/* The size of '__int8', as computed by sizeof. */
#undef SIZEOF___INT8
/* The size of `__int8_t', as computed by sizeof. */
/* The size of '__int8_t', as computed by sizeof. */
#undef SIZEOF___INT8_T
/* The size of `__uint128_t', as computed by sizeof. */
/* The size of '__uint128_t', as computed by sizeof. */
#undef SIZEOF___UINT128_T
/* Define to 1 if all of the C90 standard headers exist (not just the ones
/* Define to 1 if all of the C89 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
+20
View File
@@ -953,6 +953,26 @@ typedef struct hak_t hak_t;
# undef HAK_HAVE_INLINE
#endif
#if defined(__has_attribute)
# if __has_attribute(always_inline)
# define HAK_INLINE_ALWAYS __inline__ __attribute__((always_inline))
# define HAK_HAVE_INLINE_ALWAYS
# endif
#endif
#if !defined(HAK_HAVE_INLINE_ALWAYS)
# if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0))
# define HAK_INLINE_ALWAYS __inline__ __attribute__((__always_inline__))
# define HAK_HAVE_INLINE_ALWAYS
# elif defined(_MSC_VER) || defined(__CC_ARM) || defined(__ARMCC__)
# define HAK_INLINE_ALWAYS __forceinline
# define HAK_HAVE_INLINE_ALWAYS
# else
/* fallback to normal inline */
# define HAK_INLINE_ALWAYS HAK_INLINE
# endif
#endif
#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4))
# define HAK_SENTINEL(v) __attribute__((__sentinel__(x)))
#else
+686
View File
@@ -0,0 +1,686 @@
/*
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _HAK_HTB_H_
#define _HAK_HTB_H_
#include <hak-cmn.h>
/** \file
* This file provides a hash table encapsulated in the #hak_htb_t type that
* maintains buckets for key/value pairs with the same key hash chained under
* the same bucket. Its interface is very close to #hak_rbt_t.
*
* This sample code adds a series of keys and values and print them
* in the randome order.
* \code
* #include <hak-htb.h>
*
* static hak_htb_walk_t walk (hak_htb_t* htb, hak_htb_pair_t* pair, void* ctx)
* {
* hak_printf (HAK_T("key = %d, value = %d\n"),
* *(int*)HAK_HTB_KPTR(pair), *(int*)HAK_HTB_VPTR(pair));
* return HAK_HTB_WALK_FORWARD;
* }
*
* int main ()
* {
* hak_htb_t* s1;
* int i;
*
* hak_open_stdsios ();
* s1 = hak_htb_open (HAK_MMGR_GETDFL(), 0, 30, 75, 1, 1); // error handling skipped
* hak_htb_setstyle (s1, hak_get_htb_style(HAK_HTB_STYLE_INLINE_COPIERS));
*
* for (i = 0; i < 20; i++)
* {
* int x = i * 20;
* hak_htb_insert (s1, &i, HAK_SIZEOF(i), &x, HAK_SIZEOF(x)); // eror handling skipped
* }
*
* hak_htb_walk (s1, walk, HAK_NULL);
*
* hak_htb_close (s1);
* hak_close_stdsios ();
* return 0;
* }
* \endcode
*/
typedef struct hak_htb_t hak_htb_t;
typedef struct hak_htb_pair_t hak_htb_pair_t;
/**
* The hak_htb_walk_t type defines values that the callback function can
* return to control hak_htb_walk().
*/
enum hak_htb_walk_t
{
HAK_HTB_WALK_STOP = 0,
HAK_HTB_WALK_FORWARD = 1
};
typedef enum hak_htb_walk_t hak_htb_walk_t;
/**
* The hak_htb_id_t type defines IDs to indicate a key or a value in various
* functions.
*/
enum hak_htb_id_t
{
HAK_HTB_KEY = 0,
HAK_HTB_VAL = 1
};
typedef enum hak_htb_id_t hak_htb_id_t;
/**
* The hak_htb_copier_t type defines a pair contruction callback.
* A special copier #HAK_HTB_COPIER_INLINE is provided. This copier enables
* you to copy the data inline to the internal node. No freeer is invoked
* when the node is freeed.
*/
typedef void* (*hak_htb_copier_t) (
hak_htb_t* htb /* hash table */,
void* dptr /* pointer to a key or a value */,
hak_oow_t dlen /* length of a key or a value */
);
/**
* The hak_htb_freeer_t defines a key/value destruction callback
* The freeer is called when a node containing the element is destroyed.
*/
typedef void (*hak_htb_freeer_t) (
hak_htb_t* htb, /**< hash table */
void* dptr, /**< pointer to a key or a value */
hak_oow_t dlen /**< length of a key or a value */
);
/**
* The hak_htb_comper_t type defines a key comparator that is called when
* the htb needs to compare keys. A hash table is created with a default
* comparator which performs bitwise comparison of two keys.
* The comparator should return 0 if the keys are the same and a non-zero
* integer otherwise.
*/
typedef int (*hak_htb_comper_t) (
const hak_htb_t* htb, /**< hash table */
const void* kptr1, /**< key pointer */
hak_oow_t klen1, /**< key length */
const void* kptr2, /**< key pointer */
hak_oow_t klen2 /**< key length */
);
/**
* The hak_htb_keeper_t type defines a value keeper that is called when
* a value is retained in the context that it should be destroyed because
* it is identical to a new value. Two values are identical if their
* pointers and lengths are equal.
*/
typedef void (*hak_htb_keeper_t) (
hak_htb_t* htb, /**< hash table */
void* vptr, /**< value pointer */
hak_oow_t vlen /**< value length */
);
/**
* The hak_htb_sizer_t type defines a bucket size claculator that is called
* when hash table should resize the bucket. The current bucket size + 1 is
* passed as the hint.
*/
typedef hak_oow_t (*hak_htb_sizer_t) (
hak_htb_t* htb, /**< htb */
hak_oow_t hint /**< sizing hint */
);
/**
* The hak_htb_hasher_t type defines a key hash function
*/
typedef hak_oow_t (*hak_htb_hasher_t) (
const hak_htb_t* htb, /**< hash table */
const void* kptr, /**< key pointer */
hak_oow_t klen /**< key length in bytes */
);
/**
* The hak_htb_walker_t defines a pair visitor.
*/
typedef hak_htb_walk_t (*hak_htb_walker_t) (
hak_htb_t* htb, /**< htb */
hak_htb_pair_t* pair, /**< pointer to a key/value pair */
void* ctx /**< pointer to user-defined data */
);
/**
* The hak_htb_cbserter_t type defines a callback function for hak_htb_cbsert().
* The hak_htb_cbserter() function calls it to allocate a new pair for the
* key pointed to by \a kptr of the length \a klen and the callback context
* \a ctx. The second parameter \a pair is passed the pointer to the existing
* pair for the key or #HAK_NULL in case of no existing key. The callback
* must return a pointer to a new or a reallocated pair. When reallocating the
* existing pair, this callback must destroy the existing pair and return the
* newly reallocated pair. It must return #HAK_NULL for failure.
*/
typedef hak_htb_pair_t* (*hak_htb_cbserter_t) (
hak_htb_t* htb, /**< hash table */
hak_htb_pair_t* pair, /**< pair pointer */
void* kptr, /**< key pointer */
hak_oow_t klen, /**< key length */
void* ctx /**< callback context */
);
/**
* The hak_htb_pair_t type defines hash table pair. A pair is composed of a key
* and a value. It maintains pointers to the beginning of a key and a value
* plus their length. The length is scaled down with the scale factor
* specified in an owning hash table.
*/
struct hak_htb_pair_t
{
hak_ptl_t key;
hak_ptl_t val;
/* management information below */
hak_htb_pair_t* next;
};
typedef struct hak_htb_style_t hak_htb_style_t;
struct hak_htb_style_t
{
hak_htb_copier_t copier[2];
hak_htb_freeer_t freeer[2];
hak_htb_comper_t comper; /**< key comparator */
hak_htb_keeper_t keeper; /**< value keeper */
hak_htb_sizer_t sizer; /**< bucket capacity recalculator */
hak_htb_hasher_t hasher; /**< key hasher */
};
/**
* The hak_htb_style_kind_t type defines the type of predefined
* callback set for pair manipulation.
*/
enum hak_htb_style_kind_t
{
/** store the key and the value pointer */
HAK_HTB_STYLE_DEFAULT,
/** copy both key and value into the pair */
HAK_HTB_STYLE_INLINE_COPIERS,
/** copy the key into the pair but store the value pointer */
HAK_HTB_STYLE_INLINE_KEY_COPIER,
/** copy the value into the pair but store the key pointer */
HAK_HTB_STYLE_INLINE_VALUE_COPIER
};
typedef enum hak_htb_style_kind_t hak_htb_style_kind_t;
/**
* The hak_htb_t type defines a hash table.
*/
struct hak_htb_t
{
hak_t* hak;
const hak_htb_style_t* style;
hak_uint8_t scale[2]; /**< length scale */
hak_uint8_t factor; /**< load factor in percentage */
hak_oow_t size;
hak_oow_t capa;
hak_oow_t threshold;
hak_oow_t rev;
hak_htb_pair_t** bucket;
};
struct hak_htb_itr_t
{
hak_htb_pair_t* pair;
hak_oow_t buckno;
};
typedef struct hak_htb_itr_t hak_htb_itr_t;
/**
* The HAK_HTB_COPIER_SIMPLE macros defines a copier that remembers the
* pointer and length of data in a pair.
**/
#define HAK_HTB_COPIER_SIMPLE ((hak_htb_copier_t)1)
/**
* The HAK_HTB_COPIER_INLINE macros defines a copier that copies data into
* a pair.
**/
#define HAK_HTB_COPIER_INLINE ((hak_htb_copier_t)2)
#define HAK_HTB_COPIER_DEFAULT (HAK_HTB_COPIER_SIMPLE)
#define HAK_HTB_FREEER_DEFAULT (HAK_NULL)
#define HAK_HTB_COMPER_DEFAULT (hak_htb_dflcomp)
#define HAK_HTB_KEEPER_DEFAULT (HAK_NULL)
#define HAK_HTB_SIZER_DEFAULT (HAK_NULL)
#define HAK_HTB_HASHER_DEFAULT (hak_htb_dflhash)
/**
* The HAK_HTB_SIZE() macro returns the number of pairs in a hash table.
*/
#define HAK_HTB_SIZE(m) ((const hak_oow_t)(m)->size)
/**
* The HAK_HTB_CAPA() macro returns the maximum number of pairs that can be
* stored in a hash table without further reorganization.
*/
#define HAK_HTB_CAPA(m) ((const hak_oow_t)(m)->capa)
#define HAK_HTB_REV(m) ((const hak_oow_t)(m)->rev)
#define HAK_HTB_FACTOR(m) (*(const int*)&(m)->factor)
#define HAK_HTB_KSCALE(m) (*(const int*)&(m)->scale[HAK_HTB_KEY])
#define HAK_HTB_VSCALE(m) (*(const int*)&(m)->scale[HAK_HTB_VAL])
#define HAK_HTB_KPTL(p) (&(p)->key)
#define HAK_HTB_VPTL(p) (&(p)->val)
#define HAK_HTB_KPTR(p) ((p)->key.ptr)
#define HAK_HTB_KLEN(p) ((p)->key.len)
#define HAK_HTB_VPTR(p) ((p)->val.ptr)
#define HAK_HTB_VLEN(p) ((p)->val.len)
#define HAK_HTB_NEXT(p) ((p)->next)
#if defined(__cplusplus)
extern "C" {
#endif
/**
* The hak_get_htb_style() functions returns a predefined callback set for
* pair manipulation.
*/
HAK_EXPORT const hak_htb_style_t* hak_get_htb_style (
hak_htb_style_kind_t kind
);
/**
* The hak_htb_open() function creates a hash table with a dynamic array
* bucket and a list of values chained. The initial capacity should be larger
* than 0. The load factor should be between 0 and 100 inclusive and the load
* factor of 0 disables bucket resizing. If you need extra space associated
* with hash table, you may pass a non-zero value for \a xtnsize.
* The HAK_HTB_XTN() macro and the hak_htb_getxtn() function return the
* pointer to the beginning of the extension.
* The \a kscale and \a vscale parameters specify the unit of the key and
* value size.
* \return #hak_htb_t pointer on success, #HAK_NULL on failure.
*/
HAK_EXPORT hak_htb_t* hak_htb_open (
hak_t* hak,
hak_oow_t xtnsize, /**< extension size in bytes */
hak_oow_t capa, /**< initial capacity */
int factor, /**< load factor */
int kscale, /**< key scale - 1 to 255 */
int vscale /**< value scale - 1 to 255 */
);
/**
* The hak_htb_close() function destroys a hash table.
*/
HAK_EXPORT void hak_htb_close (
hak_htb_t* htb /**< hash table */
);
/**
* The hak_htb_init() function initializes a hash table
*/
HAK_EXPORT int hak_htb_init (
hak_htb_t* htb, /**< hash table */
hak_t* hak,
hak_oow_t capa, /**< initial capacity */
int factor, /**< load factor */
int kscale, /**< key scale */
int vscale /**< value scale */
);
/**
* The hak_htb_fini() funtion finalizes a hash table
*/
HAK_EXPORT void hak_htb_fini (
hak_htb_t* htb
);
#if defined(HAK_HAVE_INLINE)
static HAK_INLINE void* hak_htb_getxtn (hak_htb_t* htb) { return (void*)(htb + 1); }
#else
#define hak_htb_getxtn(htb) ((void*)((hak_htb_t*)(htb) + 1))
#endif
/**
* The hak_htb_getstyle() function gets manipulation callback function set.
*/
HAK_EXPORT const hak_htb_style_t* hak_htb_getstyle (
const hak_htb_t* htb /**< hash table */
);
/**
* The hak_htb_setstyle() function sets internal manipulation callback
* functions for data construction, destruction, resizing, hashing, etc.
* The callback structure pointed to by \a style must outlive the hash
* table pointed to by \a htb as the hash table doesn't copy the contents
* of the structure.
*/
HAK_EXPORT void hak_htb_setstyle (
hak_htb_t* htb, /**< hash table */
const hak_htb_style_t* style /**< callback function set */
);
/**
* The hak_htb_getsize() function gets the number of pairs in hash table.
*/
HAK_EXPORT hak_oow_t hak_htb_getsize (
const hak_htb_t* htb
);
/**
* The hak_htb_getcapa() function gets the number of slots allocated
* in a hash bucket.
*/
HAK_EXPORT hak_oow_t hak_htb_getcapa (
const hak_htb_t* htb /**< hash table */
);
HAK_EXPORT hak_oow_t hak_htb_getrev (
const hak_htb_t* htb /**< hash table */
);
/**
* The hak_htb_search() function searches a hash table to find a pair with a
* matching key. It returns the pointer to the pair found. If it fails
* to find one, it returns HAK_NULL.
* \return pointer to the pair with a maching key,
* or #HAK_NULL if no match is found.
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_search (
const hak_htb_t* htb, /**< hash table */
const void* kptr, /**< key pointer */
hak_oow_t klen /**< key length */
);
/**
* The hak_htb_upsert() function searches a hash table for the pair with a
* matching key. If one is found, it updates the pair. Otherwise, it inserts
* a new pair with the key and value given. It returns the pointer to the
* pair updated or inserted.
* \return pointer to the updated or inserted pair on success,
* #HAK_NULL on failure.
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_upsert (
hak_htb_t* htb, /**< hash table */
void* kptr, /**< key pointer */
hak_oow_t klen, /**< key length */
void* vptr, /**< value pointer */
hak_oow_t vlen /**< value length */
);
/**
* The hak_htb_ensert() function inserts a new pair with the key and the value
* given. If there exists a pair with the key given, the function returns
* the pair containing the key.
* \return pointer to a pair on success, #HAK_NULL on failure.
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_ensert (
hak_htb_t* htb, /**< hash table */
void* kptr, /**< key pointer */
hak_oow_t klen, /**< key length */
void* vptr, /**< value pointer */
hak_oow_t vlen /**< value length */
);
/**
* The hak_htb_insert() function inserts a new pair with the key and the value
* given. If there exists a pair with the key given, the function returns
* #HAK_NULL without channging the value.
* \return pointer to the pair created on success, #HAK_NULL on failure.
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_insert (
hak_htb_t* htb, /**< hash table */
void* kptr, /**< key pointer */
hak_oow_t klen, /**< key length */
void* vptr, /**< value pointer */
hak_oow_t vlen /**< value length */
);
/**
* The hak_htb_update() function updates the value of an existing pair
* with a matching key.
* \return pointer to the pair on success, #HAK_NULL on no matching pair
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_update (
hak_htb_t* htb, /**< hash table */
void* kptr, /**< key pointer */
hak_oow_t klen, /**< key length */
void* vptr, /**< value pointer */
hak_oow_t vlen /**< value length */
);
/**
* The hak_htb_cbsert() function inserts a key/value pair by delegating pair
* allocation to a callback function. Depending on the callback function,
* it may behave like hak_htb_insert(), hak_htb_upsert(), hak_htb_update(),
* hak_htb_ensert(), or totally differently. The sample code below inserts
* a new pair if the key is not found and appends the new value to the
* existing value delimited by a comma if the key is found.
*
* \code
* #include <hak-htb.h>
*
* hak_htb_walk_t print_map_pair (hak_htb_t* map, hak_htb_pair_t* pair, void* ctx)
* {
* hak_printf (HAK_T("%.*s[%d] => %.*s[%d]\n"),
* HAK_HTB_KLEN(pair), HAK_HTB_KPTR(pair), (int)HAK_HTB_KLEN(pair),
* HAK_HTB_VLEN(pair), HAK_HTB_VPTR(pair), (int)HAK_HTB_VLEN(pair));
* return HAK_HTB_WALK_FORWARD;
* }
*
* hak_htb_pair_t* cbserter (
* hak_htb_t* htb, hak_htb_pair_t* pair,
* void* kptr, hak_oow_t klen, void* ctx)
* {
* hak_oocs_t* v = (hak_oocs_t*)ctx;
* if (pair == HAK_NULL)
* {
* // no existing key for the key
* return hak_htb_allocpair(htb, kptr, klen, v->ptr, v->len);
* }
* else
* {
* // a pair with the key exists.
* // in this sample, i will append the new value to the old value
* // separated by a comma
* hak_htb_pair_t* new_pair;
* hak_ooch_t comma = HAK_T(',');
* hak_uint8_t* vptr;
*
* // allocate a new pair, but without filling the actual value.
* // note vptr is given HAK_NULL for that purpose
* new_pair = hak_htb_allocpair(
* htb, kptr, klen, HAK_NULL, HAK_HTB_VLEN(pair) + 1 + v->len);
* if (new_pair == HAK_NULL) return HAK_NULL;
*
* // fill in the value space
* vptr = HAK_HTB_VPTR(new_pair);
* hak_memcpy (vptr, HAK_HTB_VPTR(pair), HAK_HTB_VLEN(pair)*HAK_SIZEOF(hak_ooch_t));
* vptr += HAK_HTB_VLEN(pair)*HAK_SIZEOF(hak_ooch_t);
* hak_memcpy (vptr, &comma, HAK_SIZEOF(hak_ooch_t));
* vptr += HAK_SIZEOF(hak_ooch_t);
* hak_memcpy (vptr, v->ptr, v->len*HAK_SIZEOF(hak_ooch_t));
*
* // this callback requires the old pair to be destroyed
* hak_htb_freepair (htb, pair);
*
* // return the new pair
* return new_pair;
* }
* }
*
* int main ()
* {
* hak_htb_t* s1;
* int i;
* hak_ooch_t* keys[] = { HAK_T("one"), HAK_T("two"), HAK_T("three") };
* hak_ooch_t* vals[] = { HAK_T("1"), HAK_T("2"), HAK_T("3"), HAK_T("4"), HAK_T("5") };
*
* hak_open_stdsios ();
* s1 = hak_htb_open (
* HAK_MMGR_GETDFL(), 0, 10, 70,
* HAK_SIZEOF(hak_ooch_t), HAK_SIZEOF(hak_ooch_t)
* ); // note error check is skipped
* hak_htb_setstyle (s1, hak_get_htb_style(HAK_HTB_STYLE_INLINE_COPIERS));
*
* for (i = 0; i < HAK_COUNTOF(vals); i++)
* {
* hak_oocs_t ctx;
* ctx.ptr = vals[i]; ctx.len = hak_count_oocstr(vals[i]);
* hak_htb_cbsert (s1,
* keys[i%HAK_COUNTOF(keys)], hak_count_oocstr(keys[i%HAK_COUNTOF(keys)]),
* cbserter, &ctx
* ); // note error check is skipped
* }
* hak_htb_walk (s1, print_map_pair, HAK_NULL);
*
* hak_htb_close (s1);
* hak_close_stdsios ();
* return 0;
* }
* \endcode
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_cbsert (
hak_htb_t* htb, /**< hash table */
void* kptr, /**< key pointer */
hak_oow_t klen, /**< key length */
hak_htb_cbserter_t cbserter, /**< callback function */
void* ctx /**< callback context */
);
/**
* The hak_htb_delete() function deletes a pair with a matching key
* \return 0 on success, -1 on failure
*/
HAK_EXPORT int hak_htb_delete (
hak_htb_t* htb, /**< hash table */
const void* kptr, /**< key pointer */
hak_oow_t klen /**< key length */
);
/**
* The hak_htb_clear() function empties a hash table
*/
HAK_EXPORT void hak_htb_clear (
hak_htb_t* htb /**< hash table */
);
/**
* The hak_htb_walk() function traverses a hash table.
*/
HAK_EXPORT void hak_htb_walk (
hak_htb_t* htb, /**< hash table */
hak_htb_walker_t walker, /**< callback function for each pair */
void* ctx /**< pointer to user-specific data */
);
HAK_EXPORT void hak_init_htb_itr (
hak_htb_itr_t* itr
);
/**
* The hak_htb_getfirstpair() function returns the pointer to the first pair
* in a hash table.
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_getfirstpair (
hak_htb_t* htb, /**< hash table */
hak_htb_itr_t* itr /**< iterator*/
);
/**
* The hak_htb_getnextpair() function returns the pointer to the next pair
* to the current pair \a pair in a hash table.
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_getnextpair (
hak_htb_t* htb, /**< hash table */
hak_htb_itr_t* itr /**< iterator*/
);
/**
* The hak_htb_allocpair() function allocates a pair for a key and a value
* given. But it does not chain the pair allocated into the hash table \a htb.
* Use this function at your own risk.
*
* Take note of he following special behavior when the copier is
* #HAK_HTB_COPIER_INLINE.
* - If \a kptr is #HAK_NULL, the key space of the size \a klen is reserved but
* not propagated with any data.
* - If \a vptr is #HAK_NULL, the value space of the size \a vlen is reserved
* but not propagated with any data.
*/
HAK_EXPORT hak_htb_pair_t* hak_htb_allocpair (
hak_htb_t* htb,
void* kptr,
hak_oow_t klen,
void* vptr,
hak_oow_t vlen
);
/**
* The hak_htb_freepair() function destroys a pair. But it does not detach
* the pair destroyed from the hash table \a htb. Use this function at your
* own risk.
*/
HAK_EXPORT void hak_htb_freepair (
hak_htb_t* htb,
hak_htb_pair_t* pair
);
/**
* The hak_htb_dflhash() function is a default hash function.
*/
HAK_EXPORT hak_oow_t hak_htb_dflhash (
const hak_htb_t* htb,
const void* kptr,
hak_oow_t klen
);
/**
* The hak_htb_dflcomp() function is default comparator.
*/
HAK_EXPORT int hak_htb_dflcomp (
const hak_htb_t* htb,
const void* kptr1,
hak_oow_t klen1,
const void* kptr2,
hak_oow_t klen2
);
#if defined(__cplusplus)
}
#endif
#endif
+376
View File
@@ -0,0 +1,376 @@
/*
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _HAK_PIO_H_
#define _HAK_PIO_H_
#include <hak-cmn.h>
/** \file
* This file provides a piped interface to a child process encapsulated in the
* #hak_pio_t type. You can execute a child process, read and write to its
* stdin, stdout and stderr, wait for it, and terminate it. It offers more
* control than popen()/pclose(): three independent pipes instead of one,
* cross-wiring (2>&1, 1>&2), redirection to the null device, dropping
* descriptors, non-blocking pipes and a pluggable environment.
*
* hak_pio_read() and hak_pio_write() move raw bytes. There is no buffering or
* character-set conversion layer on the data path; only the command string
* itself is subject to #hak_ooch_t handling.
*
* \code
* #include <hak-pio.h>
*
* hak_pio_t* pio;
* hak_bch_t buf[256];
* hak_ooi_t n;
*
* pio = hak_pio_open(hak, 0, HAK_T("ls -l | head -3"),
* HAK_PIO_SHELL | HAK_PIO_READOUT, HAK_NULL, HAK_NULL);
* if (!pio) { ... hak_geterrnum(hak) ... }
*
* while ((n = hak_pio_read(pio, HAK_PIO_OUT, buf, HAK_SIZEOF(buf))) > 0)
* {
* ...
* }
*
* hak_pio_end(pio, HAK_PIO_OUT);
* hak_pio_wait(pio);
* hak_pio_close(pio);
* \endcode
*/
/**
* The hak_pio_flag_t type defines flags to compose the \a flags argument to
* hak_pio_open() and hak_pio_init().
*/
enum hak_pio_flag_t
{
/** execute the command through a system shell
* (/bin/sh on unix/linux, cmd.exe on windows) */
HAK_PIO_SHELL = (1 << 3),
/** indicate that the command passed to hak_pio_open()/hak_pio_init() is
* a #hak_bch_t string. it is useful when #HAK_OOCH_IS_UCH is defined and
* the caller already holds a byte string. */
HAK_PIO_BCSTRCMD = (1 << 4),
/** don't attempt to close open file descriptors unknown to pio.
* it is useful only on unix-like systems where file descriptors not set
* with FD_CLOEXEC are inherited by a child process. you're advised to set
* this option if all normal file descriptors in your application are open
* with FD_CLOEXEC set. it can skip checking a bunch of file descriptors
* and arranging to close them to prevent inheritance. */
HAK_PIO_NOCLOEXEC = (1 << 5),
/** indicate that the command passed to hak_pio_open()/hak_pio_init() is a
* pointer to a #hak_pio_fnc_t instead of a command string. supported on
* unix/linux only.
*
* the child runs the given function without exec()ing, so it inherits the
* parent's stdio buffers along with everything else. flush what you care
* about before the call - anything still pending in the parent's buffers
* is duplicated into the child, and lands in the child's stdout (that is,
* in the pipe the parent reads) if anything there flushes it. pio itself
* leaves the child through _exit(), which does not flush, but a worker
* that calls exit() or touches stdio will. */
HAK_PIO_FNCCMD = (1 << 6),
/** write to stdin of a child process */
HAK_PIO_WRITEIN = (1 << 8),
/** read stdout of a child process */
HAK_PIO_READOUT = (1 << 9),
/** read stderr of a child process */
HAK_PIO_READERR = (1 << 10),
/** redirect stderr to stdout (2>&1, requires #HAK_PIO_READOUT) */
HAK_PIO_ERRTOOUT = (1 << 11),
/** redirect stdout to stderr (1>&2, requires #HAK_PIO_READERR) */
HAK_PIO_OUTTOERR = (1 << 12),
/** redirect stdin from the null device (</dev/null, <NUL) */
HAK_PIO_INTONUL = (1 << 13),
/** redirect stderr to the null device (2>/dev/null, 2>NUL) */
HAK_PIO_ERRTONUL = (1 << 14),
/** redirect stdout to the null device (>/dev/null, >NUL) */
HAK_PIO_OUTTONUL = (1 << 15),
/** drop stdin */
HAK_PIO_DROPIN = (1 << 16),
/** drop stdout */
HAK_PIO_DROPOUT = (1 << 17),
/** drop stderr */
HAK_PIO_DROPERR = (1 << 18),
/** do not reread if read has been interrupted */
HAK_PIO_READNORETRY = (1 << 21),
/** do not rewrite if write has been interrupted */
HAK_PIO_WRITENORETRY = (1 << 22),
/** return immediately from hak_pio_wait() if a child has not exited */
HAK_PIO_WAITNOBLOCK = (1 << 23),
/** do not wait again if waitpid has been interrupted */
HAK_PIO_WAITNORETRY = (1 << 24),
/** put stdin to non-blocking mode (only on supported platforms) */
HAK_PIO_INNOBLOCK = (1 << 25),
/** put stdout to non-blocking mode (only on supported platforms) */
HAK_PIO_OUTNOBLOCK = (1 << 26),
/** put stderr to non-blocking mode (only on supported platforms) */
HAK_PIO_ERRNOBLOCK = (1 << 27)
};
typedef enum hak_pio_flag_t hak_pio_flag_t;
/**
* The hak_pio_hid_t type defines the IDs of the pipes established to a child
* process.
*/
enum hak_pio_hid_t
{
HAK_PIO_IN = 0, /**< stdin of a child process */
HAK_PIO_OUT = 1, /**< stdout of a child process */
HAK_PIO_ERR = 2 /**< stderr of a child process */
};
typedef enum hak_pio_hid_t hak_pio_hid_t;
/**
* The hak_pio_env_mk_type_t type defines the shape of the environment block
* requested from a #hak_pio_env_mk_t callback.
*/
enum hak_pio_env_mk_type_t
{
HAK_PIO_ENV_MK_BPP, /**< P1 ... PN HAK_NULL where P1 .. PN point to "K=V" */
HAK_PIO_ENV_MK_BPN /**< "K1=V\0K2=V\0\0" */
};
typedef enum hak_pio_env_mk_type_t hak_pio_env_mk_type_t;
/**
* The hak_pio_env_mk_t type defines a callback that builds the environment
* block handed to a child process. Return #HAK_NULL to make hak_pio_open() or
* hak_pio_init() fail.
*
* \a type is #HAK_PIO_ENV_MK_BPP on unix (an execve() style vector) and
* #HAK_PIO_ENV_MK_BPN on windows (a CreateProcess() style flat block).
*
* pio never frees the block returned by the callback and never invokes a
* matching deallocation callback. The caller must track and release whatever
* it allocated for the environment itself.
*/
typedef void* (*hak_pio_env_mk_t) (
hak_pio_env_mk_type_t type,
void* ctx
);
typedef int (*hak_pio_fncptr_t) (void* ctx);
/**
* The hak_pio_fnc_t type points to the function executed in a child process
* when #HAK_PIO_FNCCMD is specified.
*/
typedef struct hak_pio_fnc_t hak_pio_fnc_t;
struct hak_pio_fnc_t
{
hak_pio_fncptr_t ptr;
void* ctx;
};
#if defined(_WIN32)
/* <winnt.h> => typedef PVOID HANDLE; */
typedef void* hak_pio_hnd_t; /**< defines a pipe handle type */
typedef void* hak_pio_pid_t; /**< defines a process handle type */
# define HAK_PIO_HND_NIL ((hak_pio_hnd_t)HAK_NULL)
# define HAK_PIO_PID_NIL ((hak_pio_pid_t)HAK_NULL)
#else
typedef int hak_pio_hnd_t; /**< defines a pipe handle type */
typedef int hak_pio_pid_t; /**< defines a process handle type */
# define HAK_PIO_HND_NIL ((hak_pio_hnd_t)-1)
# define HAK_PIO_PID_NIL ((hak_pio_pid_t)-1)
#endif
typedef struct hak_pio_t hak_pio_t;
/**
* The hak_pio_t type holds the state of piped I/O to a child process. The
* hak_pio_xxx() functions are written around it. Do not change the value of
* each field directly.
*/
struct hak_pio_t
{
hak_t* hak;
int flags; /**< options */
hak_pio_pid_t child; /**< handle to a child process */
hak_pio_hnd_t handle[3]; /**< pipe handles indexed by #hak_pio_hid_t */
};
/** access the \a child field of the #hak_pio_t structure */
#define HAK_PIO_CHILD(pio) ((pio)->child)
/** get the native handle for \a hid from the #hak_pio_t structure */
#define HAK_PIO_HANDLE(pio,hid) ((pio)->handle[hid])
#if defined(__cplusplus)
extern "C" {
#endif
/**
* The hak_pio_open() function executes the command \a cmd and establishes
* pipes to it. #HAK_PIO_SHELL causes the function to execute \a cmd through
* the default shell of the underlying system: /bin/sh on unix, cmd.exe on
* windows. On unix without #HAK_PIO_SHELL, a full path to the command is
* required as no PATH lookup is performed.
*
* \a cmd is a #hak_ooch_t string, or a #hak_bch_t string if
* #HAK_PIO_BCSTRCMD is set, or a pointer to a #hak_pio_fnc_t if
* #HAK_PIO_FNCCMD is set.
*
* \a xtnsize bytes of extra space are allocated after the #hak_pio_t structure
* and zero-initialized; reach them with hak_pio_getxtn().
*
* \return #hak_pio_t pointer on success, #HAK_NULL on failure
*/
HAK_EXPORT hak_pio_t* hak_pio_open (
hak_t* hak,
hak_oow_t xtnsize, /**< extension size in bytes */
const void* cmd, /**< command to execute */
int flags, /**< 0 or a number OR'ed of the #hak_pio_flag_t enumerators */
hak_pio_env_mk_t env_mk, /**< environment builder, or #HAK_NULL to inherit */
void* env_ctx /**< context passed to \a env_mk */
);
/**
* The hak_pio_close() function closes the pipes to a child process, waits for
* the child process to exit, and frees the #hak_pio_t structure.
*/
HAK_EXPORT void hak_pio_close (
hak_pio_t* pio /**< pio object */
);
/**
* The hak_pio_init() function performs the same task as hak_pio_open() except
* that the caller provides the #hak_pio_t structure.
* \return 0 on success, -1 on failure
*/
HAK_EXPORT int hak_pio_init (
hak_pio_t* pio, /**< pio object */
hak_t* hak,
const void* cmd, /**< command to execute */
int flags, /**< 0 or a number OR'ed of the #hak_pio_flag_t enumerators */
hak_pio_env_mk_t env_mk, /**< environment builder, or #HAK_NULL to inherit */
void* env_ctx /**< context passed to \a env_mk */
);
/**
* The hak_pio_fini() function performs the same task as hak_pio_close() except
* that it does not free the #hak_pio_t structure pointed to by \a pio.
*/
HAK_EXPORT void hak_pio_fini (
hak_pio_t* pio /**< pio object */
);
#if defined(HAK_HAVE_INLINE)
static HAK_INLINE void* hak_pio_getxtn (hak_pio_t* pio) { return (void*)(pio + 1); }
#else
#define hak_pio_getxtn(pio) ((void*)((hak_pio_t*)(pio) + 1))
#endif
/**
* The hak_pio_gethnd() function gets the native handle of a pipe.
* \return pipe handle, #HAK_PIO_HND_NIL if the pipe is not established or has
* been closed
*/
HAK_EXPORT hak_pio_hnd_t hak_pio_gethnd (
const hak_pio_t* pio, /**< pio object */
hak_pio_hid_t hid /**< handle ID */
);
/**
* The hak_pio_getchild() function gets the process handle of a child.
* \return process handle
*/
HAK_EXPORT hak_pio_pid_t hak_pio_getchild (
const hak_pio_t* pio /**< pio object */
);
/**
* The hak_pio_read() function reads at most \a size bytes and stores them into
* the buffer pointed to by \a buf.
* \return -1 on failure, 0 on EOF, data length read on success
*/
HAK_EXPORT hak_ooi_t hak_pio_read (
hak_pio_t* pio, /**< pio object */
hak_pio_hid_t hid, /**< handle ID */
void* buf, /**< buffer to fill */
hak_oow_t size /**< buffer size */
);
/**
* The hak_pio_write() function writes up to \a size bytes from the buffer
* pointed to by \a data.
* \return -1 on failure, data length written on success
*/
HAK_EXPORT hak_ooi_t hak_pio_write (
hak_pio_t* pio, /**< pio object */
hak_pio_hid_t hid, /**< handle ID */
const void* data, /**< data to write */
hak_oow_t size /**< data size */
);
/**
* The hak_pio_end() function closes a pipe to a child process. A child that
* waits for EOF on its stdin needs this before it will proceed.
*/
HAK_EXPORT void hak_pio_end (
hak_pio_t* pio, /**< pio object */
hak_pio_hid_t hid /**< handle ID */
);
/**
* The hak_pio_wait() function waits for a child process to terminate.
* #HAK_PIO_WAITNORETRY causes the function to fail with #HAK_EINTR if the
* underlying system call has been interrupted. If #HAK_PIO_WAITNOBLOCK is
* used, a return value of 256 indicates that the child process has not
* terminated. Otherwise 256 is never returned.
*
* \return
* -1 on error, 256 if the child is alive and #HAK_PIO_WAITNOBLOCK is used,
* a number between 0 and 255 inclusive if the child process ends normally,
* 256 + signal number if the child process is terminated by a signal.
*/
HAK_EXPORT int hak_pio_wait (
hak_pio_t* pio /**< pio object */
);
/**
* The hak_pio_kill() function terminates a child process by force. Know the
* danger of calling this function: it can kill an unrelated process if the
* child has already terminated and its handle has been reused.
* \return 0 on success, -1 on failure
*/
HAK_EXPORT int hak_pio_kill (
hak_pio_t* pio /**< pio object */
);
#if defined(__cplusplus)
}
#endif
#endif
+1
View File
@@ -481,6 +481,7 @@ enum hak_tok_type_t
/* end of keyword enumerators */
HAK_TOK_BINOP,
HAK_TOK_PIPOP, /* -> */
HAK_TOK_IDENT,
HAK_TOK_IDENT_DOTTED,
HAK_TOK_IDENT_DOTTED_CLA,
+80 -2
View File
@@ -116,6 +116,7 @@ static void free_heap (hak_t* hak, void* ptr)
int hak_init (hak_t* hak, hak_mmgr_t* mmgr, const hak_vmprim_t* vmprim)
{
int static_mods_inited = 0;
int modtab_inited = 0;
int n;
@@ -164,6 +165,11 @@ int hak_init (hak_t* hak, hak_mmgr_t* mmgr, const hak_vmprim_t* vmprim)
hak->gci.stack.ptr = (hak_oop_t*)hak_allocmem(hak, (hak->gci.stack.capa + 1) * HAK_SIZEOF(*hak->gci.stack.ptr));
if (HAK_UNLIKELY(!hak->gci.stack.ptr)) goto oops;
n = hak_htb_init(&hak->static_mods, hak, 128, 70, HAK_SIZEOF(hak_ooch_t), 1);
if (HAK_UNLIKELY(n <= -1)) goto oops;
static_mods_inited = 1;
hak_htb_setstyle(&hak->static_mods, hak_get_htb_style(HAK_HTB_STYLE_INLINE_KEY_COPIER));
n = hak_rbt_init(&hak->modtab, hak, HAK_SIZEOF(hak_ooch_t), 1);
if (HAK_UNLIKELY(n <= -1)) goto oops;
modtab_inited = 1;
@@ -194,6 +200,7 @@ int hak_init (hak_t* hak, hak_mmgr_t* mmgr, const hak_vmprim_t* vmprim)
oops:
if (modtab_inited) hak_rbt_fini(&hak->modtab);
if (static_mods_inited) hak_htb_fini(&hak->static_mods);
if (hak->gci.stack.ptr)
{
hak_freemem(hak, hak->gci.stack.ptr);
@@ -225,6 +232,7 @@ void hak_fini (hak_t* hak)
hak_rbt_walk(&hak->modtab, unload_module, hak);
hak_rbt_fini(&hak->modtab);
hak_htb_fini(&hak->static_mods);
if (hak->log.len > 0)
{
@@ -756,6 +764,68 @@ static_modtab[] =
};
#endif
int hak_addstaticmodwithbcstr (hak_t* hak, const hak_bch_t* name, hak_mod_load_t load)
{
hak_htb_pair_t* pair;
#if defined(HAK_OOCH_IS_BCH)
pair = hak_htb_insert(&hak->static_mods, (hak_bch_t*)name, hak_count_bcstr(name), load, 0);
#else
{
hak_ucs_t wcs;
wcs.ptr = hak_dupbtoucstr(hak, name, &wcs.len);
if (HAK_UNLIKELY(!wcs.ptr))
{
const hak_ooch_t* bem = hak_backuperrmsg(hak);
hak_seterrbfmt(hak, hak_geterrnum(hak),
"unable to add static module '%hs' - %js", name, bem);
return -1;
}
pair = hak_htb_insert(&hak->static_mods, wcs.ptr, wcs.len, load, 0);
hak_freemem(hak, wcs.ptr);
}
#endif
if (HAK_UNLIKELY(!pair))
{
const hak_ooch_t* bem = hak_backuperrmsg(hak);
hak_seterrbfmt(hak, hak_geterrnum(hak), "unable to add static module '%js' - %js", name, bem);
return -1;
}
return 0;
}
int hak_addstaticmodwithucstr (hak_t* hak, const hak_uch_t* name, hak_mod_load_t load)
{
hak_htb_pair_t* pair;
#if defined(HAK_OOCH_IS_BCH)
{
hak_bcs_t mbs;
mbs.ptr = hak_duputobcstr(hak, name, &mbs.len);
if (HAK_UNLIKELY(!mbs.ptr))
{
const hak_ooch_t* bem = hak_backuperrmsg(hak);
hak_seterrbfmt(hak, hak_geterrnum(hak),
"unable to add static module '%ls' - %js", name, bem);
return -1;
}
pair = hak_htb_insert(&hak->static_mods, mbs.ptr, mbs.len, load, 0);
hak_freemem(hak, mbs.ptr);
}
#else
pair = hak_htb_insert(&hak->static_mods, (hak_uch_t*)name, hak_count_ucstr(name), load, 0);
#endif
if (HAK_UNLIKELY(!pair))
{
const hak_ooch_t* bem = hak_backuperrmsg(hak);
hak_seterrbfmt(hak, hak_geterrnum(hak), "unable to add static module '%js' - %js", name, bem);
return -1;
}
return 0;
}
hak_mod_data_t* hak_openmod (hak_t* hak, const hak_ooch_t* name, hak_oow_t namelen)
{
hak_rbt_pair_t* pair;
@@ -801,13 +871,21 @@ hak_mod_data_t* hak_openmod (hak_t* hak, const hak_ooch_t* name, hak_oow_t namel
}
}
if (!load)
{
/* check in the user-added static module table populated with
* hak_addstaticmodwithbcstr() or hak_addstaticmodwithucstr() */
hak_htb_pair_t* pair;
pair = hak_htb_search(&hak->static_mods, name, namelen);
if (pair) load = (hak_mod_load_t)pair->val.ptr;
}
if (load)
{
/* found the module in the static module table */
HAK_MEMSET(&md, 0, HAK_SIZEOF(md));
md.mod.inctx = hak->option.mod_inctx;
hak_copy_oochars ((hak_ooch_t*)md.mod.name, name, namelen);
hak_copy_oochars((hak_ooch_t*)md.mod.name, name, namelen);
/* Note md.handle is HAK_NULL for a static module */
/* i copy-insert 'md' into the table before calling 'load'.
+22
View File
@@ -26,6 +26,7 @@
#define _HAK_H_
#include <hak-cmn.h>
#include <hak-htb.h>
#include <hak-rbt.h>
#include <hak-xma.h>
#include <stdarg.h>
@@ -1751,6 +1752,8 @@ struct hak_t
hak_oow_t vm_checkbc_cb_count;
hak_cb_t* cblist;
hak_htb_t static_mods;
hak_rbt_t modtab; /* primitive module table */
struct
@@ -2119,6 +2122,7 @@ enum hak_concode_t
HAK_CONCODE_MLIST, /* (obj:message) - message send list */
HAK_CONCODE_ALIST, /* (a := 20) assignment list */
HAK_CONCODE_BLIST, /* (10 + 20) expression with binary operator */
HAK_CONCODE_PLIST, /* (in -> .. -> out) piping list */
HAK_CONCODE_BLOCK, /* { } */
HAK_CONCODE_ARRAY, /* #[ ] */
HAK_CONCODE_BYTEARRAY, /* #b[ ] */
@@ -2486,6 +2490,24 @@ HAK_EXPORT int hak_addbuiltinprims (
hak_t* hak
);
HAK_EXPORT int hak_addstaticmodwithbcstr (
hak_t* hak,
const hak_bch_t* name,
hak_mod_load_t load
);
HAK_EXPORT int hak_addstaticmodwithucstr (
hak_t* hak,
const hak_uch_t* name,
hak_mod_load_t load
);
#if defined(HAK_OOCH_IS_UCH)
#define hak_addstaticmodwithoocstr(hak,name,load) hak_addstaticmodwithucstr(hak,name,load)
#else
#define hak_addstaticmodwithoocstr(hak,name,load) hak_addstaticmodwithbcstr(hak,name,load)
#endif
/**
* The hak_execute() function executes an activated context.
*/
+754
View File
@@ -0,0 +1,754 @@
/*
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <hak-htb.h>
#include "hak-prv.h"
#define pair_t hak_htb_pair_t
#define copier_t hak_htb_copier_t
#define freeer_t hak_htb_freeer_t
#define hasher_t hak_htb_hasher_t
#define comper_t hak_htb_comper_t
#define keeper_t hak_htb_keeper_t
#define sizer_t hak_htb_sizer_t
#define walker_t hak_htb_walker_t
#define cbserter_t hak_htb_cbserter_t
#define style_t hak_htb_style_t
#define style_kind_t hak_htb_style_kind_t
#define KPTR(p) HAK_HTB_KPTR(p)
#define KLEN(p) HAK_HTB_KLEN(p)
#define VPTR(p) HAK_HTB_VPTR(p)
#define VLEN(p) HAK_HTB_VLEN(p)
#define NEXT(p) HAK_HTB_NEXT(p)
#define KTOB(htb,len) ((len) * (htb)->scale[HAK_HTB_KEY])
#define VTOB(htb,len) ((len) * (htb)->scale[HAK_HTB_VAL])
static HAK_INLINE_ALWAYS pair_t* alloc_pair (hak_htb_t* htb, void* kptr, hak_oow_t klen, void* vptr, hak_oow_t vlen)
{
pair_t* n;
copier_t kcop, vcop;
hak_oow_t as;
kcop = htb->style->copier[HAK_HTB_KEY];
vcop = htb->style->copier[HAK_HTB_VAL];
as = HAK_SIZEOF(pair_t);
if (kcop == HAK_HTB_COPIER_INLINE) as += HAK_ALIGN_POW2(KTOB(htb,klen), HAK_SIZEOF_VOID_P);
if (vcop == HAK_HTB_COPIER_INLINE) as += VTOB(htb,vlen);
n = (pair_t*) hak_allocmem(htb->hak, as);
if (HAK_UNLIKELY(!n)) return HAK_NULL;
NEXT(n) = HAK_NULL;
KLEN(n) = klen;
if (kcop == HAK_HTB_COPIER_SIMPLE)
{
KPTR(n) = kptr;
}
else if (kcop == HAK_HTB_COPIER_INLINE)
{
KPTR(n) = n + 1;
/* if kptr is HAK_NULL, the inline copier does not fill
* the actual key area */
if (kptr) HAK_MEMCPY(KPTR(n), kptr, KTOB(htb,klen));
}
else
{
KPTR(n) = kcop(htb, kptr, klen);
if (KPTR(n) == HAK_NULL)
{
hak_freemem(htb->hak, n);
return HAK_NULL;
}
}
VLEN(n) = vlen;
if (vcop == HAK_HTB_COPIER_SIMPLE)
{
VPTR(n) = vptr;
}
else if (vcop == HAK_HTB_COPIER_INLINE)
{
VPTR(n) = n + 1;
if (kcop == HAK_HTB_COPIER_INLINE)
VPTR(n) = (hak_uint8_t*)VPTR(n) + HAK_ALIGN_POW2(KTOB(htb,klen), HAK_SIZEOF_VOID_P);
/* if vptr is HAK_NULL, the inline copier does not fill
* the actual value area */
if (vptr) HAK_MEMCPY(VPTR(n), vptr, VTOB(htb,vlen));
}
else
{
VPTR(n) = vcop(htb, vptr, vlen);
if (VPTR(n) != HAK_NULL)
{
if (htb->style->freeer[HAK_HTB_KEY] != HAK_NULL)
htb->style->freeer[HAK_HTB_KEY](htb, KPTR(n), KLEN(n));
hak_freemem(htb->hak, n);
return HAK_NULL;
}
}
return n;
}
static HAK_INLINE_ALWAYS void free_pair (hak_htb_t* htb, pair_t* pair)
{
if (htb->style->freeer[HAK_HTB_KEY] != HAK_NULL)
htb->style->freeer[HAK_HTB_KEY](htb, KPTR(pair), KLEN(pair));
if (htb->style->freeer[HAK_HTB_VAL] != HAK_NULL)
htb->style->freeer[HAK_HTB_VAL](htb, VPTR(pair), VLEN(pair));
hak_freemem(htb->hak, pair);
}
pair_t* hak_htb_allocpair (hak_htb_t* htb, void* kptr, hak_oow_t klen, void* vptr, hak_oow_t vlen)
{
return alloc_pair(htb, kptr, klen, vptr, vlen);
}
void hak_htb_freepair (hak_htb_t* htb, pair_t* pair)
{
free_pair(htb, pair);
}
static HAK_INLINE_ALWAYS pair_t* change_pair_val (hak_htb_t* htb, pair_t* pair, void* vptr, hak_oow_t vlen)
{
if (VPTR(pair) == vptr && VLEN(pair) == vlen)
{
/* if the old value and the new value are the same,
* it just calls the handler for this condition.
* No value replacement occurs. */
if (htb->style->keeper != HAK_NULL)
{
htb->style->keeper(htb, vptr, vlen);
}
}
else
{
copier_t vcop = htb->style->copier[HAK_HTB_VAL];
void* ovptr = VPTR(pair);
hak_oow_t ovlen = VLEN(pair);
/* place the new value according to the copier */
if (vcop == HAK_HTB_COPIER_SIMPLE)
{
VPTR(pair) = vptr;
VLEN(pair) = vlen;
}
else if (vcop == HAK_HTB_COPIER_INLINE)
{
if (ovlen == vlen)
{
if (vptr) HAK_MEMCPY(VPTR(pair), vptr, VTOB(htb,vlen));
}
else
{
/* need to reconstruct the pair */
pair_t* p = alloc_pair(htb, KPTR(pair), KLEN(pair), vptr, vlen);
if (HAK_UNLIKELY(!p)) return HAK_NULL;
free_pair(htb, pair);
return p;
}
}
else
{
void* nvptr = vcop(htb, vptr, vlen);
if (HAK_UNLIKELY(!nvptr)) return HAK_NULL;
VPTR(pair) = nvptr;
VLEN(pair) = vlen;
}
/* free up the old value */
if (htb->style->freeer[HAK_HTB_VAL] != HAK_NULL)
{
htb->style->freeer[HAK_HTB_VAL](htb, ovptr, ovlen);
}
}
return pair;
}
static style_t style[] =
{
/* == HAK_HTB_STYLE_DEFAULT == */
{
{
HAK_HTB_COPIER_DEFAULT,
HAK_HTB_COPIER_DEFAULT
},
{
HAK_HTB_FREEER_DEFAULT,
HAK_HTB_FREEER_DEFAULT
},
HAK_HTB_COMPER_DEFAULT,
HAK_HTB_KEEPER_DEFAULT,
HAK_HTB_SIZER_DEFAULT,
HAK_HTB_HASHER_DEFAULT
},
/* == HAK_HTB_STYLE_INLINE_COPIERS == */
{
{
HAK_HTB_COPIER_INLINE,
HAK_HTB_COPIER_INLINE
},
{
HAK_HTB_FREEER_DEFAULT,
HAK_HTB_FREEER_DEFAULT
},
HAK_HTB_COMPER_DEFAULT,
HAK_HTB_KEEPER_DEFAULT,
HAK_HTB_SIZER_DEFAULT,
HAK_HTB_HASHER_DEFAULT
},
/* == HAK_HTB_STYLE_INLINE_KEY_COPIER == */
{
{
HAK_HTB_COPIER_INLINE,
HAK_HTB_COPIER_DEFAULT
},
{
HAK_HTB_FREEER_DEFAULT,
HAK_HTB_FREEER_DEFAULT
},
HAK_HTB_COMPER_DEFAULT,
HAK_HTB_KEEPER_DEFAULT,
HAK_HTB_SIZER_DEFAULT,
HAK_HTB_HASHER_DEFAULT
},
/* == HAK_HTB_STYLE_INLINE_VALUE_COPIER == */
{
{
HAK_HTB_COPIER_DEFAULT,
HAK_HTB_COPIER_INLINE
},
{
HAK_HTB_FREEER_DEFAULT,
HAK_HTB_FREEER_DEFAULT
},
HAK_HTB_COMPER_DEFAULT,
HAK_HTB_KEEPER_DEFAULT,
HAK_HTB_SIZER_DEFAULT,
HAK_HTB_HASHER_DEFAULT
}
};
const style_t* hak_get_htb_style (style_kind_t kind)
{
return &style[kind];
}
hak_htb_t* hak_htb_open (hak_t* hak, hak_oow_t xtnsize, hak_oow_t capa, int factor, int kscale, int vscale)
{
hak_htb_t* htb;
htb = (hak_htb_t*)hak_allocmem(hak, HAK_SIZEOF(hak_htb_t) + xtnsize);
if (HAK_UNLIKELY(!htb)) return HAK_NULL;
if (hak_htb_init(htb, hak, capa, factor, kscale, vscale) <= -1)
{
hak_freemem(hak, htb);
return HAK_NULL;
}
HAK_MEMSET(htb + 1, 0, xtnsize);
return htb;
}
void hak_htb_close (hak_htb_t* htb)
{
hak_htb_fini(htb);
hak_freemem(htb->hak, htb);
}
int hak_htb_init (hak_htb_t* htb, hak_t* hak, hak_oow_t capa, int factor, int kscale, int vscale)
{
/* The initial capacity should be greater than 0.
* Otherwise, it is adjusted to 1 in the release mode */
HAK_ASSERT(hak, capa > 0);
/* The load factor should be between 0 and 100 inclusive.
* In the release mode, a value out of the range is adjusted to 100 */
HAK_ASSERT(hak, factor >= 0 && factor <= 100);
HAK_ASSERT(hak, kscale >= 0 && kscale <= HAK_TYPE_MAX(hak_uint8_t));
HAK_ASSERT(hak, vscale >= 0 && vscale <= HAK_TYPE_MAX(hak_uint8_t));
/* some initial adjustment */
if (capa <= 0) capa = 1;
if (factor > 100) factor = 100;
/* do not zero out the extension */
HAK_MEMSET(htb, 0, HAK_SIZEOF(*htb));
htb->hak = hak;
htb->bucket = hak_allocmem(hak, capa * HAK_SIZEOF(pair_t*));
if (HAK_UNLIKELY(!htb->bucket)) return -1;
/*for (i = 0; i < capa; i++) htb->bucket[i] = HAK_NULL;*/
HAK_MEMSET(htb->bucket, 0, capa * HAK_SIZEOF(pair_t*));
htb->factor = factor;
htb->scale[HAK_HTB_KEY] = (kscale < 1)? 1: kscale;
htb->scale[HAK_HTB_VAL] = (vscale < 1)? 1: vscale;
htb->size = 0;
htb->capa = capa;
htb->threshold = htb->capa * htb->factor / 100;
if (htb->capa > 0 && htb->threshold <= 0) htb->threshold = 1;
htb->rev = 0;
htb->style = &style[0];
return 0;
}
void hak_htb_fini (hak_htb_t* htb)
{
hak_htb_clear(htb);
hak_freemem(htb->hak, htb->bucket);
}
const style_t* hak_htb_getstyle (const hak_htb_t* htb)
{
return htb->style;
}
void hak_htb_setstyle (hak_htb_t* htb, const style_t* style)
{
HAK_ASSERT(htb->hak, style != HAK_NULL);
htb->style = style;
}
hak_oow_t hak_htb_getsize (const hak_htb_t* htb)
{
return htb->size;
}
hak_oow_t hak_htb_getcapa (const hak_htb_t* htb)
{
return htb->capa;
}
hak_oow_t hak_htb_getrev (const hak_htb_t* htb)
{
return htb->rev;
}
pair_t* hak_htb_search (const hak_htb_t* htb, const void* kptr, hak_oow_t klen)
{
pair_t* pair;
hak_oow_t hc;
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
pair = htb->bucket[hc];
while (pair != HAK_NULL)
{
if (htb->style->comper(htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
{
return pair;
}
pair = NEXT(pair);
}
hak_seterrnum(htb->hak, HAK_ENOENT);
return HAK_NULL;
}
static HAK_INLINE int reorganize (hak_htb_t* htb)
{
hak_oow_t i, hc, new_capa;
pair_t** new_buck;
if (htb->style->sizer)
{
new_capa = htb->style->sizer(htb, htb->capa + 1);
/* if no change in capacity, return success
* without reorganization */
if (new_capa == htb->capa) return 0;
/* adjust to 1 if the new capacity is not reasonable */
if (new_capa <= 0) new_capa = 1;
}
else
{
/* the bucket is doubled until it grows up to 65536 slots.
* once it has reached it, it grows by 65536 slots */
new_capa = (htb->capa >= 65536)? (htb->capa + 65536): (htb->capa << 1);
}
new_buck = (pair_t**)hak_allocmem(htb->hak, new_capa * HAK_SIZEOF(pair_t*));
if (HAK_UNLIKELY(!new_buck))
{
/* reorganization is disabled once it fails */
htb->threshold = 0;
return -1;
}
/*for (i = 0; i < new_capa; i++) new_buck[i] = HAK_NULL;*/
HAK_MEMSET(new_buck, 0, new_capa * HAK_SIZEOF(pair_t*));
for (i = 0; i < htb->capa; i++)
{
pair_t* pair = htb->bucket[i];
while (pair != HAK_NULL)
{
pair_t* next = NEXT(pair);
hc = htb->style->hasher(htb, KPTR(pair), KLEN(pair)) % new_capa;
NEXT(pair) = new_buck[hc];
new_buck[hc] = pair;
pair = next;
}
}
hak_freemem(htb->hak, htb->bucket);
htb->bucket = new_buck;
htb->capa = new_capa;
htb->threshold = htb->capa * htb->factor / 100;
return 0;
}
/* insert options */
#define UPSERT 1
#define UPDATE 2
#define ENSERT 3
#define INSERT 4
static HAK_INLINE_ALWAYS pair_t* insert (hak_htb_t* htb, void* kptr, hak_oow_t klen, void* vptr, hak_oow_t vlen, int opt)
{
pair_t* pair, * p, * prev, * next;
hak_oow_t hc;
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
pair = htb->bucket[hc];
prev = HAK_NULL;
while (pair != HAK_NULL)
{
next = NEXT(pair);
if (htb->style->comper(htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
{
/* found a pair with a matching key */
switch (opt)
{
case UPSERT:
case UPDATE:
p = change_pair_val(htb, pair, vptr, vlen);
if (!p)
{
/* error in changing the value */
return HAK_NULL;
}
if (p != pair)
{
/* old pair destroyed. new pair reallocated.
* relink to include the new pair but to drop
* the old pair. */
if (prev == HAK_NULL) htb->bucket[hc] = p;
else NEXT(prev) = p;
NEXT(p) = next;
}
htb->rev++;
return p;
case ENSERT:
/* return existing pair */
return pair;
case INSERT:
/* return failure */
hak_seterrnum(htb->hak, HAK_EEXIST);
return HAK_NULL;
}
}
prev = pair;
pair = next;
}
if (opt == UPDATE)
{
hak_seterrnum(htb->hak, HAK_ENOENT);
return HAK_NULL;
}
if (htb->threshold > 0 && htb->size >= htb->threshold)
{
/* ingore reorganization error as it simply means
* more bucket collision and performance penalty. */
if (reorganize(htb) == 0)
{
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
}
}
HAK_ASSERT(htb->hak, pair == HAK_NULL);
pair = alloc_pair(htb, kptr, klen, vptr, vlen);
if (HAK_UNLIKELY(!pair)) return HAK_NULL; /* error */
NEXT(pair) = htb->bucket[hc];
htb->bucket[hc] = pair;
htb->size++;
htb->rev++;
return pair; /* new key added */
}
pair_t* hak_htb_upsert (hak_htb_t* htb, void* kptr, hak_oow_t klen, void* vptr, hak_oow_t vlen)
{
return insert(htb, kptr, klen, vptr, vlen, UPSERT);
}
pair_t* hak_htb_ensert (hak_htb_t* htb, void* kptr, hak_oow_t klen, void* vptr, hak_oow_t vlen)
{
return insert(htb, kptr, klen, vptr, vlen, ENSERT);
}
pair_t* hak_htb_insert (hak_htb_t* htb, void* kptr, hak_oow_t klen, void* vptr, hak_oow_t vlen)
{
return insert(htb, kptr, klen, vptr, vlen, INSERT);
}
pair_t* hak_htb_update (hak_htb_t* htb, void* kptr, hak_oow_t klen, void* vptr, hak_oow_t vlen)
{
return insert(htb, kptr, klen, vptr, vlen, UPDATE);
}
pair_t* hak_htb_cbsert (hak_htb_t* htb, void* kptr, hak_oow_t klen, cbserter_t cbserter, void* ctx)
{
pair_t* pair, * p, * prev, * next;
hak_oow_t hc;
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
pair = htb->bucket[hc];
prev = HAK_NULL;
while (pair != HAK_NULL)
{
next = NEXT(pair);
if (htb->style->comper(htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
{
/* found a pair with a matching key */
p = cbserter(htb, pair, kptr, klen, ctx);
if (!p)
{
/* error returned by the callback function */
return HAK_NULL;
}
if (p != pair)
{
/* old pair destroyed. new pair reallocated.
* relink to include the new pair but to drop
* the old pair. */
if (prev == HAK_NULL) htb->bucket[hc] = p;
else NEXT(prev) = p;
NEXT(p) = next;
}
htb->rev++;
return p;
}
prev = pair;
pair = next;
}
if (htb->threshold > 0 && htb->size >= htb->threshold)
{
/* ingore reorganization error as it simply means
* more bucket collision and performance penalty. */
if (reorganize(htb) == 0)
{
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
}
}
HAK_ASSERT(htb->hak, pair == HAK_NULL);
pair = cbserter(htb, HAK_NULL, kptr, klen, ctx);
if (HAK_UNLIKELY(!pair)) return HAK_NULL; /* error */
NEXT(pair) = htb->bucket[hc];
htb->bucket[hc] = pair;
htb->size++;
htb->rev++;
return pair; /* new key added */
}
int hak_htb_delete (hak_htb_t* htb, const void* kptr, hak_oow_t klen)
{
pair_t* pair, * prev;
hak_oow_t hc;
hc = htb->style->hasher(htb,kptr,klen) % htb->capa;
pair = htb->bucket[hc];
prev = HAK_NULL;
while (pair != HAK_NULL)
{
if (htb->style->comper(htb, KPTR(pair), KLEN(pair), kptr, klen) == 0)
{
if (prev == HAK_NULL)
htb->bucket[hc] = NEXT(pair);
else NEXT(prev) = NEXT(pair);
free_pair(htb, pair);
htb->size--;
htb->rev++;
return 0;
}
prev = pair;
pair = NEXT(pair);
}
hak_seterrnum(htb->hak, HAK_ENOENT);
return -1;
}
void hak_htb_clear (hak_htb_t* htb)
{
hak_oow_t i, sz;
pair_t* pair, * next;
sz = htb->size;
for (i = 0; i < htb->capa; i++)
{
pair = htb->bucket[i];
while (pair)
{
next = NEXT(pair);
free_pair(htb, pair);
htb->size--;
pair = next;
}
htb->bucket[i] = HAK_NULL;
}
HAK_ASSERT(htb->hak, htb->size == 0);
if (sz) htb->rev++;
}
void hak_htb_walk (hak_htb_t* htb, walker_t walker, void* ctx)
{
hak_oow_t i;
pair_t* pair, * next;
for (i = 0; i < htb->capa; i++)
{
pair = htb->bucket[i];
while (pair != HAK_NULL)
{
next = NEXT(pair);
if (walker(htb, pair, ctx) == HAK_HTB_WALK_STOP) return;
pair = next;
}
}
}
void hak_init_htb_itr (hak_htb_itr_t* itr)
{
itr->pair = HAK_NULL;
itr->buckno = 0;
}
pair_t* hak_htb_getfirstpair (hak_htb_t* htb, hak_htb_itr_t* itr)
{
hak_oow_t i;
pair_t* pair;
for (i = 0; i < htb->capa; i++)
{
pair = htb->bucket[i];
if (pair)
{
itr->buckno = i;
itr->pair = pair;
return pair;
}
}
return HAK_NULL;
}
pair_t* hak_htb_getnextpair (hak_htb_t* htb, hak_htb_itr_t* itr)
{
hak_oow_t i;
pair_t* pair;
pair = NEXT(itr->pair);
if (pair)
{
/* no change in bucket number */
itr->pair = pair;
return pair;
}
for (i = itr->buckno + 1; i < htb->capa; i++)
{
pair = htb->bucket[i];
if (pair)
{
itr->buckno = i;
itr->pair = pair;
return pair;
}
}
return HAK_NULL;
}
hak_oow_t hak_htb_dflhash (const hak_htb_t* htb, const void* kptr, hak_oow_t klen)
{
hak_oow_t h;
HAK_HASH_BYTES(h, kptr, klen);
return h ;
}
int hak_htb_dflcomp (const hak_htb_t* htb, const void* kptr1, hak_oow_t klen1, const void* kptr2, hak_oow_t klen2)
{
if (klen1 == klen2) return HAK_MEMCMP(kptr1, kptr2, KTOB(htb,klen1));
/* it just returns 1 to indicate that they are different. */
return 1;
}
+1657
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -1027,6 +1027,7 @@ hak_pfrc_t hak_pf_number_le (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
HAK_STACK_SETRET(hak, nargs, ret);
return HAK_PF_SUCCESS;
}
hak_pfrc_t hak_pf_number_eq (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
{
hak_oop_t ret;
@@ -1036,6 +1037,7 @@ hak_pfrc_t hak_pf_number_eq (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
HAK_STACK_SETRET(hak, nargs, ret);
return HAK_PF_SUCCESS;
}
hak_pfrc_t hak_pf_number_ne (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
{
hak_oop_t ret;
+6
View File
@@ -283,6 +283,7 @@ int hak_fmt_object (hak_t* hak, hak_fmtout_t* fmtout, hak_oop_t obj)
HAK_AID(HAK_CONCODE_MLIST) { "(", "(" },
HAK_AID(HAK_CONCODE_ALIST) { "(", "(" },
HAK_AID(HAK_CONCODE_BLIST) { "(", "(" },
HAK_AID(HAK_CONCODE_PLIST) { "(", "(" },
HAK_AID(HAK_CONCODE_BLOCK) { "{", "{" },
HAK_AID(HAK_CONCODE_ARRAY) { "#[", "[" },
HAK_AID(HAK_CONCODE_BYTEARRAY) { "#b[", "[" },
@@ -298,6 +299,7 @@ int hak_fmt_object (hak_t* hak, hak_fmtout_t* fmtout, hak_oop_t obj)
HAK_AID(HAK_CONCODE_DLIST) { ")", ")" },
HAK_AID(HAK_CONCODE_MLIST) { ")", ")" },
HAK_AID(HAK_CONCODE_ALIST) { ")", ")" },
HAK_AID(HAK_CONCODE_PLIST) { ")", ")" },
HAK_AID(HAK_CONCODE_BLIST) { ")", ")" },
HAK_AID(HAK_CONCODE_BLOCK) { "}", "}" },
HAK_AID(HAK_CONCODE_ARRAY) { "]", "]" },
@@ -993,6 +995,10 @@ void hak_dumpcnode (hak_t* hak, hak_cnode_t* cnode, int newline)
case HAK_CONCODE_MLIST:
hak_logbfmt(hak, HAK_LOG_FATAL, ":");
break;
case HAK_CONCODE_PLIST: /* TODO: must do something */
hak_logbfmt(hak, HAK_LOG_FATAL, " -> ");
break;
}
hak_dumpcnode(hak, HAK_CNODE_CONS_CDR(cnode),0);
+84 -14
View File
@@ -89,6 +89,7 @@ static struct voca_t
{ 4, { '(',':',' ',')' /* MLIST */ } },
{ 4, { '(',':','=',')' /* ALIST - x := y */ } },
{ 4, { '(','B','O',')' /* BLIST - x binop y */ } },
{ 4, { '(','-','>',')' /* PLIST - in -> .. -> out */ } },
{ 3, { '{',' ','}' /* BLOCK */ } },
{ 4, { '#','[',' ',']' /* ARRAY */ } },
{ 5, { '#','b','[',' ',']' /* BYTE ARRAY */ } },
@@ -157,6 +158,7 @@ enum voca_id_t
VOCA_MLIST,
VOCA_ALIST, /* assignment list */
VOCA_BLIST, /* just fake entry */
VOCA_PLIST, /* piping list */
VOCA_BLOCK,
VOCA_ARRAY,
VOCA_BYTEARRAY,
@@ -184,14 +186,15 @@ enum list_flag_t
COLONED = (1 << 3),
COLONEQED = (1 << 4),
BINOPED = (1 << 5),
PIPOPED = (1 << 6),
CLOSED = (1 << 6),
JSON = (1 << 7),
DATA_LIST = (1 << 8),
AUTO_FORGED = (1 << 9), /* automatically added list. only applicable to XLIST */
AT_BEGINNING = (1 << 10)
CLOSED = (1 << 7),
JSON = (1 << 8),
DATA_LIST = (1 << 9),
AUTO_FORGED = (1 << 10), /* automatically added list. only applicable to XLIST */
AT_BEGINNING = (1 << 11)
/* TOTOAL 16 items are allowed for LIST_FLAG_GET_CONCODE() and LIST_FLAG_SET_CONCODE().
/* TOTAL 16 items are allowed for LIST_FLAG_GET_CONCODE() and LIST_FLAG_SET_CONCODE().
* they reserve lower 16 bits as flag bits.*/
};
@@ -210,6 +213,7 @@ static struct
HAK_AID(HAK_CONCODE_MLIST) { HAK_TOK_RPAREN, HAK_SYNERR_RPAREN, VOCA_MLIST }, /* MLIST (obj:message) */
HAK_AID(HAK_CONCODE_ALIST) { HAK_TOK_RPAREN, HAK_SYNERR_RPAREN, VOCA_ALIST }, /* ALIST (var:=value) */
HAK_AID(HAK_CONCODE_BLIST) { HAK_TOK_RPAREN, HAK_SYNERR_RPAREN, VOCA_BLIST }, /* BLIST (x + y) */
HAK_AID(HAK_CONCODE_PLIST) { HAK_TOK_RPAREN, HAK_SYNERR_RPAREN, VOCA_PLIST }, /* PLIST (x -> .. -> y) */
HAK_AID(HAK_CONCODE_BLOCK) { HAK_TOK_RBRACE, HAK_SYNERR_RBRACE, VOCA_BLOCK }, /* BLOCK { } */
HAK_AID(HAK_CONCODE_ARRAY) { HAK_TOK_RBRACK, HAK_SYNERR_RBRACK, VOCA_ARRAY }, /* ARRAY #[ ] */
HAK_AID(HAK_CONCODE_BYTEARRAY) { HAK_TOK_RBRACK, HAK_SYNERR_RBRACK, VOCA_BYTEARRAY }, /* BYTEARRAY #b[ ] */
@@ -518,6 +522,7 @@ int hak_is_binop_string (const hak_oocs_t* v)
hak_oow_t i;
if (v->len <= 0) return 0; /* you can pass the zero-length value */
if (v->len == 2 && v->ptr[0] == '-' && v->ptr[1] == '>') return 0; /* -> is special piping operator */
for (i = 0; i < v->len; i++)
{
@@ -591,6 +596,13 @@ static int classify_ident_token (hak_t* hak, const hak_oocs_t* v, const hak_loc_
if (binop_char_count == v->len)
{
if (binop_char_count == 2 && v->ptr[0] == '-' && v->ptr[1] == '>')
{
/* "->" - special operator for piping */
*tok_type = HAK_TOK_PIPOP;
return 0;
}
*tok_type = HAK_TOK_BINOP;
return 0;
}
@@ -715,7 +727,7 @@ static HAK_INLINE hak_cnode_t* leave_list (hak_t* hak, hak_loc_t* list_loc, int*
hak->c->r.st = rstl->prev; /* pop off */
hak_freemem(hak, rstl); /* dispose of the stack node */
if (fv & (COMMAED | COLONED | COLONEQED | BINOPED))
if (fv & (COMMAED | COLONED | COLONEQED | BINOPED | PIPOPED))
{
/* no item after , : := or various binary operators */
if (concode == HAK_CONCODE_MLIST)
@@ -739,6 +751,13 @@ static HAK_INLINE hak_cnode_t* leave_list (hak_t* hak, hak_loc_t* list_loc, int*
hak_setsynerrbfmt(hak, HAK_SYNERR_NOVALUE, TOKEN_LOC(hak),
"missing expression after binary selector '%.*js'", HAK_CNODE_GET_TOKLEN(tmp), HAK_CNODE_GET_TOKPTR(tmp));
}
else if (concode == HAK_CONCODE_PLIST)
{
hak_cnode_t* tmp;
tmp = HAK_CNODE_CONS_CAR(tail);
hak_setsynerrbfmt(hak, HAK_SYNERR_NOVALUE, TOKEN_LOC(hak),
"missing operand after piping operator '%.*js'", HAK_CNODE_GET_TOKLEN(tmp), HAK_CNODE_GET_TOKPTR(tmp));
}
else
{
if (fv & COMMAED)
@@ -923,7 +942,7 @@ static HAK_INLINE hak_cnode_t* leave_list (hak_t* hak, hak_loc_t* list_loc, int*
* if transformation is done, it is a normal executable expression
* where the binary operator is a primitive function.
*
* alternatively, the compiler treat this as a message send expression
* alternatively, the compiler treats this as a message send expression
* if the reader skips this transformation.
*
* We keep this part commented out to have this trated as a message
@@ -938,6 +957,11 @@ static HAK_INLINE hak_cnode_t* leave_list (hak_t* hak, hak_loc_t* list_loc, int*
HAK_CNODE_CONS_CONCODE(head) = concode;
if (fv & AUTO_FORGED) HAK_CNODE_GET_FLAGS(head) |= HAK_CNODE_AUTO_FORGED;
}
else if (concode == HAK_CONCODE_PLIST)
{
/* TODO */
hak_logbfmt(hak, HAK_LOG_STDERR, "PLIST %hs:%d", __FILE__, __LINE__);
}
else
{
/* the list is empty */
@@ -984,7 +1008,7 @@ static HAK_INLINE int can_comma_list (hak_t* hak)
if (rstl->count == 1) rstl->flagv |= JSON;
else if (!(rstl->flagv & JSON)) return 0;
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED | PIPOPED)) return 0;
cc = (hak_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv);
if (cc == HAK_CONCODE_DIC)
@@ -1064,7 +1088,7 @@ static HAK_INLINE int can_colon_list (hak_t* hak)
}
/* multiple single-colons - e.g. #{ "abc": : 20 } */
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED | PIPOPED)) return 0;
if (cc == HAK_CONCODE_XLIST)
{
@@ -1110,7 +1134,7 @@ static HAK_INLINE int can_coloneq_list (hak_t* hak)
if (rstl->count <= 0 || rstl->count >= 2) return 0; /* allowed after the first item only */
/* repeated delimiters - e.g (a := := ...) (a : := ... ) */
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED | PIPOPED)) return 0;
cc = (hak_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv);
@@ -1159,7 +1183,7 @@ static HAK_INLINE int can_binop_list (hak_t* hak)
}
/* repeated delimiters - e.g (a ++ ++ ...) (a : := ... ) */
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED | PIPOPED)) return 0;
if (cc == HAK_CONCODE_BLIST)
{
@@ -1221,12 +1245,48 @@ static HAK_INLINE int can_binop_list (hak_t* hak)
return 2;
}
static HAK_INLINE int can_pipop_list (hak_t* hak)
{
hak_rstl_t* rstl;
hak_concode_t cc;
HAK_ASSERT(hak, hak->c->r.st != HAK_NULL);
rstl = hak->c->r.st;
/*
* in -> @{...} second
* @{...} -> out second
* in -> @{...} -> out second and fourth
*
* "hello\nworld\n" -> @{ grep hello } -> h
* the counter check doesn't include "->" itself.
* in and out part can be @{...}. it's not supposed to be as flexible as
* shell programming languages in this regards.
*/
if (rstl->count != 1 && rstl->count != 2) return 0;
/* since there is a check using the number of items, it's not error if popoped is repeated.
* the state transition is:
* the first "->" is seen: cc must be XLIST. flags set with POPOPED, concode set to PLIST
* the second "->" is seen: cc must be PLIST. */
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED /*| PIPOPED*/)) return 0;
cc = (hak_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv);
/* piping operator allowed only in XLIST */
if (cc != HAK_CONCODE_XLIST && cc != HAK_CONCODE_PLIST) return 0;
LIST_FLAG_SET_CONCODE(rstl->flagv, HAK_CONCODE_PLIST);
rstl->flagv |= PIPOPED;
return 1;
}
static HAK_INLINE void clear_comma_colon_binop_flag (hak_t* hak)
{
hak_rstl_t* rstl;
HAK_ASSERT(hak, hak->c->r.st != HAK_NULL);
rstl = hak->c->r.st;
rstl->flagv &= ~(COMMAED | COLONED | COLONEQED | BINOPED);
rstl->flagv &= ~(COMMAED | COLONED | COLONEQED | BINOPED | PIPOPED);
}
static int chain_to_list (hak_t* hak, hak_cnode_t* obj, hak_loc_t* loc)
@@ -1950,6 +2010,16 @@ static int feed_process_token (hak_t* hak)
goto auto_xlist;
}
case HAK_TOK_PIPOP:
if (frd->level <= 0 || !can_pipop_list(hak))
{
/* TODO: new error code HAK_SYNERR_PIPOPBANNED? */
hak_setsynerrbfmt(hak, HAK_SYNERR_BANNED, TOKEN_LOC(hak),
"prohibited piping operator around '%.*js'", TOKEN_NAME_LEN(hak), TOKEN_NAME_PTR(hak));
goto oops;
}
goto ok;
case HAK_TOK_COMMA:
if (frd->level <= 0 || !can_comma_list(hak))
{
@@ -1984,7 +2054,7 @@ static int feed_process_token (hak_t* hak)
}
/* if auto-forged */
HAK_ASSERT(hak, concode == HAK_CONCODE_XLIST || concode == HAK_CONCODE_MLIST || concode == HAK_CONCODE_ALIST || concode == HAK_CONCODE_BLIST);
HAK_ASSERT(hak, concode == HAK_CONCODE_XLIST || concode == HAK_CONCODE_MLIST || concode == HAK_CONCODE_ALIST || concode == HAK_CONCODE_BLIST || concode == HAK_CONCODE_PLIST);
frd->obj = leave_list(hak, &frd->list_loc, &frd->flagv, &oldflagv);
frd->level--;
+1 -1
View File
@@ -688,7 +688,7 @@ void* hak_xma_realloc (hak_xma_t* xma, void* b, hak_oow_t size)
else
{
/* try reallocation by merging the adjacent continuous blocks */
#if defined(HAWK_XMA_ENABLE_STAT)
#if defined(HAK_XMA_ENABLE_STAT)
xma->stat.nreallocops++;
#endif
n = _realloc_merge(xma, b, size);
+279 -187
View File
File diff suppressed because it is too large Load Diff
+68 -38
View File
@@ -1,6 +1,6 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2022 Free
# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2024 Free
# Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
@@ -8,7 +8,7 @@
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 8 ltoptions.m4
# serial 10 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -128,7 +128,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
@@ -323,29 +323,39 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
# implement the --enable-aix-soname configure option, and support the
# `aix-soname=aix' and `aix-soname=both' and `aix-soname=svr4' LT_INIT options.
# DEFAULT is either `aix', `both', or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
AC_ARG_ENABLE([aix-soname],
[AS_HELP_STRING([--enable-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
[case $enableval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --enable-aix-soname])
;;
esac
lt_cv_with_aix_soname=$enable_aix_soname],
[_AC_ENABLE_IF([with], [aix-soname],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)])
enable_aix_soname=$lt_cv_with_aix_soname])
with_aix_soname=$enable_aix_soname
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
@@ -376,30 +386,50 @@ LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# implement the --enable-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[AC_ARG_ENABLE([pic],
[AS_HELP_STRING([--enable-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])
case $enableval in
yes|no) pic_mode=$enableval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[dnl Continue to support --with-pic and --without-pic, for backward
dnl compatibility.
_AC_ENABLE_IF([with], [pic],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])]
)
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
+1 -1
View File
@@ -1,6 +1,6 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software
# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2024 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
+6 -6
View File
@@ -1,6 +1,6 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004, 2011-2019, 2021-2022 Free Software Foundation,
# Copyright (C) 2004, 2011-2019, 2021-2024 Free Software Foundation,
# Inc.
# Written by Scott James Remnant, 2004
#
@@ -10,15 +10,15 @@
# @configure_input@
# serial 4245 ltversion.m4
# serial 4441 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.7])
m4_define([LT_PACKAGE_REVISION], [2.4.7])
m4_define([LT_PACKAGE_VERSION], [2.5.4])
m4_define([LT_PACKAGE_REVISION], [2.5.4])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.7'
macro_revision='2.4.7'
[macro_version='2.5.4'
macro_revision='2.5.4'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])
+1 -1
View File
@@ -1,6 +1,6 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2022 Free
# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2024 Free
# Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
+24 -24
View File
@@ -36,7 +36,7 @@ static hak_pfrc_t pf_core_basic_new (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs
obj = HAK_STACK_GETARG(hak, nargs, 0);
if (!HAK_IS_CLASS(hak, obj))
{
hak_seterrbfmt (hak, HAK_EINVAL, "object not class - %O", obj);
hak_seterrbfmt(hak, HAK_EINVAL, "object not class - %O", obj);
return HAK_PF_FAILURE;
}
@@ -48,14 +48,14 @@ static hak_pfrc_t pf_core_basic_new (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs
size = HAK_STACK_GETARG(hak, nargs, 1);
if (!HAK_OOP_IS_SMOOI(size))
{
hak_seterrbfmt (hak, HAK_EINVAL, "size not numeric - %O", size);
hak_seterrbfmt(hak, HAK_EINVAL, "size not numeric - %O", size);
return HAK_PF_FAILURE;
}
nsize = HAK_OOP_TO_SMOOI(size);
if (nsize < 0)
{
hak_seterrbfmt (hak, HAK_EINVAL, "size not valid - %zd", nsize);
hak_seterrbfmt(hak, HAK_EINVAL, "size not valid - %zd", nsize);
return HAK_PF_FAILURE;
}
}
@@ -81,14 +81,14 @@ static hak_pfrc_t __basic_at (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, int s
{
unindexable:
/* the receiver is a special numeric object or a non-indexable object */
hak_seterrbfmt (hak, HAK_EINVAL, "receiver not indexable - %O", obj);
hak_seterrbfmt(hak, HAK_EINVAL, "receiver not indexable - %O", obj);
return HAK_PF_FAILURE;
}
if (hak_inttooow_noseterr(hak, pos, &index) <= 0)
{
/* negative integer or not integer */
hak_seterrbfmt (hak, HAK_EINVAL, "position not valid - %O", pos);
hak_seterrbfmt(hak, HAK_EINVAL, "position not valid - %O", pos);
return HAK_PF_FAILURE;
}
@@ -100,7 +100,7 @@ static hak_pfrc_t __basic_at (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, int s
size = HAK_OBJ_GET_SIZE(obj);
if (index >= size)
{
hak_seterrbfmt (hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)size);
hak_seterrbfmt(hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)size);
return HAK_PF_FAILURE;
}
}
@@ -112,7 +112,7 @@ static hak_pfrc_t __basic_at (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, int s
flexi = HAK_OBJ_GET_SIZE(obj) - fixed;
if (index >= flexi)
{
hak_seterrbfmt (hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)flexi);
hak_seterrbfmt(hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)flexi);
return HAK_PF_FAILURE;
}
index += fixed;
@@ -183,20 +183,20 @@ static hak_pfrc_t __basic_at_put (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, i
if (!HAK_OOP_IS_POINTER(obj) || !HAK_OBJ_GET_FLAGS_FLEXI(obj))
{
unindexable:
hak_seterrbfmt (hak, HAK_EINVAL, "receiver not indexable - %O", obj);
hak_seterrbfmt(hak, HAK_EINVAL, "receiver not indexable - %O", obj);
return HAK_PF_FAILURE;
}
if (HAK_OBJ_GET_FLAGS_RDONLY(obj))
{
hak_seterrbfmt (hak, HAK_EINVAL, "receiver immutable - %O", obj);
hak_seterrbfmt(hak, HAK_EINVAL, "receiver immutable - %O", obj);
return HAK_PF_FAILURE;
}
if (hak_inttooow_noseterr(hak, pos, &index) <= 0)
{
/* negative integer or not integer */
hak_seterrbfmt (hak, HAK_EINVAL, "position not valid - %O", pos);
hak_seterrbfmt(hak, HAK_EINVAL, "position not valid - %O", pos);
return HAK_PF_FAILURE;
}
@@ -208,7 +208,7 @@ static hak_pfrc_t __basic_at_put (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, i
size = HAK_OBJ_GET_SIZE(obj);
if (index >= size)
{
hak_seterrbfmt (hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)size);
hak_seterrbfmt(hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)size);
return HAK_PF_FAILURE;
}
}
@@ -220,7 +220,7 @@ static hak_pfrc_t __basic_at_put (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, i
flexi = HAK_OBJ_GET_SIZE(obj) - fixed;
if (index >= flexi)
{
hak_seterrbfmt (hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)HAK_OBJ_GET_SIZE(obj));
hak_seterrbfmt(hak, HAK_EINVAL, "position(%zd) out of range - negative or greater than or equal to %zu", index, (hak_ooi_t)HAK_OBJ_GET_SIZE(obj));
return HAK_PF_FAILURE;
}
index += fixed;
@@ -237,7 +237,7 @@ static hak_pfrc_t __basic_at_put (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, i
hak_ooch_t c;
if (!HAK_OOP_IS_CHAR(val))
{
hak_seterrbfmt (hak, HAK_EINVAL, "value not character - %O", val);
hak_seterrbfmt(hak, HAK_EINVAL, "value not character - %O", val);
return HAK_PF_FAILURE;
}
c = HAK_OOP_TO_CHAR(val);
@@ -250,7 +250,7 @@ static hak_pfrc_t __basic_at_put (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, i
hak_ooi_t b;
if (!HAK_OOP_IS_SMOOI(val))
{
hak_seterrbfmt (hak, HAK_EINVAL, "value not byte - %O", val);
hak_seterrbfmt(hak, HAK_EINVAL, "value not byte - %O", val);
return HAK_PF_FAILURE;
}
b = HAK_OOP_TO_SMOOI(val);
@@ -302,7 +302,7 @@ static hak_pfrc_t pf_core_basic_size (hak_t* hak, hak_mod_t* mod, hak_ooi_t narg
if (!HAK_OOP_IS_POINTER(src))
{
hak_seterrbfmt (hak, HAK_EINVAL, "source not sizable - %O", src);
hak_seterrbfmt(hak, HAK_EINVAL, "source not sizable - %O", src);
return HAK_PF_FAILURE;
}
@@ -322,7 +322,7 @@ static hak_pfrc_t pf_core_class_name (hak_t* hak, hak_mod_t* mod, hak_ooi_t narg
if (!HAK_IS_CLASS(hak, obj))
{
#if 0
hak_seterrbfmt (hak, HAK_EINVAL, "receiver not class - %O", obj);
hak_seterrbfmt(hak, HAK_EINVAL, "receiver not class - %O", obj);
return HAK_PF_FAILURE;
#else
obj = (hak_oop_t)HAK_CLASSOF(hak, obj);
@@ -344,12 +344,12 @@ static hak_pfrc_t pf_core_class_responds_to (hak_t* hak, hak_mod_t* mod, hak_ooi
msg = HAK_STACK_GETARG(hak, nargs, 1);
if (!HAK_IS_CLASS(hak, obj))
{
hak_seterrbfmt (hak, HAK_EINVAL, "receiver not class - %O", msg);
hak_seterrbfmt(hak, HAK_EINVAL, "receiver not class - %O", msg);
return HAK_PF_FAILURE;
}
if (!HAK_OBJ_IS_CHAR_POINTER(msg))
{
hak_seterrbfmt (hak, HAK_EINVAL, "invalid message - %O", msg);
hak_seterrbfmt(hak, HAK_EINVAL, "invalid message - %O", msg);
return HAK_PF_FAILURE;
}
@@ -368,7 +368,7 @@ static hak_pfrc_t pf_core_inst_responds_to (hak_t* hak, hak_mod_t* mod, hak_ooi_
msg = HAK_STACK_GETARG(hak, nargs, 1);
if (!HAK_OBJ_IS_CHAR_POINTER(msg))
{
hak_seterrbfmt (hak, HAK_EINVAL, "invalid message - %O", msg);
hak_seterrbfmt(hak, HAK_EINVAL, "invalid message - %O", msg);
return HAK_PF_FAILURE;
}
@@ -392,18 +392,18 @@ static hak_pfrc_t pf_core_slice (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
if (!HAK_OOP_IS_POINTER(src))
{
unsliceable:
hak_seterrbfmt (hak, HAK_EINVAL, "source not sliceable - %O", src);
hak_seterrbfmt(hak, HAK_EINVAL, "source not sliceable - %O", src);
return HAK_PF_FAILURE;
}
if (!HAK_OOP_IS_SMOOI(a1))
{
hak_seterrbfmt (hak, HAK_EINVAL, "position not numeric - %O", a1);
hak_seterrbfmt(hak, HAK_EINVAL, "position not numeric - %O", a1);
return HAK_PF_FAILURE;
}
if (!HAK_OOP_IS_SMOOI(a2))
{
hak_seterrbfmt (hak, HAK_EINVAL, "length not numeric - %O", a2);
hak_seterrbfmt(hak, HAK_EINVAL, "length not numeric - %O", a2);
return HAK_PF_FAILURE;
}
@@ -459,7 +459,7 @@ static hak_pfrc_t pf_core_char_to_smooi (hak_t* hak, hak_mod_t* mod, hak_ooi_t n
rcv = HAK_STACK_GETARG(hak, nargs, 0);
if (!HAK_OOP_IS_CHAR(rcv))
{
hak_seterrbfmt (hak, HAK_EINVAL, "receiver not Character - %O", rcv);
hak_seterrbfmt(hak, HAK_EINVAL, "receiver not Character - %O", rcv);
return HAK_PF_FAILURE;
}
@@ -477,7 +477,7 @@ static hak_pfrc_t pf_core_smooi_to_char (hak_t* hak, hak_mod_t* mod, hak_ooi_t n
rcv = HAK_STACK_GETARG(hak, nargs, 0);
if (!HAK_OOP_IS_SMOOI(rcv))
{
hak_seterrbfmt (hak, HAK_EINVAL, "receiver not SmallInteger - %O", rcv);
hak_seterrbfmt(hak, HAK_EINVAL, "receiver not SmallInteger - %O", rcv);
return HAK_PF_FAILURE;
}
+10 -10
View File
@@ -38,18 +38,18 @@ static hak_pfrc_t pf_dic_get (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
if (!HAK_IS_DIC(hak,dic))
{
hak_seterrbfmt (hak, HAK_EINVAL, "parameter not an dictionary - %O", dic);
hak_seterrbfmt(hak, HAK_EINVAL, "parameter not an dictionary - %O", dic);
return HAK_PF_FAILURE;
}
pair = hak_getatdic(hak, (hak_oop_dic_t)dic, key);
if (!pair)
{
HAK_STACK_SETRETTOERROR (hak, nargs, HAK_ENOENT);
HAK_STACK_SETRETTOERROR(hak, nargs, HAK_ENOENT);
return HAK_PF_SUCCESS;
}
HAK_STACK_SETRET (hak, nargs, HAK_CONS_CDR(pair));
HAK_STACK_SETRET(hak, nargs, HAK_CONS_CDR(pair));
return HAK_PF_SUCCESS;
}
@@ -66,25 +66,25 @@ static hak_pfrc_t pf_dic_put (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
if (!HAK_IS_DIC(hak,dic))
{
hak_seterrbfmt (hak, HAK_EINVAL, "parameter not an dictionary - %O", dic);
hak_seterrbfmt(hak, HAK_EINVAL, "parameter not an dictionary - %O", dic);
return HAK_PF_FAILURE;
}
pair = hak_putatdic(hak, (hak_oop_dic_t)dic, key, val);
if (!pair)
{
HAK_STACK_SETRETTOERRNUM (hak, nargs);
HAK_STACK_SETRETTOERRNUM(hak, nargs);
return HAK_PF_SUCCESS;
}
HAK_STACK_SETRET (hak, nargs, HAK_CONS_CDR(pair));
HAK_STACK_SETRET(hak, nargs, HAK_CONS_CDR(pair));
return HAK_PF_SUCCESS;
}
static int walker (hak_t* hak, hak_oop_dic_t dic, hak_oop_cons_t pair, void* ctx)
{
HAK_DEBUG2 (hak, "walker ===> %O =====> %O\n", HAK_CONS_CAR(pair), HAK_CONS_CDR(pair));
HAK_DEBUG2(hak, "walker ===> %O =====> %O\n", HAK_CONS_CAR(pair), HAK_CONS_CDR(pair));
return 0;
}
@@ -98,12 +98,12 @@ static hak_pfrc_t pf_dic_walk (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
arg = HAK_STACK_GETARG(hak, nargs, 0);
if (!HAK_IS_DIC(hak,arg))
{
hak_seterrbfmt (hak, HAK_EINVAL, "parameter not a dictionary - %O", arg);
hak_seterrbfmt(hak, HAK_EINVAL, "parameter not a dictionary - %O", arg);
return HAK_PF_FAILURE;
}
hak_walkdic (hak, (hak_oop_dic_t)arg, walker, HAK_NULL);
HAK_STACK_SETRET (hak, nargs, hak->_true);
hak_walkdic(hak, (hak_oop_dic_t)arg, walker, HAK_NULL);
HAK_STACK_SETRET(hak, nargs, hak->_true);
return HAK_PF_SUCCESS;
}
+63 -4
View File
@@ -26,6 +26,7 @@
#include "_sys.h"
#include <hak-str.h>
#include <stdlib.h>
#if defined(HAVE_SYS_TIME_H)
@@ -47,7 +48,7 @@ static hak_pfrc_t pf_sys_time (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
hak->vmprim.vm_gettime(hak, &now); /* should I use time() instead? */
tv = hak_oowtoint(hak, now.sec);
if (!tv) return HAK_PF_FAILURE;
HAK_STACK_SETRET (hak, nargs, tv);
HAK_STACK_SETRET(hak, nargs, tv);
return HAK_PF_SUCCESS;
}
@@ -103,7 +104,7 @@ static hak_pfrc_t pf_sys_stime (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
#endif
/* ---------------------------------------------------------------- */
HAK_STACK_SETRET (hak, nargs, hak->_nil);
HAK_STACK_SETRET(hak, nargs, hak->_nil);
return HAK_PF_SUCCESS;
}
@@ -126,7 +127,7 @@ static hak_pfrc_t pf_sys_srandom (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
srandom (seedw);
#endif
HAK_STACK_SETRET (hak, nargs, hak->_nil);
HAK_STACK_SETRET(hak, nargs, hak->_nil);
return HAK_PF_SUCCESS;
}
@@ -141,12 +142,70 @@ static hak_pfrc_t pf_sys_random (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
r = random();
#endif
rv = (hak_ooi_t)(r % HAK_SMOOI_MAX);
HAK_STACK_SETRET (hak, nargs, HAK_SMOOI_TO_OOP(rv));
HAK_STACK_SETRET(hak, nargs, HAK_SMOOI_TO_OOP(rv));
return HAK_PF_SUCCESS;
}
#include <stdio.h> // TODO: remove this and replace it by own impl
static hak_pfrc_t pf_sys_popen (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
{
hak_oop_t t;
hak_bch_t* cmd;
FILE* pp;
t = HAK_STACK_GETARG(hak, nargs, 0);
// TODO: support byte array?
/*if (!HAK_IS_STRING(hak, t)) goto oops;*/
if (!HAK_OBJ_IS_CHAR_POINTER(t) ||
HAK_OBJ_GET_SIZE(t) == 0 ||
hak_count_oocstr(HAK_OBJ_GET_CHAR_SLOT(t)) != HAK_OBJ_GET_SIZE(t))
{
/* invalid command arguments */
goto oops;
}
cmd = hak_dupootobcstr(hak, HAK_OBJ_GET_CHAR_SLOT(t), HAK_NULL);
if (!cmd) goto oops;
/* TODO: we need a bidirectional popen.. replace it with our own impl. */
pp = popen(cmd, "r");
if (!pp) goto oops;
if (!HAK_IN_SMPTR_RANGE(pp))
{
pclose(pp);
goto oops;
}
/* using smptr in this mannger is dangerous. because the caller may set random values to other function like pclose...... */
HAK_STACK_SETRET(hak, nargs, HAK_SMPTR_TO_OOP(pp));
return HAK_PF_SUCCESS;
oops:
// TODO: set return value..
return HAK_PF_SUCCESS;
}
static hak_pfrc_t pf_sys_pclose (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs)
{
hak_oop_t t;
t = HAK_STACK_GETARG(hak, nargs, 0);
if (HAK_OOP_IS_SMPTR(t))
{
FILE* pp;
pp = (FILE*)HAK_OOP_TO_SMPTR(t);
if (pp) pclose(pp);
}
HAK_STACK_SETRET(hak, nargs, HAK_SMOOI_TO_OOP(0));
return HAK_PF_SUCCESS;
}
static hak_pfinfo_t pfinfos[] =
{
{ "pclose", { HAK_PFBASE_FUNC, pf_sys_pclose, 1, 1 } },
{ "popen", { HAK_PFBASE_FUNC, pf_sys_popen, 1, 2 } },
{ "random", { HAK_PFBASE_FUNC, pf_sys_random, 0, 0 } },
{ "srandom", { HAK_PFBASE_FUNC, pf_sys_srandom, 1, 1 } },
{ "stime", { HAK_PFBASE_FUNC, pf_sys_stime, 1, 1 } },