mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
Got more NXFLAT examples to compile
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1891 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -68,7 +68,7 @@ $(CXXOBJS): %.o: %.cpp
|
|||||||
# without actually have libstdc++
|
# without actually have libstdc++
|
||||||
|
|
||||||
$(LIBSTDC_STUBS_LIB):
|
$(LIBSTDC_STUBS_LIB):
|
||||||
$(MAKE) -C $(LIBSTDC_STUBS_DIR)
|
$(MAKE) -C $(LIBSTDC_STUBS_DIR) TOPDIR=$(TOPDIR)
|
||||||
|
|
||||||
# BIN1 and BIN2 link just like C code because they contain no
|
# BIN1 and BIN2 link just like C code because they contain no
|
||||||
# static constructors. BIN1 is equivalent to a C hello world;
|
# static constructors. BIN1 is equivalent to a C hello world;
|
||||||
@@ -76,10 +76,10 @@ $(LIBSTDC_STUBS_LIB):
|
|||||||
# not statically initialized.
|
# not statically initialized.
|
||||||
|
|
||||||
$(BIN1): $(OBJS1)
|
$(BIN1): $(OBJS1)
|
||||||
$(XFLATLD) -o $@ $^
|
$(NXFLATLD) -o $@ $^
|
||||||
|
|
||||||
$(BIN2): $(OBJS2) $(LIBSTDC_STUBS_LIB)
|
$(BIN2): $(OBJS2) $(LIBSTDC_STUBS_LIB)
|
||||||
$(XFLATLD) -o $@ $^
|
$(NXFLATLD) -o $@ $^
|
||||||
|
|
||||||
# BIN3 and BIN4 require that we include --cxx in the xflat-ld command.
|
# BIN3 and BIN4 require that we include --cxx in the xflat-ld command.
|
||||||
# This will instruct xflat-ld that we want it to put togethe the correct
|
# This will instruct xflat-ld that we want it to put togethe the correct
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
CThingSayer(void)
|
CThingSayer(void)
|
||||||
{
|
{
|
||||||
printf("CThingSayer::CThingSayer: I am!\n");
|
printf("CThingSayer::CThingSayer: I am!\n");
|
||||||
szWhatToSay = NULL;
|
szWhatToSay = (const char*)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
~CThingSayer(void)
|
~CThingSayer(void)
|
||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
printf("CThingSayer::~CThingSayer: I will never say '%s' again\n",
|
printf("CThingSayer::~CThingSayer: I will never say '%s' again\n",
|
||||||
szWhatToSay);
|
szWhatToSay);
|
||||||
}
|
}
|
||||||
szWhatToSay = NULL;
|
szWhatToSay = (const char*)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(const char *czSayThis)
|
void Initialize(const char *czSayThis)
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ static CThingSayer MyThingSayer;
|
|||||||
CThingSayer::CThingSayer(void)
|
CThingSayer::CThingSayer(void)
|
||||||
{
|
{
|
||||||
printf("CThingSayer::CThingSayer: I am!\n");
|
printf("CThingSayer::CThingSayer: I am!\n");
|
||||||
szWhatToSay = NULL;
|
szWhatToSay = (const char*)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CThingSayer::~CThingSayer(void)
|
CThingSayer::~CThingSayer(void)
|
||||||
@@ -85,7 +85,7 @@ CThingSayer::~CThingSayer(void)
|
|||||||
printf("CThingSayer::~CThingSayer: I will never say '%s' again\n",
|
printf("CThingSayer::~CThingSayer: I will never say '%s' again\n",
|
||||||
szWhatToSay);
|
szWhatToSay);
|
||||||
}
|
}
|
||||||
szWhatToSay = NULL;
|
szWhatToSay = (const char*)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CThingSayer::Initialize(const char *czSayThis)
|
void CThingSayer::Initialize(const char *czSayThis)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ static CThingSayer MyThingSayer;
|
|||||||
CThingSayer::CThingSayer(void)
|
CThingSayer::CThingSayer(void)
|
||||||
{
|
{
|
||||||
cout << "CThingSayer::CThingSayer: I am!" << endl;
|
cout << "CThingSayer::CThingSayer: I am!" << endl;
|
||||||
szWhatToSay = (char*)NULL;
|
szWhatToSay = (const char*)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CThingSayer::~CThingSayer(void)
|
CThingSayer::~CThingSayer(void)
|
||||||
@@ -102,7 +102,7 @@ CThingSayer::~CThingSayer(void)
|
|||||||
cout << "CThingSayer::~CThingSayer: I will never say '"
|
cout << "CThingSayer::~CThingSayer: I will never say '"
|
||||||
<< szWhatToSay << "' again" << endl;
|
<< szWhatToSay << "' again" << endl;
|
||||||
}
|
}
|
||||||
szWhatToSay = (char*)NULL;
|
szWhatToSay = (const char*)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CThingSayer::Initialize(const char *czSayThis)
|
void CThingSayer::Initialize(const char *czSayThis)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ all: $(BIN)
|
|||||||
$(OBJS): %.o: %.c
|
$(OBJS): %.o: %.c
|
||||||
$(NXFLATCC) -c $(NXFLATCFLAGS) $< -o $@
|
$(NXFLATCC) -c $(NXFLATCFLAGS) $< -o $@
|
||||||
|
|
||||||
$(BIN): $OBJS)
|
$(BIN): $(OBJS)
|
||||||
$(NXFLATLD) $(NXFLATLDFLAGS) -o $@ $(OBJS)
|
$(NXFLATLD) $(NXFLATLDFLAGS) -o $@ $(OBJS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ all: $(BIN)
|
|||||||
$(OBJS): %.o: %.c
|
$(OBJS): %.o: %.c
|
||||||
$(NXFLATCC) -c $(NXFLATCFLAGS) $< -o $@
|
$(NXFLATCC) -c $(NXFLATCFLAGS) $< -o $@
|
||||||
|
|
||||||
$(BIN): $OBJS)
|
$(BIN): $(OBJS)
|
||||||
$(NXFLATLD) $(NXFLATLDFLAGS) -o $@ $(OBJS)
|
$(NXFLATLD) $(NXFLATLDFLAGS) -o $@ $(OBJS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -37,7 +37,9 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -37,11 +37,13 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <stdio.h> /* For printf(), fprintf(), etc. */
|
#include <sys/types.h>
|
||||||
#include <signal.h> /* For signal(), sigaction(), etc. */
|
#include <stdio.h>
|
||||||
#include <unistd.h> /* For usleep() */
|
#include <stdlib.h>
|
||||||
#include <errno.h> /* For errno */
|
#include <signal.h>
|
||||||
#include <sys/types.h> /* (needed by getpid()) */
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
static char child_name[] = "child";
|
||||||
static char child_arg[] = "Hello from your parent!";
|
static char child_arg[] = "Hello from your parent!";
|
||||||
static sem_t g_sem;
|
static sem_t g_sem;
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ static sem_t g_sem;
|
|||||||
* Privite Functions
|
* Privite Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int child_task(int argc, char **argv, char **envp)
|
int child_task(int argc, char **argv)
|
||||||
{
|
{
|
||||||
printf("Child: execv was successful!\n");
|
printf("Child: execv was successful!\n");
|
||||||
printf("Child: argc=%d\n", argc);
|
printf("Child: argc=%d\n", argc);
|
||||||
@@ -70,9 +72,9 @@ int child_task(int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
printf("Child: argv[0]=\"%s\"\n", argv[0]);
|
printf("Child: argv[0]=\"%s\"\n", argv[0]);
|
||||||
|
|
||||||
if (strcmp(argv[0], my_path) != 0)
|
if (strcmp(argv[0], child_name) != 0)
|
||||||
{
|
{
|
||||||
printf("Child: expected argv[0] to be \"%s\"\n", my_path);
|
printf("Child: expected argv[0] to be \"%s\"\n", child_name);
|
||||||
printf("Child: Exit-ting with status=3\n");
|
printf("Child: Exit-ting with status=3\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
@@ -81,7 +83,7 @@ int child_task(int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
if (strcmp(argv[1], child_arg) != 0)
|
if (strcmp(argv[1], child_arg) != 0)
|
||||||
{
|
{
|
||||||
printf("Child: expected argv[1] to be \"%s\"\n", parent_arg);
|
printf("Child: expected argv[1] to be \"%s\"\n", child_arg);
|
||||||
printf("Child: Exit-ting with status=4\n");
|
printf("Child: Exit-ting with status=4\n");
|
||||||
exit(4);
|
exit(4);
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,7 @@ int child_task(int argc, char **argv, char **envp)
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int main(int argc, char **argv, char **envp)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
pid_t parent_pid = getpid();
|
pid_t parent_pid = getpid();
|
||||||
char *child_argv[2];
|
char *child_argv[2];
|
||||||
@@ -109,7 +111,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
|
|
||||||
child_argv[0] = child_arg;
|
child_argv[0] = child_arg;
|
||||||
child_argv[1] = 0;
|
child_argv[1] = 0;
|
||||||
ret = task_create("child", 50, 512, child_task, &child_arg);
|
ret = task_create(child_name, 50, 512, child_task, child_argv);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
printf("Parent: task_create failed: %d\n", errno);
|
printf("Parent: task_create failed: %d\n", errno);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Definitions
|
// Definitions
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Definitions
|
// Definitions
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
//void *operator new[](size_t size)
|
//void *operator new[](size_t size)
|
||||||
void *operator new[]((unsigned long size)
|
void *operator new[](unsigned long nbytes)
|
||||||
{
|
{
|
||||||
// We have to allocate something
|
// We have to allocate something
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user