aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--erl-build-tool-vars.sh2
-rw-r--r--erts/aclocal.m449
-rw-r--r--erts/configure.in62
-rw-r--r--erts/doc/src/inet_cfg.xml13
-rw-r--r--erts/emulator/Makefile.in15
-rw-r--r--erts/emulator/beam/bif.c9
-rw-r--r--erts/emulator/beam/erl_binary.h14
-rw-r--r--erts/emulator/beam/erl_term.h108
-rw-r--r--erts/emulator/beam/global.h65
-rw-r--r--erts/emulator/beam/utils.c8
-rw-r--r--erts/emulator/drivers/unix/ttsl_drv.c17
-rw-r--r--erts/emulator/hipe/hipe_amd64_asm.m433
-rw-r--r--erts/emulator/hipe/hipe_amd64_bifs.m4226
-rw-r--r--erts/emulator/hipe/hipe_amd64_glue.S116
-rw-r--r--erts/emulator/sys/common/erl_poll.c17
-rw-r--r--erts/emulator/sys/unix/sys.c17
-rw-r--r--erts/emulator/sys/unix/sys_float.c13
-rw-r--r--erts/emulator/zlib/Makefile.in26
-rw-r--r--erts/etc/common/escript.c36
-rw-r--r--erts/include/internal/tile/atomic.h14
-rw-r--r--lib/kernel/doc/src/gen_sctp.xml119
-rw-r--r--lib/kernel/src/code.erl3
-rw-r--r--lib/kernel/src/gen_sctp.erl46
-rw-r--r--lib/kernel/src/hipe_unified_loader.erl42
-rw-r--r--lib/kernel/src/inet.erl147
-rw-r--r--lib/kernel/src/inet_config.erl32
-rw-r--r--lib/kernel/src/inet_db.erl107
-rw-r--r--lib/kernel/src/inet_gethost_native.erl72
-rw-r--r--lib/kernel/src/inet_parse.erl285
-rw-r--r--lib/kernel/src/inet_sctp.erl30
-rw-r--r--lib/kernel/test/code_SUITE.erl38
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ezbin0 -> 505 bytes
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam1
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam1
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/zork-0.8.ezbin0 -> 492 bytes
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam1
-rw-r--r--lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam1
-rw-r--r--lib/kernel/test/gen_sctp_SUITE.erl62
-rw-r--r--lib/kernel/test/inet_SUITE.erl198
-rw-r--r--lib/kernel/test/inet_res_SUITE.erl88
-rw-r--r--lib/megaco/test/Makefile6
-rw-r--r--lib/megaco/test/modules.mk12
-rw-r--r--lib/megaco/vsn.mk2
-rw-r--r--lib/odbc/c_src/odbcserver.c36
-rw-r--r--lib/percept/src/egd_render.erl12
-rw-r--r--lib/percept/test/egd_SUITE.erl14
-rwxr-xr-xotp_build14
-rw-r--r--xcomp/README36
-rw-r--r--xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf33
-rw-r--r--xcomp/erl-xcomp-vxworks_ppc32.conf33
-rw-r--r--xcomp/erl-xcomp-x86_64-saf-linux-gnu.conf33
-rw-r--r--xcomp/erl-xcomp.conf.template33
52 files changed, 1636 insertions, 761 deletions
diff --git a/erl-build-tool-vars.sh b/erl-build-tool-vars.sh
index c6f25d7f79..f66dc2d286 100644
--- a/erl-build-tool-vars.sh
+++ b/erl-build-tool-vars.sh
@@ -25,4 +25,4 @@
# When updating, also update $ERL_TOP/xcomp/{README,erl-xcomp.conf.template},
# and precious variables in $ERL_TOP/erts/aclocal.m4.
#
-erl_build_tool_vars="CC CFLAGS STATIC_CFLAGS CFLAG_RUNTIME_LIBRARY_PATH CPP CPPFLAGS CXX CXXFLAGS LD LDFLAGS DED_LD DED_LDFLAGS DED_LD_FLAG_RUNTIME_LIBRARY_PATH RANLIB AR"
+erl_build_tool_vars="CC CFLAGS STATIC_CFLAGS CFLAG_RUNTIME_LIBRARY_PATH CPP CPPFLAGS CXX CXXFLAGS LD LDFLAGS LIBS DED_LD DED_LDFLAGS DED_LD_FLAG_RUNTIME_LIBRARY_PATH LFS_CFLAGS LFS_LDFLAGS LFS_LIBS RANLIB AR GETCONF"
diff --git a/erts/aclocal.m4 b/erts/aclocal.m4
index 8002ed3d34..8052b2d67d 100644
--- a/erts/aclocal.m4
+++ b/erts/aclocal.m4
@@ -42,11 +42,16 @@ AC_ARG_VAR(CXX, [C++ compiler])
AC_ARG_VAR(CXXFLAGS, [C++ compiler flags])
AC_ARG_VAR(LD, [linker (is often overridden by configure)])
AC_ARG_VAR(LDFLAGS, [linker flags (can be risky to set since LD may be overriden by configure)])
+AC_ARG_VAR(LIBS, [libraries])
AC_ARG_VAR(DED_LD, [linker for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
AC_ARG_VAR(DED_LDFLAGS, [linker flags for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
AC_ARG_VAR(DED_LD_FLAG_RUNTIME_LIBRARY_PATH, [runtime library path linker flag for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
+AC_ARG_VAR(LFS_CFLAGS, [large file support C compiler flags (set all LFS_* variables or none)])
+AC_ARG_VAR(LFS_LDFLAGS, [large file support linker flags (set all LFS_* variables or none)])
+AC_ARG_VAR(LFS_LIBS, [large file support libraries (set all LFS_* variables or none)])
AC_ARG_VAR(RANLIB, [ranlib])
AC_ARG_VAR(AR, [ar])
+AC_ARG_VAR(GETCONF, [getconf])
dnl Cross system root
AC_ARG_VAR(erl_xcomp_sysroot, [Absolute cross system root path (only used when cross compiling)])
@@ -82,6 +87,29 @@ else
fi
])
+AC_DEFUN(LM_CHECK_GETCONF,
+[
+if test "$cross_compiling" != "yes"; then
+ AC_CHECK_PROG([GETCONF], [getconf], [getconf], [false])
+else
+ dnl First check if we got a `<HOST>-getconf' in $PATH
+ host_getconf="$host_alias-getconf"
+ AC_CHECK_PROG([GETCONF], [$host_getconf], [$host_getconf], [false])
+ if test "$GETCONF" = "false" && test "$erl_xcomp_sysroot" != ""; then
+ dnl We should perhaps give up if we have'nt found it by now, but at
+ dnl least in one Tilera MDE `getconf' under sysroot is a bourne
+ dnl shell script which we can use. We try to find `<HOST>-getconf'
+ dnl or `getconf' under sysconf, but only under sysconf since
+ dnl `getconf' in $PATH is almost guaranteed to be for the build
+ dnl machine.
+ GETCONF=
+ prfx="$erl_xcomp_sysroot"
+ AC_PATH_TOOL([GETCONF], [getconf], [false],
+ ["$prfx/usr/bin:$prfx/bin:$prfx/usr/local/bin"])
+ fi
+fi
+])
+
dnl ----------------------------------------------------------------------
dnl
dnl LM_FIND_EMU_CC
@@ -533,19 +561,22 @@ dnl On ofs1 the '-pthread' switch should be used
linux*)
THR_DEFS="$THR_DEFS -D_POSIX_THREAD_SAFE_FUNCTIONS"
+ LM_CHECK_GETCONF
AC_MSG_CHECKING(for Native POSIX Thread Library)
- if test X$cross_compiling = Xyes; then
- case X$erl_xcomp_linux_nptl in
- X) nptl=cross;;
- Xyes|Xno) nptl=$erl_xcomp_linux_nptl;;
+ libpthr_vsn=`$GETCONF GNU_LIBPTHREAD_VERSION 2>/dev/null`
+ if test $? -eq 0; then
+ case "$libpthr_vsn" in
+ *nptl*|*NPTL*) nptl=yes;;
+ *) nptl=no;;
+ esac
+ elif test "$cross_compiling" = "yes"; then
+ case "$erl_xcomp_linux_nptl" in
+ "") nptl=cross;;
+ yes|no) nptl=$erl_xcomp_linux_nptl;;
*) AC_MSG_ERROR([Bad erl_xcomp_linux_nptl value: $erl_xcomp_linux_nptl]);;
esac
else
- case `getconf GNU_LIBPTHREAD_VERSION 2>/dev/null` in
- nptl*) nptl=yes;;
- NPTL*) nptl=yes;;
- *) nptl=no;;
- esac
+ nptl=no
fi
AC_MSG_RESULT($nptl)
if test $nptl = cross; then
diff --git a/erts/configure.in b/erts/configure.in
index 03390de84b..f4ee1fe935 100644
--- a/erts/configure.in
+++ b/erts/configure.in
@@ -329,7 +329,6 @@ if test X${enable_darwin_64bit} = Xyes; then
esac
fi
if test X${enable_darwin_64bit} = Xyes -o X${enable_m64_build} = Xyes; then
- enable_hipe=no
case $CFLAGS in
*-m64*)
;;
@@ -502,22 +501,59 @@ case $host_os in
;;
esac
+lfs_conf=ok
+lfs_source=none
+if test "${LFS_CFLAGS+set}" = "set" || \
+ test "${LFS_LDFLAGS+set}" = "set" || \
+ test "${LFS_LIBS+set}" = "set"; then
+ lfs_source=user
+else
+ LM_CHECK_GETCONF
+ test "$GETCONF" = "false" || lfs_source=getconf
+fi
-dnl
-dnl Use the getconf utility if it exists
-dnl to find large file support flags.
-dnl
-if type getconf >/dev/null 2>&1; then
- CFLAGS="$CFLAGS `getconf LFS_CFLAGS 2>/dev/null`"
- DEBUG_CFLAGS="$DEBUG_CFLAGS `getconf LFS_CFLAGS 2>/dev/null`"
- LDFLAGS="$LDFLAGS `getconf LFS_LDFLAGS 2>/dev/null`"
- LIBS="$LIBS `getconf LFS_LIBS 2>/dev/null`"
+if test "$lfs_source" = "none"; then
+ AC_MSG_WARN([Do not know how to check for large file support flags; no getconf is available])
+else
+ for var in CFLAGS LDFLAGS LIBS; do
+ AC_MSG_CHECKING([for large file support $var])
+ if test $lfs_source = user; then
+ eval "lfs_val=\"\$LFS_$var\""
+ else
+ eval "lfs_var=LFS_$var"
+ lfs_val=`$GETCONF $lfs_var 2>/dev/null` || lfs_conf=failed
+ if test $lfs_conf = failed; then
+ AC_MSG_RESULT([failed])
+ break
+ fi
+ eval "$lfs_var=\"$lfs_val\""
+ fi
+ test "$lfs_val" != "" || lfs_val=none
+ AC_MSG_RESULT([$lfs_val])
+ done
+ if test $lfs_conf = failed; then
+ AC_MSG_WARN([Check for large file support flags failed; $GETCONF failed])
+ else
+ CFLAGS="$CFLAGS $LFS_CFLAGS"
+ DEBUG_CFLAGS="$DEBUG_CFLAGS $LFS_CFLAGS"
+ LDFLAGS="$LDFLAGS $LFS_LDFLAGS"
+ LIBS="$LIBS $LFS_LIBS"
+ fi
fi
if test "x$GCC" = xyes; then
# until the emulator can handle this, I suggest we turn it off!
#WFLAGS="-Wall -Wshadow -Wcast-qual -Wmissing-declarations"
- WFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes"
+ WFLAGS="-Wall -Wstrict-prototypes"
+
+ case "$host_cpu" in
+ tile*)
+ # tile-gcc is a bit stricter with -Wmissing-prototypes than other gccs,
+ # and too strict for our taste.
+ ;;
+ *)
+ WFLAGS="$WFLAGS -Wmissing-prototypes";;
+ esac
saved_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wdeclaration-after-statement"
@@ -727,7 +763,7 @@ fi
AC_PROG_LN_S
-AC_CHECK_PROG(AR, ar, ar, false)
+AC_CHECK_TOOL([AR], [ar], [false])
if test "$ac_cv_prog_AR" = false; then
AC_MSG_ERROR([No 'ar' command found in PATH])
fi
@@ -2206,7 +2242,7 @@ if test "$cross_compiling" != "yes" && test X${enable_hipe} != Xno; then
AC_MSG_NOTICE([HiPE disabled as no valid m4 is found in PATH])
else
case "$ARCH-$OPSYS" in
- x86-linux|amd64-linux|ppc-linux|ppc-darwin|arm-linux|amd64-freebsd|x86-freebsd|x86-sol2|amd64-sol2|ultrasparc-linux)
+ x86-linux|amd64-linux|x86-darwin*|amd64-darwin*|ppc-linux|ppc-darwin|arm-linux|amd64-freebsd|x86-freebsd|x86-sol2|amd64-sol2|ultrasparc-linux)
enable_hipe=yes
;;
esac
diff --git a/erts/doc/src/inet_cfg.xml b/erts/doc/src/inet_cfg.xml
index 18cf65759a..2a033c037c 100644
--- a/erts/doc/src/inet_cfg.xml
+++ b/erts/doc/src/inet_cfg.xml
@@ -4,7 +4,7 @@
<chapter>
<header>
<copyright>
- <year>2004</year><year>2009</year>
+ <year>2004</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>Inet configuration</title>
@@ -230,6 +230,13 @@
(use the Erlang DNS client
<seealso marker="kernel:inet_res">inet_res</seealso>
for nameserver queries).</p>
+ <p>The lookup method <c><![CDATA[string]]></c> tries to
+ parse the hostname as a IPv4 or IPv6 string and return
+ the resulting IP address. It is automatically tried
+ first when <c><![CDATA[native]]></c> is <em>not</em>
+ in the <c><![CDATA[Methods]]></c> list. To skip it in this case
+ the pseudo lookup method <c><![CDATA[nostring]]></c> can be
+ inserted anywhere in the <c><![CDATA[Methods]]></c> list.</p>
<p></p>
</item>
<tag><em><c><![CDATA[{cache_size, Size}.]]></c></em></tag>
diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in
index bc846d1e3d..2fe12be43e 100644
--- a/erts/emulator/Makefile.in
+++ b/erts/emulator/Makefile.in
@@ -167,6 +167,9 @@ ifeq ($(OPSYS),linux)
ppcBEAMLDFLAGS=-Wl,-m,elf32ppc
ppc64BEAMLDFLAGS=-Wl,-m,elf64ppc,-T,hipe/elf64ppc.x
endif
+ifeq ($(OPSYS),darwin)
+amd64BEAMLDFLAGS=-pagezero_size 0x10000000
+endif
HIPEBEAMLDFLAGS=$($(ARCH)BEAMLDFLAGS)
endif
@@ -606,7 +609,7 @@ endif
ifneq ($(filter tile-%,$(TARGET)),)
$(OBJDIR)/beam_emu.o: beam/beam_emu.c
- $(CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) \
+ $(CC) $(subst -O2, $(GEN_OPT_FLGS), $(CFLAGS)) \
-OPT:Olimit=0 -WOPT:lpre=off:spre=off:epre=off \
$(INCLUDES) -c $< -o $@
endif
@@ -1086,8 +1089,16 @@ DEP_FLAGS=-MM $(subst -O2,,$(CFLAGS)) $(INCLUDES) -I../etc/win32 -Idrivers/comm
# SYS_SRC=$(subst sys/common/erl_poll.c,,$(ALL_SYS_SRC))
else # !win32
+
+ifeq ($(findstring tile,$(TARGET)),tile)
+# tile-gcc doesn't like -MG
+MG_FLAG=
+else
+MG_FLAG=-MG
+endif
+
DEP_CC=$(CC)
-DEP_FLAGS=-MM -MG $(CFLAGS) $(INCLUDES) -Idrivers/common
+DEP_FLAGS=-MM $(MG_FLAG) $(CFLAGS) $(INCLUDES) -Idrivers/common
SYS_SRC=$(ALL_SYS_SRC)
endif
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 9c8c0df9f0..1b670585a7 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -4143,6 +4143,7 @@ BIF_RETTYPE blocking_read_file_1(BIF_ALIST_1)
FILE *file;
struct stat file_info;
char *filename = NULL;
+ size_t size;
i = list_length(BIF_ARG_1);
if (i < 0) {
@@ -4170,9 +4171,13 @@ BIF_RETTYPE blocking_read_file_1(BIF_ALIST_1)
fclose(file);
BIF_RET(TUPLE2(hp, am_error, am_allocator));
}
- fread(buff, 1, buff_size, file);
+ size = fread(buff, 1, buff_size, file);
fclose(file);
- bin = new_binary(BIF_P, buff, buff_size);
+ if (size < 0)
+ size = 0;
+ else if (size > buff_size)
+ size = (size_t) buff_size;
+ bin = new_binary(BIF_P, buff, (int) size);
erts_free(ERTS_ALC_T_TMP, (void *) buff);
BIF_RET(TUPLE2(hp, am_ok, bin));
diff --git a/erts/emulator/beam/erl_binary.h b/erts/emulator/beam/erl_binary.h
index dc5539faad..f8ecdde997 100644
--- a/erts/emulator/beam/erl_binary.h
+++ b/erts/emulator/beam/erl_binary.h
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2000-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2000-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
@@ -265,13 +265,13 @@ erts_bin_free(Binary *bp)
ERTS_GLB_INLINE Binary *
erts_create_magic_binary(Uint size, void (*destructor)(Binary *))
{
- Uint bsize = sizeof(Binary) - 1 + sizeof(ErtsBinaryMagicPart) - 1 + size;
+ Uint bsize = ERTS_MAGIC_BIN_SIZE(size);
Binary* bptr = erts_alloc_fnf(ERTS_ALC_T_BINARY, bsize);
if (!bptr)
erts_alloc_n_enomem(ERTS_ALC_T2N(ERTS_ALC_T_BINARY), bsize);
ERTS_CHK_BIN_ALIGNMENT(bptr);
bptr->flags = BIN_FLAG_MAGIC;
- bptr->orig_size = sizeof(ErtsBinaryMagicPart) - 1 + size;
+ bptr->orig_size = ERTS_MAGIC_BIN_ORIG_SIZE(size);
erts_refc_init(&bptr->refc, 0);
ERTS_MAGIC_BIN_DESTRUCTOR(bptr) = destructor;
return bptr;
diff --git a/erts/emulator/beam/erl_term.h b/erts/emulator/beam/erl_term.h
index b0a57a3ebe..a6596558fa 100644
--- a/erts/emulator/beam/erl_term.h
+++ b/erts/emulator/beam/erl_term.h
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2000-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2000-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
@@ -38,7 +38,7 @@ struct erl_node_; /* Declared in erl_node_tables.h */
#endif
#if ET_DEBUG
-#define _ET_DECLARE_CHECKED(TF,F,TX) extern TF checked_##F(TX,const char*,unsigned)
+#define _ET_DECLARE_CHECKED(TF,F,TX) extern TF checked_##F(TX,const char*,unsigned);
#define _ET_APPLY(F,X) checked_##F(X,__FILE__,__LINE__)
#else
#define _ET_DECLARE_CHECKED(TF,F,TX)
@@ -160,27 +160,27 @@ struct erl_node_; /* Declared in erl_node_tables.h */
/* boxed object access methods */
#define _is_aligned(x) (((Uint)(x) & 0x3) == 0)
#define _unchecked_make_boxed(x) ((Uint)(x) + TAG_PRIMARY_BOXED)
-_ET_DECLARE_CHECKED(Eterm,make_boxed,Eterm*);
+_ET_DECLARE_CHECKED(Eterm,make_boxed,Eterm*)
#define make_boxed(x) _ET_APPLY(make_boxed,(x))
#if 1
#define _is_not_boxed(x) ((x) & (_TAG_PRIMARY_MASK-TAG_PRIMARY_BOXED))
#define _unchecked_is_boxed(x) (!_is_not_boxed((x)))
-_ET_DECLARE_CHECKED(int,is_boxed,Eterm);
+_ET_DECLARE_CHECKED(int,is_boxed,Eterm)
#define is_boxed(x) _ET_APPLY(is_boxed,(x))
#else
#define is_boxed(x) (((x) & _TAG_PRIMARY_MASK) == TAG_PRIMARY_BOXED)
#endif
#define _unchecked_boxed_val(x) ((Eterm*)((x) - TAG_PRIMARY_BOXED))
-_ET_DECLARE_CHECKED(Eterm*,boxed_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,boxed_val,Eterm)
#define boxed_val(x) _ET_APPLY(boxed_val,(x))
/* cons cell ("list") access methods */
#define _unchecked_make_list(x) ((Uint)(x) + TAG_PRIMARY_LIST)
-_ET_DECLARE_CHECKED(Eterm,make_list,Eterm*);
+_ET_DECLARE_CHECKED(Eterm,make_list,Eterm*)
#define make_list(x) _ET_APPLY(make_list,(x))
#if 1
#define _unchecked_is_not_list(x) ((x) & (_TAG_PRIMARY_MASK-TAG_PRIMARY_LIST))
-_ET_DECLARE_CHECKED(int,is_not_list,Eterm);
+_ET_DECLARE_CHECKED(int,is_not_list,Eterm)
#define is_not_list(x) _ET_APPLY(is_not_list,(x))
#define is_list(x) (!is_not_list((x)))
#else
@@ -188,7 +188,7 @@ _ET_DECLARE_CHECKED(int,is_not_list,Eterm);
#define is_not_list(x) (!is_list((x)))
#endif
#define _unchecked_list_val(x) ((Eterm*)((x) - TAG_PRIMARY_LIST))
-_ET_DECLARE_CHECKED(Eterm*,list_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,list_val,Eterm)
#define list_val(x) _ET_APPLY(list_val,(x))
#define CONS(hp, car, cdr) \
@@ -221,10 +221,10 @@ _ET_DECLARE_CHECKED(Eterm*,list_val,Eterm);
#define is_not_valid_bit_size(x) (!is_valid_bit_size((x)))
#define MY_IS_SSMALL(x) (((Uint) (((x) >> (SMALL_BITS-1)) + 1)) < 2)
#define _unchecked_unsigned_val(x) ((x) >> _TAG_IMMED1_SIZE)
-_ET_DECLARE_CHECKED(Uint,unsigned_val,Eterm);
+_ET_DECLARE_CHECKED(Uint,unsigned_val,Eterm)
#define unsigned_val(x) _ET_APPLY(unsigned_val,(x))
#define _unchecked_signed_val(x) ((Sint)(x) >> _TAG_IMMED1_SIZE)
-_ET_DECLARE_CHECKED(Sint,signed_val,Eterm);
+_ET_DECLARE_CHECKED(Sint,signed_val,Eterm)
#define signed_val(x) _ET_APPLY(signed_val,(x))
#if _TAG_IMMED1_SMALL == 0x0F
@@ -247,14 +247,14 @@ _ET_DECLARE_CHECKED(Sint,signed_val,Eterm);
#define is_atom(x) (((x) & _TAG_IMMED2_MASK) == _TAG_IMMED2_ATOM)
#define is_not_atom(x) (!is_atom(x))
#define _unchecked_atom_val(x) ((x) >> _TAG_IMMED2_SIZE)
-_ET_DECLARE_CHECKED(Uint,atom_val,Eterm);
+_ET_DECLARE_CHECKED(Uint,atom_val,Eterm)
#define atom_val(x) _ET_APPLY(atom_val,(x))
/* header (arityval or thing) access methods */
#define _make_header(sz,tag) ((Uint)(((sz) << _HEADER_ARITY_OFFS) + (tag)))
#define is_header(x) (((x) & _TAG_PRIMARY_MASK) == TAG_PRIMARY_HEADER)
#define _unchecked_header_arity(x) ((x) >> _HEADER_ARITY_OFFS)
-_ET_DECLARE_CHECKED(Uint,header_arity,Eterm);
+_ET_DECLARE_CHECKED(Uint,header_arity,Eterm)
#define header_arity(x) _ET_APPLY(header_arity,(x))
/* arityval access methods */
@@ -262,16 +262,16 @@ _ET_DECLARE_CHECKED(Uint,header_arity,Eterm);
#define is_arity_value(x) (((x) & _TAG_HEADER_MASK) == _TAG_HEADER_ARITYVAL)
#define is_not_arity_value(x) (!is_arity_value((x)))
#define _unchecked_arityval(x) _unchecked_header_arity((x))
-_ET_DECLARE_CHECKED(Uint,arityval,Eterm);
+_ET_DECLARE_CHECKED(Uint,arityval,Eterm)
#define arityval(x) _ET_APPLY(arityval,(x))
/* thing access methods */
#define is_thing(x) (is_header((x)) && header_is_thing((x)))
#define _unchecked_thing_arityval(x) _unchecked_header_arity((x))
-_ET_DECLARE_CHECKED(Uint,thing_arityval,Eterm);
+_ET_DECLARE_CHECKED(Uint,thing_arityval,Eterm)
#define thing_arityval(x) _ET_APPLY(thing_arityval,(x))
#define _unchecked_thing_subtag(x) ((x) & _HEADER_SUBTAG_MASK)
-_ET_DECLARE_CHECKED(Uint,thing_subtag,Eterm);
+_ET_DECLARE_CHECKED(Uint,thing_subtag,Eterm)
#define thing_subtag(x) _ET_APPLY(thing_subtag,(x))
/*
@@ -301,7 +301,7 @@ _ET_DECLARE_CHECKED(Uint,thing_subtag,Eterm);
#define is_binary(x) (is_boxed((x)) && is_binary_header(*boxed_val((x))))
#define is_not_binary(x) (!is_binary((x)))
#define _unchecked_binary_val(x) _unchecked_boxed_val((x))
-_ET_DECLARE_CHECKED(Eterm*,binary_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,binary_val,Eterm)
#define binary_val(x) _ET_APPLY(binary_val,(x))
/* process binaries stuff (special case of binaries) */
@@ -318,7 +318,7 @@ _ET_DECLARE_CHECKED(Eterm*,binary_val,Eterm);
#define is_fun(x) (is_boxed((x)) && is_fun_header(*boxed_val((x))))
#define is_not_fun(x) (!is_fun((x)))
#define _unchecked_fun_val(x) _unchecked_boxed_val((x))
-_ET_DECLARE_CHECKED(Eterm*,fun_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,fun_val,Eterm)
#define fun_val(x) _ET_APPLY(fun_val,(x))
/* export access methods */
@@ -326,7 +326,7 @@ _ET_DECLARE_CHECKED(Eterm*,fun_val,Eterm);
#define is_export(x) (is_boxed((x)) && is_export_header(*boxed_val((x))))
#define is_not_export(x) (!is_export((x)))
#define _unchecked_export_val(x) _unchecked_boxed_val(x)
-_ET_DECLARE_CHECKED(Eterm*,export_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,export_val,Eterm)
#define export_val(x) _ET_APPLY(export_val,(x))
#define is_export_header(x) ((x) == HEADER_EXPORT)
#define HEADER_EXPORT _make_header(1,_TAG_HEADER_EXPORT)
@@ -336,20 +336,20 @@ _ET_DECLARE_CHECKED(Eterm*,export_val,Eterm);
#define make_neg_bignum_header(sz) _make_header((sz),_TAG_HEADER_NEG_BIG)
#define _is_bignum_header(x) (((x) & (_TAG_HEADER_MASK-_BIG_SIGN_BIT)) == _TAG_HEADER_POS_BIG)
#define _unchecked_bignum_header_is_neg(x) ((x) & _BIG_SIGN_BIT)
-_ET_DECLARE_CHECKED(int,bignum_header_is_neg,Eterm);
+_ET_DECLARE_CHECKED(int,bignum_header_is_neg,Eterm)
#define bignum_header_is_neg(x) _ET_APPLY(bignum_header_is_neg,(x))
#define _unchecked_bignum_header_neg(x) ((x) | _BIG_SIGN_BIT)
-_ET_DECLARE_CHECKED(Eterm,bignum_header_neg,Eterm);
+_ET_DECLARE_CHECKED(Eterm,bignum_header_neg,Eterm)
#define bignum_header_neg(x) _ET_APPLY(bignum_header_neg,(x))
#define _unchecked_bignum_header_arity(x) _unchecked_header_arity((x))
-_ET_DECLARE_CHECKED(Uint,bignum_header_arity,Eterm);
+_ET_DECLARE_CHECKED(Uint,bignum_header_arity,Eterm)
#define bignum_header_arity(x) _ET_APPLY(bignum_header_arity,(x))
#define BIG_ARITY_MAX ((1 << 19)-1)
#define make_big(x) make_boxed((x))
#define is_big(x) (is_boxed((x)) && _is_bignum_header(*boxed_val((x))))
#define is_not_big(x) (!is_big((x)))
#define _unchecked_big_val(x) _unchecked_boxed_val((x))
-_ET_DECLARE_CHECKED(Eterm*,big_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,big_val,Eterm)
#define big_val(x) _ET_APPLY(big_val,(x))
/* flonum ("float") access methods */
@@ -362,7 +362,7 @@ _ET_DECLARE_CHECKED(Eterm*,big_val,Eterm);
#define is_float(x) (is_boxed((x)) && *boxed_val((x)) == HEADER_FLONUM)
#define is_not_float(x) (!is_float(x))
#define _unchecked_float_val(x) _unchecked_boxed_val((x))
-_ET_DECLARE_CHECKED(Eterm*,float_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,float_val,Eterm)
#define float_val(x) _ET_APPLY(float_val,(x))
/* Float definition for byte and word access */
@@ -409,7 +409,7 @@ typedef union float_def
(is_boxed((x)) && *boxed_val((x)) == make_arityval((a)))
#define is_not_tuple_arity(x, a) (!is_tuple_arity((x),(a)))
#define _unchecked_tuple_val(x) _unchecked_boxed_val(x)
-_ET_DECLARE_CHECKED(Eterm*,tuple_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,tuple_val,Eterm)
#define tuple_val(x) _ET_APPLY(tuple_val,(x))
#define TUPLE0(t) \
@@ -548,11 +548,11 @@ _ET_DECLARE_CHECKED(Eterm*,tuple_val,Eterm);
#define is_not_internal_pid(x) (!is_internal_pid((x)))
#define _unchecked_internal_pid_data(x) _GET_PID_DATA((x))
-_ET_DECLARE_CHECKED(Uint,internal_pid_data,Eterm);
+_ET_DECLARE_CHECKED(Uint,internal_pid_data,Eterm)
#define internal_pid_data(x) _ET_APPLY(internal_pid_data,(x))
#define _unchecked_internal_pid_node(x) erts_this_node
-_ET_DECLARE_CHECKED(struct erl_node_*,internal_pid_node,Eterm);
+_ET_DECLARE_CHECKED(struct erl_node_*,internal_pid_node,Eterm)
#define internal_pid_node(x) _ET_APPLY(internal_pid_node,(x))
#define internal_pid_number(x) _GET_PID_NUM(internal_pid_data((x)))
@@ -604,13 +604,13 @@ _ET_DECLARE_CHECKED(struct erl_node_*,internal_pid_node,Eterm);
#define is_not_internal_port(x) (!is_internal_port(x))
#define _unchecked_internal_port_data(x) _GET_PORT_DATA((x))
-_ET_DECLARE_CHECKED(Uint,internal_port_data,Eterm);
+_ET_DECLARE_CHECKED(Uint,internal_port_data,Eterm)
#define internal_port_data(x) _ET_APPLY(internal_port_data,(x))
#define internal_port_number(x) _GET_PORT_NUM(internal_port_data((x)))
#define _unchecked_internal_port_node(x) erts_this_node
-_ET_DECLARE_CHECKED(struct erl_node_*,internal_port_node,Eterm);
+_ET_DECLARE_CHECKED(struct erl_node_*,internal_port_node,Eterm)
#define internal_port_node(x) _ET_APPLY(internal_port_node,(x))
#define internal_port_data_words(x) (1)
@@ -753,20 +753,20 @@ do { \
(!is_internal_ref((x)))
#define _unchecked_internal_ref_val(x) _unchecked_boxed_val((x))
-_ET_DECLARE_CHECKED(Eterm*,internal_ref_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,internal_ref_val,Eterm)
#define internal_ref_val(x) _ET_APPLY(internal_ref_val,(x))
#define _unchecked_internal_ref_data_words(x) \
(_unchecked_thing_arityval(*_unchecked_internal_ref_val(x)))
-_ET_DECLARE_CHECKED(Uint,internal_ref_data_words,Eterm);
+_ET_DECLARE_CHECKED(Uint,internal_ref_data_words,Eterm)
#define internal_ref_data_words(x) _ET_APPLY(internal_ref_data_words,(x))
#define _unchecked_internal_ref_data(x) (_unchecked_ref_thing_ptr(x)->data.ui32)
-_ET_DECLARE_CHECKED(Uint32*,internal_ref_data,Eterm);
+_ET_DECLARE_CHECKED(Uint32*,internal_ref_data,Eterm)
#define internal_ref_data(x) _ET_APPLY(internal_ref_data,(x))
#define _unchecked_internal_ref_node(x) erts_this_node
-_ET_DECLARE_CHECKED(struct erl_node_*,internal_ref_node,Eterm);
+_ET_DECLARE_CHECKED(struct erl_node_*,internal_ref_node,Eterm)
#define internal_ref_node(x) _ET_APPLY(internal_ref_node,(x))
/*
@@ -864,7 +864,7 @@ typedef struct external_thing_ {
#define make_external_ref make_external
#define _unchecked_external_val(x) _unchecked_boxed_val((x))
-_ET_DECLARE_CHECKED(Eterm*,external_val,Eterm);
+_ET_DECLARE_CHECKED(Eterm*,external_val,Eterm)
#define external_val(x) _ET_APPLY(external_val,(x))
#define external_thing_ptr(x) ((ExternalThing *) external_val((x)))
@@ -874,7 +874,7 @@ _ET_DECLARE_CHECKED(Eterm*,external_val,Eterm);
#define _unchecked_external_data_words(x) \
(_unchecked_thing_arityval(_unchecked_external_thing_ptr((x))->header) \
+ (1 - EXTERNAL_THING_HEAD_SIZE))
-_ET_DECLARE_CHECKED(Uint,external_data_words,Eterm);
+_ET_DECLARE_CHECKED(Uint,external_data_words,Eterm)
#define external_data_words(x) _ET_APPLY(external_data_words,(x))
#define _unchecked_external_data(x) (_unchecked_external_thing_ptr((x))->data.ui)
@@ -885,15 +885,15 @@ _ET_DECLARE_CHECKED(Uint,external_data_words,Eterm);
#define _unchecked_external_pid_data_words(x) \
_unchecked_external_data_words((x))
-_ET_DECLARE_CHECKED(Uint,external_pid_data_words,Eterm);
+_ET_DECLARE_CHECKED(Uint,external_pid_data_words,Eterm)
#define external_pid_data_words(x) _ET_APPLY(external_pid_data_words,(x))
#define _unchecked_external_pid_data(x) _unchecked_external_data((x))[0]
-_ET_DECLARE_CHECKED(Uint,external_pid_data,Eterm);
+_ET_DECLARE_CHECKED(Uint,external_pid_data,Eterm)
#define external_pid_data(x) _ET_APPLY(external_pid_data,(x))
#define _unchecked_external_pid_node(x) _unchecked_external_node((x))
-_ET_DECLARE_CHECKED(struct erl_node_*,external_pid_node,Eterm);
+_ET_DECLARE_CHECKED(struct erl_node_*,external_pid_node,Eterm)
#define external_pid_node(x) _ET_APPLY(external_pid_node,(x))
#define external_pid_number(x) _GET_PID_NUM(external_pid_data((x)))
@@ -901,30 +901,30 @@ _ET_DECLARE_CHECKED(struct erl_node_*,external_pid_node,Eterm);
#define _unchecked_external_port_data_words(x) \
_unchecked_external_data_words((x))
-_ET_DECLARE_CHECKED(Uint,external_port_data_words,Eterm);
+_ET_DECLARE_CHECKED(Uint,external_port_data_words,Eterm)
#define external_port_data_words(x) _ET_APPLY(external_port_data_words,(x))
#define _unchecked_external_port_data(x) _unchecked_external_data((x))[0]
-_ET_DECLARE_CHECKED(Uint,external_port_data,Eterm);
+_ET_DECLARE_CHECKED(Uint,external_port_data,Eterm)
#define external_port_data(x) _ET_APPLY(external_port_data,(x))
#define _unchecked_external_port_node(x) _unchecked_external_node((x))
-_ET_DECLARE_CHECKED(struct erl_node_*,external_port_node,Eterm);
+_ET_DECLARE_CHECKED(struct erl_node_*,external_port_node,Eterm)
#define external_port_node(x) _ET_APPLY(external_port_node,(x))
#define external_port_number(x) _GET_PORT_NUM(external_port_data((x)))
#define _unchecked_external_ref_data_words(x) \
_unchecked_external_data_words((x))
-_ET_DECLARE_CHECKED(Uint,external_ref_data_words,Eterm);
+_ET_DECLARE_CHECKED(Uint,external_ref_data_words,Eterm)
#define external_ref_data_words(x) _ET_APPLY(external_ref_data_words,(x))
#define _unchecked_external_ref_data(x) (_unchecked_external_thing_ptr((x))->data.ui32)
-_ET_DECLARE_CHECKED(Uint32*,external_ref_data,Eterm);
+_ET_DECLARE_CHECKED(Uint32*,external_ref_data,Eterm)
#define external_ref_data(x) _ET_APPLY(external_ref_data,(x))
#define _unchecked_external_ref_node(x) _unchecked_external_node((x))
-_ET_DECLARE_CHECKED(struct erl_node_*,external_ref_node,Eterm);
+_ET_DECLARE_CHECKED(struct erl_node_*,external_ref_node,Eterm)
#define external_ref_node(x) _ET_APPLY(external_ref_node,(x))
/* number tests */
@@ -945,21 +945,21 @@ _ET_DECLARE_CHECKED(struct erl_node_*,external_ref_node,Eterm);
#endif
#define _unchecked_make_cp(x) ((Eterm)(x))
-_ET_DECLARE_CHECKED(Eterm,make_cp,Uint*);
+_ET_DECLARE_CHECKED(Eterm,make_cp,Uint*)
#define make_cp(x) _ET_APPLY(make_cp,(x))
#define is_not_CP(x) ((x) & _CPMASK)
#define is_CP(x) (!is_not_CP(x))
#define _unchecked_cp_val(x) ((Uint*)(x))
-_ET_DECLARE_CHECKED(Uint*,cp_val,Eterm);
+_ET_DECLARE_CHECKED(Uint*,cp_val,Eterm)
#define cp_val(x) _ET_APPLY(cp_val,(x))
#define make_catch(x) (((x) << _TAG_IMMED2_SIZE) | _TAG_IMMED2_CATCH)
#define is_catch(x) (((x) & _TAG_IMMED2_MASK) == _TAG_IMMED2_CATCH)
#define is_not_catch(x) (!is_catch(x))
#define _unchecked_catch_val(x) ((x) >> _TAG_IMMED2_SIZE)
-_ET_DECLARE_CHECKED(Uint,catch_val,Eterm);
+_ET_DECLARE_CHECKED(Uint,catch_val,Eterm)
#define catch_val(x) _ET_APPLY(catch_val,(x))
#define make_blank(X) ((X) = NIL)
@@ -989,21 +989,21 @@ _ET_DECLARE_CHECKED(Uint,catch_val,Eterm);
#define _is_yreg(x) (beam_reg_tag(x) == Y_REG_DEF)
#define _unchecked_x_reg_offset(R) ((R) - X_REG_DEF)
-_ET_DECLARE_CHECKED(Uint,x_reg_offset,Uint);
+_ET_DECLARE_CHECKED(Uint,x_reg_offset,Uint)
#define x_reg_offset(R) _ET_APPLY(x_reg_offset,(R))
#define _unchecked_y_reg_offset(R) ((R) - Y_REG_DEF)
-_ET_DECLARE_CHECKED(Uint,y_reg_offset,Uint);
+_ET_DECLARE_CHECKED(Uint,y_reg_offset,Uint)
#define y_reg_offset(R) _ET_APPLY(y_reg_offset,(R))
#define reg_index(R) ((R) / sizeof(Eterm))
#define _unchecked_x_reg_index(R) ((R) >> 2)
-_ET_DECLARE_CHECKED(Uint,x_reg_index,Uint);
+_ET_DECLARE_CHECKED(Uint,x_reg_index,Uint)
#define x_reg_index(R) _ET_APPLY(x_reg_index,(R))
#define _unchecked_y_reg_index(R) ((R) >> 2)
-_ET_DECLARE_CHECKED(Uint,y_reg_index,Uint);
+_ET_DECLARE_CHECKED(Uint,y_reg_index,Uint)
#define y_reg_index(R) _ET_APPLY(y_reg_index,(R))
/*
diff --git a/erts/emulator/beam/global.h b/erts/emulator/beam/global.h
index df0ab40074..8def007c63 100644
--- a/erts/emulator/beam/global.h
+++ b/erts/emulator/beam/global.h
@@ -21,6 +21,7 @@
#define __GLOBAL_H__
#include "sys.h"
+#include <stddef.h> /* offsetof() */
#include "erl_alloc.h"
#include "erl_vm.h"
#include "erl_node_container_utils.h"
@@ -382,17 +383,42 @@ extern Eterm erts_ddll_monitor_driver(Process *p,
** and Binary, the macros below can convert one type to the other, as they both
** in reality are equal.
*/
-typedef struct binary {
- Uint flags;
- erts_refc_t refc;
+
#ifdef ARCH_32
- Uint32 align__; /* *DO NOT USE* only for alignment. */
+ /* *DO NOT USE* only for alignment. */
+#define ERTS_BINARY_STRUCT_ALIGNMENT Uint32 align__;
+#else
+#define ERTS_BINARY_STRUCT_ALIGNMENT
#endif
- /* Add fields BEFORE this, otherwise the drivers crash */
+
+/* Add fields in ERTS_INTERNAL_BINARY_FIELDS, otherwise the drivers crash */
+#define ERTS_INTERNAL_BINARY_FIELDS \
+ Uint flags; \
+ erts_refc_t refc; \
+ ERTS_BINARY_STRUCT_ALIGNMENT
+
+typedef struct binary {
+ ERTS_INTERNAL_BINARY_FIELDS
long orig_size;
char orig_bytes[1]; /* to be continued */
} Binary;
+typedef struct {
+ ERTS_INTERNAL_BINARY_FIELDS
+ long orig_size;
+ void (*destructor)(Binary *);
+ char magic_bin_data[1];
+} ErtsMagicBinary;
+
+typedef union {
+ Binary binary;
+ ErtsMagicBinary magic_binary;
+ struct {
+ ERTS_INTERNAL_BINARY_FIELDS
+ ErlDrvBinary binary;
+ } driver;
+} ErtsBinary;
+
/*
* 'Binary' alignment:
* Address of orig_bytes[0] of a Binary should always be 8-byte aligned.
@@ -400,25 +426,21 @@ typedef struct binary {
* 32-bits architectures and 8 bytes on 64-bits architectures.
*/
-/*
- * "magic" binary.
- */
-typedef struct {
- void (*destructor)(Binary *);
- char magic_bin_data[1];
-} ErtsBinaryMagicPart;
-
#define ERTS_MAGIC_BIN_DESTRUCTOR(BP) \
- (((ErtsBinaryMagicPart *) (BP)->orig_bytes)->destructor)
+ ((ErtsBinary *) (BP))->magic_binary.destructor
#define ERTS_MAGIC_BIN_DATA(BP) \
- ((void *) (((ErtsBinaryMagicPart *) (BP)->orig_bytes)->magic_bin_data))
+ ((void *) ((ErtsBinary *) (BP))->magic_binary.magic_bin_data)
#define ERTS_MAGIC_BIN_DATA_SIZE(BP) \
- ((BP)->orig_size - (sizeof(ErtsBinaryMagicPart) - 1))
+ ((BP)->orig_size - sizeof(void (*)(Binary *)))
+#define ERTS_MAGIC_BIN_ORIG_SIZE(Sz) \
+ (sizeof(void (*)(Binary *)) + (Sz))
+#define ERTS_MAGIC_BIN_SIZE(Sz) \
+ (sizeof(ErtsMagicBinary) - 1 + (Sz))
-#define Binary2ErlDrvBinary(B) ((ErlDrvBinary *) (&((B)->orig_size)))
+#define Binary2ErlDrvBinary(B) (&((ErtsBinary *) (B))->driver.binary)
#define ErlDrvBinary2Binary(D) ((Binary *) \
- (((char *) (D)) - \
- ((char *) &(((Binary *) 0)->orig_size))))
+ (((char *) (D)) \
+ - offsetof(ErtsBinary, driver.binary)))
/* A "magic" binary flag */
#define BIN_FLAG_MAGIC 1
@@ -1406,6 +1428,11 @@ void p_slpq(_VOID_);
/* utils.c */
+/*
+ * To be used to silence unused result warnings, but do not abuse it.
+ */
+void erts_silence_warn_unused_result(long unused);
+
void erts_cleanup_offheap(ErlOffHeap *offheap);
void erts_cleanup_externals(ExternalThing *);
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index c162395159..687e6fa67b 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -3982,6 +3982,14 @@ erts_write_env(char *key, char *value)
return res;
}
+/*
+ * To be used to silence unused result warnings, but do not abuse it.
+ */
+void erts_silence_warn_unused_result(long unused)
+{
+
+}
+
#ifdef DEBUG
/*
* Handy functions when using a debugger - don't use in the code!
diff --git a/erts/emulator/drivers/unix/ttsl_drv.c b/erts/emulator/drivers/unix/ttsl_drv.c
index 4c2514669b..4cd54c073f 100644
--- a/erts/emulator/drivers/unix/ttsl_drv.c
+++ b/erts/emulator/drivers/unix/ttsl_drv.c
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 1996-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 1996-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
/*
@@ -142,7 +142,9 @@ static int tty_init(int,int,int,int);
static int tty_set(int);
static int tty_reset(int);
static int ttysl_control(ErlDrvData, unsigned int, char *, int, char **, int);
+#ifdef ERTS_NOT_USED
static RETSIGTYPE suspend(int);
+#endif
static RETSIGTYPE cont(int);
static RETSIGTYPE winch(int);
@@ -1265,6 +1267,9 @@ static int tty_reset(int fd) /* of terminal device */
* to the orignal settings
*/
+#ifdef ERTS_NOT_USED
+/* XXX: A mistake that it isn't used, or should it be removed? */
+
static RETSIGTYPE suspend(int sig)
{
if (tty_reset(ttysl_fd) < 0) {
@@ -1284,6 +1289,8 @@ static RETSIGTYPE suspend(int sig)
}
}
+#endif
+
static RETSIGTYPE cont(int sig)
{
if (tty_set(ttysl_fd) < 0) {
diff --git a/erts/emulator/hipe/hipe_amd64_asm.m4 b/erts/emulator/hipe/hipe_amd64_asm.m4
index 9ce9b4fc5b..7f563c35d8 100644
--- a/erts/emulator/hipe/hipe_amd64_asm.m4
+++ b/erts/emulator/hipe/hipe_amd64_asm.m4
@@ -1,20 +1,20 @@
changecom(`/*', `*/')dnl
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2004-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2004-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
/*
@@ -37,6 +37,29 @@ define(SIMULATE_NSP,0)dnl change to 1 to simulate call/ret insns
`#define LEAF_WORDS 'LEAF_WORDS
/*
+ * Workarounds for Darwin.
+ */
+ifelse(OPSYS,darwin,``
+/* Darwin */
+#define TEXT .text
+#define JOIN(X,Y) X##Y
+#define CSYM(NAME) JOIN(_,NAME)
+#define ASYM(NAME) CSYM(NAME)
+#define GLOBAL(NAME) .globl NAME
+#define SET_SIZE(NAME) /*empty*/
+#define TYPE_FUNCTION(NAME) /*empty*/
+'',``
+/* Not Darwin */
+#define TEXT .section ".text"
+#define CSYM(NAME) NAME
+#define ASYM(NAME) NAME
+#define GLOBAL(NAME) .global NAME
+#define SET_SIZE(NAME) .size NAME,.-NAME
+#define TYPE_FUNCTION(NAME) .type NAME,@function
+'')dnl
+
+
+/*
* Reserved registers.
*/
`#define P %rbp'
diff --git a/erts/emulator/hipe/hipe_amd64_bifs.m4 b/erts/emulator/hipe/hipe_amd64_bifs.m4
index 66fd167f47..f7c9604e2b 100644
--- a/erts/emulator/hipe/hipe_amd64_bifs.m4
+++ b/erts/emulator/hipe/hipe_amd64_bifs.m4
@@ -1,20 +1,20 @@
changecom(`/*', `*/')dnl
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2004-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2004-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
/*
@@ -46,17 +46,17 @@ define(standard_bif_interface_1,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,1,0)
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
@@ -65,18 +65,18 @@ $1:
jz nbif_1_simple_exception
NBIF_RET(1)
HANDLE_GOT_MBUF(1)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(standard_bif_interface_2,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,2,0)
@@ -84,7 +84,7 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
@@ -93,18 +93,18 @@ $1:
jz nbif_2_simple_exception
NBIF_RET(2)
HANDLE_GOT_MBUF(2)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(standard_bif_interface_3,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,3,0)
@@ -113,7 +113,7 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
@@ -122,8 +122,8 @@ $1:
jz nbif_3_simple_exception
NBIF_RET(3)
HANDLE_GOT_MBUF(3)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
/*
@@ -136,16 +136,16 @@ define(fail_bif_interface_0,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
@@ -154,8 +154,8 @@ $1:
jz nbif_0_simple_exception
NBIF_RET(0)
HANDLE_GOT_MBUF(0)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
/*
@@ -172,59 +172,59 @@ define(nofail_primop_interface_0,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
/* return */
NBIF_RET(0)
HANDLE_GOT_MBUF(0)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(nofail_primop_interface_1,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,1,0)
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
/* return */
NBIF_RET(1)
HANDLE_GOT_MBUF(1)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(nofail_primop_interface_2,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,2,0)
@@ -232,25 +232,25 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
/* return */
NBIF_RET(2)
HANDLE_GOT_MBUF(2)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(nofail_primop_interface_3,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,3,0)
@@ -259,15 +259,15 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C
- call $2
+ call CSYM($2)
TEST_GOT_MBUF
SWITCH_C_TO_ERLANG
/* return */
NBIF_RET(3)
HANDLE_GOT_MBUF(3)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
/*
@@ -285,55 +285,55 @@ define(nocons_nofail_primop_interface_0,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(0)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(nocons_nofail_primop_interface_1,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,1,0)
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(1)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(nocons_nofail_primop_interface_2,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,2,0)
@@ -341,23 +341,23 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(2)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(nocons_nofail_primop_interface_3,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,3,0)
@@ -366,23 +366,23 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(3)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(nocons_nofail_primop_interface_5,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
movq P, %rdi
NBIF_ARG(%rsi,5,0)
@@ -393,13 +393,13 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(5)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
/*
@@ -417,74 +417,74 @@ define(noproc_primop_interface_0,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(0)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(noproc_primop_interface_1,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
NBIF_ARG(%rdi,1,0)
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(1)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(noproc_primop_interface_2,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
NBIF_ARG(%rdi,2,0)
NBIF_ARG(%rsi,2,1)
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(2)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(noproc_primop_interface_3,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
NBIF_ARG(%rdi,3,0)
NBIF_ARG(%rsi,3,1)
@@ -492,23 +492,23 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(3)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
define(noproc_primop_interface_5,
`
#ifndef HAVE_$1
#`define' HAVE_$1
- .section ".text"
+ TEXT
.align 4
- .global $1
-$1:
+ GLOBAL(ASYM($1))
+ASYM($1):
/* set up the parameters */
NBIF_ARG(%rdi,5,0)
NBIF_ARG(%rsi,5,1)
@@ -518,13 +518,13 @@ $1:
/* make the call on the C stack */
SWITCH_ERLANG_TO_C_QUICK
- call $2
+ call CSYM($2)
SWITCH_C_TO_ERLANG_QUICK
/* return */
NBIF_RET(5)
- .size $1,.-$1
- .type $1,@function
+ SET_SIZE(ASYM($1))
+ TYPE_FUNCTION(ASYM($1))
#endif')
/*
diff --git a/erts/emulator/hipe/hipe_amd64_glue.S b/erts/emulator/hipe/hipe_amd64_glue.S
index 872c5dc9e3..83b7b0397b 100644
--- a/erts/emulator/hipe/hipe_amd64_glue.S
+++ b/erts/emulator/hipe/hipe_amd64_glue.S
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2004-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2004-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
/*
@@ -56,16 +56,16 @@
/* switch to native stack */ \
SWITCH_C_TO_ERLANG
- .section ".text"
+ TEXT
/*
* int x86_call_to_native(Process *p);
* Emulated code recursively calls native code.
*/
.align 4
- .global x86_call_to_native
- .global nbif_return
-x86_call_to_native:
+ GLOBAL(CSYM(x86_call_to_native))
+ GLOBAL(ASYM(nbif_return))
+CSYM(x86_call_to_native):
ENTER_FROM_C
/* get argument registers */
LOAD_ARG_REGS
@@ -77,7 +77,7 @@ x86_call_to_native:
*
* This is where native code returns to emulated code.
*/
-nbif_return:
+ASYM(nbif_return):
movq %rax, P_ARG0(P) # save retval
movl $HIPE_MODE_SWITCH_RES_RETURN, %eax
/* FALLTHROUGH to .flush_exit
@@ -118,8 +118,8 @@ nbif_return:
* XXX: Different stubs for different number of register parameters?
*/
.align 4
- .global nbif_callemu
-nbif_callemu:
+ GLOBAL(ASYM(nbif_callemu))
+ASYM(nbif_callemu):
STORE_ARG_REGS
movl $HIPE_MODE_SWITCH_RES_CALL, %eax
jmp .suspend_exit
@@ -128,8 +128,8 @@ nbif_callemu:
* nbif_apply
*/
.align 4
- .global nbif_apply
-nbif_apply:
+ GLOBAL(ASYM(nbif_apply))
+ASYM(nbif_apply):
STORE_ARG_REGS
movl $HIPE_MODE_SWITCH_RES_APPLY, %eax
jmp .suspend_exit
@@ -145,8 +145,8 @@ nbif_apply:
*/
#if NR_ARG_REGS >= 6
.align 4
- .global nbif_ccallemu6
-nbif_ccallemu6:
+ GLOBAL(ASYM(nbif_ccallemu6))
+ASYM(nbif_ccallemu6):
movq ARG5, P_ARG5(P)
#if NR_ARG_REGS > 6
movq ARG6, ARG5
@@ -158,8 +158,8 @@ nbif_ccallemu6:
#if NR_ARG_REGS >= 5
.align 4
- .global nbif_ccallemu5
-nbif_ccallemu5:
+ GLOBAL(ASYM(nbif_ccallemu5))
+ASYM(nbif_ccallemu5):
movq ARG4, P_ARG4(P)
#if NR_ARG_REGS > 5
movq ARG5, ARG4
@@ -171,8 +171,8 @@ nbif_ccallemu5:
#if NR_ARG_REGS >= 4
.align 4
- .global nbif_ccallemu4
-nbif_ccallemu4:
+ GLOBAL(ASYM(nbif_ccallemu4))
+ASYM(nbif_ccallemu4):
movq ARG3, P_ARG3(P)
#if NR_ARG_REGS > 4
movq ARG4, ARG3
@@ -184,8 +184,8 @@ nbif_ccallemu4:
#if NR_ARG_REGS >= 3
.align 4
- .global nbif_ccallemu3
-nbif_ccallemu3:
+ GLOBAL(ASYM(nbif_ccallemu3))
+ASYM(nbif_ccallemu3):
movq ARG2, P_ARG2(P)
#if NR_ARG_REGS > 3
movq ARG3, ARG2
@@ -197,8 +197,8 @@ nbif_ccallemu3:
#if NR_ARG_REGS >= 2
.align 4
- .global nbif_ccallemu2
-nbif_ccallemu2:
+ GLOBAL(ASYM(nbif_ccallemu2))
+ASYM(nbif_ccallemu2):
movq ARG1, P_ARG1(P)
#if NR_ARG_REGS > 2
movq ARG2, ARG1
@@ -210,8 +210,8 @@ nbif_ccallemu2:
#if NR_ARG_REGS >= 1
.align 4
- .global nbif_ccallemu1
-nbif_ccallemu1:
+ GLOBAL(ASYM(nbif_ccallemu1))
+ASYM(nbif_ccallemu1):
movq ARG0, P_ARG0(P)
#if NR_ARG_REGS > 1
movq ARG1, ARG0
@@ -222,8 +222,8 @@ nbif_ccallemu1:
#endif
.align 4
- .global nbif_ccallemu0
-nbif_ccallemu0:
+ GLOBAL(ASYM(nbif_ccallemu0))
+ASYM(nbif_ccallemu0):
/* We use %rsi not ARG0 here because ARG0 is not
defined when NR_ARG_REGS == 0. */
#if NR_ARG_REGS == 0
@@ -237,8 +237,8 @@ nbif_ccallemu0:
* This is where native code suspends.
*/
.align 4
- .global nbif_suspend_0
-nbif_suspend_0:
+ GLOBAL(ASYM(nbif_suspend_0))
+ASYM(nbif_suspend_0):
movl $HIPE_MODE_SWITCH_RES_SUSPEND, %eax
jmp .suspend_exit
@@ -246,8 +246,8 @@ nbif_suspend_0:
* Suspend from a receive (waiting for a message)
*/
.align 4
- .global nbif_suspend_msg
-nbif_suspend_msg:
+ GLOBAL(ASYM(nbif_suspend_msg))
+ASYM(nbif_suspend_msg):
movl $HIPE_MODE_SWITCH_RES_WAIT, %eax
jmp .suspend_exit
@@ -257,8 +257,8 @@ nbif_suspend_msg:
* else { return 0; }
*/
.align 4
- .global nbif_suspend_msg_timeout
-nbif_suspend_msg_timeout:
+ GLOBAL(ASYM(nbif_suspend_msg_timeout))
+ASYM(nbif_suspend_msg_timeout):
movq P_FLAGS(P), %rax
/* this relies on F_TIMO (1<<2) fitting in a byte */
testb $F_TIMO, %al # F_TIMO set?
@@ -275,8 +275,8 @@ nbif_suspend_msg_timeout:
* Emulated code returns to its native code caller.
*/
.align 4
- .global x86_return_to_native
-x86_return_to_native:
+ GLOBAL(CSYM(x86_return_to_native))
+CSYM(x86_return_to_native):
ENTER_FROM_C
/* get return value */
movq P_ARG0(P), %rax
@@ -292,8 +292,8 @@ x86_return_to_native:
* Emulated code tailcalls native code.
*/
.align 4
- .global x86_tailcall_to_native
-x86_tailcall_to_native:
+ GLOBAL(CSYM(x86_tailcall_to_native))
+CSYM(x86_tailcall_to_native):
ENTER_FROM_C
/* get argument registers */
LOAD_ARG_REGS
@@ -305,8 +305,8 @@ x86_tailcall_to_native:
* Emulated code throws an exception to its native code caller.
*/
.align 4
- .global x86_throw_to_native
-x86_throw_to_native:
+ GLOBAL(CSYM(x86_throw_to_native))
+CSYM(x86_throw_to_native):
ENTER_FROM_C
/* invoke the handler */
jmp *P_NCALLEE(P) # set by hipe_find_handler()
@@ -315,15 +315,15 @@ x86_throw_to_native:
* This is the default exception handler for native code.
*/
.align 4
- .global nbif_fail
-nbif_fail:
+ GLOBAL(ASYM(nbif_fail))
+ASYM(nbif_fail):
movl $HIPE_MODE_SWITCH_RES_THROW, %eax
jmp .flush_exit
- .global nbif_0_gc_after_bif
- .global nbif_1_gc_after_bif
- .global nbif_2_gc_after_bif
- .global nbif_3_gc_after_bif
+ GLOBAL(nbif_0_gc_after_bif)
+ GLOBAL(nbif_1_gc_after_bif)
+ GLOBAL(nbif_2_gc_after_bif)
+ GLOBAL(nbif_3_gc_after_bif)
.align 4
nbif_0_gc_after_bif:
xorl %edx, %edx
@@ -346,7 +346,7 @@ nbif_3_gc_after_bif:
subq $(16-8), %rsp
movq P, %rdi
movq %rax, %rsi
- call erts_gc_after_bif_call
+ call CSYM(erts_gc_after_bif_call)
addq $(16-8), %rsp
movl $0, P_NARITY(P) # Note: narity is a 32-bit field
ret
@@ -356,10 +356,10 @@ nbif_3_gc_after_bif:
* exceptional condition.
* The stack/heap registers were just read from P.
*/
- .global nbif_0_simple_exception
- .global nbif_1_simple_exception
- .global nbif_2_simple_exception
- .global nbif_3_simple_exception
+ GLOBAL(nbif_0_simple_exception)
+ GLOBAL(nbif_1_simple_exception)
+ GLOBAL(nbif_2_simple_exception)
+ GLOBAL(nbif_3_simple_exception)
.align 4
nbif_0_simple_exception:
xorl %eax, %eax
@@ -389,7 +389,7 @@ nbif_3_simple_exception:
/* find and prepare to invoke the handler */
SWITCH_ERLANG_TO_C_QUICK # The cached state is clean and need not be saved.
movq P, %rdi
- call hipe_handle_exception # Note: hipe_handle_exception() conses
+ call CSYM(hipe_handle_exception) # Note: hipe_handle_exception() conses
SWITCH_C_TO_ERLANG # %rsp updated by hipe_find_handler()
/* now invoke the handler */
jmp *P_NCALLEE(P) # set by hipe_find_handler()
@@ -408,15 +408,15 @@ nbif_3_simple_exception:
* nbif_stack_trap_ra: trap return address for maintaining
* the gray/white stack boundary
*/
- .global nbif_stack_trap_ra
+ GLOBAL(ASYM(nbif_stack_trap_ra))
.align 4
-nbif_stack_trap_ra: # a return address, not a function
+ASYM(nbif_stack_trap_ra): # a return address, not a function
# This only handles a single return value.
# If we have more, we need to save them in the PCB.
movq %rax, TEMP_RV # save retval
SWITCH_ERLANG_TO_C_QUICK
movq P, %rdi
- call hipe_handle_stack_trap # must not cons; preserves TEMP_RV
+ call CSYM(hipe_handle_stack_trap) # must not cons; preserves TEMP_RV
movq %rax, %rdx # original RA
SWITCH_C_TO_ERLANG_QUICK
movq TEMP_RV, %rax # restore retval
@@ -425,15 +425,15 @@ nbif_stack_trap_ra: # a return address, not a function
/*
* nbif_inc_stack_0
*/
- .global nbif_inc_stack_0
+ GLOBAL(ASYM(nbif_inc_stack_0))
.align 4
-nbif_inc_stack_0:
+ASYM(nbif_inc_stack_0):
SWITCH_ERLANG_TO_C_QUICK
STORE_ARG_REGS
movq P, %rdi
# hipe_inc_nstack reads and writes NSP and NSP_LIMIT,
# but does not access HP or FCALLS (or the non-amd64 NRA).
- call hipe_inc_nstack
+ call CSYM(hipe_inc_nstack)
LOAD_ARG_REGS
SWITCH_C_TO_ERLANG_QUICK
NSP_RET0
diff --git a/erts/emulator/sys/common/erl_poll.c b/erts/emulator/sys/common/erl_poll.c
index 169d4579a2..5cca33d7eb 100644
--- a/erts/emulator/sys/common/erl_poll.c
+++ b/erts/emulator/sys/common/erl_poll.c
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2006-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2006-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
@@ -350,6 +350,7 @@ unset_interrupted_chk(ErtsPollSet ps)
#endif
+void erts_silence_warn_unused_result(long unused);
static void fatal_error(char *format, ...);
static void fatal_error_async_signal_safe(char *error_str);
@@ -2554,8 +2555,10 @@ fatal_error_async_signal_safe(char *error_str)
int len = 0;
while (error_str[len])
len++;
- if (len)
- (void) write(2, error_str, len); /* async signal safe */
+ if (len) {
+ /* async signal safe */
+ erts_silence_warn_unused_result(write(2, error_str, len));
+ }
}
abort();
}
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index 183525b222..31ab5d03de 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 1996-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 1996-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
@@ -709,7 +709,7 @@ prepare_crash_dump(void)
if (nice_val > 39) {
nice_val = 39;
}
- nice(nice_val);
+ erts_silence_warn_unused_result(nice(nice_val));
}
envsz = sizeof(env);
@@ -2332,7 +2332,7 @@ sys_async_ready_failed(int fd, int r, int err)
char buf[120];
sprintf(buf, "sys_async_ready(): Fatal error: fd=%d, r=%d, errno=%d\n",
fd, r, err);
- (void) write(2, buf, strlen(buf));
+ erts_silence_warn_unused_result(write(2, buf, strlen(buf)));
abort();
}
@@ -2891,7 +2891,7 @@ smp_sig_notify(char c)
char msg[] =
"smp_sig_notify(): Failed to notify signal-dispatcher thread "
"about received signal";
- (void) write(2, msg, sizeof(msg));
+ erts_silence_warn_unused_result(write(2, msg, sizeof(msg)));
abort();
}
}
@@ -3121,7 +3121,6 @@ erl_sys_args(int* argc, char** argv)
*argc = j;
}
-
#ifdef ERTS_TIMER_THREAD
/*
diff --git a/erts/emulator/sys/unix/sys_float.c b/erts/emulator/sys/unix/sys_float.c
index 15da6ab45c..c59c99f65e 100644
--- a/erts/emulator/sys/unix/sys_float.c
+++ b/erts/emulator/sys/unix/sys_float.c
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2001-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2001-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
@@ -93,7 +93,8 @@ void erts_fp_check_init_error(volatile unsigned long *fpexnp)
char buf[64];
snprintf(buf, sizeof buf, "ERTS_FP_CHECK_INIT at %p: detected unhandled FPE at %p\r\n",
__builtin_return_address(0), (void*)*fpexnp);
- write(2, buf, strlen(buf));
+ if (write(2, buf, strlen(buf)) <= 0)
+ erl_exit(ERTS_ABORT_EXIT, "%s", buf);
*fpexnp = 0;
#if defined(__i386__) || defined(__x86_64__)
erts_restore_fpu();
diff --git a/erts/emulator/zlib/Makefile.in b/erts/emulator/zlib/Makefile.in
index 5c99b460c1..b44a87551d 100644
--- a/erts/emulator/zlib/Makefile.in
+++ b/erts/emulator/zlib/Makefile.in
@@ -14,12 +14,7 @@
# make install prefix=$HOME
ARFLAGS = rc
-ifeq ($(findstring ose,$(TARGET)),ose)
- TYPE_FLAGS =
-else
- TYPE_FLAGS = -O3
-endif
-CFLAGS = @CFLAGS@ @DEFS@ @EMU_THR_DEFS@ $(TYPE_FLAGS)
+CFLAGS = $(subst -O2, -O3, @CFLAGS@ @DEFS@ @EMU_THR_DEFS@)
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-g -DDEBUG
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
@@ -36,24 +31,15 @@ OBJS = $(O:%=$(OBJDIR)/%)
include $(ERL_TOP)/make/target.mk
-# On windows we need a separate zlib during debug build
-ifeq ($(TARGET),win32)
-
-ifeq ($(TYPE),debug)
-CFLAGS = $(subst -O2, -g, @CFLAGS@ @DEFS@ @DEBUG_FLAGS@)
-endif # debug
-
-else # win32
-
ifeq ($(TYPE),gcov)
-CFLAGS = $(subst -O2, -g, -O0 -fprofile-arcs -ftest-coverage @CFLAGS@ @DEFS@ @DEBUG_FLAGS@)
-TYPE_FLAGS=
+CFLAGS = -O0 -fprofile-arcs -ftest-coverage @DEBUG_CFLAGS@ @DEFS@ @EMU_THR_DEFS@
else # gcov
-# On other platforms we use no special debug version of zlib
+ifeq ($(TYPE),debug)
+CFLAGS = @DEBUG_CFLAGS@ @DEFS@ @EMU_THR_DEFS@
+endif # debug
endif # gcov
-endif # win32
-
+# On windows we *need* a separate zlib during debug build
OBJDIR= $(ERL_TOP)/erts/emulator/zlib/obj/$(TARGET)/$(TYPE)
include $(ERL_TOP)/make/$(TARGET)/otp.mk
diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c
index ab37d4af46..1bc5eb7651 100644
--- a/erts/etc/common/escript.c
+++ b/erts/etc/common/escript.c
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2007-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2007-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
/*
@@ -199,9 +199,10 @@ find_prog(char *origpath)
continue;
} else {
/* Wow we found the executable. */
- strcpy(abspath, wildcard);
+ strcpy(relpath, wildcard);
FindClose(dir_handle);
- return strsave(abspath);
+ look_for_sep = FALSE;
+ break;
}
#else
dp = opendir(dir);
@@ -216,11 +217,12 @@ find_prog(char *origpath)
if (strcmp(origpath, dirp->d_name) == 0) {
/* Wow we found the executable. */
- strcpy(abspath, dir);
- strcat(abspath, DIRSEPSTR);
- strcat(abspath, dirp->d_name);
+ strcpy(relpath, dir);
+ strcat(relpath, DIRSEPSTR);
+ strcat(relpath, dirp->d_name);
closedir(dp);
- return strsave(abspath);
+ look_for_sep = FALSE;
+ break;
}
}
}
@@ -239,8 +241,8 @@ find_prog(char *origpath)
#else
if (!realpath(relpath, abspath)) {
#endif /* __WIN32__ */
- /* Cannot determine absolute path to escript. Try the relative. */
- return strsave(relpath);
+ /* Cannot determine absolute path to escript. Try the origin. */
+ return strsave(origpath);
} else {
return strsave(abspath);
}
@@ -373,11 +375,10 @@ main(int argc, char** argv)
if (strcmp(basename, "escript") == 0) {
#endif
/*
- * Push all options (without the hyphen) before the script name.
+ * Locate all options before the script name.
*/
while (argc > 1 && argv[1][0] == '-') {
- PUSH(argv[1]+1);
argc--;
argv++;
last_opt = argv;
@@ -402,6 +403,7 @@ main(int argc, char** argv)
scriptname[len-4] = '\0';
}
#endif
+
strcat(scriptname, ".escript");
}
@@ -418,7 +420,7 @@ main(int argc, char** argv)
PUSH3("-run", "escript", "start");
/*
- * Push all options (without the hyphen) before the script name.
+ * Push all options before the script name. But omit the leading hyphens.
*/
while (first_opt != last_opt) {
@@ -500,7 +502,7 @@ char *make_commandline(char **argv)
*(--p) = '\0';
if (debug) {
- printf("Processed commandline:%s\n",buff);
+ printf("Processed command line:%s\n",buff);
}
return buff;
}
diff --git a/erts/include/internal/tile/atomic.h b/erts/include/internal/tile/atomic.h
index 0622b53729..59a9250e7c 100644
--- a/erts/include/internal/tile/atomic.h
+++ b/erts/include/internal/tile/atomic.h
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 2008-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 2008-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*/
@@ -84,13 +84,13 @@ ethr_native_atomic_add_return(ethr_native_atomic_t *var, long incr)
static ETHR_INLINE long
ethr_native_atomic_inc_return(ethr_native_atomic_t *var)
{
- return ethr_native_atomic_add_return(&var->counter, 1);
+ return ethr_native_atomic_add_return(var, 1);
}
static ETHR_INLINE long
ethr_native_atomic_dec_return(ethr_native_atomic_t *var)
{
- return ethr_native_atomic_add_return(&var->counter, -1);
+ return ethr_native_atomic_add_return(var, -1);
}
static ETHR_INLINE long
diff --git a/lib/kernel/doc/src/gen_sctp.xml b/lib/kernel/doc/src/gen_sctp.xml
index de41178a17..3a8011e28b 100644
--- a/lib/kernel/doc/src/gen_sctp.xml
+++ b/lib/kernel/doc/src/gen_sctp.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2007</year><year>2009</year>
+ <year>2007</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>gen_sctp</title>
@@ -170,10 +170,19 @@
<p>Establishes a new association for the socket <c>Socket</c>,
with the peer (SCTP server socket) given by
<c>Addr</c> and <c>Port</c>. The <c>Timeout</c>,
- is expressed in milliseconds.</p>
- <p>A socket can be associated with multiple peers.
- <marker id="record-sctp_assoc_change"></marker>
+ is expressed in milliseconds. A socket can be associated with multiple peers.</p>
+ <p><b>WARNING:</b>Using a value of <c>Timeout</c> less than
+ the maximum time taken by the OS to establish an association (around 4.5 minutes
+ if the default values from RFC 4960 are used) can result in
+ inconsistent or incorrect return values. This is especially
+ relevant for associations sharing the same <c>Socket</c>
+ (i.e. source address and port) since the controlling process
+ blocks until <c>connect/*</c> returns.
+ <seealso marker="#connect_init/4">connect_init/*</seealso>
+ provides an alternative not subject to this limitation.</p>
+
+ <p><marker id="record-sctp_assoc_change"></marker>
The result of <c>connect/*</c> is an <c>#sctp_assoc_change{}</c>
event which contains, in particular, the new
<seealso marker="#type-assoc_id">Association ID:</seealso></p>
@@ -233,6 +242,45 @@
</desc>
</func>
<func>
+ <name>connect_init(Socket, Addr, Port, Opts) -&gt; ok | {error, posix()}</name>
+ <fsummary>Same as <c>connect_init(Socket, Addr, Port, Opts, infinity)</c>.</fsummary>
+ <desc>
+ <p>Same as <c>connect_init(Socket, Addr, Port, Opts, infinity)</c>.</p>
+ </desc>
+ </func>
+ <func>
+ <name>connect_init(Socket, Addr, Port, [Opt], Timeout) -&gt; ok | {error, posix()}</name>
+ <fsummary>Initiate a new association for the socket <c>Socket</c>, with a peer (SCTP server socket)</fsummary>
+ <type>
+ <v>Socket = sctp_socket()</v>
+ <v>Addr = ip_address() | Host</v>
+ <v>Port = port_number()</v>
+ <v>Opt = sctp_option()</v>
+ <v>Timeout = timeout()</v>
+ <v>Host = atom() | string()</v>
+ </type>
+ <desc>
+ <p>Initiates a new association for the socket <c>Socket</c>,
+ with the peer (SCTP server socket) given by
+ <c>Addr</c> and <c>Port</c>.</p>
+ <p>The fundamental difference between this API
+ and <c>connect/*</c> is that the return value is that of the
+ underlying OS connect(2) system call. If <c>ok</c> is returned
+ then the result of the association establishement is received
+ by the calling process as
+ an <seealso marker="#record-sctp_assoc_change">
+ #sctp_assoc_change{}</seealso>
+ event. The calling process must be prepared to receive this, or
+ poll for it using <c>recv/*</c> depending on the value of the
+ active option.</p>
+ <p>The parameters are as described
+ in <seealso marker="#connect/5">connect/*</seealso>, with the
+ exception of the <c>Timeout</c> value.</p>
+ <p>The timer associated with <c>Timeout</c> only supervises
+ IP resolution of <c>Addr</c></p>
+ </desc>
+ </func>
+ <func>
<name>controlling_process(sctp_socket(), pid()) -&gt; ok</name>
<fsummary>Assign a new controlling process pid to the socket</fsummary>
<desc>
@@ -1058,6 +1106,65 @@
gen_sctp:close(S). </pre>
<p></p>
</item>
+ <item>
+ <p>A very simple Erlang SCTP Client which uses the
+ connect_init API.</p>
+ <pre>
+-module(ex3).
+
+-export([client/4]).
+-include_lib("kernel/include/inet.hrl").
+-include_lib("kernel/include/inet_sctp.hrl").
+
+client(Peer1, Port1, Peer2, Port2)
+ when is_tuple(Peer1), is_integer(Port1), is_tuple(Peer2), is_integer(Port2) -&gt;
+ {ok,S} = gen_sctp:open(),
+ SctpInitMsgOpt = {sctp_initmsg,#sctp_initmsg{num_ostreams=5}},
+ ActiveOpt = {active, true},
+ Opts = [SctpInitMsgOpt, ActiveOpt],
+ ok = gen_sctp:connect(S, Peer1, Port1, Opts),
+ ok = gen_sctp:connect(S, Peer2, Port2, Opts),
+ io:format("Connections initiated~n", []),
+ client_loop(S, Peer1, Port1, undefined, Peer2, Port2, undefined).
+
+client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2) -&gt;
+ receive
+ {sctp, S, Peer1, Port1, {_Anc, SAC}}
+ when is_record(SAC, sctp_assoc_change), AssocId1 == undefined -&gt;
+ io:format("Association 1 connect result: ~p. AssocId: ~p~n",
+ [SAC#sctp_assoc_change.state,
+ SAC#sctp_assoc_change.assoc_id]),
+ client_loop(S, Peer1, Port1, SAC#sctp_assoc_change.assoc_id,
+ Peer2, Port2, AssocId2);
+
+ {sctp, S, Peer2, Port2, {_Anc, SAC}}
+ when is_record(SAC, sctp_assoc_change), AssocId2 == undefined -&gt;
+ io:format("Association 2 connect result: ~p. AssocId: ~p~n",
+ [SAC#sctp_assoc_change.state, SAC#sctp_assoc_change.assoc_id]),
+ client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2,
+ SAC#sctp_assoc_change.assoc_id);
+
+ {sctp, S, Peer1, Port1, Data} -&gt;
+ io:format("Association 1: received ~p~n", [Data]),
+ client_loop(S, Peer1, Port1, AssocId1,
+ Peer2, Port2, AssocId2);
+
+ {sctp, S, Peer2, Port2, Data} -&gt;
+ io:format("Association 2: received ~p~n", [Data]),
+ client_loop(S, Peer1, Port1, AssocId1,
+ Peer2, Port2, AssocId2);
+
+ Other -&gt;
+ io:format("Other ~p~n", [Other]),
+ client_loop(S, Peer1, Port1, AssocId1,
+ Peer2, Port2, AssocId2)
+
+ after 5000 -&gt;
+ ok
+ end.
+</pre>
+ <p></p>
+ </item>
</list>
</section>
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index 89d893f8c1..ffe58ae7a9 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -465,7 +465,8 @@ search([{Dir, File} | Tail]) ->
build([]) -> [];
build([Dir|Tail]) ->
- Files = filter(objfile_extension(), Dir, file:list_dir(Dir)),
+ Files = filter(objfile_extension(), Dir,
+ erl_prim_loader:list_dir(Dir)),
[decorate(Files, Dir) | build(Tail)].
decorate([], _) -> [];
diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl
index fcd1d1564a..5a31e3976f 100644
--- a/lib/kernel/src/gen_sctp.erl
+++ b/lib/kernel/src/gen_sctp.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2007-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2007-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -27,7 +27,7 @@
-include("inet_sctp.hrl").
-export([open/0,open/1,open/2,close/1]).
--export([listen/2,connect/4,connect/5]).
+-export([listen/2,connect/4,connect/5,connect_init/4,connect_init/5]).
-export([eof/2,abort/2]).
-export([send/3,send/4,recv/1,recv/2]).
-export([error_string/1]).
@@ -80,7 +80,26 @@ listen(S, Flag) ->
connect(S, Addr, Port, Opts) ->
connect(S, Addr, Port, Opts, infinity).
-connect(S, Addr, Port, Opts, Timeout) when is_port(S), is_list(Opts) ->
+connect(S, Addr, Port, Opts, Timeout) ->
+ case do_connect(S, Addr, Port, Opts, Timeout, true) of
+ badarg ->
+ erlang:error(badarg, [S,Addr,Port,Opts,Timeout]);
+ Result ->
+ Result
+ end.
+
+connect_init(S, Addr, Port, Opts) ->
+ connect_init(S, Addr, Port, Opts, infinity).
+
+connect_init(S, Addr, Port, Opts, Timeout) ->
+ case do_connect(S, Addr, Port, Opts, Timeout, false) of
+ badarg ->
+ erlang:error(badarg, [S,Addr,Port,Opts,Timeout]);
+ Result ->
+ Result
+ end.
+
+do_connect(S, Addr, Port, Opts, Timeout, ConnWait) when is_port(S), is_list(Opts) ->
case inet_db:lookup_socket(S) of
{ok,Mod} ->
case Mod:getserv(Port) of
@@ -89,21 +108,26 @@ connect(S, Addr, Port, Opts, Timeout) when is_port(S), is_list(Opts) ->
Timer ->
try Mod:getaddr(Addr, Timer) of
{ok,IP} ->
- Mod:connect(S, IP, Port, Opts, Timer);
+ ConnectTimer = if ConnWait == false ->
+ nowait;
+ true ->
+ Timer
+ end,
+ Mod:connect(S, IP, Port, Opts, ConnectTimer);
Error -> Error
after
inet:stop_timer(Timer)
end
catch
error:badarg ->
- erlang:error(badarg, [S,Addr,Port,Opts,Timeout])
+ badarg
end;
Error -> Error
end;
Error -> Error
end;
-connect(S, Addr, Port, Opts, Timeout) ->
- erlang:error(badarg, [S,Addr,Port,Opts,Timeout]).
+do_connect(_S, _Addr, _Port, _Opts, _Timeout, _ConnWait) ->
+ badarg.
diff --git a/lib/kernel/src/hipe_unified_loader.erl b/lib/kernel/src/hipe_unified_loader.erl
index 42eab67478..f289b8110d 100644
--- a/lib/kernel/src/hipe_unified_loader.erl
+++ b/lib/kernel/src/hipe_unified_loader.erl
@@ -96,14 +96,6 @@ load_hipe_modules() ->
%% code:load_file/1) and the atom `no_native' on failure.
load_native_code(Mod, Bin) when is_atom(Mod), is_binary(Bin) ->
- erlang:system_flag(multi_scheduling, block),
- try
- load_native_code_nosmp(Mod, Bin)
- after
- erlang:system_flag(multi_scheduling, unblock)
- end.
-
-load_native_code_nosmp(Mod, Bin) ->
Architecture = erlang:system_info(hipe_architecture),
try chunk_name(Architecture) of
ChunkTag ->
@@ -111,10 +103,15 @@ load_native_code_nosmp(Mod, Bin) ->
case code:get_chunk(Bin, ChunkTag) of
undefined -> no_native;
NativeCode when is_binary(NativeCode) ->
- OldReferencesToPatch = patch_to_emu_step1(Mod),
- case load_module(Mod, NativeCode, Bin, OldReferencesToPatch) of
- bad_crc -> no_native;
- Result -> Result
+ erlang:system_flag(multi_scheduling, block),
+ try
+ OldReferencesToPatch = patch_to_emu_step1(Mod),
+ case load_module(Mod, NativeCode, Bin, OldReferencesToPatch) of
+ bad_crc -> no_native;
+ Result -> Result
+ end
+ after
+ erlang:system_flag(multi_scheduling, unblock)
end
end
catch
@@ -128,17 +125,18 @@ load_native_code_nosmp(Mod, Bin) ->
-spec post_beam_load(atom()) -> 'ok'.
post_beam_load(Mod) when is_atom(Mod) ->
- erlang:system_flag(multi_scheduling, block),
- try
- post_beam_load_nosmp(Mod)
- after
- erlang:system_flag(multi_scheduling, unblock)
- end.
-
-post_beam_load_nosmp(Mod) ->
Architecture = erlang:system_info(hipe_architecture),
- try chunk_name(Architecture) of _ChunkTag -> patch_to_emu(Mod)
- catch _:_ -> ok
+ try chunk_name(Architecture) of
+ _ChunkTag ->
+ erlang:system_flag(multi_scheduling, block),
+ try
+ patch_to_emu(Mod)
+ after
+ erlang:system_flag(multi_scheduling, unblock)
+ end
+ catch
+ _:_ ->
+ ok
end.
%%========================================================================
diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl
index b86aa1839e..eb503235d8 100644
--- a/lib/kernel/src/inet.erl
+++ b/lib/kernel/src/inet.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(inet).
@@ -45,6 +45,7 @@
%% resolve
-export([gethostbyname/1, gethostbyname/2, gethostbyname/3,
gethostbyname_tm/3]).
+-export([gethostbyname_string/2, gethostbyname_self/2]).
-export([gethostbyaddr/1, gethostbyaddr/2,
gethostbyaddr_tm/2]).
@@ -411,7 +412,17 @@ gethostbyname(Name,Family,Timeout) ->
Res.
gethostbyname_tm(Name,Family,Timer) ->
- gethostbyname_tm(Name,Family,Timer,inet_db:res_option(lookup)).
+ Opts0 = inet_db:res_option(lookup),
+ Opts =
+ case (lists:member(native, Opts0) orelse
+ lists:member(string, Opts0) orelse
+ lists:member(nostring, Opts0)) of
+ true ->
+ Opts0;
+ false ->
+ [string|Opts0]
+ end,
+ gethostbyname_tm(Name, Family, Timer, Opts).
-spec gethostbyaddr(Address :: string() | ip_address()) ->
@@ -850,75 +861,61 @@ getaddrs_tm(Address, Family, Timer) ->
%%
%% gethostbyname with option search
%%
-gethostbyname_tm(Name, Type, Timer, [dns | Opts]) ->
- Res = inet_res:gethostbyname_tm(Name, Type, Timer),
- case Res of
- {ok,_} -> Res;
- {error,timeout} -> Res;
- {error,formerr} -> {error,einval};
- {error,_} -> gethostbyname_tm(Name,Type,Timer,Opts)
- end;
-gethostbyname_tm(Name, Type, Timer, [file | Opts]) ->
- case inet_hosts:gethostbyname(Name, Type) of
- {error,formerr} -> {error,einval};
- {error,_} -> gethostbyname_tm(Name,Type,Timer,Opts);
- Result -> Result
- end;
-gethostbyname_tm(Name, Type, Timer, [yp | Opts]) ->
+gethostbyname_tm(Name, Type, Timer, [string|_]=Opts) ->
+ Result = gethostbyname_string(Name, Type),
+ gethostbyname_tm(Name, Type, Timer, Opts, Result);
+gethostbyname_tm(Name, Type, Timer, [dns|_]=Opts) ->
+ Result = inet_res:gethostbyname_tm(Name, Type, Timer),
+ gethostbyname_tm(Name, Type, Timer, Opts, Result);
+gethostbyname_tm(Name, Type, Timer, [file|_]=Opts) ->
+ Result = inet_hosts:gethostbyname(Name, Type),
+ gethostbyname_tm(Name, Type, Timer, Opts, Result);
+gethostbyname_tm(Name, Type, Timer, [yp|_]=Opts) ->
gethostbyname_tm_native(Name, Type, Timer, Opts);
-gethostbyname_tm(Name, Type, Timer, [nis | Opts]) ->
+gethostbyname_tm(Name, Type, Timer, [nis|_]=Opts) ->
gethostbyname_tm_native(Name, Type, Timer, Opts);
-gethostbyname_tm(Name, Type, Timer, [nisplus | Opts]) ->
+gethostbyname_tm(Name, Type, Timer, [nisplus|_]=Opts) ->
gethostbyname_tm_native(Name, Type, Timer, Opts);
-gethostbyname_tm(Name, Type, Timer, [wins | Opts]) ->
+gethostbyname_tm(Name, Type, Timer, [wins|_]=Opts) ->
gethostbyname_tm_native(Name, Type, Timer, Opts);
-gethostbyname_tm(Name, Type, Timer, [native | Opts]) ->
+gethostbyname_tm(Name, Type, Timer, [native|_]=Opts) ->
gethostbyname_tm_native(Name, Type, Timer, Opts);
-gethostbyname_tm(_, _, _, [no_default|_]) ->
- %% If the native resolver has failed, we should not bother
- %% to try to be smarter and parse the IP address here.
- {error,nxdomain};
-gethostbyname_tm(Name, Type, Timer, [_ | Opts]) ->
+gethostbyname_tm(Name, Type, Timer, [_|_]=Opts) ->
gethostbyname_tm(Name, Type, Timer, Opts);
-%% Last resort - parse the hostname as address
-gethostbyname_tm(Name, inet, _Timer, []) ->
- case inet_parse:ipv4_address(Name) of
- {ok,IP4} ->
- {ok,make_hostent(Name, [IP4], [], inet)};
- _ ->
- gethostbyname_self(Name)
- end;
-gethostbyname_tm(Name, inet6, _Timer, []) ->
- case inet_parse:ipv6_address(Name) of
- {ok,IP6} ->
- {ok,make_hostent(Name, [IP6], [], inet6)};
- _ ->
- %% Even if Name is a valid IPv4 address, we can't
- %% assume it's correct to return it on a IPv6
- %% format ( {0,0,0,0,0,16#ffff,?u16(A,B),?u16(C,D)} ).
- %% This host might not support IPv6.
- gethostbyname_self(Name)
+%% Make sure we always can look up our own hostname.
+gethostbyname_tm(Name, Type, Timer, []) ->
+ Result = gethostbyname_self(Name, Type),
+ gethostbyname_tm(Name, Type, Timer, [], Result).
+
+gethostbyname_tm(Name, Type, Timer, Opts, Result) ->
+ case Result of
+ {ok,_} ->
+ Result;
+ {error,formerr} ->
+ {error,einval};
+ {error,_} when Opts =:= [] ->
+ {error,nxdomain};
+ {error,_} ->
+ gethostbyname_tm(Name, Type, Timer, tl(Opts))
end.
gethostbyname_tm_native(Name, Type, Timer, Opts) ->
%% Fixme: add (global) timeout to gethost_native
- case inet_gethost_native:gethostbyname(Name, Type) of
- {error,formerr} -> {error,einval};
- {error,timeout} -> {error,timeout};
- {error,_} -> gethostbyname_tm(Name, Type, Timer, Opts++[no_default]);
- Result -> Result
- end.
+ Result = inet_gethost_native:gethostbyname(Name, Type),
+ gethostbyname_tm(Name, Type, Timer, Opts, Result).
-%% Make sure we always can look up our own hostname.
-gethostbyname_self(Name) ->
- Type = case inet_db:res_option(inet6) of
- true -> inet6;
- false -> inet
- end,
+
+
+gethostbyname_self(Name, Type) when is_atom(Name) ->
+ gethostbyname_self(atom_to_list(Name), Type);
+gethostbyname_self(Name, Type)
+ when is_list(Name), Type =:= inet;
+ is_list(Name), Type =:= inet6 ->
case inet_db:gethostname() of
Name ->
- {ok,make_hostent(Name, [translate_ip(loopback, Type)],
- [], Type)};
+ {ok,make_hostent(Name,
+ [translate_ip(loopback, Type)],
+ [], Type)};
Self ->
case inet_db:res_option(domain) of
"" -> {error,nxdomain};
@@ -931,7 +928,31 @@ gethostbyname_self(Name) ->
_ -> {error,nxdomain}
end
end
- end.
+ end;
+gethostbyname_self(_, _) ->
+ {error,formerr}.
+
+gethostbyname_string(Name, Type) when is_atom(Name) ->
+ gethostbyname_string(atom_to_list(Name), Type);
+gethostbyname_string(Name, Type)
+ when is_list(Name), Type =:= inet;
+ is_list(Name), Type =:= inet6 ->
+ case
+ case Type of
+ inet ->
+ inet_parse:ipv4_address(Name);
+ inet6 ->
+ %% XXX should we really translate IPv4 addresses here
+ %% even if we do not know if this host can do IPv6?
+ inet_parse:ipv6_address(Name)
+ end of
+ {ok,IP} ->
+ {ok,make_hostent(Name, [IP], [], Type)};
+ {error,einval} ->
+ {error,nxdomain}
+ end;
+gethostbyname_string(_, _) ->
+ {error,formerr}.
make_hostent(Name, Addrs, Aliases, Type) ->
#hostent{h_name = Name,
diff --git a/lib/kernel/src/inet_config.erl b/lib/kernel/src/inet_config.erl
index b5317f72f5..311e6bc9f9 100644
--- a/lib/kernel/src/inet_config.erl
+++ b/lib/kernel/src/inet_config.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(inet_config).
@@ -130,21 +130,25 @@ init() ->
{unix,_} ->
%% The Etc variable enables us to run tests with other
%% configuration files than the normal ones
- Etc = case os:getenv("ERL_INET_ETC_DIR") of
- false -> ?DEFAULT_ETC;
- _EtcDir ->
- _EtcDir
- end,
+ Etc =
+ case os:getenv("ERL_INET_ETC_DIR") of
+ false ->
+ ?DEFAULT_ETC;
+ _EtcDir ->
+ _EtcDir
+ end,
case inet_db:res_option(resolv_conf) of
undefined ->
- inet_db:set_resolv_conf(filename:join(Etc,
- ?DEFAULT_RESOLV));
+ inet_db:res_option(
+ resolv_conf_name,
+ filename:join(Etc, ?DEFAULT_RESOLV));
_ -> ok
end,
case inet_db:res_option(hosts_file) of
undefined ->
- inet_db:set_hosts_file(filename:join(Etc,
- ?DEFAULT_HOSTS));
+ inet_db:res_option(
+ hosts_file_name,
+ filename:join(Etc, ?DEFAULT_HOSTS));
_ -> ok
end;
_ -> ok
diff --git a/lib/kernel/src/inet_db.erl b/lib/kernel/src/inet_db.erl
index 211847014f..a05b380855 100644
--- a/lib/kernel/src/inet_db.erl
+++ b/lib/kernel/src/inet_db.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -425,7 +425,9 @@ res_optname(usevc) -> res_usevc;
res_optname(edns) -> res_edns;
res_optname(udp_payload_size) -> res_udp_payload_size;
res_optname(resolv_conf) -> res_resolv_conf;
+res_optname(resolv_conf_name) -> res_resolv_conf;
res_optname(hosts_file) -> res_hosts_file;
+res_optname(hosts_file_name) -> res_hosts_file;
res_optname(_) -> undefined.
res_check_option(nameserver, NSs) -> %% Legacy
@@ -458,9 +460,15 @@ res_check_option(udp_payload_size, S) when is_integer(S), S >= 512 -> true;
res_check_option(resolv_conf, "") -> true;
res_check_option(resolv_conf, F) ->
res_check_option_absfile(F);
+res_check_option(resolv_conf_name, "") -> true;
+res_check_option(resolv_conf_name, F) ->
+ res_check_option_absfile(F);
res_check_option(hosts_file, "") -> true;
res_check_option(hosts_file, F) ->
res_check_option_absfile(F);
+res_check_option(hosts_file_name, "") -> true;
+res_check_option(hosts_file_name, F) ->
+ res_check_option_absfile(F);
res_check_option(_, _) -> false.
res_check_option_absfile(F) ->
@@ -503,7 +511,7 @@ res_update_hosts() ->
res_update(res_hosts_file, res_hosts_file_tm, res_hosts_file_info,
set_hosts_file_tm, fun set_hosts_file/1).
-res_update(Tag, TagTm, TagInfo, CallTag, SetFun) ->
+res_update(Tag, TagTm, TagInfo, TagSetTm, SetFun) ->
case db_get(TagTm) of
undefined -> ok;
TM ->
@@ -522,12 +530,12 @@ res_update(Tag, TagTm, TagInfo, CallTag, SetFun) ->
atime = undefined},
case db_get(TagInfo) of
Finfo ->
- call({CallTag, Now});
+ call({TagSetTm, Now});
_ ->
SetFun(File)
end;
_ ->
- call({CallTag, Now}),
+ call({TagSetTm, Now}),
error
end
end;
@@ -974,37 +982,55 @@ handle_call(Request, From, #state{db=Db}=State) ->
{reply, error, State}
end;
+ {res_set, hosts_file_name=Option, Fname} ->
+ handle_set_file(
+ Option, Fname, res_hosts_file_tm, res_hosts_file_info,
+ undefined, From, State);
+ {res_set, resolv_conf_name=Option, Fname} ->
+ handle_set_file(
+ Option, Fname, res_resolv_conf_tm, res_resolv_conf_info,
+ undefined, From, State);
+
{res_set, hosts_file=Option, Fname} ->
- handle_set_file(Option, Fname,
- res_hosts_file_tm, res_hosts_file_info,
- fun (Bin) ->
- case inet_parse:hosts(Fname,
- {chars,Bin}) of
- {ok,Opts} ->
- [{load_hosts_file,Opts}];
- _ -> error
- end
- end,
- From, State);
+ handle_set_file(
+ Option, Fname, res_hosts_file_tm, res_hosts_file_info,
+ fun (Bin) ->
+ case inet_parse:hosts(
+ Fname, {chars,Bin}) of
+ {ok,Opts} ->
+ [{load_hosts_file,Opts}];
+ _ -> error
+ end
+ end,
+ From, State);
%%
{res_set, resolv_conf=Option, Fname} ->
- handle_set_file(Option, Fname,
- res_resolv_conf_tm, res_resolv_conf_info,
- fun (Bin) ->
- case inet_parse:resolv(Fname,
- {chars,Bin}) of
- {ok,Opts} ->
- [del_ns,
- clear_search,
- clear_cache
- |[Opt ||
- {T,_}=Opt <- Opts,
- (T =:= nameserver orelse
- T =:= search)]];
- _ -> error
- end
- end,
- From, State);
+ handle_set_file(
+ Option, Fname, res_resolv_conf_tm, res_resolv_conf_info,
+ fun (Bin) ->
+ case inet_parse:resolv(
+ Fname, {chars,Bin}) of
+ {ok,Opts} ->
+ Search =
+ lists:foldl(
+ fun ({search,L}, _) ->
+ L;
+ ({domain,""}, S) ->
+ S;
+ ({domain,D}, _) ->
+ [D];
+ (_, S) ->
+ S
+ end, [], Opts),
+ [del_ns,
+ clear_search,
+ clear_cache,
+ {search,Search}
+ |[Opt || {nameserver,_}=Opt <- Opts]];
+ _ -> error
+ end
+ end,
+ From, State);
%%
{res_set, Opt, Value} ->
case res_optname(Opt) of
@@ -1156,6 +1182,12 @@ handle_set_file(Option, Fname, TagTm, TagInfo, ParseFun, From,
ets:delete(Db, TagInfo),
ets:delete(Db, TagTm),
handle_set_file(ParseFun, <<>>, From, State);
+ true when ParseFun =:= undefined ->
+ File = filename:flatten(Fname),
+ ets:insert(Db, {res_optname(Option), File}),
+ ets:insert(Db, {TagInfo, undefined}),
+ ets:insert(Db, {TagTm, 0}),
+ {reply,ok,State};
true ->
File = filename:flatten(Fname),
ets:insert(Db, {res_optname(Option), File}),
@@ -1178,7 +1210,8 @@ handle_set_file(Option, Fname, TagTm, TagInfo, ParseFun, From,
handle_set_file(ParseFun, Bin, From, State) ->
case ParseFun(Bin) of
- error -> {reply,error,State};
+ error ->
+ {reply,error,State};
Opts ->
handle_rc_list(Opts, From, State)
end.
diff --git a/lib/kernel/src/inet_gethost_native.erl b/lib/kernel/src/inet_gethost_native.erl
index abdbe2b8cf..fabe9bf8b3 100644
--- a/lib/kernel/src/inet_gethost_native.erl
+++ b/lib/kernel/src/inet_gethost_native.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1998-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1998-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(inet_gethost_native).
@@ -443,19 +443,23 @@ gethostbyname(Name) ->
gethostbyname(Name, inet).
gethostbyname(Name, inet) when is_list(Name) ->
- getit(?OP_GETHOSTBYNAME, ?PROTO_IPV4, Name);
+ getit(?OP_GETHOSTBYNAME, ?PROTO_IPV4, Name, Name);
gethostbyname(Name, inet6) when is_list(Name) ->
- getit(?OP_GETHOSTBYNAME, ?PROTO_IPV6, Name);
+ getit(?OP_GETHOSTBYNAME, ?PROTO_IPV6, Name, Name);
gethostbyname(Name, Type) when is_atom(Name) ->
gethostbyname(atom_to_list(Name), Type);
gethostbyname(_, _) ->
{error, formerr}.
-gethostbyaddr({A,B,C,D}) when ?VALID_V4(A), ?VALID_V4(B), ?VALID_V4(C), ?VALID_V4(D) ->
- getit(?OP_GETHOSTBYADDR, ?PROTO_IPV4, <<A,B,C,D>>);
-gethostbyaddr({A,B,C,D,E,F,G,H}) when ?VALID_V6(A), ?VALID_V6(B), ?VALID_V6(C), ?VALID_V6(D),
- ?VALID_V6(E), ?VALID_V6(F), ?VALID_V6(G), ?VALID_V6(H) ->
- getit(?OP_GETHOSTBYADDR, ?PROTO_IPV6, <<A:16,B:16,C:16,D:16,E:16,F:16,G:16,H:16>>);
+gethostbyaddr({A,B,C,D}=Addr)
+ when ?VALID_V4(A), ?VALID_V4(B), ?VALID_V4(C), ?VALID_V4(D) ->
+ getit(?OP_GETHOSTBYADDR, ?PROTO_IPV4, <<A,B,C,D>>, Addr);
+gethostbyaddr({A,B,C,D,E,F,G,H}=Addr)
+ when ?VALID_V6(A), ?VALID_V6(B), ?VALID_V6(C), ?VALID_V6(D),
+ ?VALID_V6(E), ?VALID_V6(F), ?VALID_V6(G), ?VALID_V6(H) ->
+ getit
+ (?OP_GETHOSTBYADDR, ?PROTO_IPV6,
+ <<A:16,B:16,C:16,D:16,E:16,F:16,G:16,H:16>>, Addr);
gethostbyaddr(Addr) when is_list(Addr) ->
case inet_parse:address(Addr) of
{ok, IP} -> gethostbyaddr(IP);
@@ -466,30 +470,30 @@ gethostbyaddr(Addr) when is_atom(Addr) ->
gethostbyaddr(_) -> {error, formerr}.
control({debug_level, Level}) when is_integer(Level) ->
- getit(?OP_CONTROL, ?SETOPT_DEBUG_LEVEL, <<Level:32>>);
+ getit(?OP_CONTROL, ?SETOPT_DEBUG_LEVEL, <<Level:32>>, undefined);
control(soft_restart) ->
- getit(restart_port);
+ getit(restart_port, undefined);
control(_) -> {error, formerr}.
-getit(Op, Proto, Data) ->
- getit({Op, Proto, Data}).
+getit(Op, Proto, Data, DefaultName) ->
+ getit({Op, Proto, Data}, DefaultName).
-getit(Req) ->
+getit(Req, DefaultName) ->
Pid = ensure_started(),
Ref = make_ref(),
Pid ! {{self(),Ref}, Req},
receive
{Ref, {ok,BinHostent}} ->
- parse_address(BinHostent);
- {Ref, Error} ->
- Error
+ parse_address(BinHostent, DefaultName);
+ {Ref, Result} ->
+ Result
after 5000 ->
Ref2 = erlang:monitor(process,Pid),
Res2 = receive
{Ref, {ok,BinHostent}} ->
- parse_address(BinHostent);
- {Ref, Error} ->
- Error;
+ parse_address(BinHostent, DefaultName);
+ {Ref, Result} ->
+ Result;
{'DOWN', Ref2, process,
Pid, Reason} ->
{error, Reason}
@@ -546,21 +550,23 @@ ensure_started() ->
Pid
end.
-parse_address(BinHostent) ->
+parse_address(BinHostent, DefaultName) ->
case catch
begin
case BinHostent of
<<?UNIT_ERROR, Errstring/binary>> ->
{error, list_to_atom(listify(Errstring))};
<<?UNIT_IPV4, Naddr:32, T0/binary>> ->
- {T1,Addresses} = pick_addresses_v4(Naddr, T0),
- [Name | Names] = pick_names(T1),
+ {T1, Addresses} = pick_addresses_v4(Naddr, T0),
+ {Name, Names} =
+ expand_default_name(pick_names(T1), DefaultName),
{ok, #hostent{h_addr_list = Addresses, h_addrtype = inet,
h_aliases = Names, h_length = ?UNIT_IPV4,
h_name = Name}};
<<?UNIT_IPV6, Naddr:32, T0/binary>> ->
- {T1,Addresses} = pick_addresses_v6(Naddr, T0),
- [Name | Names] = pick_names(T1),
+ {T1, Addresses} = pick_addresses_v6(Naddr, T0),
+ {Name, Names} =
+ expand_default_name(pick_names(T1), DefaultName),
{ok, #hostent{h_addr_list = Addresses, h_addrtype = inet6,
h_aliases = Names, h_length = ?UNIT_IPV6,
h_name = Name}};
@@ -573,7 +579,15 @@ parse_address(BinHostent) ->
Normal ->
Normal
end.
-
+
+expand_default_name([], DefaultName) when is_list(DefaultName) ->
+ {DefaultName, []};
+expand_default_name([], DefaultName) when is_tuple(DefaultName) ->
+ {inet_parse:ntoa(DefaultName), []};
+expand_default_name([Name|Names], DefaultName)
+ when is_list(DefaultName); is_tuple(DefaultName) ->
+ {Name, Names}.
+
listify(Bin) ->
N = byte_size(Bin) - 1,
<<Bin2:N/binary, Ch>> = Bin,
diff --git a/lib/kernel/src/inet_parse.erl b/lib/kernel/src/inet_parse.erl
index 62d44fb723..3bd5fa0958 100644
--- a/lib/kernel/src/inet_parse.erl
+++ b/lib/kernel/src/inet_parse.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(inet_parse).
@@ -34,6 +34,7 @@
-export([nsswitch_conf/1, nsswitch_conf/2]).
-export([ipv4_address/1, ipv6_address/1]).
+-export([ipv4strict_address/1, ipv6strict_address/1]).
-export([address/1]).
-export([visible_string/1, domain/1]).
-export([ntoa/1, dots/1]).
@@ -456,17 +457,15 @@ is_dom2(_) ->
%%
-%% Test ipv4 address or ipv6 address
+%% Parse ipv4 address or ipv6 address
%% Return {ok, Address} | {error, Reason}
%%
address(Cs) when is_list(Cs) ->
case ipv4_address(Cs) of
- {ok,IP} -> {ok,IP};
+ {ok,IP} ->
+ {ok,IP};
_ ->
- case ipv6_address(Cs) of
- {ok, IP} -> {ok, IP};
- Error -> Error
- end
+ ipv6strict_address(Cs)
end;
address(_) ->
{error, einval}.
@@ -477,49 +476,145 @@ address(_) ->
%% d1.d2.d4
%% d1.d4
%% d4
+%% Any d may be octal, hexadecimal or decimal by C language standards.
+%% d4 fills all LSB bytes. This is legacy behaviour from Solaris
+%% and FreeBSD. And partly Linux that behave the same except
+%% it does not accept hexadecimal.
%%
%% Return {ok, IP} | {error, einval}
%%
ipv4_address(Cs) ->
- case catch ipv4_addr(Cs) of
- {'EXIT',_} -> {error,einval};
- Addr -> {ok,Addr}
+ try ipv4_addr(Cs) of
+ Addr ->
+ {ok,Addr}
+ catch
+ error:badarg ->
+ {error,einval}
end.
-ipv4_addr(Cs) ->
- ipv4_addr(d3(Cs), []).
+ipv4_addr(Cs) ->
+ case ipv4_addr(Cs, []) of
+ [D] when D < (1 bsl 32) ->
+ <<D1,D2,D3,D4>> = <<D:32>>,
+ {D1,D2,D3,D4};
+ [D,D1] when D < (1 bsl 24), D1 < 256 ->
+ <<D2,D3,D4>> = <<D:24>>,
+ {D1,D2,D3,D4};
+ [D,D2,D1] when D < (1 bsl 16), (D2 bor D1) < 256 ->
+ <<D3,D4>> = <<D:16>>,
+ {D1,D2,D3,D4};
+ [D4,D3,D2,D1] when (D4 bor D3 bor D2 bor D1) < 256 ->
+ {D1,D2,D3,D4};
+ _ ->
+ erlang:error(badarg)
+ end.
-ipv4_addr({Cs0,[]}, A) when length(A) =< 3 ->
- case [tod(Cs0)|A] of
- [D4,D3,D2,D1] ->
+ipv4_addr([_|_], [_,_,_,_]) ->
+ %% Early bailout for extra characters
+ erlang:error(badarg);
+ipv4_addr("0x"++Cs, Ds) ->
+ ipv4_addr(strip0(Cs), Ds, [], 16, 8);
+ipv4_addr("0X"++Cs, Ds) ->
+ ipv4_addr(strip0(Cs), Ds, [], 16, 8);
+ipv4_addr("0"++Cs, Ds) ->
+ ipv4_addr(strip0(Cs), Ds, [$0], 8, 11);
+ipv4_addr(Cs, Ds) when is_list(Cs) ->
+ ipv4_addr(Cs, Ds, [], 10, 10).
+
+ipv4_addr(Cs0, Ds, Rs, Base, N) ->
+ case ipv4_field(Cs0, N, Rs, Base) of
+ {D,""} ->
+ [D|Ds];
+ {D,[$.|[_|_]=Cs]} ->
+ ipv4_addr(Cs, [D|Ds]);
+ {_,_} ->
+ erlang:error(badarg)
+ end.
+
+strip0("0"++Cs) ->
+ strip0(Cs);
+strip0(Cs) when is_list(Cs) ->
+ Cs.
+
+
+%%
+%% Parse IPv4 strict dotted decimal address, no leading zeros:
+%% d1.d2.d3.d4
+%%
+%% Return {ok, IP} | {error, einval}
+%%
+ipv4strict_address(Cs) ->
+ try ipv4strict_addr(Cs) of
+ Addr ->
+ {ok,Addr}
+ catch
+ error:badarg ->
+ {error,einval}
+ end.
+
+ipv4strict_addr(Cs) ->
+ case ipv4strict_addr(Cs, []) of
+ [D4,D3,D2,D1] when (D4 bor D3 bor D2 bor D1) < 256 ->
{D1,D2,D3,D4};
- [D4,D2,D1] ->
- {D1,D2,0,D4};
- [D4,D1] ->
- {D1,0,0,D4};
- [D4] ->
- {0,0,0,D4}
- end;
-ipv4_addr({Cs0,"."++Cs1}, A) when length(A) =< 2 ->
- ipv4_addr(d3(Cs1), [tod(Cs0)|A]).
+ _ ->
+ erlang:error(badarg)
+ end.
+
+ipv4strict_addr([_|_], [_,_,_,_]) ->
+ %% Early bailout for extra characters
+ erlang:error(badarg);
+ipv4strict_addr("0", Ds) ->
+ [0|Ds];
+ipv4strict_addr("0."++Cs, Ds) ->
+ ipv4strict_addr(Cs, [0|Ds]);
+ipv4strict_addr(Cs0, Ds) when is_list(Cs0) ->
+ case ipv4_field(Cs0, 3, [], 10) of
+ {D,""} ->
+ [D|Ds];
+ {D,[$.|[_|_]=Cs]} ->
+ ipv4strict_addr(Cs, [D|Ds]);
+ {_,_} ->
+ erlang:error(badarg)
+ end.
+
-d3(Cs) -> d3(Cs, []).
-d3([C|Cs], R) when C >= $0, C =< $9, length(R) =< 2 ->
- d3(Cs, [C|R]);
-d3(Cs, [_|_]=R) ->
- {lists:reverse(R),Cs}.
+ipv4_field("", _, Rs, Base) ->
+ {ipv4_field(Rs, Base),""};
+ipv4_field("."++_=Cs, _, Rs, Base) ->
+ {ipv4_field(Rs, Base),Cs};
+ipv4_field("0"++_, _, [], _) ->
+ erlang:error(badarg);
+ipv4_field([C|Cs], N, Rs, Base) when N > 0 ->
+ ipv4_field(Cs, N-1, [C|Rs], Base);
+ipv4_field(Cs, _, _, _) when is_list(Cs) ->
+ erlang:error(badarg).
+
+ipv4_field(Rs, Base) ->
+ V = erlang:list_to_integer(lists:reverse(Rs), Base),
+ if V < 0 ->
+ erlang:error(badarg);
+ true ->
+ V
+ end.
-tod(Cs) ->
- case erlang:list_to_integer(Cs) of
- D when D >= 0, D =< 255 ->
- D;
+
+
+%%
+%% Forgiving IPv6 address
+%%
+%% Accepts IPv4 address and returns it as a IPv4 compatible IPv6 address
+%%
+ipv6_address(Cs) ->
+ case ipv4_address(Cs) of
+ {ok,{D1,D2,D3,D4}} ->
+ {ok,{0,0,0,0,0,16#ffff,(D1 bsl 8) bor D2,(D3 bsl 8) bor D4}};
_ ->
- erlang:error(badarg, [Cs])
+ ipv6strict_address(Cs)
end.
%%
-%% Parse IPv6 address:
+%% Parse IPv6 address according to RFC 4291:
%% x1:x2:x3:x4:x5:x6:x7:x8
%% x1:x2::x7:x8
%% ::x7:x8
@@ -530,77 +625,89 @@ tod(Cs) ->
%% ::x5:x6:d7a.d7b.d8a.d8b
%% x1:x2::d7a.d7b.d8a.d8b
%% ::d7a.d7b.d8a.d8b
+%% etc
%%
%% Return {ok, IP} | {error, einval}
%%
-ipv6_address(Cs) ->
- case catch ipv6_addr(Cs) of
- {'EXIT',_} -> {error,einval};
- Addr -> {ok,Addr}
+ipv6strict_address(Cs) ->
+ try ipv6_addr(Cs) of
+ Addr ->
+ {ok,Addr}
+ catch
+ error:badarg ->
+ {error,einval}
end.
ipv6_addr("::") ->
- ipv6_addr_done([], []);
+ ipv6_addr_done([], [], 0);
ipv6_addr("::"++Cs) ->
- ipv6_addr(x4(Cs), [], []);
+ ipv6_addr(hex(Cs), [], [], 0);
ipv6_addr(Cs) ->
- ipv6_addr(x4(Cs), []).
+ ipv6_addr(hex(Cs), [], 0).
%% Before "::"
-ipv6_addr({Cs0,[]}, A) when length(A) =:= 7 ->
- ipv6_addr_done([tox(Cs0)|A]);
-ipv6_addr({Cs0,"::"}, A) when length(A) =< 6 ->
- ipv6_addr_done([tox(Cs0)|A], []);
-ipv6_addr({Cs0,"::"++Cs1}, A) when length(A) =< 5 ->
- ipv6_addr(x4(Cs1), [tox(Cs0)|A], []);
-ipv6_addr({Cs0,":"++Cs1}, A) when length(A) =< 6 ->
- ipv6_addr(x4(Cs1), [tox(Cs0)|A]);
-ipv6_addr({Cs0,"."++Cs1}, A) when length(A) =:= 6 ->
- ipv6_addr(d3(Cs1), A, [], [tod(Cs0)]).
+ipv6_addr({Cs0,[]}, A, N) when N == 7 ->
+ ipv6_addr_done([hex_to_int(Cs0)|A]);
+ipv6_addr({Cs0,"::"}, A, N) when N =< 6 ->
+ ipv6_addr_done([hex_to_int(Cs0)|A], [], N+1);
+ipv6_addr({Cs0,"::"++Cs1}, A, N) when N =< 5 ->
+ ipv6_addr(hex(Cs1), [hex_to_int(Cs0)|A], [], N+1);
+ipv6_addr({Cs0,":"++Cs1}, A, N) when N =< 6 ->
+ ipv6_addr(hex(Cs1), [hex_to_int(Cs0)|A], N+1);
+ipv6_addr({Cs0,"."++_=Cs1}, A, N) when N == 6 ->
+ ipv6_addr_done(A, [], N, ipv4strict_addr(Cs0++Cs1));
+ipv6_addr(_, _, _) ->
+ erlang:error(badarg).
%% After "::"
-ipv6_addr({Cs0,[]}, A, B) when length(A)+length(B) =< 6 ->
- ipv6_addr_done(A, [tox(Cs0)|B]);
-ipv6_addr({Cs0,":"++Cs1}, A, B) when length(A)+length(B) =< 5 ->
- ipv6_addr(x4(Cs1), A, [tox(Cs0)|B]);
-ipv6_addr({Cs0,"."++Cs1}, A, B) when length(A)+length(B) =< 5 ->
- ipv6_addr(x4(Cs1), A, B, [tod(Cs0)]).
+ipv6_addr({Cs0,[]}, A, B, N) when N =< 6 ->
+ ipv6_addr_done(A, [hex_to_int(Cs0)|B], N+1);
+ipv6_addr({Cs0,":"++Cs1}, A, B, N) when N =< 5 ->
+ ipv6_addr(hex(Cs1), A, [hex_to_int(Cs0)|B], N+1);
+ipv6_addr({Cs0,"."++_=Cs1}, A, B, N) when N =< 5 ->
+ ipv6_addr_done(A, B, N, ipv4strict_addr(Cs0++Cs1));
+ipv6_addr(_, _, _, _) ->
+ erlang:error(badarg).
-%% After "."
-ipv6_addr({Cs0,[]}, A, B, C) when length(C) =:= 3 ->
- ipv6_addr_done(A, B, [tod(Cs0)|C]);
-ipv6_addr({Cs0,"."++Cs1}, A, B, C) when length(C) =< 2 ->
- ipv6_addr(d3(Cs1), A, B, [tod(Cs0)|C]).
+ipv6_addr_done(Ar, Br, N, {D1,D2,D3,D4}) ->
+ ipv6_addr_done(Ar, [((D3 bsl 8) bor D4),((D1 bsl 8) bor D2)|Br], N+2).
-ipv6_addr_done(Ar, Br, [D4,D3,D2,D1]) ->
- ipv6_addr_done(Ar, [((D3 bsl 8) bor D4),((D1 bsl 8) bor D2)|Br]).
-
-ipv6_addr_done(Ar, Br) ->
- ipv6_addr_done(Br++dup(8-length(Ar)-length(Br), 0, Ar)).
+ipv6_addr_done(Ar, Br, N) ->
+ ipv6_addr_done(Br++dup(8-N, 0, Ar)).
ipv6_addr_done(Ar) ->
list_to_tuple(lists:reverse(Ar)).
-x4(Cs) -> x4(Cs, []).
-
-x4([C|Cs], R) when C >= $0, C =< $9, length(R) =< 3 ->
- x4(Cs, [C|R]);
-x4([C|Cs], R) when C >= $a, C =< $f, length(R) =< 3 ->
- x4(Cs, [C|R]);
-x4([C|Cs], R) when C >= $A, C =< $F, length(R) =< 3 ->
- x4(Cs, [C|R]);
-x4(Cs, [_|_]=R) ->
- {lists:reverse(R),Cs}.
-
-tox(Cs) ->
- erlang:list_to_integer(Cs, 16).
+%% Collect Hex digits
+hex(Cs) -> hex(Cs, []).
+%%
+hex([C|Cs], R) when C >= $0, C =< $9 ->
+ hex(Cs, [C|R]);
+hex([C|Cs], R) when C >= $a, C =< $f ->
+ hex(Cs, [C|R]);
+hex([C|Cs], R) when C >= $A, C =< $F ->
+ hex(Cs, [C|R]);
+hex(Cs, [_|_]=R) when is_list(Cs) ->
+ {lists:reverse(R),Cs};
+hex(_, _) ->
+ erlang:error(badarg).
+
+%% Hex string to integer
+hex_to_int(Cs0) ->
+ case strip0(Cs0) of
+ Cs when length(Cs) =< 4 ->
+ erlang:list_to_integer("0"++Cs, 16);
+ _ ->
+ erlang:error(badarg)
+ end.
+%% Dup onto head of existing list
dup(0, _, L) ->
L;
dup(N, E, L) when is_integer(N), N >= 1 ->
- dup(N-1, E, [E|L]);
-dup(N, E, L) ->
- erlang:error(badarg, [N,E,L]).
+ dup(N-1, E, [E|L]).
+
+
%% Convert IPv4 adress to ascii
%% Convert IPv6 / IPV4 adress to ascii (plain format)
@@ -674,7 +781,7 @@ separate(_E, [H], R) ->
lists:reverse(R, [H]).
%% convert to A.B decimal form
-dig_to_dec(0) -> [$0,$.,$0];
+dig_to_dec(0) -> "0.0";
dig_to_dec(X) ->
integer_to_list((X bsr 8) band 16#ff) ++ "." ++
integer_to_list(X band 16#ff).
diff --git a/lib/kernel/src/inet_sctp.erl b/lib/kernel/src/inet_sctp.erl
index 30c0e85dd9..795bf83807 100644
--- a/lib/kernel/src/inet_sctp.erl
+++ b/lib/kernel/src/inet_sctp.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2007-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2007-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
%% SCTP protocol contribution by Leonid Timochouk and Serge Aleynikov.
@@ -64,16 +64,22 @@ close(S) ->
listen(S, Flag) ->
prim_inet:listen(S, Flag).
+%% A non-blocking connect is implemented when the initial call is to
+%% gen_sctp:connect_init which passes the value nowait as the Timer
connect(S, Addr, Port, Opts, Timer) ->
case prim_inet:chgopts(S, Opts) of
ok ->
case prim_inet:getopt(S, active) of
{ok,Active} ->
- Timeout = inet:timeout(Timer),
+ Timeout = if Timer =:= nowait ->
+ infinity; %% don't start driver timer in inet_drv
+ true ->
+ inet:timeout(Timer)
+ end,
case prim_inet:connect(S, Addr, Port, Timeout) of
- ok ->
+ ok when Timer =/= nowait ->
connect_get_assoc(S, Addr, Port, Active, Timer);
- Err1 -> Err1
+ OkOrErr1 -> OkOrErr1
end;
Err2 -> Err2
end;
@@ -89,10 +95,10 @@ connect(S, Addr, Port, Opts, Timer) ->
%% connect_get_assoc/5 below mistakes it for an invalid response
%% for a socket in {active,false} or {active,once} modes.
%%
-%% In {active,true} mode it probably gets right, but it is
-%% a blocking connect that is implemented even for {active,true},
-%% and that may be a shortcoming. A non-blocking connect
-%% would be nice to have.
+%% In {active,true} mode the window of time for the race is smaller,
+%% but it is possible and also it is a blocking connect that is
+%% implemented even for {active,true}, and that may be a
+%% shortcoming.
connect_get_assoc(S, Addr, Port, false, Timer) ->
case recv(S, inet:timeout(Timer)) of
diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index 8e1e3d5390..37b9200942 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -26,7 +26,7 @@
delete/1, purge/1, soft_purge/1, is_loaded/1, all_loaded/1,
load_binary/1, dir_req/1, object_code/1, set_path_file/1,
sticky_dir/1, pa_pz_option/1, add_del_path/1,
- dir_disappeared/1, ext_mod_dep/1,
+ dir_disappeared/1, ext_mod_dep/1, clash/1,
load_cached/1, start_node_with_cache/1, add_and_rehash/1,
where_is_file_cached/1, where_is_file_no_cache/1,
purge_stacktrace/1, mult_lib_roots/1, bad_erl_libs/1,
@@ -48,7 +48,7 @@ all(suite) ->
delete, purge, soft_purge, is_loaded, all_loaded,
load_binary, dir_req, object_code, set_path_file,
pa_pz_option, add_del_path,
- dir_disappeared, ext_mod_dep,
+ dir_disappeared, ext_mod_dep, clash,
load_cached, start_node_with_cache, add_and_rehash,
where_is_file_no_cache, where_is_file_cached,
purge_stacktrace, mult_lib_roots, bad_erl_libs,
@@ -531,7 +531,7 @@ pa_pz_option(Config) when is_list(Config) ->
add_del_path(suite) ->
[];
add_del_path(doc) -> ["add_path, del_path should not cause priv_dir(App) to fail"];
-add_del_path(Config) ->
+add_del_path(Config) when is_list(Config) ->
DDir = ?config(data_dir,Config),
Dir1 = filename:join(DDir,"dummy_app-1.0/ebin"),
Dir2 = filename:join(DDir,"dummy_app-2.0/ebin"),
@@ -545,6 +545,38 @@ add_del_path(Config) ->
ok.
+clash(Config) when is_list(Config) ->
+ DDir = ?config(data_dir,Config)++"clash/",
+ P = code:get_path(),
+
+ %% test non-clashing entries
+
+ %% remove "." to prevent clash with test-server path
+ ?line true = code:del_path("."),
+ ?line true = code:add_path(DDir++"foobar-0.1/ebin"),
+ ?line true = code:add_path(DDir++"zork-0.8/ebin"),
+ ?line test_server:capture_start(),
+ ?line code:clash(),
+ ?line test_server:capture_stop(),
+ ?line OKMsg = test_server:capture_get(),
+ ?line lists:prefix("** Found 0 name clashes in code paths", OKMsg),
+ ?line true = code:set_path(P),
+
+ %% test clashing entries
+
+ %% remove "." to prevent clash with test-server path
+ ?line true = code:del_path("."),
+ ?line true = code:add_path(DDir++"foobar-0.1/ebin"),
+ ?line true = code:add_path(DDir++"foobar-0.1.ez/foobar-0.1/ebin"),
+ ?line test_server:capture_start(),
+ ?line code:clash(),
+ ?line test_server:capture_stop(),
+ ?line [ErrMsg1|_] = test_server:capture_get(),
+ ?line {match, [" hides "]} = re:run(ErrMsg1, "\\*\\* .*( hides ).*",
+ [{capture,all_but_first,list}]),
+ ?line true = code:set_path(P),
+ ok.
+
ext_mod_dep(suite) ->
[];
ext_mod_dep(doc) ->
diff --git a/lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ez b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ez
new file mode 100644
index 0000000000..33d8a59b92
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1.ez
Binary files differ
diff --git a/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam
new file mode 100644
index 0000000000..da87f32b9f
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/baz.beam
@@ -0,0 +1 @@
+baz 298734
diff --git a/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam
new file mode 100644
index 0000000000..e4c70c267c
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/foobar-0.1/ebin/blarg.beam
@@ -0,0 +1 @@
+baz 86234
diff --git a/lib/kernel/test/code_SUITE_data/clash/zork-0.8.ez b/lib/kernel/test/code_SUITE_data/clash/zork-0.8.ez
new file mode 100644
index 0000000000..051fa1efe4
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/zork-0.8.ez
Binary files differ
diff --git a/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam
new file mode 100644
index 0000000000..7b292c0b44
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/bork.beam
@@ -0,0 +1 @@
+baz 23784
diff --git a/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam
new file mode 100644
index 0000000000..7b2f6a850f
--- /dev/null
+++ b/lib/kernel/test/code_SUITE_data/clash/zork-0.8/ebin/flarp.beam
@@ -0,0 +1 @@
+baz 3246238
diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl
index dd7d5f111a..fad8c7398b 100644
--- a/lib/kernel/test/gen_sctp_SUITE.erl
+++ b/lib/kernel/test/gen_sctp_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2007-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2007-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(gen_sctp_SUITE).
@@ -24,10 +24,11 @@
%%-compile(export_all).
-export([all/1,init_per_testcase/2,fin_per_testcase/2,
- basic/1,xfer_min/1,xfer_active/1,api_open_close/1,api_listen/1]).
+ basic/1,api_open_close/1,api_listen/1,api_connect_init/1,
+ xfer_min/1,xfer_active/1]).
all(suite) ->
- [basic,xfer_min,xfer_active,api_open_close,api_listen].
+ [basic,api_open_close,api_listen,api_connect_init,xfer_min,xfer_active].
init_per_testcase(_Func, Config) ->
Dog = test_server:timetrap(test_server:seconds(15)),
@@ -325,7 +326,7 @@ api_listen(Config) when is_list(Config) ->
?line {ok,{Localhost,
Pb,[],
#sctp_assoc_change{
- state = comm_lost}}} =
+ state=comm_lost}}} =
gen_sctp:recv(Sa, infinity);
{error,#sctp_assoc_change{state=cant_assoc}} -> ok
end,
@@ -336,3 +337,48 @@ api_listen(Config) when is_list(Config) ->
?line ok = gen_sctp:close(Sa),
?line ok = gen_sctp:close(Sb),
ok.
+
+api_connect_init(doc) ->
+ "Test the API function connect_init/4";
+api_connect_init(suite) ->
+ [];
+api_connect_init(Config) when is_list(Config) ->
+ ?line Localhost = {127,0,0,1},
+
+ ?line {ok,S} = gen_sctp:open(),
+ ?line {ok,Pb} = inet:port(S),
+ ?line try gen_sctp:connect_init(S, Localhost, not_allowed_for_port, [])
+ catch error:badarg -> ok
+ end,
+ ?line try gen_sctp:connect_init(S, Localhost, 12345, not_allowed_for_opts)
+ catch error:badarg -> ok
+ end,
+ ?line ok = gen_sctp:close(S),
+ ?line {error,closed} = gen_sctp:connect_init(S, Localhost, 12345, []),
+
+ ?line {ok,Sb} = gen_sctp:open(Pb),
+ ?line {ok,Sa} = gen_sctp:open(),
+ ?line case gen_sctp:connect_init(Sa, localhost, Pb, []) of
+ {error,econnrefused} ->
+ ?line {ok,{Localhost,
+ Pb,[],
+ #sctp_assoc_change{state=comm_lost}}} =
+ gen_sctp:recv(Sa, infinity);
+ ok ->
+ ?line {ok,{Localhost,
+ Pb,[],
+ #sctp_assoc_change{state=cant_assoc}}} =
+ gen_sctp:recv(Sa, infinity)
+ end,
+ ?line ok = gen_sctp:listen(Sb, true),
+ ?line case gen_sctp:connect_init(Sa, localhost, Pb, []) of
+ ok ->
+ ?line {ok,{Localhost,
+ Pb,[],
+ #sctp_assoc_change{
+ state = comm_up}}} =
+ gen_sctp:recv(Sa, infinity)
+ end,
+ ?line ok = gen_sctp:close(Sa),
+ ?line ok = gen_sctp:close(Sb),
+ ok.
diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl
index cf33e8b27f..eb8f918491 100644
--- a/lib/kernel/test/inet_SUITE.erl
+++ b/lib/kernel/test/inet_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(inet_SUITE).
@@ -28,7 +28,7 @@
gethostnative_parallell/1, cname_loop/1,
gethostnative_soft_restart/1,gethostnative_debug_level/1,getif/1]).
--export([get_hosts/1, get_ipv6_hosts/1, parse_hosts/1,
+-export([get_hosts/1, get_ipv6_hosts/1, parse_hosts/1, parse_address/1,
kill_gethost/0, parallell_gethost/0]).
-export([init_per_testcase/2, end_per_testcase/2]).
@@ -249,14 +249,16 @@ t_getaddr_v6(Config) when is_list(Config) ->
?line {ok,IP46} = inet:getaddr(IP46, inet6),
?line {ok,IP46} = inet:getaddr(Name, inet6),
?line {ok,IP46} = inet:getaddr(FullName, inet6),
- ?line IP4toIP6 = inet:getaddr(IPStr, inet6),
- ?line case IP4toIP6 of
- {ok,IP46} -> % only native can do this
- ?line true = lists:member(native,
- inet_db:res_option(lookup));
- {error,nxdomain} ->
- ok
- end,
+ ?line {ok,IP46} = inet:getaddr(IPStr, inet6),
+%% ?line IP4toIP6 = inet:getaddr(IPStr, inet6),
+%% ?line case IP4toIP6 of
+%% {ok,IP46} ->
+%% ?line ok;
+%% {error,nxdomain} ->
+%% ?line false =
+%% lists:member(native,
+%% inet_db:res_option(lookup))
+%% end,
?line {Name6, FullName6, IPStr6, IP6, _} =
?config(test_host_ipv6_only, Config),
?line {ok,_} = inet:getaddr(list_to_atom(Name6), inet6),
@@ -301,7 +303,6 @@ ipv4_to_ipv6(Config) when is_list(Config) ->
end,
?line case {IP4to6Res,inet:gethostbyname(IPStr, inet6)} of
{true,{ok,HEnt}} ->
- ?line true = lists:member(native, inet_db:res_option(lookup)),
?line HEnt_ = HEnt#hostent{h_addrtype = inet6,
h_length = 16,
h_addr_list = [IP_46]},
@@ -374,9 +375,10 @@ get_hosts([C|Rest], Cur, Ip, Result) ->
get_hosts([], _, _, Result) ->
Result.
-parse(suite) -> [parse_hosts];
+parse(suite) -> [parse_hosts, parse_address];
parse(doc) -> ["Test that parsing of the hosts file or equivalent works,",
"and that erroneous lines are skipped"].
+
parse_hosts(Config) when is_list(Config) ->
?line DataDir = ?config(data_dir,Config),
?line HostFile = filename:join(DataDir, "hosts"),
@@ -388,6 +390,170 @@ parse_hosts(Config) when is_list(Config) ->
?line ResolvErr1 = filename:join(DataDir,"resolv.conf.err1"),
?line inet_parse:resolv(ResolvErr1).
+parse_address(Config) when is_list(Config) ->
+ V4Strict =
+ [{{0,0,0,0},"0.0.0.0"},
+ {{1,2,3,4},"1.2.3.4"},
+ {{253,252,251,250},"253.252.251.250"},
+ {{1,2,255,254},"1.2.255.254"}],
+ V6Strict =
+ [{{0,0,0,0,0,0,0,0},"::"},
+ {{15,0,0,0,0,0,0,2},"f::2"},
+ {{15,16#f11,0,0,0,0,256,2},"f:f11::0100:2"},
+ {{0,0,0,0,0,0,0,16#17},"::17"},
+ {{16#700,0,0,0,0,0,0,0},"0700::"},
+ {{0,0,0,0,0,0,2,1},"::2:1"},
+ {{0,0,0,0,0,3,2,1},"::3:2:1"},
+ {{0,0,0,0,4,3,2,1},"::4:3:2:1"},
+ {{0,0,0,5,4,3,2,1},"::5:4:3:2:1"},
+ {{0,0,6,5,4,3,2,1},"::6:5:4:3:2:1"},
+ {{0,7,6,5,4,3,2,1},"::7:6:5:4:3:2:1"},
+ {{7,0,0,0,0,0,0,0},"7::"},
+ {{7,6,0,0,0,0,0,0},"7:6::"},
+ {{7,6,5,0,0,0,0,0},"7:6:5::"},
+ {{7,6,5,4,0,0,0,0},"7:6:5:4::"},
+ {{7,6,5,4,3,0,0,0},"7:6:5:4:3::"},
+ {{7,6,5,4,3,2,0,0},"7:6:5:4:3:2::"},
+ {{7,6,5,4,3,2,1,0},"7:6:5:4:3:2:1::"},
+ {{16#c11,16#c22,16#5c33,16#c440,16#55c0,16#c66c,16#77,16#88},
+ "c11:0c22:5c33:c440:55c0:c66c:77:0088"},
+ {{16#c11,0,16#5c33,16#c440,16#55c0,16#c66c,16#77,16#88},
+ "c11::5c33:c440:55c0:c66c:77:0088"},
+ {{16#c11,16#c22,0,16#c440,16#55c0,16#c66c,16#77,16#88},
+ "c11:0c22::c440:55c0:c66c:77:0088"},
+ {{16#c11,16#c22,16#5c33,0,16#55c0,16#c66c,16#77,16#88},
+ "c11:0c22:5c33::55c0:c66c:77:0088"},
+ {{16#c11,16#c22,16#5c33,16#c440,0,16#c66c,16#77,16#88},
+ "c11:0c22:5c33:c440::c66c:77:0088"},
+ {{16#c11,16#c22,16#5c33,16#c440,16#55c0,0,16#77,16#88},
+ "c11:0c22:5c33:c440:55c0::77:0088"},
+ {{16#c11,16#c22,16#5c33,16#c440,16#55c0,16#c66c,0,16#88},
+ "c11:0c22:5c33:c440:55c0:c66c::0088"},
+ {{16#c11,0,0,16#c440,16#55c0,16#c66c,16#77,16#88},
+ "c11::c440:55c0:c66c:77:0088"},
+ {{16#c11,16#c22,0,0,16#55c0,16#c66c,16#77,16#88},
+ "c11:0c22::55c0:c66c:77:0088"},
+ {{16#c11,16#c22,16#5c33,0,0,16#c66c,16#77,16#88},
+ "c11:0c22:5c33::c66c:77:0088"},
+ {{16#c11,16#c22,16#5c33,16#c440,0,0,16#77,16#88},
+ "c11:0c22:5c33:c440::77:0088"},
+ {{16#c11,16#c22,16#5c33,16#c440,16#55c0,0,0,16#88},
+ "c11:0c22:5c33:c440:55c0::0088"},
+ {{16#c11,0,0,0,16#55c0,16#c66c,16#77,16#88},
+ "c11::55c0:c66c:77:0088"},
+ {{16#c11,16#c22,0,0,0,16#c66c,16#77,16#88},
+ "c11:0c22::c66c:77:0088"},
+ {{16#c11,16#c22,16#5c33,0,0,0,16#77,16#88},
+ "c11:0c22:5c33::77:0088"},
+ {{16#c11,16#c22,16#5c33,16#c440,0,0,0,16#88},
+ "c11:0c22:5c33:c440::0088"},
+ {{16#c11,0,0,0,0,16#c66c,16#77,16#88},
+ "c11::c66c:77:0088"},
+ {{16#c11,16#c22,0,0,0,0,16#77,16#88},
+ "c11:0c22::77:0088"},
+ {{16#c11,16#c22,16#5c33,0,0,0,0,16#88},
+ "c11:0c22:5c33::0088"},
+ {{16#c11,0,0,0,0,0,16#77,16#88},
+ "c11::77:0088"},
+ {{16#c11,16#c22,0,0,0,0,0,16#88},
+ "c11:0c22::0088"},
+ {{0,0,0,0,0,65535,258,65534},"::FFFF:1.2.255.254"},
+ {{16#ffff,16#ffff,16#ffff,16#ffff,16#ffff,16#ffff,16#ffff,16#ffff},
+ "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"}
+ |[{{D2,0,0,0,0,P,(D1 bsl 8) bor D2,(D3 bsl 8) bor D4},
+ erlang:integer_to_list(D2, 16)++"::"++Q++S}
+ || {{D1,D2,D3,D4},S} <- V4Strict,
+ {P,Q} <- [{0,""},{16#17,"17:"},{16#ff0,"0ff0:"}]]],
+ V4Sloppy =
+ [{{10,1,16#98,16#76},"10.0x019876"},
+ {{8#12,1,8#130,8#321},"012.01.054321"},
+ {{255,255,255,255},"255.255.255.0377"},
+ {{255,255,255,255},"0Xff.000000000377.0x0000ff.255"},
+ {{255,255,255,255},"255.255.65535"},
+ {{255,255,255,255},"255.0xFF.0177777"},
+ {{255,255,255,255},"255.16777215"},
+ {{255,255,255,255},"00377.0XFFFFFF"},
+ {{255,255,255,255},"4294967295"},
+ {{255,255,255,255},"0xffffffff"},
+ {{255,255,255,255},"00000000000037777777777"},
+ {{16#12,16#34,16#56,16#78},"0x12345678"},
+ {{16#12,16#34,16#56,16#78},"0x12.0x345678"},
+ {{16#12,16#34,16#56,16#78},"0x12.0X34.0x5678"},
+ {{16#12,16#34,16#56,16#78},"0x12.0X34.0x56.0X78"},
+ {{0,0,0,0},"0"},
+ {{0,0,0,0},"00"},
+ {{0,0,0,0},"0.0"},
+ {{0,0,0,0},"00.00.00"},
+ {{0,0,0,0},"0.00.0.0"},
+ {{0,0,0,0},"0.0.000000000000.0"}],
+ V6Sloppy =
+ [{{0,0,0,0,0,65535,(D1 bsl 8) bor D2,(D3 bsl 8) bor D4},S}
+ || {{D1,D2,D3,D4},S} <- V4Strict++V4Sloppy],
+ V4Err =
+ ["0.256.0.1",
+ "1.2.3.4.5",
+ "256.255.65535",
+ "4294967296",
+ "0x100000000",
+ "040000000000",
+ "1.2.3.-4",
+ "1.2.-3.4",
+ "1.-2.3.4",
+ "-1.2.3.4",
+ "10.",
+ "172.16.",
+ "198.168.0.",
+ "127.0.0.1."],
+ V6Err =
+ [":::",
+ "f:::2",
+ "::-1",
+ "::g",
+ "f:f11::10100:2",
+ "::17000",
+ "10000::",
+ "::8:7:6:5:4:3:2:1",
+ "8:7:6:5:4:3:2:1::",
+ "8:7:6:5:4::3:2:1",
+ "::1.2.3.4.5",
+ "::1.2.3.04",
+ "::1.256.3.4",
+ "::-5.4.3.2",
+ "::5.-4.3.2",
+ "::5.4.-3.2",
+ "::5.4.3.-2",
+ "::FFFF:1.2.3.4.5",
+ "::10.",
+ "::FFFF:172.16.",
+ "fe80::198.168.0.",
+ "fec0::fFfF:127.0.0.1."],
+ t_parse_address
+ (ipv6_address,
+ V6Strict++V6Sloppy++V6Err++V4Err),
+ t_parse_address
+ (ipv6strict_address,
+ V6Strict++V6Err++V4Err++[S || {_,S} <- V6Sloppy]),
+ t_parse_address
+ (ipv4_address,
+ V4Strict++V4Sloppy++V4Err++V6Err++[S || {_,S} <- V6Strict]),
+ t_parse_address
+ (ipv4strict_address,
+ V4Strict++V4Err++V6Err++[S || {_,S} <- V4Sloppy++V6Strict]).
+
+t_parse_address(Func, []) ->
+ io:format("~p done.~n", [Func]),
+ ok;
+t_parse_address(Func, [{Addr,String}|L]) ->
+ io:format("~p = ~p.~n", [Addr,String]),
+ {ok,Addr} = inet_parse:Func(String),
+ t_parse_address(Func, L);
+t_parse_address(Func, [String|L]) ->
+ io:format("~p.~n", [String]),
+ {error,einval} = inet_parse:Func(String),
+ t_parse_address(Func, L).
+
+
+
t_gethostnative(suite) ->[];
t_gethostnative(doc) ->[];
t_gethostnative(Config) when is_list(Config) ->
diff --git a/lib/kernel/test/inet_res_SUITE.erl b/lib/kernel/test/inet_res_SUITE.erl
index 659cfc5988..cc32d1f8f9 100644
--- a/lib/kernel/test/inet_res_SUITE.erl
+++ b/lib/kernel/test/inet_res_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2009-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(inet_res_SUITE).
@@ -239,16 +239,37 @@ resolve(_Opts, []) -> ok;
resolve(Opts, [{Class,Type,Name,Answers,Authority}=Q|Qs]) ->
io:format("Query: ~p~nOptions: ~p~n", [Q,Opts]),
{ok,Msg} = inet_res:resolve(Name, Class, Type, Opts),
- if Answers =/= undefined ->
- AnList = lists:sort(Answers),
- AnList = lists:sort([inet_dns:rr(RR, data) ||
- RR <- inet_dns:msg(Msg, anlist)]);
- true -> ok end,
- if Authority =/= undefined ->
- NsList = lists:sort(Authority),
- NsList = lists:sort([inet_dns:rr(RR, data) ||
- RR <- inet_dns:msg(Msg, nslist)]);
- true -> ok end,
+ AnList =
+ if
+ Answers =/= undefined ->
+ lists:sort(Answers);
+ true ->
+ undefined
+ end,
+ NsList =
+ if
+ Authority =/= undefined ->
+ lists:sort(Authority);
+ true ->
+ undefined
+ end,
+ case {lists:sort
+ ([inet_dns:rr(RR, data) || RR <- inet_dns:msg(Msg, anlist)]),
+ lists:sort
+ ([inet_dns:rr(RR, data) || RR <- inet_dns:msg(Msg, nslist)])} of
+ {AnList,NsList} ->
+ ok;
+ {NsList,AnList} when Type =:= ns ->
+ %% This whole case statement is kind of inside out just
+ %% to accept this case when some legacy DNS resolvers
+ %% return the answer to a NS query in the answer section
+ %% instead of in the authority section.
+ ok;
+ {AnList,_} when NsList =:= undefined ->
+ ok;
+ {_,NsList} when AnList =:= undefined ->
+ ok
+ end,
Buf = inet_dns:encode(Msg),
{ok,Msg} = inet_dns:decode(Buf),
resolve(Opts, Qs).
@@ -292,10 +313,23 @@ edns0(Config) when is_list(Config) ->
MXs = lists:sort(inet_res_filter(inet_dns:msg(Msg2, anlist), in, mx)),
Buf2 = inet_dns:encode(Msg2),
{ok,Msg2} = inet_dns:decode(Buf2),
- [OptRR] = [RR || RR <- inet_dns:msg(Msg2, arlist),
- inet_dns:rr(RR, type) =:= opt],
- io:format("~p~n", [inet_dns:rr(OptRR)]),
- ok.
+ case [RR || RR <- inet_dns:msg(Msg2, arlist),
+ inet_dns:rr(RR, type) =:= opt] of
+ [OptRR] ->
+ io:format("~p~n", [inet_dns:rr(OptRR)]),
+ ok;
+ [] ->
+ case os:type() of
+ {unix,sunos} ->
+ case os:version() of
+ {M,V,_} when M < 5; M == 5, V =< 8 ->
+ %% In our test park only known platform
+ %% with an DNS resolver that can not do
+ %% EDNS0.
+ {comment,"No EDNS0"}
+ end
+ end
+ end.
inet_res_filter(Anlist, Class, Type) ->
[inet_dns:rr(RR, data) || RR <- Anlist,
@@ -331,11 +365,13 @@ files_monitor(suite) ->
files_monitor(doc) ->
["Tests monitoring of /etc/hosts and /etc/resolv.conf, but not them"];
files_monitor(Config) when is_list(Config) ->
+ Search = inet_db:res_option(search),
HostsFile = inet_db:res_option(hosts_file),
ResolvConf = inet_db:res_option(resolv_conf),
Inet6 = inet_db:res_option(inet6),
try do_files_monitor(Config)
after
+ inet_db:res_option(search, Search),
inet_db:res_option(resolv_conf, ResolvConf),
inet_db:res_option(hosts_file, HostsFile),
inet_db:res_option(inet6, Inet6)
@@ -344,7 +380,13 @@ files_monitor(Config) when is_list(Config) ->
do_files_monitor(Config) ->
Dir = ?config(priv_dir, Config),
{ok,Hostname} = inet:gethostname(),
- FQDN = Hostname++"."++inet_db:res_option(domain),
+ FQDN =
+ case inet_db:res_option(domain) of
+ "" ->
+ Hostname;
+ _ ->
+ Hostname++"."++inet_db:res_option(domain)
+ end,
HostsFile = filename:join(Dir, "files_monitor_hosts"),
ResolvConf = filename:join(Dir, "files_monitor_resolv.conf"),
ok = inet_db:res_option(resolv_conf, ResolvConf),
@@ -362,20 +404,20 @@ do_files_monitor(Config) ->
{error,nxdomain} = inet_res:gethostbyname(FQDN),
{ok,{127,0,0,10}} = inet:getaddr("mx.otptest", inet),
{ok,{0,0,0,0,0,0,32512,28}} = inet:getaddr("resolve.otptest", inet6),
- ok = inet_db:res_option(inet6, true),
{ok,#hostent{h_name = Hostname,
h_addrtype = inet6,
h_length = 16,
h_addr_list = [{0,0,0,0,0,0,0,1}]}} =
- inet:gethostbyname(Hostname),
+ inet:gethostbyname(Hostname, inet6),
{ok,#hostent{h_name = FQDN,
h_addrtype = inet6,
h_length = 16,
h_addr_list = [{0,0,0,0,0,0,0,1}]}} =
- inet:gethostbyname(FQDN),
+ inet:gethostbyname(FQDN, inet6),
{error,nxdomain} = inet_res:gethostbyname("resolve"),
%% XXX inet does not honour res_option inet6, might be a problem?
%% therefore inet_res is called here
+ ok = inet_db:res_option(inet6, true),
{ok,#hostent{h_name = "resolve.otptest",
h_addrtype = inet6,
h_length = 16,
diff --git a/lib/megaco/test/Makefile b/lib/megaco/test/Makefile
index 85c97359d7..682b83d368 100644
--- a/lib/megaco/test/Makefile
+++ b/lib/megaco/test/Makefile
@@ -62,8 +62,6 @@ SOURCE = $(HRL_FILES) $(ERL_FILES)
TARGET_FILES = $(MODULES:%=%.$(EMULATOR))
-COVER_SPEC_FILE = megaco.cover
-
APP_CASES = app appup
CODEC_CASES = codec1 codec2 codec3a codec3b codec3c
@@ -80,10 +78,10 @@ MAKE_EMAKE = $(wildcard $(ERL_TOP)/make/make_emakefile)
ifeq ($(MAKE_EMAKE),)
BUILDTARGET = $(TARGET_FILES)
-RELTEST_FILES = $(MEGACO_SPECS) $(COVER_SPEC_FILE) $(SOURCE)
+RELTEST_FILES = $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) $(SOURCE)
else
BUILDTARGET = emakebuild
-RELTEST_FILES = $(EMAKEFILE) $(MEGACO_SPECS) $(COVER_SPEC_FILE) $(SOURCE)
+RELTEST_FILES = $(EMAKEFILE) $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) $(SOURCE)
endif
diff --git a/lib/megaco/test/modules.mk b/lib/megaco/test/modules.mk
index 0186a84c26..049d8babe2 100644
--- a/lib/megaco/test/modules.mk
+++ b/lib/megaco/test/modules.mk
@@ -1,24 +1,26 @@
#-*-makefile-*- ; force emacs to enter makefile-mode
# %CopyrightBegin%
-#
-# Copyright Ericsson AB 2001-2009. All Rights Reserved.
-#
+#
+# Copyright Ericsson AB 2001-2010. All Rights Reserved.
+#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
-#
+#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
-#
+#
# %CopyrightEnd%
TEST_SPEC_FILE = megaco.spec
+COVER_SPEC_FILE = megaco.cover
+
BEHAVIOUR_MODULES = \
megaco_test_generator
diff --git a/lib/megaco/vsn.mk b/lib/megaco/vsn.mk
index b0574bbeef..1ee78c423a 100644
--- a/lib/megaco/vsn.mk
+++ b/lib/megaco/vsn.mk
@@ -19,7 +19,7 @@
APPLICATION = megaco
MEGACO_VSN = 3.13.1
-PRE_VSN =-p03
+PRE_VSN =-p04
APP_VSN = "$(APPLICATION)-$(MEGACO_VSN)$(PRE_VSN)"
TICKETS = OTP-8317 OTP-8323 OTP-8362 OTP-8403
diff --git a/lib/odbc/c_src/odbcserver.c b/lib/odbc/c_src/odbcserver.c
index 63177121bc..6a920e6c76 100644
--- a/lib/odbc/c_src/odbcserver.c
+++ b/lib/odbc/c_src/odbcserver.c
@@ -1,19 +1,19 @@
/*
* %CopyrightBegin%
- *
- * Copyright Ericsson AB 1999-2009. All Rights Reserved.
- *
+ *
+ * Copyright Ericsson AB 1999-2010. All Rights Reserved.
+ *
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
* compliance with the License. You should have received a copy of the
* Erlang Public License along with this software. If not, it can be
* retrieved online at http://www.erlang.org/.
- *
+ *
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
- *
+ *
* %CopyrightEnd%
*
@@ -749,11 +749,12 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
byte *sql;
db_result_msg msg;
int i, num_param_values, ver = 0,
- erl_type = 0, index = 0, size = 0, cols = 0;
+ erl_type = 0, index = 0, size = 0, cols = 0;
long long_num_param_values;
param_status param_status;
diagnos diagnos;
- param_array *params;
+ param_array *params;
+ SQLRETURN result;
if (associated_result_set(state)) {
clean_state(state);
@@ -784,10 +785,16 @@ static db_result_msg db_param_query(byte *buffer, db_state *state)
num_param_values, state);
if(params != NULL) {
- if(!sql_success(SQLExecDirect(statement_handle(state),
- sql, SQL_NTS))) {
- diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
- msg = encode_error_message(diagnos.error_msg);
+
+ result = SQLExecDirect(statement_handle(state), sql, SQL_NTS);
+ if (!sql_success(result) || result == SQL_NO_DATA) {
+ diagnos = get_diagnos(SQL_HANDLE_STMT, statement_handle(state));
+ }
+ /* SQL_NO_DATA and SQLSTATE 00000 indicate success for
+ updates/deletes that affect no rows */
+ if(!sql_success(result) &&
+ !(result == SQL_NO_DATA && !strcmp((char *)diagnos.sqlState, INFO))) {
+ msg = encode_error_message(diagnos.error_msg);
} else {
for (i = 0; i < param_status.params_processed; i++) {
switch (param_status.param_status_array[i]) {
@@ -2452,6 +2459,7 @@ static diagnos get_diagnos(SQLSMALLINT handleType, SQLHANDLE handle)
int acc_errmsg_size;
byte *current_errmsg_pos;
SQLCHAR current_sql_state[SQL_STATE_SIZE];
+ SQLRETURN result;
diagnos.error_msg[0] = 0;
@@ -2464,10 +2472,10 @@ static diagnos get_diagnos(SQLSMALLINT handleType, SQLHANDLE handle)
/* Foreach diagnostic record in the current set of diagnostic records
the error message is obtained */
for(record_nr = 1; ;record_nr++) {
- if(SQLGetDiagRec(handleType, handle, record_nr, current_sql_state,
+ result = SQLGetDiagRec(handleType, handle, record_nr, current_sql_state,
&nativeError, current_errmsg_pos,
- (SQLSMALLINT)errmsg_buffer_size, &errmsg_size)
- != SQL_SUCCESS) {
+ (SQLSMALLINT)errmsg_buffer_size, &errmsg_size);
+ if(result != SQL_SUCCESS && result != SQL_NO_DATA) {
break;
diff --git a/lib/percept/src/egd_render.erl b/lib/percept/src/egd_render.erl
index cea9d2d926..4a0247dd33 100644
--- a/lib/percept/src/egd_render.erl
+++ b/lib/percept/src/egd_render.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -179,7 +179,7 @@ color(Trans,Layers,Type,OldC) ->
color([],_) -> {0.0,0.0,0.0,0.0};
color([{_,C}|_],opaque) -> C;
-color(Layers,alpha) -> color1({0,0,0,0},Layers).
+color(Layers,alpha) -> color1({0.0,0.0,0.0,0.0},Layers).
color1(Color,[]) -> Color;
color1(Color,[{_,C}|Layers]) -> color1(alpha_blend(Color,C),Layers).
diff --git a/lib/percept/test/egd_SUITE.erl b/lib/percept/test/egd_SUITE.erl
index a2595400dd..fde02b47d5 100644
--- a/lib/percept/test/egd_SUITE.erl
+++ b/lib/percept/test/egd_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2007-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2007-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -143,6 +143,8 @@ image_shape(Config) when is_list(Config) ->
?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt2, Fgc),
?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt1, Fgc),
+ ?line <<_/binary>> = egd:render(Im, raw_bitmap, [{render_engine, alpha}]),
+
?line ok = egd:destroy(Im),
erase(image_size),
ok.
@@ -177,6 +179,8 @@ image_primitives(Config) when is_list(Config) ->
?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt2, Fgc),
?line ok = bitmap_point_has_color(Bitmap, {W,H}, Pt1, Fgc),
+ ?line <<_/binary>> = egd_render:binary(Im2, alpha),
+
erase(image_size),
ok.
diff --git a/otp_build b/otp_build
index 3e8c60ef52..165f9dc66d 100755
--- a/otp_build
+++ b/otp_build
@@ -1,20 +1,20 @@
#! /bin/sh
#
# %CopyrightBegin%
-#
+#
# Copyright Ericsson AB 2002-2010. All Rights Reserved.
-#
+#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
-#
+#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
-#
+#
# %CopyrightEnd%
#
@@ -225,6 +225,8 @@ set_config_flags ()
export CONFIG_FLAGS;
}
+NL="\
+"
create_lib_configure_in()
{
cd $ERL_TOP
@@ -241,7 +243,7 @@ create_lib_configure_in()
lib/*)
if [ -f "$lib_app/configure.in" ]; then
app=`echo "$lib_app" | sed "s|lib/\(.*\)|\1|"`
- sdirs="${sdirs}test ! -f $app/configure || AC_CONFIG_SUBDIRS($app/.)\n"
+ sdirs="${sdirs}test ! -f $app/configure || AC_CONFIG_SUBDIRS($app/.)${NL}"
fi;;
*)
;;
@@ -258,7 +260,7 @@ create_lib_configure_in()
done
if [ $is_bapp = false ] && [ -f "$lib_app/configure.in" ]; then
app=`echo "$lib_app" | sed "s|lib/\(.*\)|\1|"`
- sdirs="${sdirs} test ! -f $app/configure || AC_CONFIG_SUBDIRS($app/.)\n"
+ sdirs="${sdirs} test ! -f $app/configure || AC_CONFIG_SUBDIRS($app/.)${NL}"
fi
done
diff --git a/xcomp/README b/xcomp/README
index 4cb577471a..f4285cd16f 100644
--- a/xcomp/README
+++ b/xcomp/README
@@ -1,5 +1,5 @@
===============================================================================
- Cross compiling Erlang/OTP
+ Cross Compiling Erlang/OTP
===============================================================================
%CopyrightBegin%
@@ -244,14 +244,14 @@ build machine and the cross host system.
$ ./otp_build boot -a
- 'otp_build boot -a' will first build a bootstrap system
-for the build machine and then do the cross build of the system.
+`otp_build boot -a' will first build a bootstrap system for the build machine
+and then do the cross build of the system.
[11]
$ ./otp_build release -a <RELEASE_DIR>
-'otp_build release -a' will do the same as [5], and you will after this have
+`otp_build release -a' will do the same as [5], and you will after this have
to do a manual install either by doing [6], or [7].
======== Currently used configuration variables ===============================
@@ -312,13 +312,15 @@ not need to set these variables (where `<HOST>' is what has been passed as
* CXXFLAGS - C++ compiler flags.
-* LD - Linker
+* LD - Linker.
* LDFLAGS - Linker flags.
--- Dynamic Erlang Driver linker flags. --
+* LIBS - Libraries.
-NOTE! Either define all or non of the DED_LD* variables.
+-- Dynamic Erlang Driver linker flags --
+
+NOTE! Either set all or non of the DED_LD* variables.
* DED_LD - Linker.
@@ -328,11 +330,23 @@ NOTE! Either define all or non of the DED_LD* variables.
This flag should set a specific runtime library path for the shared
library at link time.
+-- Large file support --
+
+NOTE! Either set all or non of the LFS_* variables.
+
+* LFS_CFLAGS - Large file support C compiler flags.
+
+* LFS_LDFLAGS - Large file support linker flags.
+
+* LFS_LIBS - Large file support libraries.
+
-- Other tools --
-* RANLIB - ranlib
+* RANLIB - `ranlib' archive index tool.
-* AR - ar
+* AR - `ar' archiving tool.
+
+* GETCONF - `getconf' system configuration inspection tool.
-------- Cross System Root Locations ------------------------------------------
@@ -356,6 +370,10 @@ These tests cannot (always) be done automatically when cross compiling. You
usually does not need to set these variables. Only set these if you really
know what you are doing.
+Note that some of these values will override results of tests performed
+by `configure', and some will not be used until `configure' is sure that
+it cannot figure the result out.
+
The `configure' script will issue a warning when a default value is used.
When a variable has been set, no warning will be issued.
diff --git a/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf b/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf
index 67da8b5abb..5ceb4ec145 100644
--- a/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf
+++ b/xcomp/erl-xcomp-TileraMDE2.0-tilepro.conf
@@ -94,15 +94,18 @@ erl_xcomp_configure_flags="--without-termcap"
## CXXFLAGS - C++ compiler flags.
#CXXFLAGS=
-## LD - Linker
+## LD - Linker.
#LD=
## LDFLAGS - Linker flags.
#LDFLAGS=
-### -- Dynamic Erlang Driver linker flags. --
+## LIBS - Libraries.
+#LIBS=
-### NOTE! Either define all or non of the DED_LD* variables.
+### -- Dynamic Erlang Driver linker flags --
+
+### NOTE! Either set all or non of the DED_LD* variables.
## DED_LD - Linker.
#DED_LD=
@@ -115,14 +118,30 @@ erl_xcomp_configure_flags="--without-termcap"
## library at link time.
#DED_LD_FLAG_RUNTIME_LIBRARY_PATH=
+### -- Large file support --
+
+### NOTE! Either set all or non of the LFS_* variables.
+
+## LFS_CFLAGS - Large file support C compiler flags.
+#LFS_CFLAGS=
+
+## LFS_LDFLAGS - Large file support linker flags.
+#LFS_LDFLAGS=
+
+## LFS_LIBS - Large file support libraries.
+#LFS_LIBS=
+
### -- Other tools --
-## RANLIB - ranlib
+## RANLIB - `ranlib' archive index tool.
#RANLIB=
-## AR - ar
+## AR - `ar' archiving tool.
#AR=
+## GETCONF - `getconf' system configuration inspection tool.
+#GETCONF=
+
### ---- Cross System Root Locations ------------------------------------------
## erl_xcomp_sysroot - Absolute cross system root path.
@@ -147,6 +166,10 @@ erl_xcomp_sysroot="$TILERA_ROOT/tile"
### usually does not need to set these variables. Only set these if you really
### know what you are doing.
+### Note that some of these values will override results of tests performed
+### by `configure', and some will not be used until `configure' is sure that
+### it cannot figure the result out.
+
### The `configure' script will issue a warning when a default value is used.
### When a variable has been set, no warning will be issued.
diff --git a/xcomp/erl-xcomp-vxworks_ppc32.conf b/xcomp/erl-xcomp-vxworks_ppc32.conf
index fbd23c2fb9..aa7c652d80 100644
--- a/xcomp/erl-xcomp-vxworks_ppc32.conf
+++ b/xcomp/erl-xcomp-vxworks_ppc32.conf
@@ -94,15 +94,18 @@ CPP="$CC $CFLAGS -E"
## CXXFLAGS - C++ compiler flags.
#CXXFLAGS=
-## LD - Linker
+## LD - Linker.
LD="$WIND_BASE/gnu/3.4.4-vxworks-6.3/$WIND_HOST_TYPE/bin/ldppc"
## LDFLAGS - Linker flags.
LDFLAGS="-mlongcall"
-### -- Dynamic Erlang Driver linker flags. --
+## LIBS - Libraries.
+#LIBS=
-### NOTE! Either define all or non of the DED_LD* variables.
+### -- Dynamic Erlang Driver linker flags --
+
+### NOTE! Either set all or non of the DED_LD* variables.
## DED_LD - Linker.
#DED_LD=
@@ -115,14 +118,30 @@ LDFLAGS="-mlongcall"
## library at link time.
#DED_LD_FLAG_RUNTIME_LIBRARY_PATH=
+### -- Large file support --
+
+### NOTE! Either set all or non of the LFS_* variables.
+
+## LFS_CFLAGS - Large file support C compiler flags.
+#LFS_CFLAGS=
+
+## LFS_LDFLAGS - Large file support linker flags.
+#LFS_LDFLAGS=
+
+## LFS_LIBS - Large file support libraries.
+#LFS_LIBS=
+
### -- Other tools --
-## RANLIB - ranlib
+## RANLIB - `ranlib' archive index tool.
RANLIB="$WIND_BASE/gnu/3.4.4-vxworks-6.3/$WIND_HOST_TYPE/bin/ranlibppc"
-## AR - ar
+## AR - `ar' archiving tool.
AR="$WIND_BASE/gnu/3.4.4-vxworks-6.3/$WIND_HOST_TYPE/bin/arppc"
+## GETCONF - `getconf' system configuration inspection tool.
+#GETCONF=
+
### ---- Cross System Root Locations ------------------------------------------
## erl_xcomp_sysroot - Absolute cross system root path.
@@ -147,6 +166,10 @@ AR="$WIND_BASE/gnu/3.4.4-vxworks-6.3/$WIND_HOST_TYPE/bin/arppc"
### usually does not need to set these variables. Only set these if you really
### know what you are doing.
+### Note that some of these values will override results of tests performed
+### by `configure', and some will not be used until `configure' is sure that
+### it cannot figure the result out.
+
### The `configure' script will issue a warning when a default value is used.
### When a variable has been set, no warning will be issued.
diff --git a/xcomp/erl-xcomp-x86_64-saf-linux-gnu.conf b/xcomp/erl-xcomp-x86_64-saf-linux-gnu.conf
index b6730cff0a..1d57876172 100644
--- a/xcomp/erl-xcomp-x86_64-saf-linux-gnu.conf
+++ b/xcomp/erl-xcomp-x86_64-saf-linux-gnu.conf
@@ -94,15 +94,18 @@ CXX=x86_64-saf-g++
## CXXFLAGS - C++ compiler flags.
#CXXFLAGS=
-## LD - Linker
+## LD - Linker.
LD=x86_64-saf-ld
## LDFLAGS - Linker flags.
#LDFLAGS=
-### -- Dynamic Erlang Driver linker flags. --
+## LIBS - Libraries.
+#LIBS=
-### NOTE! Either define all or non of the DED_LD* variables.
+### -- Dynamic Erlang Driver linker flags --
+
+### NOTE! Either set all or non of the DED_LD* variables.
## DED_LD - Linker.
#DED_LD=
@@ -115,14 +118,30 @@ LD=x86_64-saf-ld
## library at link time.
#DED_LD_FLAG_RUNTIME_LIBRARY_PATH=
+### -- Large file support --
+
+### NOTE! Either set all or non of the LFS_* variables.
+
+## LFS_CFLAGS - Large file support C compiler flags.
+#LFS_CFLAGS=
+
+## LFS_LDFLAGS - Large file support linker flags.
+#LFS_LDFLAGS=
+
+## LFS_LIBS - Large file support libraries.
+#LFS_LIBS=
+
### -- Other tools --
-## RANLIB - ranlib
+## RANLIB - `ranlib' archive index tool.
RANLIB=x86_64-saf-ranlib
-## AR - ar
+## AR - `ar' archiving tool.
AR=x86_64-saf-ar
+## GETCONF - `getconf' system configuration inspection tool.
+#GETCONF=
+
### ---- Cross System Root Locations ------------------------------------------
## erl_xcomp_sysroot - Absolute cross system root path.
@@ -147,6 +166,10 @@ erl_xcomp_sysroot="$SAF_SYSROOT_X86_64"
### usually does not need to set these variables. Only set these if you really
### know what you are doing.
+### Note that some of these values will override results of tests performed
+### by `configure', and some will not be used until `configure' is sure that
+### it cannot figure the result out.
+
### The `configure' script will issue a warning when a default value is used.
### When a variable has been set, no warning will be issued.
diff --git a/xcomp/erl-xcomp.conf.template b/xcomp/erl-xcomp.conf.template
index 9242318577..afbef66af1 100644
--- a/xcomp/erl-xcomp.conf.template
+++ b/xcomp/erl-xcomp.conf.template
@@ -94,15 +94,18 @@
## CXXFLAGS - C++ compiler flags.
#CXXFLAGS=
-## LD - Linker
+## LD - Linker.
#LD=
## LDFLAGS - Linker flags.
#LDFLAGS=
-### -- Dynamic Erlang Driver linker flags. --
+## LIBS - Libraries.
+#LIBS=
-### NOTE! Either define all or non of the DED_LD* variables.
+### -- Dynamic Erlang Driver linker flags --
+
+### NOTE! Either set all or non of the DED_LD* variables.
## DED_LD - Linker.
#DED_LD=
@@ -115,14 +118,30 @@
## library at link time.
#DED_LD_FLAG_RUNTIME_LIBRARY_PATH=
+### -- Large file support --
+
+### NOTE! Either set all or non of the LFS_* variables.
+
+## LFS_CFLAGS - Large file support C compiler flags.
+#LFS_CFLAGS=
+
+## LFS_LDFLAGS - Large file support linker flags.
+#LFS_LDFLAGS=
+
+## LFS_LIBS - Large file support libraries.
+#LFS_LIBS=
+
### -- Other tools --
-## RANLIB - ranlib
+## RANLIB - `ranlib' archive index tool.
#RANLIB=
-## AR - ar
+## AR - `ar' archiving tool.
#AR=
+## GETCONF - `getconf' system configuration inspection tool.
+#GETCONF=
+
### ---- Cross System Root Locations ------------------------------------------
## erl_xcomp_sysroot - Absolute cross system root path.
@@ -147,6 +166,10 @@
### usually does not need to set these variables. Only set these if you really
### know what you are doing.
+### Note that some of these values will override results of tests performed
+### by `configure', and some will not be used until `configure' is sure that
+### it cannot figure the result out.
+
### The `configure' script will issue a warning when a default value is used.
### When a variable has been set, no warning will be issued.