diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-20 18:18:19 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-03-20 18:18:19 +0000 |
commit | eafaeb9398216dacb92de69683ccdda6007efb1d (patch) | |
tree | e513e4fd791670d9b74d33821682d4059ed73098 /nuttx/examples/nxflat | |
parent | f68c474e8ae9cfa5c9124a6eb92ec06fe2bf40a1 (diff) | |
download | px4-nuttx-eafaeb9398216dacb92de69683ccdda6007efb1d.tar.gz px4-nuttx-eafaeb9398216dacb92de69683ccdda6007efb1d.tar.bz2 px4-nuttx-eafaeb9398216dacb92de69683ccdda6007efb1d.zip |
Move nuttx/examples to apps/examples
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3405 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nxflat')
28 files changed, 0 insertions, 3053 deletions
diff --git a/nuttx/examples/nxflat/Makefile b/nuttx/examples/nxflat/Makefile deleted file mode 100644 index dae8a4ea7..000000000 --- a/nuttx/examples/nxflat/Makefile +++ /dev/null @@ -1,77 +0,0 @@ -############################################################################ -# examples/nxflat/Makefile -# -# Copyright (C) 2008, 2010 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config --include $(TOPDIR)/Make.defs - -ASRCS = -AOBJS = $(ASRCS:.S=$(OBJEXT)) -CSRCS = nxflat_main.c -COBJS = $(CSRCS:.c=$(OBJEXT)) - -SRCS = $(ASRCS) $(CSRCS) -OBJS = $(AOBJS) $(COBJS) - -BIN = libapp$(LIBEXT) - -all: $(BIN) -.PHONY: headers clean distclean - -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -headers: - @$(MAKE) -C tests TOPDIR=$(TOPDIR) CROSSDEV=$(CROSSDEV) - -$(BIN): headers $(OBJS) - @( for obj in $(OBJS) ; do \ - $(call ARCHIVE, $@, $${obj}); \ - done ; ) - -# We can't make dependencies in this directory because the required -# header files may not yet exist. - -depend: - -clean: - @rm -f $(BIN) *~ .*.swp - $(call CLEAN) - -distclean: clean - --include Make.dep diff --git a/nuttx/examples/nxflat/nxflat_main.c b/nuttx/examples/nxflat/nxflat_main.c deleted file mode 100644 index a710112c3..000000000 --- a/nuttx/examples/nxflat/nxflat_main.c +++ /dev/null @@ -1,232 +0,0 @@ -/**************************************************************************** - * examples/nxflat/nxflat_main.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> -#include <nuttx/compiler.h> - -#include <sys/mount.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <pthread.h> -#include <debug.h> -#include <errno.h> - -#include <nuttx/ramdisk.h> -#include <nuttx/binfmt.h> -#include <nuttx/nxflat.h> - -#include "tests/romfs.h" -#include "tests/dirlist.h" -#include "tests/symtab.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/* Check configuration. This is not all of the configuration settings that - * are required -- only the more obvious. - */ - -#if CONFIG_NFILE_DESCRIPTORS < 1 -# error "You must provide file descriptors via CONFIG_NFILE_DESCRIPTORS in your configuration file" -#endif - -#ifndef CONFIG_NXFLAT -# error "You must select CONFIG_NXFLAT in your configuration file" -#endif - -#ifndef CONFIG_FS_ROMFS -# error "You must select CONFIG_FS_ROMFS in your configuration file" -#endif - -#ifdef CONFIG_DISABLE_MOUNTPOINT -# error "You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT in your configuration file" -#endif - -#ifdef CONFIG_BINFMT_DISABLE -# error "You must not disable loadable modules via CONFIG_BINFMT_DISABLE in your configuration file" -#endif - -/* Describe the ROMFS file system */ - -#define SECTORSIZE 512 -#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE) -#define ROMFSDEV "/dev/ram0" -#define MOUNTPT "/mnt/romfs" - -/* If CONFIG_DEBUG is enabled, use dbg instead of printf so that the - * output will be synchronous with the debug output. - */ - -#ifdef CONFIG_CPP_HAVE_VARARGS -# ifdef CONFIG_DEBUG -# define message(format, arg...) dbg(format, ##arg) -# define err(format, arg...) dbg(format, ##arg) -# else -# define message(format, arg...) printf(format, ##arg) -# define err(format, arg...) fprintf(stderr, format, ##arg) -# endif -#else -# ifdef CONFIG_DEBUG -# define message dbg -# define err dbg -# else -# define message printf -# define err printf -# endif -#endif - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static const char delimiter[] = - "****************************************************************************"; - -static char path[128]; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: testheader - ****************************************************************************/ - -static inline void testheader(FAR const char *progname) -{ - message("\n%s\n* Executing %s\n%s\n\n", delimiter, progname, delimiter); -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: user_initialize - ****************************************************************************/ - -void user_initialize(void) -{ -} - -/**************************************************************************** - * Name: user_start - ****************************************************************************/ - -int user_start(int argc, char *argv[]) -{ - struct binary_s bin; - int ret; - int i; - - /* Initialize the NXFLAT binary loader */ - - message("Initializing the NXFLAT binary loader\n"); - ret = nxflat_initialize(); - if (ret < 0) - { - err("ERROR: Initialization of the NXFLAT loader failed: %d\n", ret); - exit(1); - } - - /* Create a ROM disk for the ROMFS filesystem */ - - message("Registering romdisk\n"); - ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), SECTORSIZE); - if (ret < 0) - { - err("ERROR: romdisk_register failed: %d\n", ret); - nxflat_uninitialize(); - exit(1); - } - - /* Mount the file system */ - - message("Mounting ROMFS filesystem at target=%s with source=%s\n", - MOUNTPT, ROMFSDEV); - - ret = mount(ROMFSDEV, MOUNTPT, "romfs", MS_RDONLY, NULL); - if (ret < 0) - { - err("ERROR: mount(%s,%s,romfs) failed: %s\n", - ROMFSDEV, MOUNTPT, errno); - nxflat_uninitialize(); - } - - /* Now excercise every progrm in the ROMFS file system */ - - for (i = 0; dirlist[i]; i++) - { - testheader(dirlist[i]); - - memset(&bin, 0, sizeof(struct binary_s)); - snprintf(path, 128, "%s/%s", MOUNTPT, dirlist[i]); - - bin.filename = path; - bin.exports = exports; - bin.nexports = NEXPORTS; - - ret = load_module(&bin); - if (ret < 0) - { - err("ERROR: Failed to load program '%s'\n", dirlist[i]); - exit(1); - } - - ret = exec_module(&bin, 50); - if (ret < 0) - { - err("ERROR: Failed to execute program '%s'\n", dirlist[i]); - unload_module(&bin); - } - - message("Wait a bit for test completion\n"); - sleep(4); - } - - message("End-of-Test.. Exit-ing\n"); - return 0; -} diff --git a/nuttx/examples/nxflat/tests/Makefile b/nuttx/examples/nxflat/tests/Makefile deleted file mode 100644 index 638b2548c..000000000 --- a/nuttx/examples/nxflat/tests/Makefile +++ /dev/null @@ -1,103 +0,0 @@ -############################################################################ -# examples/nxflat/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - -# Most of these do no build yet -#SUBDIRS = errno hello hello++ longjmp mutex pthread signal task struct -SUBDIRS = errno hello mutex pthread task struct - -NXFLAT_DIR = $(TOPDIR)/examples/nxflat -TESTS_DIR = $(NXFLAT_DIR)/tests -ROMFS_DIR = $(TESTS_DIR)/romfs -ROMFS_IMG = $(TESTS_DIR)/romfs.img -ROMFS_HDR = $(TESTS_DIR)/romfs.h -ROMFS_DIRLIST = $(TESTS_DIR)/dirlist.h -SYMTAB = $(TESTS_DIR)/symtab.h - -define DIR_template -$(1)_$(2): - @$(MAKE) -C $(1) $(3) TOPDIR=$(TOPDIR) ROMFS_DIR=$(ROMFS_DIR) CROSSDEV=$(CROSSDEV) -endef - -all: $(ROMFS_HDR) $(ROMFS_DIRLIST) $(SYMTAB) -.PHONY: all build clean install populate - -$(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),build, all))) -$(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),clean,clean))) -$(foreach DIR, $(SUBDIRS), $(eval $(call DIR_template,$(DIR),install,install))) - -# Build program(s) in each sud-directory - -build: $(foreach DIR, $(SUBDIRS), $(DIR)_build) - -# Install each program in the romfs directory - -install: $(foreach DIR, $(SUBDIRS), $(DIR)_install) - -# Create the romfs directory - -$(ROMFS_DIR): - @mkdir $(ROMFS_DIR) - -# Populate the romfs directory - -populate: $(ROMFS_DIR) build install - -# Create the romfs.img file from the populated romfs directory - -$(ROMFS_IMG): populate - @genromfs -f $@ -d $(ROMFS_DIR) -V "NXFLATTEST" - -# Create the romfs.h header file from the romfs.img file - -$(ROMFS_HDR) : $(ROMFS_IMG) - @(cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/static const unsigned/g" >$@) - -# Create the dirlist.h header file from the romfs directory - -$(ROMFS_DIRLIST) : populate - @$(TESTS_DIR)/mkdirlist.sh $(ROMFS_DIR) >$@ - -# Create the exported symbol table list from the derived *-thunk.S files - -$(SYMTAB): build - @$(TESTS_DIR)/mksymtab.sh $(TESTS_DIR) >$@ - -# Clean each subdirectory - -clean: $(foreach DIR, $(SUBDIRS), $(DIR)_clean) - @rm -f $(ROMFS_HDR) $(ROMFS_IMG) $(SYMTAB) - @rm -rf $(ROMFS_DIR) - - diff --git a/nuttx/examples/nxflat/tests/errno/Makefile b/nuttx/examples/nxflat/tests/errno/Makefile deleted file mode 100644 index 158768b85..000000000 --- a/nuttx/examples/nxflat/tests/errno/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################ -# examples/nxflat/tests/hello/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN = errno - -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - diff --git a/nuttx/examples/nxflat/tests/errno/errno.c b/nuttx/examples/nxflat/tests/errno/errno.c deleted file mode 100644 index b06679165..000000000 --- a/nuttx/examples/nxflat/tests/errno/errno.c +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/errno/errno.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -static const char g_nonexistent[] = "aflav-sautga-ay"; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - FILE *test_stream; - - /* Try using stdout and stderr explicitly. These are global variables - * exported from the base code. - */ - - fprintf(stdout, "Hello, World on stdout\n"); - fprintf(stderr, "Hello, World on stderr\n"); - - /* Try opening a non-existent file using buffered IO. */ - - test_stream = fopen(g_nonexistent, "r"); - if (test_stream) - { - fprintf(stderr, "Hmm... Delete \"%s\" and try this again\n", - g_nonexistent); - exit(1); - } - - /* Now print the errno on stderr. Errno is also a global - * variable exported by the base code. - */ - - fprintf(stderr, "We failed to open \"%s!\" errno is %d\n", - g_nonexistent, errno); - - return 0; -} diff --git a/nuttx/examples/nxflat/tests/hello++/Makefile b/nuttx/examples/nxflat/tests/hello++/Makefile deleted file mode 100644 index 113520da5..000000000 --- a/nuttx/examples/nxflat/tests/hello++/Makefile +++ /dev/null @@ -1,180 +0,0 @@ -############################################################################ -# examples/nxflat/tests/hello/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN1 = hello++1 -BIN2 = hello++2 -BIN3 = hello++3 -#BIN4 = hello++4 -ALL_BIN = $(BIN1) $(BIN2) $(BIN3) $(BIN4) - -R1SRCS1 = $(BIN1).c -R1OBJS1 = $(R1SRCS1:.c=.o) -R2SRC1 = $(BIN1)-thunk.S -R2OBJ1 = $(R2SRC1:.S=.o) - -R1SRCS2 = $(BIN2).c -R1OBJS2 = $(R1SRCS2:.c=.o) -R2SRC2 = $(BIN2)-thunk.S -R2OBJ2 = $(R2SRC2:.S=.o) - -R1SRCS3 = $(BIN3).c -R1OBJS3 = $(R1SRCS3:.c=.o) -R2SRC3 = $(BIN3)-thunk.S -R2OBJ3 = $(R2SRC3:.S=.o) - -#R1SRCS4 = $(BIN4).c -#R1OBJS4 = $(R1SRCS4:.c=.o) -#R2SRC4 = $(BIN4)-thunk.S -#R2OBJ4 = $(R2SRC4:.S=.o) - -DERIVED = $(R2SRC1) $(R2SRC2) $(R2SRC3) $(R2SRC4) - -R1CXXOBJS = $(R1OBJS1) $(R1OBJS2) $(R1OBJS3) # $(R1OBJS4) -R2AOBJS = $(R2OBJ1) $(R2OBJ2) $(R2OBJ3) # $(R2OBJ4) - -LIBSTDC_STUBS_DIR = $(TOPDIR)/libxx -LIBSTDC_STUBS_LIB = $(LIBSTDC_STUBS_DIR)/liblibxx.a - -all: $(BIN1) $(BIN2) $(BIN3) # $(BIN4) - -$(R1CXXOBJS): %.o: %.cpp - @echo "CC: $<" - @$(CXX) -c $(CXXPICFLAGS) $< -o $@ - -$(R2AOBJS): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -# This contains libstdc++ stubs to that you can build C++ code -# without actually having libstdc++ - -$(LIBSTDC_STUBS_LIB): - @$(MAKE) -C $(LIBSTDC_STUBS_DIR) TOPDIR=$(TOPDIR) - -# BIN1 and BIN2 link just like C code because they contain no -# static constructors. BIN1 is equivalent to a C hello world; -# BIN2 contains a class that implements hello world, but it is -# not statically initialized. - -$(BIN1).r1: $(R1OBJS1) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC1): $(BIN1).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN1).r2: $(R2OBJ1) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS1) $(R2OBJ1) - -$(BIN1): $(BIN1).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -$(BIN2).r1: $(R1OBJS2) $(LIBSTDC_STUBS_LIB) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC2): $(BIN2).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN2).r2: $(R2OBJ2) - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS2) $(R2OBJ2) - -$(BIN2): $(BIN2).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -# BIN3 and BIN4 require that we include --cxx in the xflat-ld command. -# This will instruct xflat-ld that we want it to put together the correct -# startup files to handle the C++ static initializers. -# -# BIN3 is equivalent to BIN2 except that is uses static initializers - -$(BIN3).r1: $(R1OBJS3) $(LIBSTDC_STUBS_LIB) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC3): $(BIN3).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN3).r2: $(R2OBJ3) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS3) $(R2OBJ3) - -$(BIN3): $(BIN3).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -# BIN4 is similar to BIN3 except that it uses the streams code from libstdc++ -# -# NOTE: libstdc++ is not available for XFLAT as of this writing -# -#$(BIN4).r1: $(R1OBJS4) $(LIBSTDC_STUBS_LIB) -# @echo "LD: $<" -# $(LD) $(NXFLATLDFLAGS1) -o $@ $^ -# -#$(R2SRC4): $(BIN4).r1 -# @echo "MK: $<" -# $(MKNXFLAT) -o $@ $^ -# -#$(BIN4).r2: $(R2OBJ4)# @echo "LD: $<" -# $(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS4) $(R2OBJ4) -# -#$(BIN4): $(BIN4).r2 -# @echo "LD: $<" -# $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(ALL_BIN) $(DERIVED) *.o *.r1 *.r2 *~ .*.swp core - -install: $(ALL_BIN) - @install -D $(BIN1) $(ROMFS_DIR)/$(BIN1) - @install -D $(BIN2) $(ROMFS_DIR)/$(BIN2) - @install -D $(BIN3) $(ROMFS_DIR)/$(BIN3) -# @install -D $(BIN4) $(ROMFS_DIR)/$(BIN4) - - - - - - - diff --git a/nuttx/examples/nxflat/tests/hello++/hello++1.cpp b/nuttx/examples/nxflat/tests/hello++/hello++1.cpp deleted file mode 100644 index 779f3307a..000000000 --- a/nuttx/examples/nxflat/tests/hello++/hello++1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// examples/nxflat/tests/hello++/hello++1.c -// -// Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// 3. Neither the name NuttX nor the names of its contributors may be -// used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -///////////////////////////////////////////////////////////////////////////// -// -// This is an trivial version of "Hello, World" program. It illustrates -// that we can build C programs using the C++ compiler. -// -// - Building a C++ program to use the C library -// - No class creation -// - NO Streams -// - NO Static constructor and destructors -// -///////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// Included Files -///////////////////////////////////////////////////////////////////////////// - -#include <cstdio> - -///////////////////////////////////////////////////////////////////////////// -// Public Functions -///////////////////////////////////////////////////////////////////////////// - -int main(int argc, char **argv) -{ - printf("Hello, World!\n"); - return 0; -} diff --git a/nuttx/examples/nxflat/tests/hello++/hello++2.cpp b/nuttx/examples/nxflat/tests/hello++/hello++2.cpp deleted file mode 100644 index 87166f3ab..000000000 --- a/nuttx/examples/nxflat/tests/hello++/hello++2.cpp +++ /dev/null @@ -1,123 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// examples/nxflat/tests/hello++/hello++2.c -// -// Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// 3. Neither the name NuttX nor the names of its contributors may be -// used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -///////////////////////////////////////////////////////////////////////////// -// -// This is an another trivial version of "Hello, World" design. It illustrates -// -// - Building a C++ program to use the C library -// - Basic class creation -// - NO Streams -// - NO Static constructor and destructors -// -///////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// Included Files -///////////////////////////////////////////////////////////////////////////// - -#include <cstdio> - -///////////////////////////////////////////////////////////////////////////// -// Classes -///////////////////////////////////////////////////////////////////////////// - -class CThingSayer -{ - const char *szWhatToSay; -public: - CThingSayer(void) - { - printf("CThingSayer::CThingSayer: I am!\n"); - szWhatToSay = (const char*)NULL; - } - - ~CThingSayer(void) - { - printf("CThingSayer::~CThingSayer: I cease to be\n"); - if (szWhatToSay) - { - printf("CThingSayer::~CThingSayer: I will never say '%s' again\n", - szWhatToSay); - } - szWhatToSay = (const char*)NULL; - } - - void Initialize(const char *czSayThis) - { - printf("CThingSayer::Initialize: When told, I will say '%s'\n", - czSayThis); - szWhatToSay = czSayThis; - } - - void SayThing(void) - { - printf("CThingSayer::SayThing: I am now saying '%s'\n", szWhatToSay); - } -}; - -///////////////////////////////////////////////////////////////////////////// -// Public Functions -///////////////////////////////////////////////////////////////////////////// - -int main(int argc, char **argv) -{ - CThingSayer *MyThingSayer; - - printf("main: Started. Creating MyThingSayer\n"); - - // Create an instance of the CThingSayer class - // We should see the message from constructor, CThingSayer::CThingSayer(), - - MyThingSayer = new CThingSayer; - printf("main: Created MyThingSayer=0x%08lx\n", (long)MyThingSayer); - - // Tell MyThingSayer that "Hello, World!" is the string to be said - - printf("main: Calling MyThingSayer->Initialize\n");; - MyThingSayer->Initialize("Hello, World!"); - - // Tell MyThingSayer to say the thing we told it to say - - printf("main: Calling MyThingSayer->SayThing\n");; - MyThingSayer->SayThing(); - - // We should see the message from the destructor, - // CThingSayer::~CThingSayer(), AFTER we see the following - - printf("main: Destroying MyThingSayer\n"); - delete MyThingSayer; - - printf("main: Returning\n");; - return 0; -} diff --git a/nuttx/examples/nxflat/tests/hello++/hello++3.cpp b/nuttx/examples/nxflat/tests/hello++/hello++3.cpp deleted file mode 100644 index ed7302fa6..000000000 --- a/nuttx/examples/nxflat/tests/hello++/hello++3.cpp +++ /dev/null @@ -1,132 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// examples/nxflat/tests/hello++/hello++3.c -// -// Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// 3. Neither the name NuttX nor the names of its contributors may be -// used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -///////////////////////////////////////////////////////////////////////////// -// -// This is an another trivial version of "Hello, World" design. It illustrates -// -// - Building a C++ program to use the C library and stdio -// - Basic class creation with virtual methods. -// - Static constructor and destructors (in main program only) -// - NO Streams -// -///////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// Included Files -///////////////////////////////////////////////////////////////////////////// - -#include <cstdio> - -///////////////////////////////////////////////////////////////////////////// -// Classes -///////////////////////////////////////////////////////////////////////////// - -class CThingSayer -{ - const char *szWhatToSay; -public: - CThingSayer(void); - virtual ~CThingSayer(void); - virtual void Initialize(const char *czSayThis); - virtual void SayThing(void); -}; - -// A static instance of the CThingSayer class. This instance MUST -// be constructed by the system BEFORE the program is started at -// main() and must be destructed by the system AFTER the main() -// returns to the system - -static CThingSayer MyThingSayer; - -// These are implementations of the methods of the CThingSayer class - -CThingSayer::CThingSayer(void) -{ - printf("CThingSayer::CThingSayer: I am!\n"); - szWhatToSay = (const char*)NULL; -} - -CThingSayer::~CThingSayer(void) -{ - printf("CThingSayer::~CThingSayer: I cease to be\n"); - if (szWhatToSay) - { - printf("CThingSayer::~CThingSayer: I will never say '%s' again\n", - szWhatToSay); - } - szWhatToSay = (const char*)NULL; -} - -void CThingSayer::Initialize(const char *czSayThis) -{ - printf("CThingSayer::Initialize: When told, I will say '%s'\n", - czSayThis); - szWhatToSay = czSayThis; -} - -void CThingSayer::SayThing(void) -{ - printf("CThingSayer::SayThing: I am now saying '%s'\n", szWhatToSay); -} - -///////////////////////////////////////////////////////////////////////////// -// Public Functions -///////////////////////////////////////////////////////////////////////////// - -int main(int argc, char **argv) -{ - // We should see the message from constructor, CThingSayer::CThingSayer(), - // BEFORE we see the following messages. That is proof that the - // C++ static initializer is working - - printf("main: Started. MyThingSayer should already exist\n"); - - // Tell MyThingSayer that "Hello, World!" is the string to be said - - printf("main: Calling MyThingSayer.Initialize\n");; - MyThingSayer.Initialize("Hello, World!"); - - // Tell MyThingSayer to say the thing we told it to say - - printf("main: Calling MyThingSayer.SayThing\n");; - MyThingSayer.SayThing(); - - // We are finished, return. We should see the message from the - // destructor, CThingSayer::~CThingSayer(), AFTER we see the following - // message. That is proof that the C++ static destructor logic - // is working - - printf("main: Returning. MyThingSayer should be destroyed\n");; - return 0; -} diff --git a/nuttx/examples/nxflat/tests/hello++/hello++4.cpp b/nuttx/examples/nxflat/tests/hello++/hello++4.cpp deleted file mode 100644 index 97d026093..000000000 --- a/nuttx/examples/nxflat/tests/hello++/hello++4.cpp +++ /dev/null @@ -1,150 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// examples/nxflat/tests/hello++/hello++4.c -// -// Copyright (C) 2009 Gregory Nutt. All rights reserved. -// Author: Gregory Nutt <spudmonkey@racsa.co.cr> -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in -// the documentation and/or other materials provided with the -// distribution. -// 3. Neither the name NuttX nor the names of its contributors may be -// used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -///////////////////////////////////////////////////////////////////////////// -// -// This is an excessively complex version of "Hello, World" design to -// illustrate some basic properties of C++: -// -// - Building a C++ program -// - Streams / statically linked libstdc++ -// - Static constructor and destructors (in main program only) -// -///////////////////////////////////////////////////////////////////////////// - -///////////////////////////////////////////////////////////////////////////// -// Included Files -///////////////////////////////////////////////////////////////////////////// - -#include <cstdio> -#include <iostream> - -#ifndef NULL -# define NULL ((void*)0L) -#endif - -///////////////////////////////////////////////////////////////////////////// -// Classes -///////////////////////////////////////////////////////////////////////////// - -using namespace std; - -// A hello world sayer class - -class CThingSayer -{ - const char *szWhatToSay; -public: - CThingSayer(void); - virtual ~CThingSayer(void); - virtual void Initialize(const char *czSayThis); - virtual void SayThing(void); -}; - -///////////////////////////////////////////////////////////////////////////// -// Private Data -///////////////////////////////////////////////////////////////////////////// - -// A static instance of the CThingSayer class. This instance MUST -// be constructed by the system BEFORE the program is started at -// main() and must be destructed by the system AFTER the main() -// returns to the system - -static CThingSayer MyThingSayer; - -///////////////////////////////////////////////////////////////////////////// -// Method Implementations -///////////////////////////////////////////////////////////////////////////// - -// These are implementations of the methods of the CThingSayer class - -CThingSayer::CThingSayer(void) -{ - cout << "CThingSayer::CThingSayer: I am!" << endl; - szWhatToSay = (const char*)NULL; -} - -CThingSayer::~CThingSayer(void) -{ - cout << "CThingSayer::~CThingSayer: I cease to be" << endl; - if (szWhatToSay) - { - cout << "CThingSayer::~CThingSayer: I will never say '" - << szWhatToSay << "' again" << endl; - } - szWhatToSay = (const char*)NULL; -} - -void CThingSayer::Initialize(const char *czSayThis) -{ - cout << "CThingSayer::Initialize: When told, I will say '" - << czSayThis << "'" << endl; - szWhatToSay = czSayThis; -} - -void CThingSayer::SayThing(void) -{ - cout << "CThingSayer::SayThing: I am now saying '" - << szWhatToSay << "'" << endl; -} - -///////////////////////////////////////////////////////////////////////////// -// Public Functions -///////////////////////////////////////////////////////////////////////////// - -int main(int argc, char **argv) -{ - // We should see the message from constructor, CThingSayer::CThingSayer(), - // BEFORE we see the following messages. That is proof that the - // C++ static initializer is working - - cout << "main: Started" << endl; - - // Tell MyThingSayer that "Hello, World!" is the string to be said - - cout << "main: Calling MyThingSayer.Initialize" << endl; - MyThingSayer.Initialize("Hello, World!"); - - // Tell MyThingSayer to say the thing we told it to say - - cout << "main: Calling MyThingSayer.SayThing" << endl; - MyThingSayer.SayThing(); - - // We are finished, return. We should see the message from the - // destructor, CThingSayer::~CThingSayer(), AFTER we see the following - // message. That is proof that the C++ static destructor logic - // is working - - cout << "main: Returning" << endl; - return 0; -} diff --git a/nuttx/examples/nxflat/tests/hello/Makefile b/nuttx/examples/nxflat/tests/hello/Makefile deleted file mode 100644 index ccde7a98f..000000000 --- a/nuttx/examples/nxflat/tests/hello/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################ -# examples/nxflat/tests/hello/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN = hello - -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - diff --git a/nuttx/examples/nxflat/tests/hello/hello.c b/nuttx/examples/nxflat/tests/hello/hello.c deleted file mode 100644 index 028bdfe00..000000000 --- a/nuttx/examples/nxflat/tests/hello/hello.c +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/hello/hello.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - int i; - - /* Mandatory "Hello, world!" */ - - puts("Getting ready to say \"Hello, world\"\n"); - printf("Hello, world!\n"); - puts("It has been said.\n"); - - /* Print arguments */ - - printf("argc\t= %d\n", argc); - printf("argv\t= 0x%p\n", argv); - - for (i = 0; i < argc; i++) - { - printf("argv[%d]\t= ", i); - if (argv[i]) - { - printf("(0x%p) \"%s\"\n", argv[i], argv[i]); - } - else - { - printf("NULL?\n"); - } - } - - printf("argv[%d]\t= 0x%p\n", argc, argv[argc]); - printf("Goodbye, world!\n"); - return 0; -} diff --git a/nuttx/examples/nxflat/tests/longjmp/Makefile b/nuttx/examples/nxflat/tests/longjmp/Makefile deleted file mode 100644 index d0c93ebbd..000000000 --- a/nuttx/examples/nxflat/tests/longjmp/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################ -# examples/nxflat/tests/longjmp/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN = longjmp - -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - diff --git a/nuttx/examples/nxflat/tests/longjmp/longjmp.c b/nuttx/examples/nxflat/tests/longjmp/longjmp.c deleted file mode 100644 index b5b317d99..000000000 --- a/nuttx/examples/nxflat/tests/longjmp/longjmp.c +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/longjmp/longjmp.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdio.h> -#include <setjmp.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define MAIN_VAL 47 -#define FUNC_VAL 92 -#define LEAF_VAL 163 - -#define FUNCTION_ARG MAIN_VAL -#define LEAF_ARG (FUNCTION_ARG + FUNC_VAL) -#define SETJMP_RETURN (LEAF_ARG + LEAF_VAL) - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static jmp_buf env; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -static int leaf(int *some_arg) -{ - int some_local_variable = *some_arg + LEAF_VAL; - - printf("leaf: received %d\n", *some_arg); - - if (*some_arg != LEAF_ARG) - printf("leaf: ERROR: expected %d\n", LEAF_ARG); - - printf("leaf: Calling longjmp() with %d\n", some_local_variable); - - longjmp(env, some_local_variable); -} - -static int function(int some_arg) -{ - int some_local_variable = some_arg + FUNC_VAL; - int retval; - - printf("function: received %d\n", some_arg); - - if (some_arg != FUNCTION_ARG) - printf("function: ERROR: expected %d\n", FUNCTION_ARG); - - printf("function: Calling leaf() with %d\n", some_local_variable); - - retval = leaf(&some_local_variable); - - printf("function: ERROR -- leaf returned!\n"); - return retval; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - int value; - - printf("main: Calling setjmp\n"); - value = setjmp(env); - printf("main: setjmp returned %d\n", value); - - if (value == 0) - { - printf("main: Normal setjmp return\n"); - printf("main: Calling function with %d\n", MAIN_VAL); - function(MAIN_VAL); - printf("main: ERROR -- function returned!\n"); - return 1; - } - else if (value != SETJMP_RETURN) - { - printf("main: ERROR: Expected %d\n", SETJMP_RETURN); - return 1; - } - else - { - printf("main: SUCCESS: setjmp return from longjmp call\n"); - return 0; - } -} - diff --git a/nuttx/examples/nxflat/tests/mkdirlist.sh b/nuttx/examples/nxflat/tests/mkdirlist.sh deleted file mode 100755 index cc55ac0b5..000000000 --- a/nuttx/examples/nxflat/tests/mkdirlist.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -usage="Usage: %0 <romfs-dir-path>" - -dir=$1 -if [ -z "$dir" ]; then - echo "ERROR: Missing <romfs-dir-path>" - echo "" - echo $usage - exit 1 -fi - -if [ ! -d "$dir" ]; then - echo "ERROR: Directory $dir does not exist" - echo "" - echo $usage - exit 1 -fi - -echo "#ifndef __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" -echo "#define __EXAMPLES_NXFLAT_TESTS_DIRLIST_H" -echo "" -echo "static const char *dirlist[] =" -echo "{" - -for file in `ls $dir`; do - echo " \"$file\"," -done - -echo " NULL" -echo "};" -echo "" -echo "#endif /* __EXAMPLES_NXFLAT_TESTS_DIRLIST_H */" - - diff --git a/nuttx/examples/nxflat/tests/mksymtab.sh b/nuttx/examples/nxflat/tests/mksymtab.sh deleted file mode 100755 index 611d3a87a..000000000 --- a/nuttx/examples/nxflat/tests/mksymtab.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -usage="Usage: %0 <test-dir-path>" - -dir=$1 -if [ -z "$dir" ]; then - echo "ERROR: Missing <test-dir-path>" - echo "" - echo $usage - exit 1 -fi - -if [ ! -d "$dir" ]; then - echo "ERROR: Directory $dir does not exist" - echo "" - echo $usage - exit 1 -fi - -varlist=`find $dir -name "*-thunk.S"| xargs grep -h asciz | cut -f3 | sort | uniq` - -echo "#ifndef __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" -echo "#define __EXAMPLES_NXFLAT_TESTS_SYMTAB_H" -echo "" -echo "#include <nuttx/symtab.h>" -echo "" -echo "static const struct symtab_s exports[] = " -echo "{" - -for string in $varlist; do - var=`echo $string | sed -e "s/\"//g"` - echo " {$string, $var}," -done - -echo "};" -echo "#define NEXPORTS (sizeof(exports)/sizeof(struct symtab_s))" -echo "" -echo "#endif /* __EXAMPLES_NXFLAT_TESTS_SYMTAB_H */" - diff --git a/nuttx/examples/nxflat/tests/mutex/Makefile b/nuttx/examples/nxflat/tests/mutex/Makefile deleted file mode 100644 index 8c9fbb4a3..000000000 --- a/nuttx/examples/nxflat/tests/mutex/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################ -# examples/nxflat/tests/mutex/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN = mutex - -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - diff --git a/nuttx/examples/nxflat/tests/mutex/mutex.c b/nuttx/examples/nxflat/tests/mutex/mutex.c deleted file mode 100644 index 78a63306d..000000000 --- a/nuttx/examples/nxflat/tests/mutex/mutex.c +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/mutex/mutex.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdbool.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <pthread.h> - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static pthread_mutex_t mut; -static volatile int my_mutex = 0; -static unsigned long nloops[2] = {0, 0}; -static unsigned long nerrors[2] = {0, 0}; -static volatile bool bendoftest; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* NOTE: it is necessary for functions that are referred to by function pointers - * pointer to be declared with global scope (at least for ARM). Otherwise, - * a relocation type that is not supported by NXFLAT is generated by GCC. - */ - -void thread_func(void *parameter) -{ - int my_id = (int)parameter; - int my_ndx = my_id - 1; - int i; - - /* Loop 20 times. There is a 100 MS delay in the loop so this should - * take about 2 seconds. The main thread will stop this thread after - * 2 seconds by setting bendoftest in any event. - */ - - for (i = 0; i < 20 && !bendoftest; i++); - { - if ((pthread_mutex_lock(&mut)) != 0) - { - printf("ERROR thread %d: pthread_mutex_lock failed\n", my_id); - } - - if (my_mutex == 1) - { - printf("ERROR thread=%d: " - "my_mutex should be zero, instead my_mutex=%d\n", - my_id, my_mutex); - nerrors[my_ndx]++; - } - - my_mutex = 1; - usleep(100000); - my_mutex = 0; - - if ((pthread_mutex_unlock(&mut)) != 0) - { - printf("ERROR thread %d: pthread_mutex_unlock failed\n", my_id); - } - - nloops[my_ndx]++; - } -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - pthread_t thread1; - pthread_t thread2; - - /* Initialize the mutex */ - - pthread_mutex_init(&mut, NULL); - - /* Start two thread instances */ - - printf("Starting thread 1\n"); - bendoftest = false; - if ((pthread_create(&thread1, NULL, (void*)thread_func, (void*)1)) != 0) - { - fprintf(stderr, "Error in thread#1 creation\n"); - } - - printf("Starting thread 2\n"); - if ((pthread_create(&thread2, NULL, (void*)thread_func, (void*)2)) != 0) - { - fprintf(stderr, "Error in thread#2 creation\n"); - } - - /* Wait a bit for the threads to do their thing. */ - - sleep(2); - - /* Then ask them politely to stop running */ - - printf("Stopping threads\n"); - bendoftest = true; - pthread_join(thread1, NULL); - pthread_join(thread2, NULL); - - printf("\tThread1\tThread2\n"); - printf("Loops\t%ld\t%ld\n", nloops[0], nloops[1]); - printf("Errors\t%ld\t%ld\n", nerrors[0], nerrors[1]); - - return 0; -} - diff --git a/nuttx/examples/nxflat/tests/pthread/Makefile b/nuttx/examples/nxflat/tests/pthread/Makefile deleted file mode 100644 index 27da42e7c..000000000 --- a/nuttx/examples/nxflat/tests/pthread/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################ -# examples/nxflat/tests/pthread/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN = pthread - -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - diff --git a/nuttx/examples/nxflat/tests/pthread/pthread.c b/nuttx/examples/nxflat/tests/pthread/pthread.c deleted file mode 100644 index 019ec453e..000000000 --- a/nuttx/examples/nxflat/tests/pthread/pthread.c +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/pthread/pthread.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <pthread.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define CHILD_ARG ((void*)0x12345678) -#define CHILD_RET ((void*)0x87654321) - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -enum exit_values_e -{ - TESTRESULT_SUCCESS = 0, - TESTRESULT_PTHREAD_ATTR_INIT_FAIL, - TESTRESULT_PTHREAD_CREATE_FAIL, - TESTRESULT_PTHREAD_JOIN_FAIL, - TESTRESULT_CHILD_ARG_FAIL, - TESTRESULT_CHILD_RETVAL_FAIL, -}; - -/**************************************************************************** - * External Functions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/* NOTE: it is necessary for functions that are referred to by function pointers - * pointer to be declared with global scope (at least for ARM). Otherwise, - * a relocation type that is not supported by NXFLAT is generated by GCC. - */ - -void *child_start_routine(void *arg) -{ - printf("CHILD: started with arg=%d\n", (int)arg); - - if (arg != CHILD_ARG) - { - printf("CHILD: expected arg=%d\n", (int)CHILD_ARG); - return (void*)TESTRESULT_CHILD_ARG_FAIL; - } - sleep(2); - - printf("CHILD: returning %d\n", (int)CHILD_RET); - pthread_exit(CHILD_RET); -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - pthread_attr_t attr; - pthread_t thread; - void *retval; - int status; - - puts("PARENT: started\n"); - - status = pthread_attr_init(&attr); - if (status != 0) - { - printf("PARENT: pthread_attr_init() returned %d\n", status); - exit(TESTRESULT_PTHREAD_ATTR_INIT_FAIL); - } - - printf("PARENT: calling pthread_start with arg=%d\n", (int)CHILD_ARG); - status = pthread_create(&thread, &attr, child_start_routine, CHILD_ARG); - if (status != 0) - { - printf("PARENT: pthread_create() returned %d\n", status); - exit(TESTRESULT_PTHREAD_CREATE_FAIL); - } - - status = pthread_join(thread, &retval); - if (status != 0) - { - printf("PARENT pthread_join() returned %d\n", status); - - exit(TESTRESULT_PTHREAD_JOIN_FAIL); - } - - printf("PARENT child exitted with %d\n", (int)retval); - if (retval != CHILD_RET) - { - printf("PARENT child thread did not exit with %d\n", (int)CHILD_RET); - exit(TESTRESULT_CHILD_RETVAL_FAIL); - } - - puts("PARENT returning success\n"); - return TESTRESULT_SUCCESS; -} diff --git a/nuttx/examples/nxflat/tests/signal/Makefile b/nuttx/examples/nxflat/tests/signal/Makefile deleted file mode 100644 index d967fbf09..000000000 --- a/nuttx/examples/nxflat/tests/signal/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -############################################################################ -# examples/nxflat/tests/signal/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN = signal - -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - diff --git a/nuttx/examples/nxflat/tests/signal/signal.c b/nuttx/examples/nxflat/tests/signal/signal.c deleted file mode 100644 index ff1c58305..000000000 --- a/nuttx/examples/nxflat/tests/signal/signal.c +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/signal/signal.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <signal.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -#define USEC_PER_MSEC 1000 -#define MSEC_PER_SEC 1000 -#define USEC_PER_SEC (USEC_PER_MSEC * MSEC_PER_SEC) -#define SHORT_DELAY (USEC_PER_SEC / 3) - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static int sigusr1_rcvd = 0; -static int sigusr2_rcvd = 0; - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: sigusr1_sighandler - ****************************************************************************/ - -/* NOTE: it is necessary for functions that are referred to by function pointers - * pointer to be declared with global scope (at least for ARM). Otherwise, - * a relocation type that is not supported by NXFLAT is generated by GCC. - */ - -void sigusr1_sighandler(int signo) -{ - printf("sigusr1_sighandler: Received SIGUSR1, signo=%d\n", signo); - sigusr1_rcvd = 1; -} - -/**************************************************************************** - * Name: sigusr2_sigaction - ***************************************************************************/ - -/* NOTE: it is necessary for functions that are referred to by function pointers - * pointer to be declared with global scope (at least for ARM). Otherwise, - * a relocation type that is not supported by NXFLAT is generated by GCC. - */ - -#ifdef __USE_POSIX199309 -void sigusr2_sigaction(int signo, siginfo_t *siginfo, void *arg) -{ - printf("sigusr2_sigaction: Received SIGUSR2, signo=%d siginfo=%p arg=%p\n", - signo, siginfo, arg); - -#ifdef HAVE_SIGQUEUE - if (siginfo) - { - printf(" si_signo = %d\n", siginfo->si_signo); - printf(" si_errno = %d\n", siginfo->si_errno); - printf(" si_code = %d\n", siginfo->si_code); - printf(" si_pid = %d\n", siginfo->si_pid); - printf(" si_uid = %d\n", siginfo->si_uid); - printf(" si_status = %d\n", siginfo->si_status); - printf(" si_utime = %ld\n", (long)siginfo->si_utime); - printf(" si_stime = %ld\n", (long)siginfo->si_stime); - printf(" si_value = %d\n", siginfo->si_value.sival_int); - printf(" si_int = %d\n", siginfo->si_int); - printf(" si_ptr = %p\n", siginfo->si_ptr); - printf(" si_addr = %p\n", siginfo->si_addr); - printf(" si_band = %ld\n", siginfo->si_band); - printf(" si_fd = %d\n", siginfo->si_fd); - } -#endif - sigusr2_rcvd = 1; -} -#else -void sigusr2_sigaction(int signo) -{ - printf("sigusr2_sigaction: Received SIGUSR2, signo=%d\n", signo); - sigusr2_rcvd = 1; -} - -#endif - -/**************************************************************************** - * Name: sigusr2_sighandler - ****************************************************************************/ - -static void sigusr2_sighandler(int signo) -{ - printf("sigusr2_sighandler: Received SIGUSR2, signo=%d\n", signo); - sigusr2_rcvd = 1; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: main - ****************************************************************************/ - -int main(int argc, char **argv) -{ - struct sigaction act; - struct sigaction oact; - void (*old_sigusr1_sighandler)(int signo); - void (*old_sigusr2_sighandler)(int signo); - pid_t mypid = getpid(); -#if defined(__USE_POSIX199309) && defined(HAVE_SIGQUEUE) - sigval_t sigval; -#endif - int status; - - printf("Setting up signal handlers from pid=%d\n", mypid); - - /* Set up so that sigusr1_sighandler will respond to SIGUSR1 */ - - old_sigusr1_sighandler = signal(SIGUSR1, sigusr1_sighandler); - if (old_sigusr1_sighandler == SIG_ERR) - { - fprintf(stderr, "Failed to install SIGUSR1 handler, errno=%d\n", - errno); - exit(1); - } - - printf("Old SIGUSR1 sighandler at %p\n", old_sigusr1_sighandler); - printf("New SIGUSR1 sighandler at %p\n", sigusr1_sighandler); - - /* Set up so that sigusr2_sigaction will respond to SIGUSR2 */ - - memset(&act, 0, sizeof(struct sigaction)); - act.sa_sigaction = sigusr2_sigaction; - act.sa_flags = SA_SIGINFO; - - (void)sigemptyset(&act.sa_mask); - - status = sigaction(SIGUSR2, &act, &oact); - if (status != 0) - { - fprintf(stderr, "Failed to install SIGUSR2 handler, errno=%d\n", - errno); - exit(2); - } - - printf("Old SIGUSR2 sighandler at %p\n", oact.sa_handler); - printf("New SIGUSR2 sighandler at %p\n", sigusr2_sigaction); - printf("Raising SIGUSR1 from pid=%d\n", mypid); - - fflush(stdout); usleep(SHORT_DELAY); - - /* Send SIGUSR1 to ourselves via raise() */ - - status = raise(SIGUSR1); - if (status != 0) - { - fprintf(stderr, "Failed to raise SIGUSR1, errno=%d\n", errno); - exit(3); - } - - usleep(SHORT_DELAY); - printf("SIGUSR1 raised from pid=%d\n", mypid); - - /* Verify that we received SIGUSR1 */ - - if (sigusr1_rcvd == 0) - { - fprintf(stderr, "SIGUSR1 not received\n"); - exit(4); - } - sigusr1_rcvd = 0; - - /* Send SIGUSR2 to ourselves */ - - printf("Killing SIGUSR2 from pid=%d\n", mypid); - fflush(stdout); usleep(SHORT_DELAY); - -#if defined(__USE_POSIX199309) && defined(HAVE_SIGQUEUE) - /* Send SIGUSR2 to ourselves via sigqueue() */ - - sigval.sival_int = 87; - status = sigqueue(mypid, SIGUSR2, sigval); - if (status != 0) - { - fprintf(stderr, "Failed to queue SIGUSR2, errno=%d\n", errno); - exit(5); - } - - usleep(SHORT_DELAY); - printf("SIGUSR2 queued from pid=%d, sigval=97\n", mypid); -#else - /* Send SIGUSR2 to ourselves via kill() */ - - status = kill(mypid, SIGUSR2); - if (status != 0) - { - fprintf(stderr, "Failed to kill SIGUSR2, errno=%d\n", errno); - exit(5); - } - - usleep(SHORT_DELAY); - printf("SIGUSR2 killed from pid=%d\n", mypid); -#endif - /* Verify that SIGUSR2 was received */ - - if (sigusr2_rcvd == 0) - { - fprintf(stderr, "SIGUSR2 not received\n"); - exit(6); - } - sigusr2_rcvd = 0; - - /* Remove the sigusr2_sigaction handler and replace the SIGUSR2 - * handler with sigusr2_sighandler. - */ - - printf("Resetting SIGUSR2 signal handler from pid=%d\n", mypid); - - old_sigusr2_sighandler = signal(SIGUSR2, sigusr2_sighandler); - if (old_sigusr2_sighandler == SIG_ERR) - { - fprintf(stderr, "Failed to install SIGUSR2 handler, errno=%d\n", - errno); - exit(7); - } - - printf("Old SIGUSR2 sighandler at %p\n", old_sigusr2_sighandler); - printf("New SIGUSR2 sighandler at %p\n", sigusr2_sighandler); - - /* Verify that the handler that was removed was sigusr2_sigaction */ - - if ((void*)old_sigusr2_sighandler != (void*)sigusr2_sigaction) - { - fprintf(stderr, - "Old SIGUSR2 signhanlder (%p) is not sigusr2_sigation (%p)\n", - old_sigusr2_sighandler, sigusr2_sigaction); - exit(8); - } - - /* Send SIGUSR2 to ourselves via kill() */ - - printf("Killing SIGUSR2 from pid=%d\n", mypid); - fflush(stdout); usleep(SHORT_DELAY); - - status = kill(mypid, SIGUSR2); - if (status != 0) - { - fprintf(stderr, "Failed to kill SIGUSR2, errno=%d\n", errno); - exit(9); - } - - usleep(SHORT_DELAY); - printf("SIGUSR2 killed from pid=%d\n", mypid); - - /* Verify that SIGUSR2 was received */ - - if (sigusr2_rcvd == 0) - { - fprintf(stderr, "SIGUSR2 not received\n"); - exit(10); - } - sigusr2_rcvd = 0; - - return 0; -} diff --git a/nuttx/examples/nxflat/tests/struct/Makefile b/nuttx/examples/nxflat/tests/struct/Makefile deleted file mode 100644 index 7a5f3fb82..000000000 --- a/nuttx/examples/nxflat/tests/struct/Makefile +++ /dev/null @@ -1,80 +0,0 @@ -############################################################################ -# examples/nxflat/tests/hello/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -CFLAGS += -I. - -BIN = struct - -R1SRCS = struct_main.c struct_dummy.c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - diff --git a/nuttx/examples/nxflat/tests/struct/struct.h b/nuttx/examples/nxflat/tests/struct/struct.h deleted file mode 100644 index 0b1747d8c..000000000 --- a/nuttx/examples/nxflat/tests/struct/struct.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/struct/struct.h - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -#ifndef __EXAMPLES_NXFLAT_TESTS_STRUCT_STRUCT_H -#define __EXAMPLES_NXFLAT_TESTS_STRUCT_STRUCT_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#define DUMMY_SCALAR_VALUE1 42 -#define DUMMY_SCALAR_VALUE2 87 -#define DUMMY_SCALAR_VALUE3 117 - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -typedef void (*dummy_t)(void); - -struct struct_dummy_s -{ - int n; /* This is a simple scalar value (DUMMY_SCALAR_VALUE3) */ -}; - -struct struct_s -{ - int n; /* This is a simple scalar value (DUMMY_SCALAR_VALUE1) */ - const int *pn; /* This is a pointer to a simple scalar value */ - const struct struct_dummy_s *ps; /* This is a pointer to a structure */ - dummy_t pf; /* This is a pointer to a function */ -}; - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -extern int dummy_scalar; /* (DUMMY_SCALAR_VALUE2) */ -extern const struct struct_dummy_s dummy_struct; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -extern void dummyfunc(void); -extern const struct struct_s *getstruct(void); - -#endif /* __EXAMPLES_NXFLAT_TESTS_STRUCT_STRUCT_H */ - - diff --git a/nuttx/examples/nxflat/tests/struct/struct_dummy.c b/nuttx/examples/nxflat/tests/struct/struct_dummy.c deleted file mode 100644 index 7f0be6a1f..000000000 --- a/nuttx/examples/nxflat/tests/struct/struct_dummy.c +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/struct/struct_dummy.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> - -#include "struct.h" - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -const struct struct_s dummy = -{ - DUMMY_SCALAR_VALUE1, - &dummy_scalar, - &dummy_struct, - (dummy_t)dummyfunc -}; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -const struct struct_s *getstruct(void) -{ - return &dummy; -} - diff --git a/nuttx/examples/nxflat/tests/struct/struct_main.c b/nuttx/examples/nxflat/tests/struct/struct_main.c deleted file mode 100644 index d82cdd706..000000000 --- a/nuttx/examples/nxflat/tests/struct/struct_main.c +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/struct/struct_main.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> - -#include "struct.h" - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -const struct struct_dummy_s dummy_struct = -{ - DUMMY_SCALAR_VALUE3 -}; - -int dummy_scalar = DUMMY_SCALAR_VALUE2; - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - const struct struct_s *mystruct = getstruct(); - - printf("Calling getstruct()\n"); - mystruct = getstruct(); - printf("getstruct returned %p\n", mystruct); - printf(" n = %d (vs %d) %s\n", - mystruct->n, DUMMY_SCALAR_VALUE1, - mystruct->n == DUMMY_SCALAR_VALUE1 ? "PASS" : "FAIL"); - - printf(" pn = %p (vs %p) %s\n", - mystruct->pn, &dummy_scalar, - mystruct->pn == &dummy_scalar ? "PASS" : "FAIL"); - if (mystruct->pn == &dummy_scalar) - { - printf(" *pn = %d (vs %d) %s\n", - *mystruct->pn, DUMMY_SCALAR_VALUE2, - *mystruct->pn == DUMMY_SCALAR_VALUE2 ? "PASS" : "FAIL"); - } - - printf(" ps = %p (vs %p) %s\n", - mystruct->ps, &dummy_struct, - mystruct->ps == &dummy_struct ? "PASS" : "FAIL"); - if (mystruct->ps == &dummy_struct) - { - printf(" ps->n = %d (vs %d) %s\n", - mystruct->ps->n, DUMMY_SCALAR_VALUE3, - mystruct->ps->n == DUMMY_SCALAR_VALUE3 ? "PASS" : "FAIL"); - } - - printf(" pf = %p (vs %p) %s\n", - mystruct->pf, dummyfunc, - mystruct->pf == dummyfunc ? "PASS" : "FAIL"); - if (mystruct->pf == dummyfunc) - { - printf("Calling mystruct->pf()\n"); - mystruct->pf(); - } - - printf("Exit-ing\n"); - return 0; -} - -void dummyfunc(void) -{ - printf("In dummyfunc() -- PASS\n"); -} - - diff --git a/nuttx/examples/nxflat/tests/task/Makefile b/nuttx/examples/nxflat/tests/task/Makefile deleted file mode 100644 index 0881d4717..000000000 --- a/nuttx/examples/nxflat/tests/task/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################ -# examples/nxflat/tests/task/Makefile -# -# Copyright (C) 2009 Gregory Nutt. All rights reserved. -# Author: Gregory Nutt <spudmonkey@racsa.co.cr> -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in -# the documentation and/or other materials provided with the -# distribution. -# 3. Neither the name NuttX nor the names of its contributors may be -# used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -############################################################################ - --include $(TOPDIR)/.config # Current configuration --include $(TOPDIR)/Make.defs # Basic make info - -BIN = task - -R1SRCS = $(BIN).c -R1OBJS = $(R1SRCS:.c=.o) - -R2SRC = $(BIN)-thunk.S -R2OBJ = $(R2SRC:.S=.o) - -all: $(BIN) - -$(R1OBJS): %.o: %.c - @echo "CC: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(R2OBJ): %.o: %.S - @echo "AS: $<" - @$(CC) -c $(CPICFLAGS) $< -o $@ - -$(BIN).r1: $(R1OBJS) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS1) -o $@ $^ - -$(R2SRC): $(BIN).r1 - @echo "MK: $<" - @$(MKNXFLAT) -o $@ $^ - -$(BIN).r2: $(R2OBJ) - @echo "LD: $<" - @$(LD) $(NXFLATLDFLAGS2) -o $@ $(R1OBJS) $(R2OBJ) - -$(BIN): $(BIN).r2 - @echo "LD: $<" - @$(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ - -clean: - @rm -f $(BIN) $(R2SRC) *.o *.r1 *.r2 *~ .*.swp core - -install: - @install -D $(BIN) $(ROMFS_DIR)/$(BIN) - - diff --git a/nuttx/examples/nxflat/tests/task/task.c b/nuttx/examples/nxflat/tests/task/task.c deleted file mode 100644 index 63e8188ed..000000000 --- a/nuttx/examples/nxflat/tests/task/task.c +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** - * examples/nxflat/tests/task/parent.c - * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <sys/types.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <sched.h> -#include <semaphore.h> -#include <errno.h> - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -static char child_name[] = "child"; -static char child_arg[] = "Hello from your parent!"; -static sem_t g_sem; - -#if CONFIG_TASK_NAME_SIZE == 0 -static char no_name[] = "<noname>"; -#endif - -/**************************************************************************** - * Privite Functions - ****************************************************************************/ - -/* NOTE: it is necessary for functions that are referred to by function pointers - * pointer to be declared with global scope (at least for ARM). Otherwise, - * a relocation type that is not supported by NXFLAT is generated by GCC. - */ - - int child_task(int argc, char **argv) -{ - printf("Child: execv was successful!\n"); - printf("Child: argc=%d\n", argc); - - if (argc != 2) - { - printf("Child: expected argc to be 2\n"); - printf("Child: Exit-ting with status=2\n"); - exit(2); - } - printf("Child: argv[0]=\"%s\"\n", argv[0]); - -#if CONFIG_TASK_NAME_SIZE == 0 - if (strcmp(argv[0], no_name) != 0) - { - printf("Child: expected argv[0] to be \"%s\"\n", no_name); - printf("Child: Exit-ting with status=3\n"); - exit(3); - } -#else - if (strncmp(argv[0], child_name, CONFIG_TASK_NAME_SIZE) != 0) - { - printf("Child: expected argv[0] to be \"%s\"\n", child_name); - printf("Child: Exit-ting with status=3\n"); - exit(3); - } -#endif - - printf("Child: argv[1]=\"%s\"\n", argv[1]); - - if (strcmp(argv[1], child_arg) != 0) - { - printf("Child: expected argv[1] to be \"%s\"\n", child_arg); - printf("Child: Exit-ting with status=4\n"); - exit(4); - } - - printf("Child: Exit-ting with status=0\n"); - sem_post(&g_sem); - return 0; -} - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -int main(int argc, char **argv) -{ - pid_t parent_pid = getpid(); - char *child_argv[2]; - pid_t child_pid; - - printf("Parent: Started, pid=%d\n", parent_pid); - - sem_init(&g_sem, 0, 0); - - printf("Parent: Calling task_create()\n"); - - child_argv[0] = child_arg; - child_argv[1] = 0; - child_pid = task_create(child_name, 50, 512, child_task, (const char**)child_argv); - if (child_pid < 0) - { - printf("Parent: task_create failed: %d\n", errno); - } - - printf("Parent: Waiting for child (pid=%d)\n", child_pid); - sem_wait(&g_sem); - printf("Parent: Exit-ing\n"); - sem_destroy(&g_sem); - return 0; -} - |