diff options
Diffstat (limited to 'erts/etc')
26 files changed, 227 insertions, 2251 deletions
diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in index 28c5e5ccad..0e128fda12 100644 --- a/erts/etc/common/Makefile.in +++ b/erts/etc/common/Makefile.in @@ -33,11 +33,7 @@ else ifeq ($(TYPE),purify) PURIFY = purify TYPEMARKER = -ifeq ($(findstring ose,$(TARGET)),ose) -TYPE_FLAGS = -g -XO -DPURIFY -else TYPE_FLAGS = -g -O2 -DPURIFY -endif else override TYPE=opt @@ -77,25 +73,15 @@ EMUDIR = $(ERL_TOP)/erts/emulator/beam EMUOSDIR = $(ERL_TOP)/erts/emulator/@ERLANG_OSTYPE@ SYSDIR = $(ERL_TOP)/erts/emulator/sys/@ERLANG_OSTYPE@ DRVDIR = $(ERL_TOP)/erts/emulator/drivers/@ERLANG_OSTYPE@ -VXETC = ../vxworks UXETC = ../unix OSEETC = ../ose WINETC = ../win32 -ifeq ($(findstring vxworks,$(TARGET)), vxworks) -ERLEXEC = erl.exec -else -ifeq ($(findstring ose,$(TARGET)), ose) -ERLEXEC = -TAR = @TAR@ -else ifeq ($(TARGET), win32) ERLEXEC = erlexec.dll else ERLEXEC = erlexec endif -endif -endif # On windows we always need reentrant libraries. ifeq ($(TARGET),win32) @@ -110,42 +96,6 @@ ERTS_LIB = $(ERL_TOP)/erts/lib_src/obj/$(TARGET)/$(TYPE)/MADE # Release directory specification # ---------------------------------------------------- -ifeq ($(findstring vxworks,$(TARGET)), vxworks) -INSTALL_EMBEDDED_PROGS = $(BINDIR)/erl_io $(BINDIR)/rdate $(BINDIR)/vxcall -INSTALL_EMBEDDED_DATA = $(BINDIR)/erl_script.sam $(VXETC)/resolv.conf -INSTALL_INCLUDES = $(VXETC)/reclaim.h -INSTALL_TOP = $(VXETC)/README.VxWorks -INSTALL_MISC = -INSTALL_SRC = heart.c $(VXETC)/heart_config.h $(VXETC)/heart_config.c \ - $(VXETC)/erl.exec.c $(VXETC)/rdate.c $(VXETC)/vxcall.c \ - $(VXETC)/erl_io.c -ERLEXECDIR = $(VXETC) -INSTALL_LIBS = $(OBJDIR)/reclaim.o -INSTALL_OBJS = $(OBJDIR)/heart.o -TEXTFILES = $(BINDIR)/erl_script.sam -ERLSRV_OBJECTS= -MC_OUTPUTS= -ENTRY_LDFLAGS= -ENTRY_OBJ= -INSTALL_PROGS = \ - $(INET_GETHOST) \ - $(BINDIR)/heart \ - $(BINDIR)/$(ERLEXEC) \ - $(INSTALL_EMBEDDED_PROGS) -else -ifeq ($(findstring ose,$(TARGET)), ose) -INSTALL_TOP = $(OSEETC)/README.OSE -INSTALL_ERL_OSE = monolith lm erl_utils drivers port_progs host -INSTALL_SRC = -INSTALL_LIBS = -INSTALL_OBJS = -INSTALL_INCLUDES = -INSTALL_PROGS = -ERLSRV_OBJECTS= -MC_OUTPUTS= -ENTRY_LDFLAGS= -ENTRY_OBJ= -else ifeq ($(TARGET),win32) CFLAGS += -I$(EMUOSDIR) -I$(WINETC) RC=rc.sh @@ -207,7 +157,7 @@ endif PORT_ENTRY_POINT=erl_port_entry ENTRY_LDFLAGS=-entry:$(PORT_ENTRY_POINT) -else +else # UNIX (!win32) ENTRY_LDFLAGS= ENTRY_OBJ= ERLSRV_OBJECTS= @@ -232,8 +182,6 @@ INSTALL_PROGS = \ $(BINDIR)/$(ERLEXEC) \ $(INSTALL_EMBEDDED_PROGS) endif -endif -endif .PHONY: etc etc: $(ENTRY_OBJ) $(INSTALL_PROGS) $(INSTALL_LIBS) $(TEXTFILES) $(INSTALL_TOP_BIN) @@ -396,24 +344,6 @@ endif # End of windows specific targets. #--------------------------------------------------------- -ifeq ($(findstring vxworks,$(TARGET)), vxworks) -$(BINDIR)/heart: $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o - $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/heart.o $(OBJDIR)/heart_config.o - -$(OBJDIR)/heart_config.o: $(VXETC)/heart_config.c - $(CC) $(CFLAGS) -o $@ -c $(VXETC)/heart_config.c - -$(OBJDIR)/reclaim.o: $(VXETC)/reclaim.c - $(CC) $(CFLAGS) -o $@ -c $(VXETC)/reclaim.c - -$(OBJDIR)/heart.o: heart.c - $(CC) $(CFLAGS) -I$(VXETC) -o $@ -c heart.c - -$(BINDIR)/erl_script.sam: $(VXETC)/erl_script.sam.in ../../vsn.mk - sed -e 's;%VSN%;$(VSN);' \ - $(VXETC)/erl_script.sam.in > $(BINDIR)/erl_script.sam -else - $(BINDIR)/heart@EXEEXT@: $(OBJDIR)/heart.o $(ENTRY_OBJ) $(LD) $(LDFLAGS) $(ENTRY_LDFLAGS) -o $@ $(OBJDIR)/heart.o \ $(ENTRY_OBJ) $(WINDSOCK) @@ -421,31 +351,6 @@ $(BINDIR)/heart@EXEEXT@: $(OBJDIR)/heart.o $(ENTRY_OBJ) $(OBJDIR)/heart.o: heart.c $(RC_GENERATED) $(CC) $(CFLAGS) -o $@ -c heart.c -endif - - -# VxWorks specific executables and objects ... - -$(BINDIR)/erl_io: $(OBJDIR)/erl_io.o - $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/erl_io.o - -$(OBJDIR)/erl_io.o: $(VXETC)/erl_io.c - $(CC) $(CFLAGS) -o $@ -c $(VXETC)/erl_io.c - -$(BINDIR)/rdate: $(OBJDIR)/rdate.o - $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/rdate.o - -$(OBJDIR)/rdate.o: $(VXETC)/rdate.c - $(CC) $(CFLAGS) -o $@ -c $(VXETC)/rdate.c - -$(BINDIR)/vxcall: $(OBJDIR)/vxcall.o - $(LD) $(LDFLAGS) -o $@ $(OBJDIR)/vxcall.o - -$(OBJDIR)/vxcall.o: $(VXETC)/vxcall.c - $(CC) $(CFLAGS) -o $@ -c $(VXETC)/vxcall.c - - - # # Objects & executables # @@ -545,48 +450,48 @@ include $(ERL_TOP)/make/otp_release_targets.mk .PHONY: release_spec release_spec: etc ifneq ($(INSTALL_OBJS),) - $(INSTALL_DIR) $(RELEASE_PATH)/erts-$(VSN)/obj - $(INSTALL_DATA) $(INSTALL_OBJS) $(RELEASE_PATH)/erts-$(VSN)/obj + $(INSTALL_DIR) "$(RELEASE_PATH)/erts-$(VSN)/obj" + $(INSTALL_DATA) $(INSTALL_OBJS) "$(RELEASE_PATH)/erts-$(VSN)/obj" endif - $(INSTALL_DIR) $(RELEASE_PATH)/erts-$(VSN)/bin + $(INSTALL_DIR) "$(RELEASE_PATH)/erts-$(VSN)/bin" ifneq ($(TARGET), win32) ifneq ($(findstring vxworks,$(TARGET)), vxworks) ifneq ($(findstring ose,$(TARGET)), ose) - $(INSTALL_SCRIPT) erl.src $(RELEASE_PATH)/erts-$(VSN)/bin + $(INSTALL_SCRIPT) erl.src "$(RELEASE_PATH)/erts-$(VSN)/bin" endif endif endif ifneq ($(INSTALL_PROGS),) - $(INSTALL_PROGRAM) $(INSTALL_PROGS) $(RELEASE_PATH)/erts-$(VSN)/bin + $(INSTALL_PROGRAM) $(INSTALL_PROGS) "$(RELEASE_PATH)/erts-$(VSN)/bin" endif ifneq ($(INSTALL_TOP),) - $(INSTALL_SCRIPT) $(INSTALL_TOP) $(RELEASE_PATH) + $(INSTALL_SCRIPT) $(INSTALL_TOP) "$(RELEASE_PATH)" endif ifneq ($(INSTALL_TOP_BIN),) - $(INSTALL_PROGRAM) $(INSTALL_TOP_BIN) $(RELEASE_PATH) + $(INSTALL_PROGRAM) $(INSTALL_TOP_BIN) "$(RELEASE_PATH)" endif ifneq ($(INSTALL_MISC),) - $(INSTALL_DIR) $(RELEASE_PATH)/misc - $(INSTALL_SCRIPT) $(INSTALL_MISC) $(RELEASE_PATH)/misc + $(INSTALL_DIR) "$(RELEASE_PATH)/misc" + $(INSTALL_SCRIPT) $(INSTALL_MISC) "$(RELEASE_PATH)/misc" endif ifneq ($(INSTALL_ERL_OSE),) - $(INSTALL_DIR) $(RELEASE_PATH)/build_erl_ose + $(INSTALL_DIR) "$(RELEASE_PATH)/build_erl_ose" cd $(OSEETC) && $(TAR) erl_ose_$(SYSTEM_VSN).tar $(INSTALL_ERL_OSE) - cd $(OSEETC) && $(INSTALL_SCRIPT) erl_ose_$(SYSTEM_VSN).tar $(RELEASE_PATH)/build_erl_ose + cd $(OSEETC) && $(INSTALL_SCRIPT) erl_ose_$(SYSTEM_VSN).tar "$(RELEASE_PATH)/build_erl_ose" endif ifneq ($(INSTALL_SRC),) - $(INSTALL_DIR) $(RELEASE_PATH)/erts-$(VSN)/src - $(INSTALL_DATA) $(INSTALL_SRC) $(RELEASE_PATH)/erts-$(VSN)/src + $(INSTALL_DIR) "$(RELEASE_PATH)/erts-$(VSN)/src" + $(INSTALL_DATA) $(INSTALL_SRC) "$(RELEASE_PATH)/erts-$(VSN)/src" endif ifneq ($(INSTALL_EMBEDDED_DATA),) - $(INSTALL_DATA) $(INSTALL_EMBEDDED_DATA) $(RELEASE_PATH)/erts-$(VSN)/bin + $(INSTALL_DATA) $(INSTALL_EMBEDDED_DATA) "$(RELEASE_PATH)/erts-$(VSN)/bin" endif ifneq ($(INSTALL_LIBS),) - $(INSTALL_DATA) $(INSTALL_LIBS) $(RELEASE_PATH)/erts-$(VSN)/bin + $(INSTALL_DATA) $(INSTALL_LIBS) "$(RELEASE_PATH)/erts-$(VSN)/bin" endif ifneq ($(INSTALL_INCLUDES),) - $(INSTALL_DIR) $(RELEASE_PATH)/erts-$(VSN)/include - $(INSTALL_DATA) $(INSTALL_INCLUDES) $(RELEASE_PATH)/erts-$(VSN)/include + $(INSTALL_DIR) "$(RELEASE_PATH)/erts-$(VSN)/include" + $(INSTALL_DATA) $(INSTALL_INCLUDES) "$(RELEASE_PATH)/erts-$(VSN)/include" endif .PHONY: release_docs_spec diff --git a/erts/etc/common/dialyzer.c b/erts/etc/common/dialyzer.c index 04e9199ef3..70b11b1b36 100644 --- a/erts/etc/common/dialyzer.c +++ b/erts/etc/common/dialyzer.c @@ -189,6 +189,18 @@ main(int argc, char** argv) argc--, argv++; } + if (argc > 2 && strcmp(argv[1], "+P") == 0) { + PUSH2("+P", argv[2]); + argc--, argv++; + argc--, argv++; + } else PUSH2("+P", "1000000"); + + if (argc > 2 && strcmp(argv[1], "+sbt") == 0) { + PUSH2("+sbt", argv[2]); + argc--, argv++; + argc--, argv++; + } + PUSH("+B"); PUSH2("-boot", "start_clean"); PUSH3("-run", "dialyzer", "plain_cl"); diff --git a/erts/etc/common/erlc.c b/erts/etc/common/erlc.c index 23f009ff4d..0223cc5274 100644 --- a/erts/etc/common/erlc.c +++ b/erts/etc/common/erlc.c @@ -252,13 +252,6 @@ main(int argc, char** argv) } } break; - case 'h': - if (strcmp(argv[1], "-hybrid") == 0) { - UNSHIFT(argv[1]); - } else { - usage(); - } - break; case 'I': PUSH2("@i", process_opt(&argc, &argv, 0)); break; @@ -649,7 +642,6 @@ usage(void) {"-d", "turn on debugging of erlc itself"}, {"-Dname", "define name"}, {"-Dname=value", "define name to have value"}, - {"-hybrid", "compile using hybrid-heap emulator"}, {"-help", "shows this help text"}, {"-I path", "where to search for include files"}, {"-M", "generate a rule for make(1) describing the dependencies"}, diff --git a/erts/etc/common/erlexec.c b/erts/etc/common/erlexec.c index 19b3bb82ef..790b0ed400 100644 --- a/erts/etc/common/erlexec.c +++ b/erts/etc/common/erlexec.c @@ -121,9 +121,11 @@ static char *plusM_other_switches[] = { /* +s arguments with values */ static char *pluss_val_switches[] = { "bt", + "bwt", "cl", "ct", "wt", + "ws", "ss", NULL }; @@ -157,20 +159,13 @@ static char *plusz_val_switches[] = { #endif #define SMP_SUFFIX ".smp" -#define HYBRID_SUFFIX ".hybrid" - -#ifdef __WIN32__ #define DEBUG_SUFFIX ".debug" -#define EMU_TYPE_SUFFIX_LENGTH (strlen(HYBRID_SUFFIX)+(strlen(DEBUG_SUFFIX))) -#else -/* The length of the longest memory architecture suffix. */ -#define EMU_TYPE_SUFFIX_LENGTH strlen(HYBRID_SUFFIX) -#endif +#define EMU_TYPE_SUFFIX_LENGTH strlen(DEBUG_SUFFIX) + /* * Define flags for different memory architectures. */ #define EMU_TYPE_SMP 0x0001 -#define EMU_TYPE_HYBRID 0x0002 #ifdef __WIN32__ #define EMU_TYPE_DEBUG 0x0004 @@ -184,7 +179,7 @@ void error(char* format, ...); * Local functions. */ -#if !defined(ERTS_HAVE_SMP_EMU) || !defined(ERTS_HAVE_HYBRID_EMU) +#if !defined(ERTS_HAVE_SMP_EMU) static void usage_notsup(const char *switchname); #endif static void usage_msg(const char *msg); @@ -367,9 +362,6 @@ add_extra_suffixes(char *prog, int type) if (type == EMU_TYPE_SMP) { p = write_str(p, SMP_SUFFIX); } - else if (type == EMU_TYPE_HYBRID) { - p = write_str(p, HYBRID_SUFFIX); - } #ifdef __WIN32__ if (dll) { p = write_str(p, DLL_EXT); @@ -535,13 +527,6 @@ int main(int argc, char **argv) emu_type_passed |= EMU_TYPE_DEBUG; emu_type |= EMU_TYPE_DEBUG; #endif - } else if (strcmp(argv[i], "-hybrid") == 0) { - emu_type_passed |= EMU_TYPE_HYBRID; -#ifdef ERTS_HAVE_HYBRID_EMU - emu_type |= EMU_TYPE_HYBRID; -#else - usage_notsup("-hybrid"); -#endif } else if (strcmp(argv[i], "-extra") == 0) { break; } @@ -552,19 +537,6 @@ int main(int argc, char **argv) erts_cpu_info_destroy(cpuinfo); cpuinfo = NULL; - if ((emu_type & EMU_TYPE_HYBRID) && (emu_type & EMU_TYPE_SMP)) { - /* - * We have a conflict. Only using explicitly passed arguments - * may solve it... - */ - emu_type &= emu_type_passed; - if ((emu_type & EMU_TYPE_HYBRID) && (emu_type & EMU_TYPE_SMP)) { - usage_msg("Hybrid heap emulator with SMP support selected. The " - "combination hybrid heap and SMP support is currently " - "not supported."); - } - } - if (malloc_lib) { if (strcmp(malloc_lib, "libc") != 0) usage("+MYm"); @@ -1115,9 +1087,6 @@ usage_aux(void) "]" #endif "] " -#ifdef ERTS_HAVE_HYBRID_EMU - "[-hybrid] " -#endif "[-make] [-man [manopts] MANPAGE] [-x] [-emu_args] " "[-args_file FILENAME] [+A THREADS] [+a SIZE] [+B[c|d|i]] [+c] " "[+h HEAP_SIZE_OPTION] [+K BOOLEAN] " @@ -1135,7 +1104,7 @@ usage(const char *switchname) usage_aux(); } -#if !defined(ERTS_HAVE_SMP_EMU) || !defined(ERTS_HAVE_HYBRID_EMU) +#if !defined(ERTS_HAVE_SMP_EMU) static void usage_notsup(const char *switchname) { @@ -1176,7 +1145,7 @@ start_epmd(char *epmd) erts_snprintf(epmd_cmd, sizeof(epmd_cmd), "%s" DIRSEP "epmd", bindir); arg1 = "-daemon"; #else - erts_snprintf(epmd_cmd, sizeof(epmd_cmd), "%s" DIRSEP "epmd -daemon", bindir); + erts_snprintf(epmd_cmd, sizeof(epmd_cmd), "\"%s" DIRSEP "epmd\" -daemon", bindir); #endif } #ifdef __WIN32__ diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c index 755e308219..6ac77e4e63 100644 --- a/erts/etc/common/heart.c +++ b/erts/etc/common/heart.c @@ -66,8 +66,7 @@ * input and output file descriptors (0 and 1). These descriptors * (and the standard error descriptor 2) must NOT be closed * explicitely by this program at termination (in UNIX it is - * taken care of by the operating system itself; in VxWorks - * it is taken care of by the spawn driver part of the Emulator). + * taken care of by the operating system itself). * * END OF FILE * @@ -75,12 +74,6 @@ * that there is no process at the other end of the connection * having the connection open for writing (end-of-file). * - * HARDWARE WATCHDOG - * - * When used with VxWorks(with CPU40), the hardware - * watchdog is enabled, making sure that the system reboots - * even if the heart port program malfunctions or the system - * is completely overloaded. */ #ifdef HAVE_CONFIG_H @@ -93,9 +86,6 @@ #include <fcntl.h> #include <process.h> #endif -#ifdef VXWORKS -#include "sys.h" -#endif /* * Implement time correction using times() call even on Linuxes @@ -116,19 +106,7 @@ #include <time.h> #include <errno.h> -#ifdef VXWORKS -# include <vxWorks.h> -# include <ioLib.h> -# include <selectLib.h> -# include <netinet/in.h> -# include <rebootLib.h> -# include <sysLib.h> -# include <taskLib.h> -# include <wdLib.h> -# include <taskHookLib.h> -# include <selectLib.h> -#endif -#if !defined(__WIN32__) && !defined(VXWORKS) +#if !defined(__WIN32__) # include <sys/types.h> # include <netinet/in.h> # include <sys/time.h> @@ -550,8 +528,7 @@ kill_old_erlang(void){ CloseHandle(erlh); } } -#elif !defined(VXWORKS) -/* Unix eh? */ +#else static void kill_old_erlang(void){ pid_t pid; @@ -570,7 +547,7 @@ kill_old_erlang(void){ } } } -#endif /* Not on VxWorks */ +#endif #ifdef __WIN32__ void win_system(char *command) @@ -653,7 +630,7 @@ do_terminate(reason) case R_ERROR: case R_CLOSED: default: -#if defined(__WIN32__) /* Not VxWorks */ +#if defined(__WIN32__) { if(!cmd[0]) { char *command = get_env(HEART_COMMAND_ENV); @@ -1026,59 +1003,6 @@ time_t timestamp(time_t *res) return r; } -#elif defined(VXWORKS) - -static WDOG_ID watchdog_id; -static volatile unsigned elapsed; -static WIND_TCB *this_task; -/* A simple variable is enough to lock the time update, as the - watchdog is run at interrupt level and never preempted. */ -static volatile int lock_time; - -static void my_delete_hook(WIND_TCB *tcb) -{ - if (tcb == this_task) { - wdDelete(watchdog_id); - watchdog_id = NULL; - taskDeleteHookDelete((FUNCPTR) &my_delete_hook); - } -} - -static void my_wd_routine(int count) -{ - if (watchdog_id != NULL) { - ++count; - if (!lock_time) { - elapsed += count; - count = 0; - } - wdStart(watchdog_id, sysClkRateGet(), - (FUNCPTR) &my_wd_routine, count); - } -} - -void init_timestamp(void) -{ - lock_time = 0; - elapsed = 0; - watchdog_id = wdCreate(); - this_task = (WIND_TCB *) taskIdSelf(); - taskDeleteHookAdd((FUNCPTR) &my_delete_hook); - wdStart(watchdog_id, sysClkRateGet(), - (FUNCPTR) &my_wd_routine, 0); -} - -time_t timestamp(time_t *res) -{ - time_t r; - ++lock_time; - r = (time_t) elapsed; - --lock_time; - if (res != NULL) - *res = r; - return r; -} - #elif defined(HAVE_GETHRTIME) void init_timestamp(void) diff --git a/erts/etc/unix/Install.src b/erts/etc/unix/Install.src index 8f40c43874..58f7b38ed0 100644 --- a/erts/etc/unix/Install.src +++ b/erts/etc/unix/Install.src @@ -66,12 +66,12 @@ then exit 1 fi -if [ ! -d $ERL_ROOT/bin ] +if [ ! -d "$ERL_ROOT/bin" ] then - mkdir $ERL_ROOT/bin + mkdir "$ERL_ROOT/bin" fi -cd $ERL_ROOT/erts-%I_VSN%/bin +cd "$ERL_ROOT/erts-%I_VSN%/bin" sed -e "s;%FINAL_ROOTDIR%;$TARGET_ERL_ROOT;" erl.src > erl chmod 755 erl @@ -79,18 +79,18 @@ chmod 755 erl # # Create start file for embedded system use, # -(cd $ERL_ROOT/erts-%I_VSN%/bin; +(cd "$ERL_ROOT/erts-%I_VSN%/bin"; sed -e "s;%FINAL_ROOTDIR%;$TARGET_ERL_ROOT;" start.src > start; chmod 755 start) -cd $ERL_ROOT/bin +cd "$ERL_ROOT/bin" -cp -p $ERL_ROOT/erts-%I_VSN%/bin/erl . -cp -p $ERL_ROOT/erts-%I_VSN%/bin/erlc . -cp -p $ERL_ROOT/erts-%I_VSN%/bin/dialyzer . -cp -p $ERL_ROOT/erts-%I_VSN%/bin/typer . -cp -p $ERL_ROOT/erts-%I_VSN%/bin/ct_run . -cp -p $ERL_ROOT/erts-%I_VSN%/bin/escript . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/erl" . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/erlc" . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/dialyzer" . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/typer" . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/ct_run" . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/escript" . # Remove in R16B ln -s ct_run run_test @@ -107,15 +107,15 @@ fi ln -s ../erts-%I_VSN%/bin/epmd epmd -cp -p $ERL_ROOT/erts-%I_VSN%/bin/run_erl . -cp -p $ERL_ROOT/erts-%I_VSN%/bin/to_erl . -cp -p $ERL_ROOT/erts-%I_VSN%/bin/start . -sed -e "s;%EMU%;%EMULATOR%%EMULATOR_NUMBER%;" $ERL_ROOT/erts-%I_VSN%/bin/start_erl.src > start_erl +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/run_erl" . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/to_erl" . +cp -p "$ERL_ROOT/erts-%I_VSN%/bin/start" . +sed -e "s;%EMU%;%EMULATOR%%EMULATOR_NUMBER%;" "$ERL_ROOT/erts-%I_VSN%/bin/start_erl.src" > start_erl chmod 755 start_erl echo "" -echo %I_VSN% %I_SYSTEM_VSN% > $ERL_ROOT/releases/start_erl.data -sed -e "s;%ERL_ROOT%;$TARGET_ERL_ROOT;" $ERL_ROOT/releases/RELEASES.src > $ERL_ROOT/releases/RELEASES +echo %I_VSN% %I_SYSTEM_VSN% > "$ERL_ROOT/releases/start_erl.data" +sed -e "s;%ERL_ROOT%;$TARGET_ERL_ROOT;" "$ERL_ROOT/releases/RELEASES.src" > "$ERL_ROOT/releases/RELEASES" if [ "$start_option" = "query" ] then @@ -147,10 +147,10 @@ cp -p ../releases/%I_SYSTEM_VSN%/$Name.script start.script # Fixing the man pages # -if [ -d $ERL_ROOT/man ] +if [ -d "$ERL_ROOT/man" ] then - cd $ERL_ROOT - ./misc/format_man_pages $ERL_ROOT + cd "$ERL_ROOT" + ./misc/format_man_pages "$ERL_ROOT" fi exit 0 diff --git a/erts/etc/unix/cerl.src b/erts/etc/unix/cerl.src index 0b2d6512ea..ffd48d5811 100644 --- a/erts/etc/unix/cerl.src +++ b/erts/etc/unix/cerl.src @@ -227,7 +227,7 @@ done PATH=$BINDIR:$ROOTDIR/bin:$PATH EXEC=$BINDIR/erlexec -PROGNAME="$PROGNAME $cargs" +PROGNAME="$PROGNAME$cargs" EMU="$EMU$TYPE" EMU_NAME=`$EXEC -emu_name_exit $eeargs` @@ -302,7 +302,7 @@ else # Set annotation level for gdb in emacs 22 and higher. emacs_major=`$EMACS --version | head -1 | sed 's,^[^0-9]*\([0-9]*\).*,\1,g'` if [ '!' -z "$emacs_major" -a $emacs_major -gt 21 ]; then - GDBARGS="--annotate=3 " + GDBARGS="--annotate=1 " fi gdbcmd="$gdbcmd $GDBBP \ (insert-string \"source $ROOTDIR/erts/etc/unix/etp-commands\") \ diff --git a/erts/etc/unix/erl.src.src b/erts/etc/unix/erl.src.src index 50603f12f4..fa187c5509 100644 --- a/erts/etc/unix/erl.src.src +++ b/erts/etc/unix/erl.src.src @@ -17,7 +17,7 @@ # # %CopyrightEnd% # -ROOTDIR=%FINAL_ROOTDIR% +ROOTDIR="%FINAL_ROOTDIR%" BINDIR=$ROOTDIR/erts-%VSN%/bin EMU=%EMULATOR%%EMULATOR_NUMBER% PROGNAME=`echo $0 | sed 's/.*\///'` @@ -25,4 +25,4 @@ export EMU export ROOTDIR export BINDIR export PROGNAME -exec $BINDIR/erlexec ${1+"$@"} +exec "$BINDIR/erlexec" ${1+"$@"} diff --git a/erts/etc/unix/etp-commands b/erts/etc/unix/etp-commands index 46d35a7f76..aed8a6461a 100644 --- a/erts/etc/unix/etp-commands +++ b/erts/etc/unix/etp-commands @@ -1022,16 +1022,17 @@ define etp-cp-1 # Non-reentrant # set $etp_cp = (Eterm)($arg0) - set $etp_cp_low = modules - set $etp_cp_high = $etp_cp_low + num_loaded_modules - set $etp_cp_mid = mid_module + set $etp_ranges = &r[(int)the_active_code_index] + set $etp_cp_low = $etp_ranges->modules + set $etp_cp_high = $etp_cp_low + $etp_ranges->n + set $etp_cp_mid = (Range*)$etp_ranges->mid set $etp_cp_p = 0 # while $etp_cp_low < $etp_cp_high if $etp_cp < $etp_cp_mid->start set $etp_cp_high = $etp_cp_mid else - if $etp_cp > $etp_cp_mid->end + if $etp_cp > (BeamInstr*)$etp_cp_mid->end set $etp_cp_low = $etp_cp_mid + 1 else set $etp_cp_p = $etp_cp_low = $etp_cp_high = $etp_cp_mid diff --git a/erts/etc/unix/run_erl.c b/erts/etc/unix/run_erl.c index 8db8e09bee..6b350e8bd5 100644 --- a/erts/etc/unix/run_erl.c +++ b/erts/etc/unix/run_erl.c @@ -126,7 +126,7 @@ /* prototypes */ static void usage(char *); static int create_fifo(char *name, int perm); -static int open_pty_master(char **name); +static int open_pty_master(char **name, int *sfd); static int open_pty_slave(char *name); static void pass_on(pid_t); static void exec_shell(char **); @@ -150,6 +150,10 @@ static int write_all(int fd, const char* buf, int len); static int extract_ctrl_seq(char* buf, int len); static void set_window_size(unsigned col, unsigned row); +static ssize_t sf_write(int fd, const void *buffer, size_t len); +static ssize_t sf_read(int fd, void *buffer, size_t len); +static int sf_open(const char *path, int flags, mode_t mode); +static int sf_close(int fd); #ifdef DEBUG static void show_terminal_settings(struct termios *t); @@ -216,7 +220,7 @@ static char* outbuf_in; int main(int argc, char **argv) { int childpid; - int sfd; + int sfd = -1; int fd; char *p, *ptyslave=NULL; int i = 1; @@ -338,9 +342,9 @@ int main(int argc, char **argv) strn_cat(fifo2, sizeof(fifo2), ".w"); /* Check that nobody is running run_erl already */ - if ((fd = open (fifo2, O_WRONLY|DONT_BLOCK_PLEASE, 0)) >= 0) { + if ((fd = sf_open(fifo2, O_WRONLY|DONT_BLOCK_PLEASE, 0)) >= 0) { /* Open as client succeeded -- run_erl is already running! */ - close(fd); + sf_close(fd); if (calculated_pipename) { ++highest_pipe_num; strn_catf(pipename, sizeof(pipename), "%s.%d", @@ -361,7 +365,7 @@ int main(int argc, char **argv) * Open master pseudo-terminal */ - if ((mfd = open_pty_master(&ptyslave)) < 0) { + if ((mfd = open_pty_master(&ptyslave, &sfd)) < 0) { ERRNO_ERR0(LOG_ERR,"Could not open pty master"); exit(1); } @@ -376,7 +380,7 @@ int main(int argc, char **argv) } if (childpid == 0) { /* Child */ - close(mfd); + sf_close(mfd); /* disassociate from control terminal */ #ifdef USE_SETPGRP_NOARGS /* SysV */ setpgrp(); @@ -386,15 +390,30 @@ int main(int argc, char **argv) setsid(); #endif /* Open the slave pty */ - if ((sfd = open_pty_slave(ptyslave)) < 0) { - ERRNO_ERR1(LOG_ERR,"Could not open pty slave '%s'", ptyslave); - exit(1); + if (sfd < 0) { + /* not allocated by open_pty_master */ + if ((sfd = open_pty_slave(ptyslave)) < 0) { + ERRNO_ERR1(LOG_ERR,"Could not open pty slave '%s'", ptyslave); + exit(1); + } + /* But sfd may be one of the stdio fd's now, and we should be unmodern and not use dup2... */ + /* easiest to dup it up... */ + while (sfd < 3) { + sfd = dup(sfd); + } } - /* But sfd may be one of the stdio fd's now, and we should be unmodern and not use dup2... */ - /* easiest to dup it up... */ - while (sfd < 3) { - sfd = dup(sfd); +#if defined(HAVE_OPENPTY) && defined(TIOCSCTTY) + else { + /* sfd is from open_pty_master + * openpty -> fork -> login_tty (forkpty) + * + * It would be preferable to implement a portable + * forkpty instead of open_pty_master / open_pty_slave + */ + /* login_tty(sfd); <- FAIL */ + ioctl(sfd, TIOCSCTTY, (char *)NULL); } +#endif #ifndef NO_SYSLOG /* Before fiddling with file descriptors we make sure syslog is turned off @@ -407,14 +426,14 @@ int main(int argc, char **argv) #endif /* Close stdio */ - close(0); - close(1); - close(2); + sf_close(0); + sf_close(1); + sf_close(2); if (dup(sfd) != 0 || dup(sfd) != 1 || dup(sfd) != 2) { status("Cannot dup\n"); } - close(sfd); + sf_close(sfd); exec_shell(argv+off_argv); /* exec_shell expects argv[2] to be */ /* the command name, so we have to */ /* adjust. */ @@ -466,7 +485,7 @@ static void pass_on(pid_t childpid) * We can't open the writing side because nobody is reading and * we'd either hang or get an error. */ - if ((rfd = open(fifo2, O_RDONLY|DONT_BLOCK_PLEASE, 0)) < 0) { + if ((rfd = sf_open(fifo2, O_RDONLY|DONT_BLOCK_PLEASE, 0)) < 0) { ERRNO_ERR1(LOG_ERR,"Could not open FIFO '%s' for reading.", fifo2); exit(1); } @@ -559,7 +578,7 @@ static void pass_on(pid_t childpid) char* buf = outbuf_first(); len = outbuf_size(); - written = write(wfd, buf, len); + written = sf_write(wfd, buf, len); if (written < 0 && errno == EAGAIN) { /* * Nothing was written - this is really strange because @@ -570,7 +589,7 @@ static void pass_on(pid_t childpid) * A write error. Assume that to_erl has terminated. */ clear_outbuf(); - close(wfd); + sf_close(wfd); wfd = 0; } else { /* Delete the written part (or all) from the buffer. */ @@ -585,10 +604,10 @@ static void pass_on(pid_t childpid) #ifdef DEBUG status("Pty master read; "); #endif - if ((len = read(mfd, buf, BUFSIZ)) <= 0) { - close(rfd); - if(wfd) close(wfd); - close(mfd); + if ((len = sf_read(mfd, buf, BUFSIZ)) <= 0) { + sf_close(rfd); + if(wfd) sf_close(wfd); + sf_close(mfd); unlink(fifo1); unlink(fifo2); if (len < 0) { @@ -619,10 +638,10 @@ static void pass_on(pid_t childpid) #ifdef DEBUG status("FIFO read; "); #endif - if ((len = read(rfd, buf, BUFSIZ)) < 0) { - close(rfd); - if(wfd) close(wfd); - close(mfd); + if ((len = sf_read(rfd, buf, BUFSIZ)) < 0) { + sf_close(rfd); + if(wfd) sf_close(wfd); + sf_close(mfd); unlink(fifo1); unlink(fifo2); ERRNO_ERR0(LOG_ERR,"Error in reading from FIFO."); @@ -631,8 +650,8 @@ static void pass_on(pid_t childpid) if(!len) { /* to_erl closed its end of the pipe */ - close(rfd); - rfd = open(fifo2, O_RDONLY|DONT_BLOCK_PLEASE, 0); + sf_close(rfd); + rfd = sf_open(fifo2, O_RDONLY|DONT_BLOCK_PLEASE, 0); if (rfd < 0) { ERRNO_ERR1(LOG_ERR,"Could not open FIFO '%s' for reading.", fifo2); exit(1); @@ -645,11 +664,11 @@ static void pass_on(pid_t childpid) * from to_erl, to_erl should already be reading this pipe - open * should succeed. But in case of error, we just ignore it. */ - if ((wfd = open(fifo1, O_WRONLY|DONT_BLOCK_PLEASE, 0)) < 0) { + if ((wfd = sf_open(fifo1, O_WRONLY|DONT_BLOCK_PLEASE, 0)) < 0) { status("Client expected on FIFO %s, but can't open (len=%d)\n", fifo1, len); - close(rfd); - rfd = open(fifo2, O_RDONLY|DONT_BLOCK_PLEASE, 0); + sf_close(rfd); + rfd = sf_open(fifo2, O_RDONLY|DONT_BLOCK_PLEASE, 0); if (rfd < 0) { ERRNO_ERR1(LOG_ERR,"Could not open FIFO '%s' for reading.", fifo2); exit(1); @@ -683,9 +702,9 @@ static void pass_on(pid_t childpid) } else if (len>0 && write_all(mfd, buf, len) != len) { ERRNO_ERR0(LOG_ERR,"Error in writing to terminal."); - close(rfd); - if(wfd) close(wfd); - close(mfd); + sf_close(rfd); + if(wfd) sf_close(wfd); + sf_close(mfd); exit(1); } } @@ -797,7 +816,7 @@ static int open_log(int log_num, int flags) /* Create or continue on the current log file */ sn_printf(buf, sizeof(buf), "%s/%s%d", log_dir, LOG_STUBNAME, log_num); - if((lfd = open(buf, flags, LOG_PERM))<0){ + if((lfd = sf_open(buf, flags, LOG_PERM))<0){ ERRNO_ERR1(LOG_ERR,"Can't open log file '%s'.", buf); exit(1); } @@ -841,7 +860,7 @@ static void write_to_log(int* lfd, int* log_num, char* buf, int len) size = lseek(*lfd,0,SEEK_END); if(size+len > log_maxsize) { - close(*lfd); + sf_close(*lfd); *log_num = next_log(*log_num); *lfd = open_log(*log_num, O_RDWR|O_CREAT|O_TRUNC|O_SYNC); } @@ -872,7 +891,7 @@ static int create_fifo(char *name, int perm) * Find a master device, open and return fd and slave device name. */ -static int open_pty_master(char **ptyslave) +static int open_pty_master(char **ptyslave, int *sfdp) { int mfd; @@ -882,7 +901,9 @@ static int open_pty_master(char **ptyslave) # ifdef HAVE_WORKING_POSIX_OPENPT if ((mfd = posix_openpt(O_RDWR)) >= 0) { # elif defined(__sun) && defined(__SVR4) - if ((mfd = open("/dev/ptmx", O_RDWR)) >= 0) { + mfd = sf_open("/dev/ptmx", O_RDWR, 0); + + if (mfd >= 0) { # endif if ((*ptyslave = ptsname(mfd)) != NULL && grantpt(mfd) == 0 && @@ -890,12 +911,12 @@ static int open_pty_master(char **ptyslave) return mfd; } - close(mfd); + sf_close(mfd); } /* fallback to openpty if it exist */ #endif -#ifdef HAVE_OPENPTY +#if defined(HAVE_OPENPTY) # ifdef PATH_MAX # define SLAVE_SIZE PATH_MAX # else @@ -903,11 +924,8 @@ static int open_pty_master(char **ptyslave) # endif { static char slave[SLAVE_SIZE]; - int sfd; # undef SLAVE_SIZE - - if (openpty(&mfd, &sfd, slave, NULL, NULL) == 0) { - close(sfd); + if (openpty(&mfd, sfdp, slave, NULL, NULL) == 0) { *ptyslave = slave; return mfd; } @@ -939,7 +957,8 @@ static int open_pty_master(char **ptyslave) for (minor = minorchars; *minor; minor++) { ptyname[10] = *minor; - if ((mfd = open(ptyname, O_RDWR, 0)) >= 0) { + + if ((mfd = sf_open(ptyname, O_RDWR, 0)) >= 0) { ptyname[9] = 's'; *ptyslave = ptyname; return mfd; @@ -957,7 +976,7 @@ static int open_pty_master(char **ptyslave) ptyname[13] = *major; for (minor = minorchars; *minor; minor++) { ptyname[14] = *minor; - if ((mfd = open(ptyname, O_RDWR, 0)) >= 0) { + if ((mfd = sf_open(ptyname, O_RDWR, 0)) >= 0) { ttyname[12] = *major; ttyname[13] = *minor; *ptyslave = ttyname; @@ -976,7 +995,7 @@ static int open_pty_master(char **ptyslave) ptyname[8] = *major; for (minor = minorchars; *minor; minor++) { ptyname[9] = *minor; - if ((mfd = open(ptyname, O_RDWR, 0)) >= 0) { + if ((mfd = sf_open(ptyname, O_RDWR, 0)) >= 0) { ptyname[5] = 't'; *ptyslave = ptyname; return mfd; @@ -993,7 +1012,7 @@ static int open_pty_slave(char *name) int sfd; struct termios tty_rmode; - if ((sfd = open(name, O_RDWR, 0)) < 0) { + if ((sfd = sf_open(name, O_RDWR, 0)) < 0) { return -1; } @@ -1120,7 +1139,7 @@ static void daemon_init(void) would be backward incompatible */ for (i = 0; i < maxfd; ++i ) { - close(i); + sf_close(i); } OPEN_SYSLOG(); @@ -1246,7 +1265,7 @@ static int write_all(int fd, const char* buf, int len) int left = len; int written; for (;;) { - written = write(fd,buf,left); + written = sf_write(fd,buf,left); if (written == left) { return len; } @@ -1258,6 +1277,36 @@ static int write_all(int fd, const char* buf, int len) } } +static ssize_t sf_read(int fd, void *buffer, size_t len) { + ssize_t n = 0; + + do { n = read(fd, buffer, len); } while (n < 0 && errno == EINTR); + + return n; +} + +static ssize_t sf_write(int fd, const void *buffer, size_t len) { + ssize_t n = 0; + + do { n = write(fd, buffer, len); } while (n < 0 && errno == EINTR); + + return n; +} + +static int sf_open(const char *path, int type, mode_t mode) { + int fd = 0; + + do { fd = open(path, type, mode); } while(fd < 0 && errno == EINTR); + + return fd; +} +static int sf_close(int fd) { + int res = 0; + + do { res = close(fd); } while(fd < 0 && errno == EINTR); + + return res; +} /* Extract any control sequences that are ment only for run_erl * and should not be forwarded to the pty. */ diff --git a/erts/etc/vxworks/README.VxWorks b/erts/etc/vxworks/README.VxWorks deleted file mode 100644 index 299e35b513..0000000000 --- a/erts/etc/vxworks/README.VxWorks +++ /dev/null @@ -1,350 +0,0 @@ - - %CopyrightBegin% - - Copyright Ericsson AB 1997-2009. 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% - ------------------------------------------------------------------------ -README, Erlang/OTP R11B for VxWorks on PPC860 and PPC603 ------------------------------------------------------------------------ -20060515 -- Patrik Nyblom, [email protected] - -R11B is a libraries only release for VxWorks. Only the libraries of -erl_interface (ei+erl_inteface) and ic are expected to be used. Still -the whole erlang system is distributed, although no support will be -given for anything else but the libraries. The information in this -file still applies to the full erlang distribution and parts of it are -therefore somewhat irrelevant to commercial users. - - -Included OTP applications -------------------------- - -appmon -asn1 -compiler -cosEvent -cosNotification -cosTime -cosTransaction -debugger -erl_interface -erts -eva [1] -ic -inets [2] -jinterface -kernel -mesh -mnemosyne -mnesia [1] -mnesia_session -orber -os_mon -pman -runtime_tools -sasl -snmp -stdlib -tools -tv - -[1] Only ram_copies work, The VxWorks filesystems are not - reliable enough for disk_copies to be fully supported. -[2] CGI scripts do not work on VxWorks. - -Omitted applications --------------------- - -crypto -emacs -etk -gs -odbc -parsetools -toolbar -ssl -megaco -webtools - -As `crypto' and `ssl' provides cryptographic functionality to `inets' -and `snmp', the latter applications will not handle cryptography on -VxWorks. - -Graphical interfaces --------------------- - -For applications using graphical interfaces, only the backend part works. - -Compilers ---------- - -All compilers are expected to be run on a cross host. The VxWorks -systems memory capabilities are too restricting to allow native -compiling. The expected host system is a Sun Solaris machine, although -Erlang compilation may be done on most platforms. - -Supported boards and configuration (only libraries supported) ----------------------------------- -The following boards and configurations are supported: - -* Force PowerCore 603 with Force pcore603 BSP and VxWorks 3.5.1 (no - SENS or SENS 1.1 + SPR23938) and a minimum of 32 Mb memory. - -* Force Powercore 750 with Force pcore750 BSP and VxWorks 3.5.1 (no - SENS or SENS 1.1 + SPR23938) and a minimum of 32 Mb memory. - -* PSS Core PPC860 processors, only erl_interface (too small main memory). - -Most PowerPC boards with FPU are expected to work, but will need to be -tested by OTP to be fully supported. - -The PPC603 build has been compiled with Wind River's `-mlongcall' -flag (SPR25893) to support arbitrary function calls across more -than 32 MB of memory. - -The PPC860 (PowerQuicc) has no FPU and requires a separate build. - -For Erlang to run, the Wind kernel has to be configured with a minimum -of these variables defined in config.h (or by the Tornado -configuration tool): - - INCLUDE_ANSI_ALL - INCLUDE_ENV_VARS - INCLUDE_EXC_HANDLING - INCLUDE_EXC_TASK - INCLUDE_FLOATING_POINT - INCLUDE_FORMATTED_IO - INCLUDE_IO_SYSTEM - INCLUDE_LOADER - INCLUDE_NETWORK - INCLUDE_NET_INIT - INCLUDE_NET_SHOW - INCLUDE_NET_SYM_TBL or INCLUDE_STANDALONE_SYM_TBL - INCLUDE_PIPES - INCLUDE_POSIX_FTRUNC - INCLUDE_RLOGIN or INCLUDE_TELNET (for pty's only) - INCLUDE_SELECT - INCLUDE_SEM_BINARY - INCLUDE_SEM_COUNTING - INCLUDE_SEM_MUTEX - INCLUDE_SHELL (*) - INCLUDE_SHOW_ROUTINES - INCLUDE_SIGNALS - INCLUDE_STARTUP_SCRIPT (*) - INCLUDE_STDIO - INCLUDE_SYM_TBL - INCLUDE_TASK_HOOKS - INCLUDE_TASK_VARS - INCLUDE_TTY_DEV - INCLUDE_UNLOADER - INCLUDE_NFS or INCLUDE_RAMDRV or INCLUDE_DOSFS (i.e. a file system, - possibly read-only) (**) - -(*) Needed for the example startup script, not actually needed in production if - erlang is set up by a c routine called from usrConfig.c. -(**) INCLUDE_NFS usually requires the NFS_USER_ID and NFS_GROUP_ID variables - to be set in config.h - -As an erlang system may open a lot of files, it is recommended to raise the -default NUM_FILES variable to something like 256 in config.h like this: - #ifdef NUM_FILES - #undef NUM_FILES - #endif - #define NUM_FILES 256 - -The SENS stack *has* to be of version 1.1 or higher, 1.0 is *not* -supported and will not work reliably. Upgrades as well as the patch -for SPR23938 can be found at www.wrs.com (i.e. WindSurf). Also, the -following constants in $WIND_BASE/target/h/netBufLib.h has to be -raised to a value of at least four times the default: - - NUM_NET_MBLKS - NUM_64 - NUM_128 - NUM_256 - NUM_512 - NUM_1024 - NUM_2048 - - NUM_SYS_64 - NUM_SYS_128 - NUM_SYS_256 - NUM_SYS_512 - -Use the show routines mbufShow and netStackSysPoolShow to verify that -these pools are not exhausted. - -Installation ------------- - -To install Erlang on a VxWorks card, the following knowledge is -expected: - -* VxWorks installation and configuration. - -* Network (TCP/IP) configuration. - -* Erlang basic operation and configuration. - -There is no specific install script for erlang on the VxWorks -platform. There is however an example VxWorks startup file named -erts-5.0.1/bin/erl_script.sam under the root of an unpacked -release. There may of course be other things to do in the start -script, like using the rdate program in the erlang distribution to get -a correct date and set the TIMEZONE variable. - -Please consult the "Embedded System" documentation for further -information on installation. - -Known Bugs and problems ------------------------ - -We have found the VxWorks/NFS client file system to be unreliable. -Important file operations like rename, ftruncate, cd and unlink -doesn't always work as expected. Therefore more complex file using -parts of OTP, like DETS and disk based mnesia tables cannot be used -reliably with NFS. Lowering the NFS cache size (global variable -nfsCacheSize) to 512 gives a more reliable NFS client, but to disk -base the mnesia tables over NFS is still not a good idea, especially -as disk based mnesia tables are not supported on VxWorks. Another -problem with VxWorks file systems is that the error codes they produce -are not consistent. We have worked around this problem by mapping the -codes to POSIX ones, by doing this we make the VxWorks Erlang platform -behave similarly to the UNIX and Windows implementations. - -The rename and ftruncate operations over NFS are emulated using -copying of files. This is mainly for our own test suites and it is not -recommended to use file:rename and/or file:ftruncate on NFS file -systems in production. - -Floating point operations is somewhat faulty. For instance, testing -floating point numbers for equality should be done with care. This is -actually not a bug, IEEE specifies no equality among floating point -numbers. - -Memory handling ---------------- - -Please read the erl_set_memory_block(3) manual page in the ERTS -documentation for information concerning memory handling in the erlang -emulator. Also please observe that reclaim.o has to be loaded and -reclaim_init() called before any other erlang routines are loaded and -started. If one wish to use the resource reclamation routines in other -programs, refer to the header file in `erts-5.0.1/include/reclaim.h'. -Including that file in your C source makes malloc/realloc/free and -open/fopen/socket/close etc be redefined to routines that makes the -memory and files be free'd/closed when the task exits. Still, -reclaim_init() *has* to be called before any program that uses this is -started. - -Using heart ------------ - -The default behavior of the heart object file that is part of the -distribution is that it reboots the target when the Erlang process -hasn't given it a heart beat in 60 seconds. The normal heart beat rate -is one beat per five seconds. This makes an effective "software -watchdog" but there is really no substitute for the real thing --- a -hardware watchdog. If you want to add a hardware watchdog to the -system please contact us for directions. If you want to disable the -reboot you may set the environment variable HEART_DONT_REBOOT (see the -example erlang start script, erl). Please note that if you DO want the -card to reboot you mustn't define HEART_DONT_REBOOT at all. E.g. to -disable heart reboot you may include the following line in the start -script (as is indeed the case with the example start script). - - putenv "HEART_DONT_REBOOT=1" - -A few words on writing port program and dynamically loaded drivers for VxWorks ------------------------------------------------------------------------------- - -VxWorks has one name-space for all symbols. This makes it harder to -write C programs whose global symbols doesn't interfere with each -other. It is a good rule to avoid all globally visible symbols that -are not absolutely necessary. Due to these facts we use the following -naming rules that are crucial to follow. (there are more issues -involved but the issues described here is a good beginning). - -Port programs must have a function with the same name as the object -file. E.g. if you have an object file named `port_test.o' it must -contain a globally visible function named `port_test'. This is the -function that will be called when you output data from Erlang to the -port. (The object file, in this example, should be named -`port_test.o', but `port_test' will also do). - -Also, in an embedded system, it is recommended to load the port -program into the system before the port program is used. This is to -avoid the real time degradation dynamical linking in runtime would -introduce. Use VxWorks command ld < "port_prg" to accomplish this. - -Dynamically linked drivers must have a function with the same name as -the object file with the added suffix `_init'. We recommend the use of -the macro DRIVER_INIT in `driver.h'. E.g. if you have an object file -named `echo_drv.eld' it must contain a globally visible function -`echo_drv_init'. (The object file, in this example, should be named -`echo_drv.eld' (`eld' is short for Erlang Loadable Driver), but -`echo_drv.o' and `echo_drv' will both also do). It is also very -important to initialize all unused function pointer in the -`driver_entry' struct to NULL (see example below). - -Example of dynamically linked driver ------------------------------------- - -#include <stdio.h> -#include "driver.h" - -static int erlang_port; -static long echo_start(); -static int echo_stop(), echo_read(); - -static struct driver_entry echo_driver_entry = { - null_func, - echo_start, - echo_stop, - echo_read, - null_func, - null_func, - "echo_drv", - null_func -}; - -int DRIVER_INIT(echo_drv)(void *handle) -{ - erlang_port = -1; - - echo_driver_entry.handle = handle; - return (int) &echo_driver_entry; -} - -static long echo_start(long port,char *buf) -{ - if (erlang_port != -1) { - return -1; - } - - erlang_port = port; - return port; -} - -static int echo_read(long port, char *buf, int count) -{ - return driver_output(erlang_port, buf, count); -} - -static int echo_stop() -{ - return erlang_port = -1; -} diff --git a/erts/etc/vxworks/erl.exec.c b/erts/etc/vxworks/erl.exec.c deleted file mode 100644 index 6b45ebaa39..0000000000 --- a/erts/etc/vxworks/erl.exec.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. 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% - */ -/* - A simpified version of the 'erl.exec' "startup script". - Called (e.g. from VxWorks shell) with all arguments in a - single string, e.g.: erl "-name thisnode -s mymod myfunc". - These arguments are handled as in 'erl.exec': - -name - -sname - -noshell - -noinput - anything else is just passed on to the emulator. Note that there - is no automatic start of epmd, that -oldshell is implicit, and - that you need to set current directory appropriately if you want - auto-load of port programs -*/ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#ifndef DEFAULT_HOMEDIR /* used if environment HOME isn't set */ -#define DEFAULT_HOMEDIR "/" -#endif - -#define ARGLEN 2048 /* Total length of args passed to erl_main */ -#define ARGMAX 64 /* Max no of "extra" args */ - -static char *erl_cmd = "erl_main -n "; - -static toomuch() -{ - fprintf(stderr, "erl: Too many arguments\n"); - return(-1); -} - -static toolittle(arg) -char *arg; -{ - fprintf(stderr, "erl.exec: Missing argument for %s\n", arg); - return(-1); -} - -erl_exec(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) -int arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10; -{ - char *shell = "-oldshell ", *noshell = "", - *home, *rootdir, *bindir, *progname; - char cmd[ARGLEN], eargs[ARGLEN], iargs[ARGLEN]; - char *args[ARGMAX], *arglast = NULL, *argp; - int nargs = 0, len, i; - - if ((rootdir = getenv("ROOTDIR")) == NULL || - (bindir = getenv("BINDIR")) == NULL || - (progname = getenv("PROGNAME")) == NULL) { - fprintf(stderr, "erl.exec: ROOTDIR, BINDIR, and PROGNAME must be set."); - return -1; - } - eargs[0] = '\0'; - iargs[0] = '\0'; - if ((home = getenv("HOME")) == NULL) - home = DEFAULT_HOMEDIR; - argp = strtok_r((char *)arg1, " \t", &arglast); - while (argp != NULL) { - if (strcmp(argp, "-name") == 0) { - if ((argp = strtok_r((char *)NULL, " \t", &arglast)) == NULL) - return(toolittle("-name")); - strcat(iargs, "-name "); - strcat(iargs, argp); - strcat(iargs, " "); - } else if (strcmp(argp, "-sname") == 0) { - if ((argp = strtok_r((char *)NULL, " \t", &arglast)) == NULL) - return(toolittle("-sname")); - strcat(iargs, "-sname "); - strcat(iargs, argp); - strcat(iargs, " "); - } else if (strcmp(argp, "-noshell") == 0) { - strcat(iargs, "-noshell -noinp_shell "); - } else if (strcmp(argp, "-noinput") == 0) { - strcat(iargs, "-noshell -noinput "); - } else { - if (nargs > ARGMAX - 1) - return(toomuch()); - args[nargs++] = argp; - } - argp = strtok_r((char *)NULL, " \t", &arglast); - } - strcpy(cmd, erl_cmd); - strcat(cmd, eargs); - strcat(cmd, " -- -root "); - strcat(cmd, rootdir); - strcat(cmd, " -progname "); - strcat(cmd, progname); - strcat(cmd, " -- "); - strcat(cmd, "-home "); - strcat(cmd, home); - strcat(cmd, " "); - strcat(cmd, iargs); - - len = strlen(cmd); - for (i = 0; i < nargs; i++) { - if (len + strlen(args[i]) + 2 >= ARGLEN) - return(toomuch()); - cmd[len++] = ' '; - strcpy(&cmd[len], args[i]); - len += strlen(args[i]); - } - argcall(cmd); -} - diff --git a/erts/etc/vxworks/erl_io.c b/erts/etc/vxworks/erl_io.c deleted file mode 100644 index 0032b77079..0000000000 --- a/erts/etc/vxworks/erl_io.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. 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% - */ -/* Some stuff to let the Erlang and VxWorks shells coexist peacefully. - Basically, run Erlang as a spawned task with input redirected to - the slave side of a pseudo-tty, and connect explicitly to the master - side of the pseudo-tty to send input to Erlang when desired. */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include <stdio.h> -#include <ioLib.h> -#include <taskLib.h> -#include <ptyDrv.h> - -extern int spTaskPriority, spTaskOptions; - -#define TBUFSIZ 512 - -#define DEFAULT_STACK_SIZE 100000 - -static int slavefd = -1, masterfd = -1; -static run_erl(); - -/* Frontend to the Erlang startup function - callable from VxWorks shell - or script. 'arg' is actually a string passed to the real startup. */ -start_erl(arg) -int arg; -{ - int stacksize; - char *stackenv; - - /* create and open the pty - we want the master side to be open - all the time, since closing it probably generates EOF on the - slave side */ - (void)ptyDevCreate("/pty/erlang.", TBUFSIZ, TBUFSIZ); - if (slavefd != -1) - (void)close(slavefd); - slavefd = open("/pty/erlang.S", O_RDONLY, 0); - if (masterfd != -1) - (void)close(masterfd); - masterfd = open("/pty/erlang.M", O_WRONLY, 0); - - /* flush any old leftover garbage */ - (void) ioctl(masterfd, FIOFLUSH, 0); - if ((stackenv = getenv("ERLSTACKSIZE")) == NULL) - stacksize = DEFAULT_STACK_SIZE; - else - stacksize = atoi(stackenv); - /* spawn Erlang, via stub below */ - return(taskSpawn("erlang", spTaskPriority, spTaskOptions, stacksize, - run_erl, arg, 0,0,0,0,0,0,0,0,0)); -} - -/* Little stub that runs in the spawned task - we need this to redirect - stdin reliably (redirections aren't "inherited" in VxWorks) */ -static -run_erl(arg) -int arg; -{ - ioTaskStdSet(0, 0, slavefd); /* redirect stdin to slave side of pty */ - - /* We don't want to redirect stdout/err since no one will be reading - from the master side (to_erl - and the open()s above - could be - made bidirectional, but still the master side would only be read - when to_erl was running), and output can eventually fill the pty - buffer and cause the Erlang system to block. Not redirecting - stdout/err will have the effect that output from Erlang, e.g. the - shell prompt, will appear on console/rlogin/whatever even when - to_erl isn't running, which may be confusing - can't win 'em all... */ - - erl_exec(arg, 0,0,0,0,0,0,0,0); /* call the real startup */ -} - -/* Function callable from VxWorks shell to talk to Erlang - stop talking - and return to VxWorks shell through ^D (EOF) */ -to_erl() -{ - char buf[TBUFSIZ]; - int cc; - - if (masterfd == -1) { /* sanity check */ - fprintf(stderr, "Must start_erl first!\n"); - return(-1); - } - while ((cc = read(0, buf, TBUFSIZ)) > 0) /* just pass everything through */ - if (write(masterfd, buf, cc) != cc) { - fprintf(stderr, "Write to Erlang failed!\n"); - return(-1); - } - return(cc); -} diff --git a/erts/etc/vxworks/erl_script.sam.in b/erts/etc/vxworks/erl_script.sam.in deleted file mode 100644 index 81c2b0128d..0000000000 --- a/erts/etc/vxworks/erl_script.sam.in +++ /dev/null @@ -1,100 +0,0 @@ -# -# %CopyrightBegin% -# -# Copyright Ericsson AB 1997-2009. 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% -# -# -# erl_script.sam -# Sample VxWorks script to start Erlang -# -# Note! This is not a complete or ready to use VxWorks startup script, -# rather an example of what You should add to Your existing startupscript -# to execute the erlang emulator at boot. -# -# When writing Your own script to start erlang, the paths to -# the binaries have to be changed to reflect your system. -# -# The ROOTDIR variable should not point to a ftp or rcp filesystem unless -# the erlang machine is run in embedded mode. Loading of modules -# is far to slow if the erlang binaries are not placed on a real filesystem -# like NFS or any type of local filesystem. -# - -# -# Load modules -# - -# -# First load and initiate the reclaim facility -# -ld </home/tornado/erlvxworks/erts-%VSN%/bin/reclaim.o -reclaim_init() - -# -# Now load the runtime system -# -ld </home/tornado/erlvxworks/erts-%VSN%/bin/jam -ld </home/tornado/erlvxworks/erts-%VSN%/bin/erl.exec -ld </home/tornado/erlvxworks/erts-%VSN%/bin/erl_io -ld </home/tornado/erlvxworks/erts-%VSN%/bin/vxcall -ld </home/tornado/erlvxworks/erts-%VSN%/bin/heart -ld </home/tornado/erlvxworks/erts-%VSN%/bin/epmd - -# -# Stack sizes -# -putenv "ERLSTACKSIZE=100000" -putenv "ERLPORTSTACKSIZE=100000" - -# -# Activate Round robin scheduling -# -kernelTimeSlice 1 - -# -# Distribution -# The VxWorks machines host name -sethostname "sb001", 5 -# Erlangs internal resolver -putenv "ERLRESCONF=/home/tornado/erlvxworks/erts-%VSN%/bin/resolv.conf" - -# -# Start epmd (for distribution) -# -start_epmd "-daemon" - -# -# Misc environment variables -# -putenv "ROOTDIR=/home/tornado/erlvxworks" -putenv "BINDIR=/home/tornado/erlvxworks/erts-%VSN%/bin" -putenv "PROGNAME=erl" -putenv "HOME=/home/tornado/erlvxworks" - -# -# Set heart no reboot mode (to make heart reboot - -# don't define HEART_DONT_REBOOT at all) -# -putenv "HEART_DONT_REBOOT=1" - -# To get fullsweep garbage collection on systems with -# very limited memory, set ERL_FULLSWEEP_AFTER to "0": -# putenv "ERL_FULLSWEEP_AFTER=0" - -# -# Start Erlang/OTP -# -start_erl "-oldshell -heart -sname vxnode -setcookie switch -boot start_sasl" diff --git a/erts/etc/vxworks/heart_config.c b/erts/etc/vxworks/heart_config.c deleted file mode 100644 index 7e60e61fbb..0000000000 --- a/erts/etc/vxworks/heart_config.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. 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% - */ -/* - * A basic heart configure module for VxWorks. - * - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include <vxWorks.h> -#include <stdio.h> -#include <stdlib.h> -#include <rebootLib.h> -#include <sysLib.h> - -/* wd_init is executed to initialize a watchdog (if one is used). */ -int wd_init(timeout, prio) - int timeout, prio; -{ - -} - -/* wd_reset should be called every 5th second from heart */ -void wd_reset() -{ - -} - -/* This routine is called when erlang has closed */ -void heart_reboot() -{ - if (getenv("HEART_DONT_REBOOT") != NULL) { - fprintf(stderr, "heart_config: HEART_DONT_REBOOT set, no reboot ...\n"); - } else { - fprintf(stderr, "heart_config: rebooting ...\n"); - taskDelay(sysClkRateGet() * 5); - reboot(BOOT_CLEAR); - } -} - - - - diff --git a/erts/etc/vxworks/heart_config.h b/erts/etc/vxworks/heart_config.h deleted file mode 100644 index 5ffaaa8c3f..0000000000 --- a/erts/etc/vxworks/heart_config.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. 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% - */ -/* - * This is heart's watchdog interface for VxWorks. - */ - -#ifndef _HW_WATCHDOG_H -#define _HW_WATCHDOG_H - -extern void wd_init(int timeout, int prio); /* wd_init initializes the - watchdog, if one is used. */ -extern void wd_reset(void); /* wd_reset is used by heart to kick - the watchdog, if one is used. */ -extern void heart_reboot(void); /* reboot is called if heart discovers - that the Erlang task has stopped sending - heart beats. It can log system status - and should reboot VxWorks. */ - -#endif diff --git a/erts/etc/vxworks/rdate.c b/erts/etc/vxworks/rdate.c deleted file mode 100644 index 3e8cc644d0..0000000000 --- a/erts/etc/vxworks/rdate.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. 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% - */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <vxWorks.h> -#include <timers.h> -#ifdef NETDB -#include <netdb.h> -#endif -#include <sys/socket.h> -#include <netinet/in.h> - -/* - rdate("host") - Set the time from "host". -*/ - -/* No getservbyname() available... */ -#define TIME_PORT 37 - -rdate(host) -char *host; -{ - u_long haddr; -#ifdef NETDB - struct hostent *hp; -#endif - struct sockaddr_in saddr; - int sock; - u_long net_time; - struct timespec t; - - if ((haddr = inet_addr(host)) == ERROR) { -#ifdef NETDB - if ((hp = gethostbyname(host)) == NULL) { -#else - if ((haddr = hostGetByName(host)) == ERROR) { -#endif - printf("Host not found.\n"); - return(-1); - } -#ifdef NETDB - memcpy(&haddr, hp->h_addr, sizeof(haddr)); -#endif - } - memset(&saddr, 0, sizeof(saddr)); - saddr.sin_family = AF_INET; - memcpy(&saddr.sin_addr, &haddr, sizeof(haddr)); - saddr.sin_port = htons(TIME_PORT); - if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - perror("socket"); - return(-1); - } - if (connect(sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - perror("connect"); - close(sock); - return(-1); - } - if (read(sock, &net_time, 4) != 4) { - perror("read"); - close(sock); - return(-1); - } - t.tv_sec = ntohl(net_time); - t.tv_sec -= 2208988800; /* seconds 1900-01-01 -- 1970-01-01 */ - t.tv_nsec = 0; - clock_settime(CLOCK_REALTIME, &t); - close(sock); - return(0); -} diff --git a/erts/etc/vxworks/reclaim.c b/erts/etc/vxworks/reclaim.c deleted file mode 100644 index d8676b3750..0000000000 --- a/erts/etc/vxworks/reclaim.c +++ /dev/null @@ -1,551 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2009. 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% - */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <vxWorks.h> -#include <version.h> -#include <string.h> -#include <types.h> -#include <sigLib.h> -#include <ioLib.h> -#include <iosLib.h> -#include <fioLib.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <symLib.h> -#include <sysLib.h> -#include <sysSymTbl.h> -#include <loadLib.h> -#include <taskLib.h> -#include <taskVarLib.h> -#include <taskHookLib.h> -#include <tickLib.h> -#include <time.h> -#include <rngLib.h> -#include <semLib.h> -#include <selectLib.h> -#include <sockLib.h> -#include <a_out.h> -#include <wdLib.h> -#include <timers.h> -#include <ctype.h> -#include <sys/stat.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <stdarg.h> - -#include <stdio.h> -#include <math.h> -#include <limits.h> -#include <stdlib.h> -#include <string.h> - - - -#define RECLAIM_NO_ALIAS /* No #defines for open/malloc/fopen etc */ -#include "reclaim.h" -#include "reclaim_private.h" - -#undef open -#undef creat -#undef socket -#undef accept -#undef close -#undef fopen -#undef fdopen -#undef freopen -#undef fclose -/* XXX Should do opendir/closedir too... */ -#undef malloc -#undef calloc -#undef realloc -#undef free -#undef cfree - -#ifdef _ARCH_PPC -#define MAX_FILES_SYM_NAME "maxFiles" -#else -#define MAX_FILES_SYM_NAME "_maxFiles" -#endif - - -/* - * Use another free() function upon task deletion? - * Note! When changing free function, the new free function will have to - * be able to cope with ALL previously used malloced areas, that is - * it has to be able to find out how things are malloced - * to free them in the right way! - */ -static FreeFunction reclaim_free_function = NULL; - -/* delete hook handling (see below) */ -static int hook_added = 0; /* Initated at first reclaim_init, an extra - non MT-safe check that we only get - initialized once */ - -/* Forward... */ -static void save_reclaim(WIND_TCB *tcbp); - -struct mall_data { - struct mall_data *next; - char *self; -}; - -struct task_data { - FUNCPTR version; /* To recognize when we have reloaded */ - int max_files; /* It may change... */ - struct fd_set open_fds; - struct mall_data *mall_data; - FUNCPTR delete_hook; - caddr_t hook_data; - FILE *open_fps[1]; /* Will be max_files long */ -} *task_data = NULL; - -static int max_files = 50; /* default configAll.h */ - -int reclaim_max_files(void) -{ - return max_files; -} - -#ifdef DEBUG -#define check_hook() \ -((task_data != NULL || \ - fdprintf(2,"check_hook() TID = 0x%08x, Called from line %d\n", \ - (unsigned int)taskIdSelf(),\ - __LINE__)) && \ -(task_data != NULL || \ - (taskVarAdd(0, (int *)&task_data) == OK && \ - (task_data = (struct task_data *)\ - calloc(1, sizeof(struct task_data) + max_files*sizeof(FILE *))) != NULL && \ - (task_data->version = (FUNCPTR)save_reclaim) != NULL && \ - (task_data->max_files = max_files) != 0 && \ - fdprintf(2,"taskVar Added for 0x%08x\n",(unsigned int)taskIdSelf())))) -#else -#define check_hook() \ -(task_data != NULL || \ - (taskVarAdd(0, (int *)&task_data) == OK && \ - (task_data = (struct task_data *)\ - calloc(1, sizeof(struct task_data) + max_files*sizeof(FILE *))) != NULL && \ - (task_data->version = (FUNCPTR)save_reclaim) != NULL && \ - (task_data->max_files = max_files) != 0)) -#endif - -/* - * Global initialization of the reclaim data structures, mainly - * the max_files variable. This HAS to be called by some task before - * the first task that utilizes this exit's, preferrably before any - * task makes the first use of this library. - */ -STATUS reclaim_init(void) -{ - int *mp; - SYM_TYPE type; - struct task_data *tdp; - int i; - - if (!hook_added) { - /* race condition */ - ++hook_added; - /* Try to find the maxFiles value */ - if (symFindByNameAndType(sysSymTbl, MAX_FILES_SYM_NAME, (char **)&mp, - &type, - N_EXT | N_BSS, N_EXT | N_BSS) == OK || - symFindByNameAndType(sysSymTbl, MAX_FILES_SYM_NAME, (char **)&mp, - &type, - N_EXT | N_DATA, N_EXT | N_DATA) == OK) { - -#ifdef DEBUG - fdprintf(2, "Found maxFiles=%d\n", *mp); -#endif - if (*mp <= FD_SETSIZE) - max_files = *mp; - else - max_files = FD_SETSIZE; - } - if (task_data != NULL && task_data->max_files != max_files) { - /* fix our own iff we have one */ - if ((tdp = (struct task_data *) - realloc(task_data, sizeof(struct task_data) + - max_files*sizeof(FILE *))) != NULL) { - task_data = tdp; - for (i = task_data->max_files; i < max_files; i++) - task_data->open_fps[i] = NULL; - task_data->max_files = max_files; - } - } - /* Make sure taskVariables are deleted AFTER our hook is run. */ - taskVarInit(); - if(taskDeleteHookAdd((FUNCPTR)save_reclaim) != OK) { - fprintf(stderr, - "Panic: taskDeleteHook cannot be added for reclaim.\n"); - return ERROR; - } - return OK; - } else - return ERROR; -} - -/* N.B.!! We do *not* execute in the context of the dying task here, - but rather that of tExcTask - we do get a pointer to the task's - TCB though - this pointer is in fact also the task's ID. */ -static void save_reclaim(WIND_TCB *tcbp) -{ - int i, var, oldfd; - struct task_data *tdp; - struct mall_data *mdp, *mdnextp; - - if ((var = taskVarGet((int)tcbp, (int *)&task_data)) != ERROR && - var != 0) { - tdp = (struct task_data *)var; - if (tdp->version == (FUNCPTR)save_reclaim) { /* Only handle our own */ -#ifdef DEBUG - fdprintf(2, "Reclaiming for task id 0x%x:\nFiles: ", (int)tcbp); -#endif - /* Ugh! VxWorks doesn't even flush stdout/err - we need to - get at those (which are task-private of course, i.e. we - can't just do fflush(stdout) here) - we could be really - pedantic and try to redefine stdout/err (which "are" - function calls) too, snarfing the values when they are - used - but besides the overhead this is problematic since - they are actually #defines already... We'll peek in the - TCB instead (no documentation of course). And of course, - we must also meddle with the *file descriptor* indirections, - or we'll just flush out on tExcTask's descriptors... */ - for (i = 1; i <= 2; i++) { - if (tcbp->taskStdFp[i] != NULL) { -#ifdef DEBUG - fdprintf(2, "fflush(%s) ", i == 1 ? "stdout" : "stderr"); -#endif - oldfd = ioTaskStdGet(0, i); - ioTaskStdSet(0, i, tcbp->taskStd[i]); - fflush(tcbp->taskStdFp[i]); - ioTaskStdSet(0, i, oldfd); - } - } - for (i = 3; i < tdp->max_files; i++) { - if (FD_ISSET(i, &tdp->open_fds)) { -#ifdef DEBUG - fdprintf(2, "close(%d) ", i); -#endif - (void) close(i); - } - if (tdp->open_fps[i] != NULL) { -#ifdef DEBUG - fdprintf(2, "fclose(%0x%x) ", (int)tdp->open_fps[i]); -#endif - (void) fclose(tdp->open_fps[i]); - } - } - i = 0; - mdp = tdp->mall_data; - while (mdp != NULL) { - mdnextp = mdp->next; - if(reclaim_free_function != NULL) - (*reclaim_free_function)(mdp->self); - else - free(mdp->self); - i++; - mdp = mdnextp; - } -#ifdef DEBUG - fdprintf(2, "\nFreeing memory: total %d mallocs\n", i); -#endif - - if (tdp->delete_hook != NULL) { -#ifdef DEBUG - fdprintf(2, "Calling delete hook at 0x%08x\n", tdp->delete_hook); -#endif - (*tdp->delete_hook)(tdp->hook_data); -#ifdef DEBUG - fdprintf(2, "Called delete hook at 0x%08x\n", tdp->delete_hook); -#endif - } -#ifdef DEBUG - fdprintf(2, "Freeing own mem at 0x%08x\n", tdp); -#endif - (void) free((char *)tdp); -#ifdef DEBUG - fdprintf(2, "Freed own mem at 0x%08x, done (0x%08x)\n**********\n", tdp, - taskIdSelf()); - checkStack(0); -#endif - } - } -#ifdef DEBUG - else - fdprintf(2, "No task data found for id 0x%x, var = %d\n", (int)tcbp, var); -#endif -} - -/* - * This sets another free function to be used by the task deletion hook. - * The free function HAS to be able to free ANY type of dynamically allocated - * memory that can be in the task data list of allocated memory, that is - * also memory that's allocated before the free function was set. - * A "user-supplied" free function is GLOBAL to the system!!! - * A race condition is present, a task delete hook may be running when this - * function is called, that may not be especially funny... - */ -void set_reclaim_free_function(FreeFunction f){ - reclaim_free_function = f; -} - -void save_delete_hook(FUNCPTR func, caddr_t parm) -{ - if (check_hook()) { - task_data->delete_hook = func; - task_data->hook_data = parm; - } -} - -/* - * plain_malloc is only used by spawn_start; plain_free by call_proc; - * save_fd is used by both. - */ -void *plain_malloc(size_t size){ - return(malloc(size)); -} - -void *plain_realloc(void *ptr, size_t size){ - return(realloc(ptr, size)); -} - -void plain_free(void *ptr){ - free(ptr); -} - -void save_fd(int fd){ - if (fd >= 0 && check_hook() && fd < task_data->max_files) - FD_SET(fd, &task_data->open_fds); -} - -int save_open(char *path, int flags, /*mode_t mode*/ ...){ - int fd; - mode_t mode = 0; - if(flags & O_CREAT){ - va_list pvar; - va_start(pvar,flags); -#ifdef __GNUC__ -#warning save_open() gives three known alignment warnings. -#endif - mode = va_arg(pvar, mode_t); - va_end(pvar); - } - if ((fd = open(path, flags, mode)) >= 0 && check_hook()) - FD_SET(fd, &task_data->open_fds); - return(fd); -} - -int save_creat(char *path, int mode){ - int fd; - if ((fd = creat(path, mode)) >= 0 && check_hook()) - FD_SET(fd, &task_data->open_fds); - return(fd); -} - -int save_socket(int domain, int type, int protocol){ - int fd; - if ((fd = socket(domain, type, protocol)) >= 0 && check_hook()) - FD_SET(fd, &task_data->open_fds); - return(fd); -} - -int save_accept(int s, struct sockaddr *addr, int *addrlen){ - int fd; - if ((fd = accept(s, addr, addrlen)) >= 0 && check_hook()) - FD_SET(fd, &task_data->open_fds); - return(fd); -} - -int save_close(int fd){ - if (fd >= 0 && fd <= FD_SETSIZE && check_hook()) - FD_CLR(fd, &task_data->open_fds); - return(close(fd)); -} - -/* The dealing with FILE *'s below isn't strictly correct, we assume - that one never has several pointing to the same fd - in the unlikely - event that one does, all but the last one opened is forgotten */ -FILE *save_fopen(const char *filename, char *type){ - FILE *fp; - - if ((fp = fopen(filename, type)) != NULL && - check_hook() && fileno(fp) < task_data->max_files) - task_data->open_fps[fileno(fp)] = fp; - return(fp); -} - -FILE *save_fdopen(int fd, char *type){ - FILE *fp; - - if ((fp = fdopen(fd, type)) != NULL && - check_hook() && fileno(fp) < task_data->max_files) { - task_data->open_fps[fileno(fp)] = fp; - FD_CLR(fd, &task_data->open_fds); - } - return(fp); -} - -FILE *save_freopen(char *filename, char *type, FILE *stream){ - FILE *fp; - - if (check_hook()) { - if(fileno(stream) < task_data->max_files && - task_data->open_fps[fileno(stream)] == stream) - task_data->open_fps[fileno(stream)] = NULL; - if ((fp = freopen(filename, type, stream)) != NULL && - fileno(fp) < task_data->max_files) - task_data->open_fps[fileno(fp)] = fp; - } else - fp = freopen(filename, type, stream); - return(fp); -} - -int save_fclose(FILE *stream){ - if (check_hook() && fileno(stream) < task_data->max_files && - task_data->open_fps[fileno(stream)] == stream) - task_data->open_fps[fileno(stream)] = NULL; - return(fclose(stream)); -} - -/* We link all malloc'ed segments by adding a couple of pointers - at the *end* - that way we can return the address malloc gave - (need to make sure we align those pointers) */ - -/* - #define MALL_MARGIN 32 - #define save_mall_size(size) save_mall_size1((size) + 2 * MALL_MARGIN) - #define save_mall_size1(size) \ - (((size) + sizeof(char *) - 1) & (unsigned long)(-sizeof(char*))) - - #define save_mall_enq(ptr, mdp) save_mall_enq1((ptr), (mdp) - MALL_MARGIN) - #define save_mall_enq1(ptr, mdp) \ - (((struct mall_data *)(mdp))->self = (ptr), \ - ((struct mall_data *)(mdp))->next = task_data->mall_data, \ - task_data->mall_data = (struct mall_data *)(mdp)) -*/ -#define save_mall_size(size) \ -(((size) + sizeof(char *) - 1) & (unsigned long)(-sizeof(char*))) -#define save_mall_enq(ptr, mdp) \ -(((struct mall_data *)(mdp))->self = (ptr), \ - ((struct mall_data *)(mdp))->next = task_data->mall_data, \ - task_data->mall_data = (struct mall_data *)(mdp)) - - -#define save_mall_deq(ptr) { \ - struct mall_data *mdp = task_data->mall_data, \ - **prevnext = &task_data->mall_data; \ - while (mdp != NULL && mdp->self != (ptr)) { \ - prevnext = &mdp->next; \ - mdp = mdp->next; \ - } \ - if (mdp != NULL) *prevnext = mdp->next; \ -} - -void *save_malloc2(size_t size, MallocFunction mf){ - unsigned msize = save_mall_size(size); - char *ptr; - - if ((ptr = (*mf)(msize + sizeof(struct mall_data))) != NULL && - check_hook()) - save_mall_enq((void *) ptr, (void *) (ptr + msize)); - return((void *) ptr); -} - -void *save_malloc(size_t size){ - return save_malloc2(size, &malloc); -} - -void *save_calloc2(size_t nelem, size_t elsize, CallocFunction cf){ - unsigned msize = save_mall_size(nelem * elsize); - char *ptr; - - if ((ptr = (*cf)(1, msize + sizeof(struct mall_data))) != NULL && - check_hook()) - save_mall_enq((void *) ptr, (void *) (ptr + msize)); - return((void *) ptr); -} - -void *save_calloc(size_t nelem, size_t elsize){ - return save_calloc2(nelem,elsize,&calloc); -} - -void *save_realloc2(void *optr, size_t size, ReallocFunction rf){ - unsigned msize = save_mall_size(size); - char *ptr; - - /* First we must dequeue the old save block, after that - we try to realloc, if that succeeds we enqueue the new - block, if it fails we have to enqueue the old one anew - so we must deduce the size of that old block first. */ - - struct mall_data *mdp0 = task_data->mall_data, - **prevnext0 = &task_data->mall_data; - while (mdp0 != NULL && mdp0->self != (((char *) optr))) { - prevnext0 = &mdp0->next; - mdp0 = mdp0->next; - } - /* mdp0 == NULL (can) mean that the block that is realloced - have been malloced with an (for example) ordinary malloc - (that is not a save_malloc). This is handled like: no dequeing - is done of that block, the new block is enqueued */ - if (mdp0 != NULL) - save_mall_deq(((char *) optr)); - - if ((ptr = (*rf)(optr, msize + sizeof(struct mall_data))) != NULL && - check_hook()) - save_mall_enq((void *) ptr, (void *) (ptr + msize)); - else if (mdp0 != NULL) - /* re-enqueue the old block that has just been dequeued */ - save_mall_enq(((char *) optr), mdp0); - - return((void *) ptr); -} - -void *save_realloc(void *optr, size_t size){ - return save_realloc2(optr,size,&realloc); -} - -void save_free2(void *ptr, FreeFunction ff) -{ - if (check_hook()) - save_mall_deq(((char *) ptr)); - (*ff)(ptr); -} - -void save_free(void *ptr){ - save_free2(ptr,&free); -} - -void save_cfree2(void *ptr, CfreeFunction cf) -{ - if (check_hook()) - save_mall_deq(((char *)ptr)); - (*cf)(ptr); -} - -void save_cfree(void *ptr){ - save_cfree2(ptr,&cfree); -} - diff --git a/erts/etc/vxworks/reclaim.h b/erts/etc/vxworks/reclaim.h deleted file mode 100644 index ca9aa8f6be..0000000000 --- a/erts/etc/vxworks/reclaim.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2009. 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% - */ -#ifndef _RECLAIM_H -#define _RECLAIM_H - - -/* The Erlang release for VxWorks includes a simple mechanism for - "resource reclamation" at task exit - it allows replacement of the - functions that open/close "files" and malloc/free memory with versions - that keep track, to be able to "reclaim" file descriptors and memory - when a task exits (regardless of *how* it exits). - - The interface to this mechanism is made available via this file, - with the following caveats: - - - The interface may change (or perhaps even be removed, though that - isn't likely until VxWorks itself provides similar functionality) - in future releases - i.e. you must always use the version of this - file that comes with the Erlang release you are using. - - - Disaster is guaranteed if you use the mechanism incorrectly (see - below for the correct way), e.g. allocate memory with the "tracking" - version of malloc() and free it with the "standard" version of free(). - - - The mechanism (of course) incurs some performance penalty - thus - for a simple program you may be better off with careful programming, - making sure that you do whatever close()/free()/etc calls that are - appropriate at all exit points (though if you need to guard against - taskDelete() etc, things get messy...). - - To use the mechanism, simply program your application normally, i.e. - use open()/close()/malloc()/free() etc as usual, but #include this - file before any usage of the relevant functions. NOTE: To avoid the - "disaster" mentioned above, you *must* #include it in *all* (or none) - of the files that manipulate a particular file descriptor, allocated - memory area, etc. - - Before any task that uses this utility is loaded (which includes the - erlang emulator), the reclaim.o object file has to be loaded and - the function reclaim_init() has to be called. reclaim_init should be called - only _ONCE_ in a systems lifetime and has only a primitive guard - against multiple calls (i.e. a global variable is checked). Therefore - the initialization should occur either in the start script of the system - or (even better) in the usrInit() part of system initialization. The - object file itself should be loaded only once, so linking it with the - kernel is a good idea, linking with each application is an extremely bad - dito. Make really sure that it's loaded _before_ any application that - uses it if You want to load it in the startup script. - - If You dont want to have #define's for the posix/stdio names - of the file/memory operations (i.e. no #define malloc save_malloc etc), - #define RECLAIM_NO_ALIAS in Your source before reclaim.h is included. -*/ - -#include <vxWorks.h> /* STATUS, size_t */ -#include <sockLib.h> /* struct sockaddr */ -#include <memLib.h> -#include <stdio.h> /* FILE */ - -#if defined(__STDC__) -#define _RECLAIM_DECL_FUN(RetType, FunName, ParamList) \ -extern RetType FunName ParamList -#define _RECLAIM_VOID_PTR void * -#define _RECLAIM_VOID_PARAM void -#define _RECLAIM_VOID_RETURN void -#elif defined(__cplusplus) -#define _RECLAIM_DECL_FUN(RetType, FunName, ParamList) \ -extern "C" RetType FunName ParamList -#define _RECLAIM_VOID_PTR void * -#define _RECLAIM_VOID_PARAM -#define _RECLAIM_VOID_RETURN void -#else -#define _RECLAIM_DECL_FUN(RetType, FunName, Ignore) extern RetType FunName() -#define DECLARE_FUNCTION_TYPE(RetType, Type, PList) typedef RetType (* Type)() -#define _RECLAIM_VOID_PTR char * -#define _RECLAIM_VOID_PARAM -#define _RECLAIM_VOID_RETURN -#endif /* __STDC__ / __cplusplus */ - -/* Initialize the facility, on a per system basis. */ -_RECLAIM_DECL_FUN(STATUS, reclaim_init, (_RECLAIM_VOID_PARAM)); - -/* File descriptor operations */ -_RECLAIM_DECL_FUN(int,save_open,(char *, int, ...)); -_RECLAIM_DECL_FUN(int,save_creat,(char *, int)); -_RECLAIM_DECL_FUN(int,save_socket,(int, int, int)); -_RECLAIM_DECL_FUN(int,save_accept,(int, struct sockaddr *, int *)); -_RECLAIM_DECL_FUN(int,save_close,(int)); -/* Interface to add an fd to what's reclaimed even though it's not open with - one of the above functions */ -_RECLAIM_DECL_FUN(_RECLAIM_VOID_RETURN, save_fd, (int fd)); -#ifndef RECLAIM_NO_ALIAS -#define open save_open -#define creat save_creat -#define socket save_socket -#define accept save_accept -#define close save_close -#endif -/* Stdio file operations */ -_RECLAIM_DECL_FUN(FILE *, save_fopen, (const char *, char *)); -_RECLAIM_DECL_FUN(FILE *, save_fdopen, (int, char *)); -_RECLAIM_DECL_FUN(FILE *, save_freopen, (char *, char *, FILE *)); -_RECLAIM_DECL_FUN(int, save_fclose, (FILE *)); -/* XXX Should do opendir/closedir too... */ -#ifndef RECLAIM_NO_ALIAS -#define fopen save_fopen -#define fdopen save_fdopen -#define freopen save_freopen -#define fclose save_fclose -#endif -/* Memory allocation */ -_RECLAIM_DECL_FUN(_RECLAIM_VOID_PTR, save_malloc, (size_t)); -_RECLAIM_DECL_FUN(_RECLAIM_VOID_PTR, save_calloc, (size_t, size_t)); -_RECLAIM_DECL_FUN(_RECLAIM_VOID_PTR, save_realloc, - (_RECLAIM_VOID_PTR, size_t)); -_RECLAIM_DECL_FUN(void, save_free, (_RECLAIM_VOID_PTR)); -_RECLAIM_DECL_FUN(void, save_cfree, (_RECLAIM_VOID_PTR)); -#ifndef RECLAIM_NO_ALIAS -#define malloc save_malloc -#define calloc save_calloc -#define realloc save_realloc -#define free save_free -#define cfree save_cfree -#endif -/* Generic interfaces to malloc etc... */ -_RECLAIM_DECL_FUN(_RECLAIM_VOID_PTR, plain_malloc, (size_t)); -_RECLAIM_DECL_FUN(_RECLAIM_VOID_PTR, plain_realloc, - (_RECLAIM_VOID_PTR, size_t)); -_RECLAIM_DECL_FUN(void, plain_free, (_RECLAIM_VOID_PTR)); -#endif /* _RECLAIM_H */ - - - - diff --git a/erts/etc/vxworks/reclaim_private.h b/erts/etc/vxworks/reclaim_private.h deleted file mode 100644 index 4ed935bee2..0000000000 --- a/erts/etc/vxworks/reclaim_private.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1998-2009. 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% - */ -#ifndef _RECLAIM_PRIVATE_H -#define _RECLAIM_PRIVATE_H -/* - * Private header for the reclaim facility, also included in the emulator. - */ - -#include "reclaim.h" - -/* Typedefs for ANSI memory allocation function pointers */ -typedef void *(*MallocFunction)(size_t); -typedef void *(*ReallocFunction)(void *, size_t); -typedef void *(*CallocFunction)(size_t, size_t); -typedef void (*FreeFunction)(void *); -typedef STATUS (*CfreeFunction)(char *); - -/* Functions for internal use and use by the emulator */ -extern int reclaim_max_files(void); -extern void set_reclaim_free_function(FreeFunction f); -extern void save_delete_hook(FUNCPTR func, caddr_t parm); -extern void *save_malloc2(size_t size, MallocFunction mf); -extern void *save_calloc2(size_t nelem, size_t elsize, CallocFunction cf); -extern void *save_realloc2(void *optr, size_t size, ReallocFunction rf); -extern void save_free2(void *ptr, FreeFunction ff); -extern void save_cfree2(void *ptr, CfreeFunction ff); - -#endif /* _RECLAIM_PRIVATE_H */ diff --git a/erts/etc/vxworks/resolv.conf b/erts/etc/vxworks/resolv.conf deleted file mode 100644 index 85c89d64c4..0000000000 --- a/erts/etc/vxworks/resolv.conf +++ /dev/null @@ -1,6 +0,0 @@ -domain du.uab.ericsson.se -nameserver 134.138.176.16 -nameserver 136.225.254.224 -nameserver 134.138.128.25 -search du.uab.ericsson.se uab.ericsson.se ericsson.se -lookup bind file diff --git a/erts/etc/vxworks/vxcall.c b/erts/etc/vxworks/vxcall.c deleted file mode 100644 index 3362d05fc5..0000000000 --- a/erts/etc/vxworks/vxcall.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. 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% - */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <vxWorks.h> -#include <symLib.h> -#include <sysSymTbl.h> -#include <a_out.h> - -extern char *malloc(); -static STATUS lookup(); - -/* - Little utility to convert from Unix' argv,argv calling conventions to - VxWorks' arg0,arg1,arg2,... - Will do limited argument parsing - no parenthesis around nor commas - between the args, which may be "-enclosed strings (without \ escapes), - '-enclosed characters (also no \ escapes), integers, or symbols. -*/ - -int vxcall(argc, argv) -int argc; -char **argv; -{ - int vxarg[10]; /* Max 10 args can be passed */ - FUNCPTR entry; - SYM_TYPE type; - int i, l; - -#ifdef DEBUG - fdprintf(2, "vxcall:"); - for (i = 1; i < argc; i++) - fdprintf(2, " %s", argv[i]); - fdprintf(2, "\n"); -#endif - if (lookup(argv[1], N_EXT | N_TEXT, (char **)&entry) != OK) - return(ERROR); - /* Do limited "C" parsing of the args */ - for (i = 0; i < 10; i++) { - if (i < argc - 2) { - switch (argv[i+2][0]) { - case '"': - l = strlen(argv[i+2]) - 1; - if (argv[i+2][l] != '"') - return(ERROR); - /* just strip the quotes - should do \escapes within... */ - vxarg[i] = (int)&argv[i+2][1]; - argv[i+2][l] = '\0'; - break; - case '\'': - if (argv[i+2][2] != '\'') - return(ERROR); - vxarg[i] = argv[i+2][1]; /* should do \escapes... */ - break; - case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - vxarg[i] = atoi(argv[i+2]); /* should do octal, hex, float.. */ - break; - default: - if (lookup(argv[i+2], 0, (char **)&vxarg[i]) != OK) - return(ERROR); - } - } else - vxarg[i] = 0; - } -#ifdef DEBUG - fdprintf(2, "calling 0x%x(0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x)\n", - entry, vxarg[0], vxarg[1], vxarg[2], vxarg[3], vxarg[4], - vxarg[5], vxarg[6], vxarg[7], vxarg[8], vxarg[9]); -#endif - return((*entry)(vxarg[0], vxarg[1], vxarg[2], vxarg[3], vxarg[4], - vxarg[5], vxarg[6], vxarg[7], vxarg[8], vxarg[9])); -} - -/* Entry point for unix:cmd in post-4.1 erlang - uses "sh -c 'cmd...'" */ -int sh(argc, argv) -int argc; -char **argv; -{ - int ll = strlen(argv[argc-1]) - 1; - -#ifdef DEBUG - int i; - fdprintf(2, "sh:"); - for (i = 1; i < argc; i++) - fdprintf(2, " %s", argv[i]); - fdprintf(2, "\n"); -#endif - if (strcmp(argv[1], "-c") != 0 || - argv[2][0] != '\'' || argv[argc-1][ll] != '\'') - return(ERROR); - argv[argc-1][ll] = '\0'; /* delete trailing ' */ - argv[2]++; /* skip leading ' (*after* the above!) */ - return(vxcall(argc-1, argv+1)); -} - -/* Lookup symbol; get address for text symbols, value (assuming int) - otherwise; return OK or ERROR on failure - Symbol name is null-terminated and without the leading '_' */ -STATUS -lookup(sym, stype, value) -char *sym, **value; -int stype; -{ - char buf[256]; - char *symname = buf; - int len, ret; - SYM_TYPE type; - - len = strlen(sym); - if (len > 254 && (symname = malloc(len+2)) == NULL) - return(ERROR); -#if defined _ARCH_PPC || defined SIMSPARCSOLARIS - /* GCC for PPC or SIMSPARC doesn't add a leading _ to symbols */ - strcpy(symname, sym); -#else - sprintf(symname, "_%s", sym); -#endif - ret = (stype != 0) ? - symFindByNameAndType(sysSymTbl, symname, value, &type, stype, stype) : - symFindByName(sysSymTbl, symname, value, &type); - if (symname != buf) - free(symname); - if (ret == OK && (type & N_TEXT) == 0) /* get value */ - *value = (char *)*((int *)*value); - return(ret); -} diff --git a/erts/etc/vxworks/wd_example.c b/erts/etc/vxworks/wd_example.c deleted file mode 100644 index 0e3a6a1cb2..0000000000 --- a/erts/etc/vxworks/wd_example.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * %CopyrightBegin% - * - * Copyright Ericsson AB 1997-2009. 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% - */ -/* - * File: frc5te_wd.c - * Purpose: Watchdog NMI handling for FORCE 5TE - * - * Description: - * The watchdog handler routines are system specific. A program that - * wants to utilize a hardware watchdog should call wd_init and test - * the return value. If wd_init returns true (!0); there is a hardware - * watchdog, and that watchdog has been activated. If no watchdog exists, - * wd_init returns false (0). - * - * To keep the watchdog happy, call wd_reset at least every X seconds, - * where X is the number of seconds specified in the call to wd_init. - * - * The watchdog can be disarmed by setting the variable wd_disarmed to 1, - * and armed again by setting the same variable to 0. Watchdog status - * information can be retrieved using the function wd_status. - * - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include <frc5e.h> -#include <logLib.h> -#include <taskLib.h> -#include <sysLib.h> -#include <stdio.h> -#include "hw_watchdog.h" - -/* prototypes */ -extern sysNMIConnect(); -#ifdef __STDC__ -void wd_keeper(int); -void wd_nmi_int(UINT8); -void wd_status(void); -#else -void wd_keeper(); -void wd_nmi_int(); -void wd_status(); -#endif - -#define WD_NMI_MIN_DELAY 0.830 /* Min time before watchdog NMI (in seconds) */ -#define WD_RESET_FREQUENCY (WD_NMI_MIN_DELAY / 2) /* how often the timer is reset */ - -#define WD_KEEPER_STACK_SIZE 10000 - -/* global variables */ -extern int spTaskOptions; -static volatile int wd_count_startval; /* start value set by wd_init */ -static volatile int wd_count; /* counter for wd_keeper */ -volatile int wd_disarmed = 0; /* debug feature */ - -/* wd_init is executed to initialize the watchdog. It spawns the task */ -/* wd_keeper and returns true (non-zero) if a hardware watchdog exists, */ -/* or returns false (zero) otherwise. */ -int wd_init(timeout, prio) - int timeout, prio; -{ - taskSpawn("wd_keeper", prio, spTaskOptions, WD_KEEPER_STACK_SIZE, - (FUNCPTR)wd_keeper, timeout,0,0,0,0,0,0,0,0,0); - return !0; /* watchdog exists */ -} - - -/* wd_reset is called as an alive-signal from the supervisor process. */ -/* If there is no call to this function within a certain time, the */ -/* watchdog will reboot the system. */ -void wd_reset() -{ - wd_count = wd_count_startval; -} - - -/* wd_keeper runs as a separate task and resets the watchdog timer */ -/* before an NMI is generated. This task uses the counter wd_count to */ -/* decide if it should exit or keep resetting the timer. */ -/* Note! This task must run with higher priority than the application! */ -void wd_keeper(timeout) - int timeout; -{ - int wd_delay = sysClkRateGet() * WD_RESET_FREQUENCY; - wd_count_startval = (int)(timeout / WD_RESET_FREQUENCY); - wd_count = wd_count_startval; - - /* Connect and enable level 15 interrupts */ - sysNMIConnect((VOIDFUNCPTR) wd_nmi_int, WD_NMI, WD_NMI); - *(char *)FRC5CE_GEN_PURPOSE2_REG |= FRC5CE_NMI_ENABLE; - - while ((wd_count > 0) || wd_disarmed) { - *(char *)FRC5CE_VME_A32MAP_REG |= FRC5CE_WATCHDOG_ENABLE; - taskDelay(wd_delay); - if (!wd_disarmed) wd_count--; - else wd_count = wd_count_startval; - } - logMsg("Watchdog keeper exits. No alive signal from application in %d seconds.\n",wd_count_startval * WD_RESET_FREQUENCY,0,0,0,0,0); -} - - -/* wd_nmi_int is the function connected to the watchdog interrupt. */ -/* It will report the failure to reset the watchdog timer. */ -void wd_nmi_int(type) - UINT8 type; -{ - switch(type) { - case WD_NMI: - logMsg("Watchdog interrupt! System will reboot.\n",0,0,0,0,0,0); - break; - default: - logMsg("Bad type (%d) in call to watchdog interrupt handler.\n",type,0,0,0,0,0); - break; - } -} - - -/* wd_status displays the current value of the counter. */ -void wd_status() -{ - fprintf(stderr, "Watchdog is %sarmed.\n", wd_disarmed ? "dis" : ""); - fprintf(stderr, "Counter value: %d\n", wd_count); - fprintf(stderr, "Start value is: %d (%d seconds)\n", - wd_count_startval, (int)(wd_count_startval * WD_RESET_FREQUENCY)); -} diff --git a/erts/etc/win32/Makefile b/erts/etc/win32/Makefile index 400e5c5bba..4218be1eff 100644 --- a/erts/etc/win32/Makefile +++ b/erts/etc/win32/Makefile @@ -59,14 +59,14 @@ opt debug all clean depend: include $(ERL_TOP)/make/otp_release_targets.mk release_spec: - $(INSTALL_DIR) $(RELSYSDIR)/bin - $(INSTALL_DIR) $(RELSYSDIR)/src - $(INSTALL_DIR) $(ROOTSYSDIR)/usr/include - $(INSTALL_DIR) $(ROOTSYSDIR)/usr/lib - $(INSTALL_DIR) $(ROOTSYSDIR)/usr/lib/icons - $(INSTALL_PROGRAM) $(INSTALL_PROGS) $(RELSYSDIR)/bin - $(INSTALL_DATA) $(INSTALL_SRC) $(RELSYSDIR)/src - $(INSTALL_DATA) $(INSTALL_ICONS) $(ROOTSYSDIR)/usr/lib/icons + $(INSTALL_DIR) "$(RELSYSDIR)/bin" + $(INSTALL_DIR) "$(RELSYSDIR)/src" + $(INSTALL_DIR) "$(ROOTSYSDIR)/usr/include" + $(INSTALL_DIR) "$(ROOTSYSDIR)/usr/lib" + $(INSTALL_DIR) "$(ROOTSYSDIR)/usr/lib/icons" + $(INSTALL_PROGRAM) $(INSTALL_PROGS) "$(RELSYSDIR)/bin" + $(INSTALL_DATA) $(INSTALL_SRC) "$(RELSYSDIR)/src" + $(INSTALL_DATA) $(INSTALL_ICONS) "$(ROOTSYSDIR)/usr/lib/icons" release_docs release_docs_spec docs: diff --git a/erts/etc/win32/nsis/Makefile b/erts/etc/win32/nsis/Makefile index 6a93c5153d..4ed4ef2700 100644 --- a/erts/etc/win32/nsis/Makefile +++ b/erts/etc/win32/nsis/Makefile @@ -44,14 +44,14 @@ TARGET_DIR = $(RELEASE_PATH) ifeq ($(MSYSTEM),MINGW32) MAKENSISFLAGS = //V2 - WTESTROOT=$(shell (msys2win_path.sh $(RELEASE_PATH))) - WTARGET_DIR=$(shell (msys2win_path.sh $(TARGET_DIR))) + WTESTROOT=$(shell (msys2win_path.sh "$(RELEASE_PATH)")) + WTARGET_DIR=$(shell (msys2win_path.sh "$(TARGET_DIR)")) else MAKENSISFLAGS = /V2 - WTESTROOT=$(shell (cygpath -d $(RELEASE_PATH) 2>/dev/null || cygpath -w $(RELEASE_PATH))) - WTARGET_DIR=$(shell (cygpath -d $(TARGET_DIR) 2>/dev/null || cygpath -d $(TARGET_DIR))) + WTESTROOT=$(shell (cygpath -d "$(RELEASE_PATH)" 2>/dev/null || cygpath -w "$(RELEASE_PATH)")) + WTARGET_DIR=$(shell (cygpath -d "$(TARGET_DIR)" 2>/dev/null || cygpath -d "$(TARGET_DIR)")) endif @@ -74,7 +74,7 @@ release_spec: echo '!define ERTS_VERSION "$(VSN)"' >> $(VERSION_HEADER);\ echo '!define TESTROOT "$(WTESTROOT)"' >> $(VERSION_HEADER);\ echo '!define OUTFILEDIR "$(WTARGET_DIR)"' >> $(VERSION_HEADER);\ - if [ -f $(RELEASE_PATH)/docs/doc/index.html ];\ + if [ -f "$(RELEASE_PATH)/docs/doc/index.html" ];\ then\ echo '!define HAVE_DOCS 1' >> $(VERSION_HEADER); \ fi;\ @@ -91,13 +91,13 @@ release_spec: fi;\ if [ '!' -z "$(REDIST_FILE)" -a '!' -z "$(REDIST_DLL_VERSION)" ];\ then \ - cp $(REDIST_FILE) $(RELEASE_PATH)/$(REDIST_TARGET);\ + cp $(REDIST_FILE) "$(RELEASE_PATH)/$(REDIST_TARGET);"\ echo '!define HAVE_REDIST_FILE 1' >> $(VERSION_HEADER); \ echo '!define REDIST_DLL_VERSION "$(REDIST_DLL_VERSION)"' >> $(VERSION_HEADER);\ echo '!define REDIST_DLL_NAME "$(REDIST_DLL_NAME)"' >> $(VERSION_HEADER);\ echo '!define REDIST_EXECUTABLE "$(REDIST_TARGET)"' >> $(VERSION_HEADER);\ fi;\ - if [ -f $(RELEASE_PATH)/docs/doc/index.html ];\ + if [ -f "$(RELEASE_PATH)/docs/doc/index.html" ];\ then \ echo '!define HAVE_DOCS 1' >> $(VERSION_HEADER); \ fi;\ diff --git a/erts/etc/win32/nsis/erlang20.nsi b/erts/etc/win32/nsis/erlang20.nsi index fb0eff3867..c5ada9e3b3 100644 --- a/erts/etc/win32/nsis/erlang20.nsi +++ b/erts/etc/win32/nsis/erlang20.nsi @@ -4,6 +4,25 @@ ; Original example written by Joost Verburg
; Modified for Erlang by Patrik
+;
+; %CopyrightBegin%
+;
+; Copyright Ericsson AB 2012. 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%
+;
+
; Verbosity does not come naturally with MUI, have to set it back now and then.
!verbose 1
!define MUI_MANUALVERBOSE 1
@@ -109,8 +128,11 @@ Section "Microsoft redistributable libraries." SecMSRedist ; Set back verbosity...
!verbose 1
-; Run the setup program
- ExecWait '"$INSTDIR\${REDIST_EXECUTABLE}"'
+; Run the setup program
+ IfSilent +3
+ ExecWait '"$INSTDIR\${REDIST_EXECUTABLE}"'
+ Goto +2
+ ExecWait '"$INSTDIR\${REDIST_EXECUTABLE}" /q'
!verbose 1
SectionEnd ; MSRedist
@@ -317,24 +339,32 @@ Function DllVersionGoodEnough FunctionEnd
Function .onInit
- SectionGetFlags 0 $MYTEMP
- ;MessageBox MB_YESNO "Found $SYSDIR\${REDIST_DLL_NAME}" IDYES FoundLbl
- IfFileExists $SYSDIR\${REDIST_DLL_NAME} MaybeFoundInSystemLbl
- SearchSxsLbl:
- FindFirst $0 $1 $WINDIR\WinSxS\x86*
+ Var /GLOBAL archprefix
+ Var /GLOBAL sysnativedir
+ SectionGetFlags 0 $MYTEMP
+ StrCmpS ${WINTYPE} "win64" +1 +4
+ StrCpy $archprefix "amd64"
+ StrCpy $sysnativedir "$WINDIR\sysnative"
+ Goto +3
+ StrCpy $archprefix "x86"
+ StrCpy $sysnativedir $SYSDIR
+ ;MessageBox MB_YESNO "Found $sysnativedir\${REDIST_DLL_NAME}" IDYES FoundLbl
+ IfFileExists $sysnativedir\${REDIST_DLL_NAME} MaybeFoundInSystemLbl
+ SearchSxSLbl:
+ FindFirst $0 $1 $WINDIR\WinSxS\$archprefix*
LoopLbl:
StrCmp $1 "" NotFoundLbl
- IfFileExists $WINDIR\WinSxS\$1\${REDIST_DLL_NAME} MaybeFoundInSxsLbl
+ IfFileExists $WINDIR\WinSxS\$1\${REDIST_DLL_NAME} MaybeFoundInSxSLbl
FindNext $0 $1
Goto LoopLbl
- MaybeFoundInSxsLbl:
+ MaybeFoundInSxSLbl:
GetDllVersion $WINDIR\WinSxS\$1\${REDIST_DLL_NAME} $R0 $R1
Call DllVersionGoodEnough
FindNext $0 $1
IntCmp 2 $R0 LoopLbl
Goto FoundLbl
MaybeFoundInSystemLbl:
- GetDllVersion $SYSDIR\${REDIST_DLL_NAME} $R0 $R1
+ GetDllVersion $sysnativedir\${REDIST_DLL_NAME} $R0 $R1
Call DllVersionGoodEnough
IntCmp 2 $R0 SearchSxSLbl
FoundLbl:
|