diff --git a/arch/sim/src/up_setjmp.S b/arch/sim/src/up_setjmp.S index 56c72370c7..a65317c65a 100644 --- a/arch/sim/src/up_setjmp.S +++ b/arch/sim/src/up_setjmp.S @@ -1,8 +1,8 @@ /************************************************************************** * up_setjmp.S * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -104,11 +104,11 @@ SYMBOL(up_setjmp): /* Save the framepointer */ - movl %ebp, (JB_EBP)(%eax) + movl %ebp, (JB_EBP)(%eax) /* And return 0 */ - xorl %eax, %eax + xorl %eax, %eax ret #ifndef __CYGWIN__ .size SYMBOL(up_setjmp), . - SYMBOL(up_setjmp) @@ -123,19 +123,19 @@ SYMBOL(up_longjmp): /* Save the return address now. */ - movl (JB_PC)(%ecx), %edx + movl (JB_PC)(%ecx), %edx /* Restore registers. */ - movl (JB_EBX)(%ecx), %ebx - movl (JB_ESI)(%ecx), %esi - movl (JB_EDI)(%ecx), %edi - movl (JB_EBP)(%ecx), %ebp - movl (JB_SP)(%ecx), %esp + movl (JB_EBX)(%ecx), %ebx + movl (JB_ESI)(%ecx), %esi + movl (JB_EDI)(%ecx), %edi + movl (JB_EBP)(%ecx), %ebp + movl (JB_SP)(%ecx), %esp /* Jump to saved PC. */ - jmp *%edx + jmp *%edx #ifndef __CYGWIN__ .size SYMBOL(up_longjmp), . - SYMBOL(up_longjmp) #endif diff --git a/configs/sim/README.txt b/configs/sim/README.txt index 2ad8099f9d..f02f442581 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -10,6 +10,7 @@ Contents o Debugging o Issues - 64-bit Issues + - Compiler differences - Stack Size Issues - Buffered I/O Issues - Networking Issues @@ -107,6 +108,14 @@ are included in the LDFLAGS. See the patch 0001-Quick-hacks-to-build-sim-nsh-ostest-on-x86_64-as-32-.patch that can be found at http://tech.groups.yahoo.com/group/nuttx/files. +Compiler differences +-------------------- + +operator new + + Problem: "'operator new' takes size_t ('...') as first parameter" + Workaround: Add -fpermissive to the compilation flags + Stack Size Issues ----------------- When you run the NuttX simulation, it uses stacks allocated by NuttX from the diff --git a/configs/sim/nx11/Make.defs b/configs/sim/nx11/Make.defs index 2dfda3e659..d385d823be 100644 --- a/configs/sim/nx11/Make.defs +++ b/configs/sim/nx11/Make.defs @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/nxwm/Make.defs b/configs/sim/nxwm/Make.defs index 89fc79cd32..958ded466c 100644 --- a/configs/sim/nxwm/Make.defs +++ b/configs/sim/nxwm/Make.defs @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/configs/sim/touchscreen/Make.defs b/configs/sim/touchscreen/Make.defs index 599b374327..2ea9a3c890 100644 --- a/configs/sim/touchscreen/Make.defs +++ b/configs/sim/touchscreen/Make.defs @@ -53,6 +53,11 @@ ARCHINCLUDES = -I. -isystem $(TOPDIR)/include ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx ARCHSCRIPT = +ifeq ($(CONFIG_SIM_M32),y) + ARCHCPUFLAGS += -m32 + ARCHCPUFLAGSXX += -m32 +endif + CROSSDEV = CC = $(CROSSDEV)gcc CXX = $(CROSSDEV)g++ @@ -79,8 +84,20 @@ else EXEEXT = endif -ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") - LDFLAGS += -g +LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD) +CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC) +LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS + +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDLINKFLAGS += -g + CCLINKFLAGS += -g + LDFLAGS += -g +endif + +ifeq ($(CONFIG_SIM_M32),y) + LDLINKFLAGS += -melf_i386 + CCLINKFLAGS += -m32 + LDFLAGS += -m32 endif define PREPROCESS diff --git a/drivers/mmcsd/mmcsd_spi.c b/drivers/mmcsd/mmcsd_spi.c index f7bbd64b48..c2321efc77 100644 --- a/drivers/mmcsd/mmcsd_spi.c +++ b/drivers/mmcsd/mmcsd_spi.c @@ -1,8 +1,8 @@ /**************************************************************************** * drivers/mmcsd/mmcsd_spi.c * - * Copyright (C) 2008-2010, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2008-2010, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/drivers/mtd/rammtd.c b/drivers/mtd/rammtd.c index 72acc73e8f..82a7191ea4 100644 --- a/drivers/mtd/rammtd.c +++ b/drivers/mtd/rammtd.c @@ -1,8 +1,8 @@ /**************************************************************************** * drivers/mtd/rammtd.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/drivers/mtd/ramtron.c b/drivers/mtd/ramtron.c index 0c922e69e6..5615823d67 100644 --- a/drivers/mtd/ramtron.c +++ b/drivers/mtd/ramtron.c @@ -3,9 +3,9 @@ * Driver for SPI-based RAMTRON NVRAM Devices FM25V10 and others (not tested) * * Copyright (C) 2011 Uros Platise. All rights reserved. - * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010, 2012 Gregory Nutt. All rights reserved. * Author: Uros Platise - * Gregory Nutt + * Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c index 2c98368a17..f0845070ba 100644 --- a/fs/fat/fs_fat32.c +++ b/fs/fat/fs_fat32.c @@ -377,7 +377,6 @@ errout_with_semaphore: static int fat_close(FAR struct file *filep) { struct inode *inode; - struct fat_mountpt_s *fs; struct fat_file_s *ff; int ret = OK; @@ -389,9 +388,6 @@ static int fat_close(FAR struct file *filep) ff = filep->f_priv; inode = filep->f_inode; - fs = inode->i_private; - - DEBUGASSERT(fs != NULL); /* Do not check if the mount is healthy. We must support closing of * the file even when there is healthy mount. @@ -1107,7 +1103,6 @@ static int fat_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { struct inode *inode; struct fat_mountpt_s *fs; - struct fat_file_s *ff; int ret; /* Sanity checks */ @@ -1116,7 +1111,6 @@ static int fat_ioctl(FAR struct file *filep, int cmd, unsigned long arg) /* Recover our private data from the struct file instance */ - ff = filep->f_priv; inode = filep->f_inode; fs = inode->i_private; diff --git a/fs/fs_fcntl.c b/fs/fs_fcntl.c index f0102ce8e8..b7e688895a 100644 --- a/fs/fs_fcntl.c +++ b/fs/fs_fcntl.c @@ -59,7 +59,7 @@ static inline int file_vfcntl(int fildes, int cmd, va_list ap) FAR struct filelist *list; FAR struct file *this_file; int err = 0; - int ret = 0; + int ret = OK; /* Get the thread-specific file list */ @@ -202,7 +202,7 @@ errout: errno = err; return ERROR; } - return OK; + return ret; } #endif /* CONFIG_NFILE_DESCRIPTORS > 0 */ diff --git a/libxx/README.txt b/libxx/README.txt index 7b292bff52..c97dae4ba4 100644 --- a/libxx/README.txt +++ b/libxx/README.txt @@ -7,11 +7,30 @@ embedded world, that is probably all that is necessary. If you have a need for more extensive C++ support, the following libraries are recommended: - - libstdc++ (part of GCC) - - STLport http://www.stlport.org/ - - uClibc++ http://cxx.uclibc.org/ + - libstdc++ (part of GCC) + - STLport http://www.stlport.org/ + - uClibc++ http://cxx.uclibc.org/ At present, only the following are supported here: - void *operator new(std::size_t nbytes); - - void operator delete(void* ptr); \ No newline at end of file + - void operator delete(void* ptr); + - void operator delete[](void *ptr); + - void __cxa_pure_virtual(void); + - int __aeabi_atexit(void* object, void (*destroyer)(void*), void *dso_handle); + +operator new +------------ + + This operator should take a type of size_t. But size_t has an unknown underlying + type. In the nuttx sys/types.h header file, size_t is typed as uint32_t + (which is determined by architecture-specific logic). But the C++ + compiler may believe that size_t is of a different type resulting in + compilation errors in the operator. Using the underlying integer type + instead of size_t seems to resolve the compilation issues. Need to + REVISIT this. + + Once some C++ compilers, this will cause an error: + + Problem: "'operator new' takes size_t ('...') as first parameter" + Workaround: Add -fpermissive to the compilation flags diff --git a/sched/prctl.c b/sched/prctl.c index bc55992b48..817083561a 100644 --- a/sched/prctl.c +++ b/sched/prctl.c @@ -140,7 +140,7 @@ int prctl(int option, ...) /* The returned value will be null-terminated, truncating if necessary */ strncpy(name, tcb->name, CONFIG_TASK_NAME_SIZE-1); - name[CONFIG_TASK_NAME_SIZE-1]; + name[CONFIG_TASK_NAME_SIZE-1] = '\0'; } } break; diff --git a/sched/pthread_exit.c b/sched/pthread_exit.c index 31ac623627..b8183142a3 100644 --- a/sched/pthread_exit.c +++ b/sched/pthread_exit.c @@ -1,7 +1,7 @@ /************************************************************************ * sched/pthread_exit.c * - * Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011-2012 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ #include +#include #include #include #include @@ -92,7 +93,7 @@ void pthread_exit(FAR void *exit_value) { - int error_code = (int)exit_value; + int error_code = (int)((intptr_t)exit_value); int status; sdbg("exit_value=%p\n", exit_value); diff --git a/sched/sem_open.c b/sched/sem_open.c index cd9ca6129a..d5b22f0183 100644 --- a/sched/sem_open.c +++ b/sched/sem_open.c @@ -1,8 +1,8 @@ /**************************************************************************** * sched/sem_open.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/sched/sig_deliver.c b/sched/sig_deliver.c index 2244ca2fe0..bbfe0965ce 100644 --- a/sched/sig_deliver.c +++ b/sched/sig_deliver.c @@ -1,8 +1,8 @@ /**************************************************************************** * sched/sig_deliver.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -86,7 +86,6 @@ void sig_deliver(FAR _TCB *stcb) { - pid_t rpid; FAR sigq_t *sigq; FAR sigq_t *next; sigset_t savesigprocmask; @@ -129,12 +128,6 @@ void sig_deliver(FAR _TCB *stcb) savesigprocmask = stcb->sigprocmask; stcb->sigprocmask = savesigprocmask | sigq->mask | SIGNO2SET(sigq->info.si_signo); - /* The current tasks process.ID. We'll need this later to see if - * the signal handler caused a context switch. - */ - - rpid = getpid(); - /* Deliver the signal */ (*sigq->action.sighandler)(sigq->info.si_signo, &sigq->info, NULL); diff --git a/sched/wd_start.c b/sched/wd_start.c index 1f37dbf99f..a2f19fbdc5 100644 --- a/sched/wd_start.c +++ b/sched/wd_start.c @@ -1,8 +1,8 @@ /**************************************************************************** * sched/wd_start.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -294,7 +294,6 @@ int wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, int argc, ...) void wd_timer(void) { - pid_t pid; FAR wdog_t *wdog; /* Check if there are any active watchdogs to process */ @@ -333,12 +332,6 @@ void wd_timer(void) wdog->active = false; - /* Get the current task's process ID. We'll need this later to - * see if the watchdog function caused a context switch. - */ - - pid = getpid(); - /* Execute the watchdog function */ up_setpicbase(wdog->picbase);