From 2611da5e2a32b93ee0dc3fbca906a98c27e1950c Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 27 Feb 2007 21:17:21 +0000 Subject: [PATCH] Finally, a clean SDCC compile git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@20 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/arch/README.txt | 5 - nuttx/arch/c5471/defconfig | 26 -- nuttx/arch/sim/defconfig | 26 -- nuttx/drivers/Makefile | 2 +- nuttx/drivers/dev_null.c | 7 +- nuttx/examples/ostest/Makefile | 2 +- nuttx/examples/ostest/cancel.c | 4 +- nuttx/examples/ostest/cond.c | 7 + nuttx/examples/ostest/main.c | 14 +- nuttx/examples/ostest/mqueue.c | 14 +- nuttx/examples/ostest/mutex.c | 25 +- nuttx/examples/ostest/sem.c | 15 +- nuttx/examples/ostest/sighand.c | 6 + nuttx/examples/ostest/timedwait.c | 2 +- nuttx/fs/Makefile | 2 +- nuttx/fs/fs_close.c | 4 +- nuttx/fs/fs_dup.c | 4 +- nuttx/fs/fs_files.c | 52 ++-- nuttx/fs/fs_inode.c | 67 +++-- nuttx/fs/fs_internal.h | 17 +- nuttx/fs/fs_ioctl.c | 16 +- nuttx/fs/fs_open.c | 6 +- nuttx/fs/fs_read.c | 20 +- nuttx/fs/fs_write.c | 4 +- nuttx/include/assert.h | 4 +- nuttx/include/errno.h | 8 +- nuttx/include/mqueue.h | 5 +- nuttx/include/nuttx/arch.h | 20 +- nuttx/include/nuttx/compiler.h | 104 ++++++- nuttx/include/nuttx/fs.h | 76 +++-- nuttx/include/nuttx/irq.h | 4 +- nuttx/include/nuttx/kmalloc.h | 8 +- nuttx/include/nuttx/lib.h | 8 +- nuttx/include/nuttx/os_external.h | 2 +- nuttx/include/pthread.h | 59 ++-- nuttx/include/queue.h | 46 +-- nuttx/include/sched.h | 53 ++-- nuttx/include/semaphore.h | 18 +- nuttx/include/signal.h | 5 +- nuttx/include/stdio.h | 30 +- nuttx/include/stdlib.h | 40 ++- nuttx/include/string.h | 4 +- nuttx/include/unistd.h | 2 +- nuttx/include/wdog.h | 2 +- nuttx/lib/Makefile | 2 +- nuttx/lib/dq_addafter.c | 12 +- nuttx/lib/dq_addbefore.c | 12 +- nuttx/lib/dq_addfirst.c | 3 +- nuttx/lib/dq_addlast.c | 3 +- nuttx/lib/dq_rem.c | 7 +- nuttx/lib/dq_remfirst.c | 7 +- nuttx/lib/dq_remlast.c | 7 +- nuttx/lib/lib_fclose.c | 2 +- nuttx/lib/lib_fflush.c | 2 +- nuttx/lib/lib_filesem.c | 10 +- nuttx/lib/lib_fopen.c | 28 +- nuttx/lib/lib_getenv.c | 93 +++--- nuttx/lib/lib_init.c | 15 +- nuttx/lib/lib_internal.h | 14 +- nuttx/lib/lib_libvsprintf.c | 1 + nuttx/lib/lib_sscanf.c | 322 +++++++++++---------- nuttx/lib/lib_strdup.c | 6 +- nuttx/lib/lib_streamsem.c | 4 +- nuttx/lib/sq_addafter.c | 2 +- nuttx/lib/sq_addfirst.c | 2 +- nuttx/lib/sq_addlast.c | 2 +- nuttx/lib/sq_rem.c | 6 +- nuttx/lib/sq_remafter.c | 5 +- nuttx/lib/sq_remfirst.c | 5 +- nuttx/lib/sq_remlast.c | 6 +- nuttx/mm/Makefile | 2 +- nuttx/mm/mm_addfreechunk.c | 6 +- nuttx/mm/mm_calloc.c | 4 +- nuttx/mm/mm_environment.h | 1 + nuttx/mm/mm_free.c | 21 +- nuttx/mm/mm_initialize.c | 24 +- nuttx/mm/mm_internal.h | 47 +-- nuttx/mm/mm_mallinfo.c | 34 ++- nuttx/mm/mm_malloc.c | 12 +- nuttx/mm/mm_memalign.c | 20 +- nuttx/mm/mm_realloc.c | 38 +-- nuttx/mm/mm_shrinkchunk.c | 18 +- nuttx/mm/mm_zalloc.c | 4 +- nuttx/sched/Makefile | 4 +- nuttx/sched/get_errno_ptr.c | 4 +- nuttx/sched/get_errorptr.c | 83 ------ nuttx/sched/irq_attach.c | 4 + nuttx/sched/irq_dispatch.c | 6 +- nuttx/sched/irq_internal.h | 2 +- nuttx/sched/irq_unexpectedisr.c | 2 +- nuttx/sched/mq_close.c | 15 +- nuttx/sched/mq_descreate.c | 4 +- nuttx/sched/mq_findnamed.c | 6 +- nuttx/sched/mq_initialize.c | 6 +- nuttx/sched/mq_internal.h | 55 ++-- nuttx/sched/mq_msgfree.c | 6 +- nuttx/sched/mq_msgqfree.c | 8 +- nuttx/sched/mq_open.c | 12 +- nuttx/sched/mq_receive.c | 20 +- nuttx/sched/mq_send.c | 42 +-- nuttx/sched/mq_unlink.c | 9 +- nuttx/sched/os_internal.h | 42 +-- nuttx/sched/os_start.c | 7 +- nuttx/sched/pthread_completejoin.c | 8 +- nuttx/sched/pthread_condtimedwait.c | 125 +++++--- nuttx/sched/pthread_create.c | 24 +- nuttx/sched/pthread_detach.c | 2 +- nuttx/sched/pthread_exit.c | 3 +- nuttx/sched/pthread_findjoininfo.c | 4 +- nuttx/sched/pthread_getspecific.c | 7 +- nuttx/sched/pthread_initialize.c | 5 +- nuttx/sched/pthread_internal.h | 14 +- nuttx/sched/pthread_join.c | 5 +- nuttx/sched/pthread_removejoininfo.c | 7 +- nuttx/sched/pthread_setspecific.c | 5 +- nuttx/sched/sched_addblocked.c | 5 +- nuttx/sched/sched_addprioritized.c | 25 +- nuttx/sched/sched_addreadytorun.c | 4 +- nuttx/sched/sched_free.c | 5 +- nuttx/sched/sched_getfiles.c | 4 +- nuttx/sched/sched_getparam.c | 7 +- nuttx/sched/sched_getstreams.c | 4 +- nuttx/sched/sched_gettcb.c | 5 +- nuttx/sched/sched_mergepending.c | 14 +- nuttx/sched/sched_processtimer.c | 1 + nuttx/sched/sched_releasetcb.c | 4 +- nuttx/sched/sched_removeblocked.c | 5 +- nuttx/sched/sched_removereadytorun.c | 4 +- nuttx/sched/sched_rrgetinterval.c | 4 +- nuttx/sched/sched_setparam.c | 8 +- nuttx/sched/sched_setscheduler.c | 3 +- nuttx/sched/sched_setupidlefiles.c | 2 +- nuttx/sched/sched_setuppthreadfiles.c | 4 +- nuttx/sched/sched_setupstreams.c | 2 +- nuttx/sched/sched_setuptaskfiles.c | 4 +- nuttx/sched/sched_yield.c | 2 +- nuttx/sched/sem_close.c | 9 +- nuttx/sched/sem_findnamed.c | 6 +- nuttx/sched/sem_internal.h | 16 +- nuttx/sched/sem_open.c | 17 +- nuttx/sched/sem_post.c | 6 +- nuttx/sched/sem_unlink.c | 9 +- nuttx/sched/sem_wait.c | 5 +- nuttx/sched/sem_waitirq.c | 3 +- nuttx/sched/sig_action.c | 22 +- nuttx/sched/sig_allocatependingsigaction.c | 12 +- nuttx/sched/sig_cleanup.c | 16 +- nuttx/sched/sig_deliver.c | 22 +- nuttx/sched/sig_findaction.c | 30 +- nuttx/sched/sig_initialize.c | 34 +-- nuttx/sched/sig_internal.h | 41 +-- nuttx/sched/sig_mqnotempty.c | 3 +- nuttx/sched/sig_pending.c | 14 +- nuttx/sched/sig_procmask.c | 63 ++-- nuttx/sched/sig_queue.c | 3 +- nuttx/sched/sig_received.c | 46 +-- nuttx/sched/sig_releasependingsigaction.c | 6 +- nuttx/sched/sig_releasependingsignal.c | 6 +- nuttx/sched/sig_removependingsignal.c | 10 +- nuttx/sched/sig_suspend.c | 12 +- nuttx/sched/sig_timedwait.c | 18 +- nuttx/sched/sig_unmaskpendingsignal.c | 9 +- nuttx/sched/task_create.c | 33 ++- nuttx/sched/task_delete.c | 9 +- nuttx/sched/task_restart.c | 12 +- nuttx/sched/wd_cancel.c | 2 +- nuttx/sched/wd_delete.c | 4 +- nuttx/sched/wd_initialize.c | 8 +- nuttx/sched/wd_internal.h | 2 +- nuttx/sched/wd_start.c | 10 +- nuttx/tools/mkdeps.sh | 4 +- 171 files changed, 1513 insertions(+), 1325 deletions(-) delete mode 100644 nuttx/sched/get_errorptr.c diff --git a/nuttx/arch/README.txt b/nuttx/arch/README.txt index 0c7e19536..bdc353cbb 100644 --- a/nuttx/arch/README.txt +++ b/nuttx/arch/README.txt @@ -92,11 +92,6 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_ARCH_STRNCPY, CONFIG_ARCH_STRLEN, CONFIG_ARCH_BZERO CONFIG_ARCH_KMALLOC, CONFIG_ARCH_KZMALLOC, CONFIG_ARCH_KFREE - General Compile environment setup - - CONFIG_HAVE_LONG_LONG - enable if your architecture supports - long long types and if you plan to use them - Sizes of configurable things (0 disables) CONFIG_NPTHREAD_KEYS - The number of items of thread- diff --git a/nuttx/arch/c5471/defconfig b/nuttx/arch/c5471/defconfig index 2dd38f014..449d1a2d2 100644 --- a/nuttx/arch/c5471/defconfig +++ b/nuttx/arch/c5471/defconfig @@ -129,32 +129,6 @@ CONFIG_ARCH_KMALLOC=n CONFIG_ARCH_KZMALLOC=n CONFIG_ARCH_KFREE=n -# -# General Compile environment setup -# -# CONFIG_SMALL_MEMORY - enable if your processor supports -# 16-bit addressing; disable if it supports 32-bit. -# CONFIG_HAVE_INLINE - enable if your compiler supports -# inline functions -# CONFIG_HAVE_DOUBLE - enable if your compiler supports type -# double. -# CONFIG_HAVE_LONG_LONG - enable if your architecture supports -# long long types and if you plan to use them -# CONFIG_CAN_PASS_STRUCTS - enable if your compiler supports -# passing and assiging structures and unions as values -# CONFIG_CAN_CAST_POINTERS - enable if you can cast between -# integers and pointer. -# CONFIG_HAVE_WEAKFUNCTIONS - enable if you compiler supports -# weak functions (see include/nuttx/comp -# -CONFIG_SMALL_MEMORY=n -CONFIG_HAVE_INLINE=y -CONFIG_HAVE_DOUBLE=y -CONFIG_HAVE_LONG_LONG=n -CONFIG_CAN_PASS_STRUCTS=y -CONFIG_CAN_CAST_POINTERS=y -CONFIG_HAVE_WEAKFUNCTIONS=y - # # General build options # diff --git a/nuttx/arch/sim/defconfig b/nuttx/arch/sim/defconfig index 5b6f2ae6f..00a8e6e59 100644 --- a/nuttx/arch/sim/defconfig +++ b/nuttx/arch/sim/defconfig @@ -96,32 +96,6 @@ CONFIG_ARCH_KMALLOC=n CONFIG_ARCH_KZMALLOC=n CONFIG_ARCH_KFREE=n -# -# General Compile environment setup -# -# CONFIG_SMALL_MEMORY - enable if your processor supports -# 16-bit addressing; disable if it supports 32-bit. -# CONFIG_HAVE_INLINE - enable if your compiler supports -# inline functions -# CONFIG_HAVE_DOUBLE - enable if your compiler supports type -# double. -# CONFIG_HAVE_LONG_LONG - enable if your architecture supports -# long long types and if you plan to use them -# CONFIG_CAN_PASS_STRUCTS - enable if your compiler supports -# passing and assiging structures and unions as values -# CONFIG_CAN_CAST_POINTERS - enable if you can cast between -# integers and pointer. -# CONFIG_HAVE_WEAKFUNCTIONS - enable if you compiler supports -# weak functions (see include/nuttx/comp -# -CONFIG_SMALL_MEMORY=n -CONFIG_HAVE_INLINE=y -CONFIG_HAVE_DOUBLE=y -CONFIG_HAVE_LONG_LONG=n -CONFIG_CAN_PASS_STRUCTS=y -CONFIG_CAN_CAST_POINTERS=y -CONFIG_HAVE_WEAKFUNCTIONS=y - # # General build options # diff --git a/nuttx/drivers/Makefile b/nuttx/drivers/Makefile index 695dd806a..711b0ca33 100644 --- a/nuttx/drivers/Makefile +++ b/nuttx/drivers/Makefile @@ -69,7 +69,7 @@ $(BIN): $(OBJS) depend: .depend clean: - rm -f $(BIN) *.o *~ + rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ distclean: clean rm -f Make.dep .depend diff --git a/nuttx/drivers/dev_null.c b/nuttx/drivers/dev_null.c index f4211b513..1d449df1f 100644 --- a/nuttx/drivers/dev_null.c +++ b/nuttx/drivers/dev_null.c @@ -61,8 +61,11 @@ static ssize_t devnull_write(struct file *, const char *, size_t); static struct file_operations devnull_fops = { - .read = devnull_read, - .write = devnull_write, + NULL, /* open */ + NULL, /* close */ + devnull_read, /* read */ + devnull_write, /* write */ + NULL /* ioctl */ }; /************************************************************ diff --git a/nuttx/examples/ostest/Makefile b/nuttx/examples/ostest/Makefile index df30ca841..44c7f3f06 100644 --- a/nuttx/examples/ostest/Makefile +++ b/nuttx/examples/ostest/Makefile @@ -70,7 +70,7 @@ $(BIN): $(OBJS) depend: .depend clean: - rm -f $(BIN) *.o *~ + rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ distclean: clean rm -f Make.dep .depend diff --git a/nuttx/examples/ostest/cancel.c b/nuttx/examples/ostest/cancel.c index 1fda4166c..c6803c048 100644 --- a/nuttx/examples/ostest/cancel.c +++ b/nuttx/examples/ostest/cancel.c @@ -96,7 +96,7 @@ static void *thread_waiter(void *parameter) } printf("thread_waiter: Exit with status 0x12345678\n"); - pthread_exit((void*)0x12345678); + pthread_exit((pthread_addr_t)0x12345678); return NULL; } @@ -140,7 +140,7 @@ static void start_thread(pthread_t *waiter, int cancelable) /* Start the waiter thread */ printf("start_thread: Starting thread\n"); - status = pthread_create(waiter, NULL, thread_waiter, (void*)cancelable); + status = pthread_create(waiter, &attr, thread_waiter, (pthread_addr_t)cancelable); if (status != 0) { printf("start_thread: ERROR pthread_create failed, status=%d\n", status); diff --git a/nuttx/examples/ostest/cond.c b/nuttx/examples/ostest/cond.c index 13e7b4669..6214ea9d0 100644 --- a/nuttx/examples/ostest/cond.c +++ b/nuttx/examples/ostest/cond.c @@ -190,6 +190,9 @@ void cond_test(void) pthread_t waiter; pthread_t signaler; pthread_attr_t attr; +#ifdef SDCC + pthread_addr_t result; +#endif struct sched_param sparam; int prio_min; int prio_max; @@ -270,7 +273,11 @@ void cond_test(void) /* Wait for the threads to stop */ +#ifdef SDCC + pthread_join(signaler, &result); +#else pthread_join(signaler, NULL); +#endif printf("cond_test: signaler terminated, now cancel the waiter\n"); pthread_detach(waiter); pthread_cancel(waiter); diff --git a/nuttx/examples/ostest/main.c b/nuttx/examples/ostest/main.c index 3122ef343..ff1072176 100644 --- a/nuttx/examples/ostest/main.c +++ b/nuttx/examples/ostest/main.c @@ -55,18 +55,18 @@ #define STACKSIZE 8192 #define NARGS 4 -#define ARG1 "Arg1" -#define ARG2 "Arg2" -#define ARG3 "Arg3" -#define ARG4 "Arg4" - /************************************************************ * Private Data ************************************************************/ +static FAR char arg1[] = "Arg1"; +static FAR char arg2[] = "Arg2"; +static FAR char arg3[] = "Arg3"; +static FAR char arg4[] = "Arg4"; + static char write_data1[] = "Standard I/O Check: write fd=1\n"; static char write_data2[] = "Standard I/O Check: write fd=2\n"; -static char *args[NARGS] = { ARG1, ARG2, ARG3, ARG4 }; +static char *args[NARGS] = { arg1, arg2, arg3, arg4 }; /************************************************************ * Private Functions @@ -165,7 +165,7 @@ int user_start(int parm1, int parm2, int parm3, int parm4) /* Verify that we can spawn a new task */ result = task_create("ostest", PRIORITY, STACKSIZE, user_main, - ARG1, ARG2, ARG3, ARG4); + arg1, arg2, arg3, arg4); if (result == ERROR) { fprintf(stderr, "user_start: Failed to start user_main\n"); diff --git a/nuttx/examples/ostest/mqueue.c b/nuttx/examples/ostest/mqueue.c index acdbea99e..9e9360726 100644 --- a/nuttx/examples/ostest/mqueue.c +++ b/nuttx/examples/ostest/mqueue.c @@ -50,7 +50,11 @@ **************************************************************************/ #define TEST_MESSAGE "This is a test and only a test" +#ifdef SDCC +#define TEST_MSGLEN (31) +#else #define TEST_MSGLEN (strlen(TEST_MESSAGE)+1) +#endif /************************************************************************** * Private Types @@ -108,7 +112,7 @@ static void *sender_thread(void *arg) if (mqfd < 0) { printf("sender_thread: ERROR mq_open failed\n"); - pthread_exit((void*)1); + pthread_exit((pthread_addr_t)1); } /* Fill in a test message buffer to send */ @@ -139,7 +143,7 @@ static void *sender_thread(void *arg) } printf("sender_thread: returning nerrors=%d\n", nerrors); - return (void*)nerrors; + return (pthread_addr_t)nerrors; } static void *receiver_thread(void *arg) @@ -174,7 +178,7 @@ static void *receiver_thread(void *arg) if (mqfd < 0) { printf("receiver_thread: ERROR mq_open failed\n"); - pthread_exit((void*)1); + pthread_exit((pthread_addr_t)1); } /* Perform the receive 10 times */ @@ -221,7 +225,7 @@ static void *receiver_thread(void *arg) nerrors++; } - pthread_exit((void*)nerrors); + pthread_exit((pthread_addr_t)nerrors); /* Destroy the queue */ @@ -232,7 +236,7 @@ static void *receiver_thread(void *arg) } printf("receiver_thread: returning nerrors=%d\n", nerrors); - return (void*)nerrors; + return (pthread_addr_t)nerrors; } void mqueue_test(void) diff --git a/nuttx/examples/ostest/mutex.c b/nuttx/examples/ostest/mutex.c index cb8996053..5edf60dba 100644 --- a/nuttx/examples/ostest/mutex.c +++ b/nuttx/examples/ostest/mutex.c @@ -91,6 +91,11 @@ static void *thread_func(void *parameter) void mutex_test(void) { pthread_t thread1, thread2; +#ifdef SDCC + pthread_addr_t result1, result2; + pthread_attr_t attr; +#endif + int status; /* Initialize the mutex */ @@ -100,19 +105,35 @@ void mutex_test(void) /* Start two thread instances */ printf("Starting thread 1\n"); - if ((pthread_create(&thread1, NULL, thread_func, (void*)1)) != 0) +#ifdef SDCC + (void)pthread_attr_init(&attr); + status = pthread_create(&thread1, &attr, thread_func, (pthread_addr_t)1); +#else + status = pthread_create(&thread1, NULL, thread_func, (pthread_addr_t)1); +#endif + if (status != 0) { printf("Error in thread#1 creation\n"); } printf("Starting thread 2\n"); - if ((pthread_create(&thread2, NULL, thread_func, (void*)2)) != 0) +#ifdef SDCC + status = pthread_create(&thread2, &attr, thread_func, (pthread_addr_t)2); +#else + status = pthread_create(&thread2, NULL, thread_func, (pthread_addr_t)2); +#endif + if (status != 0) { printf("Error in thread#2 creation\n"); } +#ifdef SDCC + pthread_join(thread1, &result1); + pthread_join(thread2, &result2); +#else pthread_join(thread1, NULL); pthread_join(thread2, NULL); +#endif printf("\t\tThread1\tThread2\n"); printf("\tLoops\t%ld\t%ld\n", nloops[0], nloops[1]); diff --git a/nuttx/examples/ostest/sem.c b/nuttx/examples/ostest/sem.c index 73be6910e..f6e6ddbb5 100644 --- a/nuttx/examples/ostest/sem.c +++ b/nuttx/examples/ostest/sem.c @@ -144,6 +144,9 @@ void sem_test(void) pthread_t waiter_thread1; pthread_t waiter_thread2; pthread_t poster_thread; +#ifdef SDCC + pthread_addr_t result; +#endif struct sched_param sparam; int prio_min; int prio_max; @@ -178,7 +181,7 @@ void sem_test(void) printf("sem_test: Set thread 1 priority to %d\n", sparam.sched_priority); } - status = pthread_create(&waiter_thread1, &attr, waiter_func, (void*)1); + status = pthread_create(&waiter_thread1, &attr, waiter_func, (pthread_addr_t)1); if (status != 0) { printf("sem_test: Error in thread 1 creation, status=%d\n", status); @@ -202,7 +205,7 @@ void sem_test(void) printf("sem_test: Set thread 2 priority to %d\n", sparam.sched_priority); } - status = pthread_create(&waiter_thread2, &attr, waiter_func, (void*)2); + status = pthread_create(&waiter_thread2, &attr, waiter_func, (pthread_addr_t)2); if (status != 0) { printf("sem_test: Error in thread 2 creation, status=%d\n", status); @@ -226,13 +229,19 @@ void sem_test(void) printf("sem_test: Set thread 3 priority to %d\n", sparam.sched_priority); } - status = pthread_create(&poster_thread, &attr, poster_func, (void*)3); + status = pthread_create(&poster_thread, &attr, poster_func, (pthread_addr_t)3); if (status != 0) { printf("sem_test: Error in thread 3 creation, status=%d\n", status); } +#ifdef SDCC + pthread_join(waiter_thread1, &result); + pthread_join(waiter_thread2, &result); + pthread_join(poster_thread, &result); +#else pthread_join(waiter_thread1, NULL); pthread_join(waiter_thread2, NULL); pthread_join(poster_thread, NULL); +#endif } diff --git a/nuttx/examples/ostest/sighand.c b/nuttx/examples/ostest/sighand.c index ada7d8836..f6970deb0 100644 --- a/nuttx/examples/ostest/sighand.c +++ b/nuttx/examples/ostest/sighand.c @@ -145,8 +145,10 @@ static int waiter_main(int argc, char *argv[]) printf("waiter_main: ERROR sigaction failed, status=%d\n" , status); } +#ifndef SDCC printf("waiter_main: oact.sigaction=%p oact.sa_flags=%x oact.sa_mask=%x\n", oact.sa_sigaction, oact.sa_flags, oact.sa_mask); +#endif /* Take the semaphore */ @@ -225,7 +227,11 @@ void sighand_test(void) /* Then signal the waiter thread. */ sigvalue.sival_int = SIGVALUE_INT; +#ifdef CONFIG_CAN_PASS_STRUCTS status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue); +#else + status = sigqueue(waiterpid, WAKEUP_SIGNAL, sigvalue.sival_ptr); +#endif if (status != OK) { printf("sighand_test: ERROR sigqueue failed\n" ); diff --git a/nuttx/examples/ostest/timedwait.c b/nuttx/examples/ostest/timedwait.c index af2fd2551..81e7c4a61 100644 --- a/nuttx/examples/ostest/timedwait.c +++ b/nuttx/examples/ostest/timedwait.c @@ -95,7 +95,7 @@ static void *thread_waiter(void *parameter) } printf("thread_waiter: Exit with status 0x12345678\n"); - pthread_exit((void*)0x12345678); + pthread_exit((pthread_addr_t)0x12345678); return NULL; } diff --git a/nuttx/fs/Makefile b/nuttx/fs/Makefile index 36b651739..6cce1face 100644 --- a/nuttx/fs/Makefile +++ b/nuttx/fs/Makefile @@ -70,7 +70,7 @@ $(BIN): $(OBJS) depend: .depend clean: - rm -f $(BIN) *.o *~ + rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ distclean: clean rm -f Make.dep .depend diff --git a/nuttx/fs/fs_close.c b/nuttx/fs/fs_close.c index a6a81d254..d8195a6d4 100644 --- a/nuttx/fs/fs_close.c +++ b/nuttx/fs/fs_close.c @@ -60,7 +60,7 @@ int close(int fd) { - struct filelist *list; + FAR struct filelist *list; /* Get the thread-specific file list */ @@ -73,7 +73,7 @@ int close(int fd) if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) { - struct inode *inode = list->fl_files[fd].f_inode; + FAR struct inode *inode = list->fl_files[fd].f_inode; if (inode) { files_release(fd); diff --git a/nuttx/fs/fs_dup.c b/nuttx/fs/fs_dup.c index 114f4b951..1a012903c 100644 --- a/nuttx/fs/fs_dup.c +++ b/nuttx/fs/fs_dup.c @@ -69,7 +69,7 @@ int dup(int fildes) { - struct filelist *list; + FAR struct filelist *list; int fildes2; /* Get the thread-specific file list */ @@ -109,7 +109,7 @@ int dup(int fildes) int dup2(int fildes1, int fildes2) { - struct filelist *list; + FAR struct filelist *list; /* Get the thread-specific file list */ diff --git a/nuttx/fs/fs_files.c b/nuttx/fs/fs_files.c index a280f9210..63a3554aa 100644 --- a/nuttx/fs/fs_files.c +++ b/nuttx/fs/fs_files.c @@ -72,7 +72,7 @@ * Private Functions ************************************************************/ -static void _files_semtake(struct filelist *list) +static void _files_semtake(FAR struct filelist *list) { /* Take the semaphore (perhaps waiting) */ @@ -102,10 +102,10 @@ void files_initialize(void) /* Allocate a list of files for a new task */ -struct filelist *files_alloclist(void) +FAR struct filelist *files_alloclist(void) { - struct filelist *list; - list = (struct filelist*)kzmalloc(sizeof(struct filelist)); + FAR struct filelist *list; + list = (FAR struct filelist*)kzmalloc(sizeof(struct filelist)); if (list) { /* Start with a reference count of one */ @@ -121,7 +121,7 @@ struct filelist *files_alloclist(void) /* Increase the reference count on a file list */ -int files_addreflist(struct filelist *list) +int files_addreflist(FAR struct filelist *list) { if (list) { @@ -136,7 +136,7 @@ int files_addreflist(struct filelist *list) /* Release a reference to the file list */ -int files_releaselist(struct filelist *list) +int files_releaselist(FAR struct filelist *list) { int crefs; if (list) @@ -159,7 +159,7 @@ int files_releaselist(struct filelist *list) for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) { - struct inode *inode = list->fl_files[i].f_inode; + FAR struct inode *inode = list->fl_files[i].f_inode; if (inode) { inode_release(inode); @@ -179,9 +179,9 @@ int files_releaselist(struct filelist *list) * heart of dup2. */ -int files_dup(struct file *filep1, struct file *filep2) +int files_dup(FAR struct file *filep1, FAR struct file *filep2) { - struct filelist *list; + FAR struct filelist *list; if (!filep1 || !filep1->f_inode || !filep2) { @@ -225,34 +225,34 @@ int files_dup(struct file *filep1, struct file *filep2) * the files array. */ -int files_allocate(struct inode *inode, int oflags, off_t pos) +int files_allocate(FAR struct inode *inode, int oflags, off_t pos) { - struct filelist *list; + FAR struct filelist *list; int i; list = sched_getfiles(); if (list) { - _files_semtake(list); - for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) - { - if (!list->fl_files[i].f_inode) - { - list->fl_files[i].f_oflags = oflags; - list->fl_files[i].f_pos = pos; - list->fl_files[i].f_inode = inode; - _files_semgive(list); - return i; - } - } - _files_semgive(list); - } + _files_semtake(list); + for (i = 0; i < CONFIG_NFILE_DESCRIPTORS; i++) + { + if (!list->fl_files[i].f_inode) + { + list->fl_files[i].f_oflags = oflags; + list->fl_files[i].f_pos = pos; + list->fl_files[i].f_inode = inode; + _files_semgive(list); + return i; + } + } + _files_semgive(list); + } return ERROR; } void files_release(int filedes) { - struct filelist *list; + FAR struct filelist *list; list = sched_getfiles(); if (list) diff --git a/nuttx/fs/fs_inode.c b/nuttx/fs/fs_inode.c index db7451d30..c6d673190 100644 --- a/nuttx/fs/fs_inode.c +++ b/nuttx/fs/fs_inode.c @@ -69,7 +69,7 @@ static sem_t tree_sem; * Public Variables ************************************************************/ -struct inode *root_inode = NULL; +FAR struct inode *root_inode = NULL; /************************************************************ * Private Functions @@ -92,7 +92,7 @@ static void _inode_semtake(void) #define _inode_semgive(void) sem_post(&tree_sem) static int _inode_compare(const char *fname, - struct inode *node) + FAR struct inode *node) { char *nname = node->i_name; @@ -172,12 +172,12 @@ static const char *_inode_nextname(const char *name) return name; } -static struct inode *_inode_alloc(const char *name, - struct file_operations *fops, - mode_t mode, void *private) +static FAR struct inode *_inode_alloc(const char *name, + struct file_operations *fops, + mode_t mode, void *private) { int namelen = _inode_namelen(name); - struct inode *node = malloc(FSNODE_SIZE(namelen)); + FAR struct inode *node = (FAR struct inode*)malloc(FSNODE_SIZE(namelen)); if (node) { node->i_peer = NULL; @@ -192,14 +192,14 @@ static struct inode *_inode_alloc(const char *name, return node; } -static struct inode *_inode_find(const char **path, - struct inode **peer, - struct inode **parent) +static FAR struct inode *_inode_find(const char **path, + FAR struct inode **peer, + FAR struct inode **parent) { - const char *name = *path + 1; /* Skip over leading '/' */ - struct inode *node = root_inode; - struct inode *left = NULL; - struct inode *above = NULL; + const char *name = *path + 1; /* Skip over leading '/' */ + FAR struct inode *node = root_inode; + FAR struct inode *left = NULL; + FAR struct inode *above = NULL; while (node) { @@ -278,9 +278,9 @@ static struct inode *_inode_find(const char **path, return node; } -static void _inode_insert(struct inode *node, - struct inode *peer, - struct inode *parent) +static void _inode_insert(FAR struct inode *node, + FAR struct inode *peer, + FAR struct inode *parent) { /* If peer is non-null, then new node simply goes to the right * of that peer node. @@ -342,7 +342,7 @@ static void _inode_remove(struct inode *node, node->i_peer = NULL; } -static void _inode_free(struct inode *node) +static void _inode_free(FAR struct inode *node) { if (node) { @@ -370,7 +370,9 @@ void fs_initialize(void) /* Initialize files array (if it is used) */ +#ifdef CONFIG_HAVE_WEAKFUNCTIONS if (files_initialize != NULL) +#endif { files_initialize(); } @@ -380,9 +382,9 @@ void fs_initialize(void) * to the inode associatged with a path. */ -struct inode *inode_find(const char *path) +FAR struct inode *inode_find(const char *path) { - struct inode *node; + FAR struct inode *node; if (!*path || path[0] != '/') { @@ -394,7 +396,7 @@ struct inode *inode_find(const char *path) */ _inode_semtake(); - node = _inode_find(&path, NULL, NULL); + node = _inode_find(&path, (FAR void*)NULL, (FAR void*)NULL); if (node) node->i_crefs++; _inode_semgive(); return node; @@ -404,7 +406,7 @@ struct inode *inode_find(const char *path) * descriptor is dup'ed. */ -void inode_addref(struct inode *inode) +void inode_addref(FAR struct inode *inode) { if (inode) { @@ -418,14 +420,17 @@ void inode_addref(struct inode *inode) * to the inode. */ -void inode_release(struct inode *node) +void inode_release(FAR struct inode *node) { if (node) { /* Decrement the references of the inode */ _inode_semtake(); - if (node->i_crefs) node->i_crefs--; + if (node->i_crefs) + { + node->i_crefs--; + } /* If the subtree was previously deleted and the reference * count has decrement to zero, then delete the inode @@ -450,9 +455,9 @@ STATUS register_inode(const char *path, struct file_operations *fops, mode_t mode, void *private) { - const char *name = path; - struct inode *left; - struct inode *parent; + const char *name = path; + FAR struct inode *left; + FAR struct inode *parent; if (!*path || path[0] != '/') { @@ -474,7 +479,7 @@ STATUS register_inode(const char *path, for (;;) { - struct inode *node; + FAR struct inode *node; /* Create a new node -- we need to know if this is the * the leaf node or some intermediary. We can find this @@ -519,10 +524,10 @@ STATUS register_inode(const char *path, STATUS unregister_inode(const char *path) { - const char *name = path; - struct inode *node; - struct inode *left; - struct inode *parent; + const char *name = path; + FAR struct inode *node; + FAR struct inode *left; + FAR struct inode *parent; if (*path && path[0] == '/') { diff --git a/nuttx/fs/fs_internal.h b/nuttx/fs/fs_internal.h index e8e8a33c9..a063335fb 100644 --- a/nuttx/fs/fs_internal.h +++ b/nuttx/fs/fs_internal.h @@ -58,10 +58,7 @@ * Global Variables ************************************************************/ -#if CONFIG_NFILE_DESCRIPTORS >0 -extern struct file files[CONFIG_NFILE_DESCRIPTORS]; -#endif -extern struct inode *root_inode; +extern FAR struct inode *root_inode; /************************************************************ * Pulblic Function Prototypes @@ -77,23 +74,21 @@ extern "C" { /* fs_inode.c ***********************************************/ -EXTERN struct inode *inode_find(const char *path); -EXTERN void inode_addref(struct inode *inode); -EXTERN void inode_release(struct inode *inode); +EXTERN FAR struct inode *inode_find(const char *path); +EXTERN void inode_addref(FAR struct inode *inode); +EXTERN void inode_release(FAR struct inode *inode); /* fs_files.c ***********************************************/ #if CONFIG_NFILE_DESCRIPTORS >0 EXTERN void weak_function files_initialize(void); -EXTERN int files_allocate(struct inode *inode, int oflags, off_t pos); +EXTERN int files_allocate(FAR struct inode *inode, int oflags, off_t pos); EXTERN void files_release(int filedes); #endif #undef EXTERN #if defined(__cplusplus) } -#endif - - +#endif #endif /* __FS_INTERNAL_H */ diff --git a/nuttx/fs/fs_ioctl.c b/nuttx/fs/fs_ioctl.c index 483a2d929..4202ce8b3 100644 --- a/nuttx/fs/fs_ioctl.c +++ b/nuttx/fs/fs_ioctl.c @@ -53,14 +53,24 @@ int ioctl(int fd, int req, unsigned long arg) { + FAR struct filelist *list; int ret = EBADF; - /* We we give a valid file descriptor? */ + /* Get the thread-specific file list */ + + list = sched_getfiles(); + if (!list) + { + *get_errno_ptr() = EMFILE; + return ERROR; + } + + /* Were we give a valid file descriptor? */ if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) { - struct file *this_file = &files[fd]; - struct inode *inode = this_file->f_inode; + FAR struct file *this_file = &list->fl_files[fd]; + struct inode *inode = this_file->f_inode; /* Is a driver registered? Does it support the ioctl method? */ diff --git a/nuttx/fs/fs_open.c b/nuttx/fs/fs_open.c index deedd60fe..3703fecda 100644 --- a/nuttx/fs/fs_open.c +++ b/nuttx/fs/fs_open.c @@ -68,7 +68,7 @@ * Public Functions ************************************************************/ -int inode_checkflags(struct inode *inode, int oflags) +int inode_checkflags(FAR struct inode *inode, int oflags) { if (((oflags & O_RDOK) != 0 && !inode->i_ops->read) || ((oflags & O_WROK) != 0 && !inode->i_ops->write)) @@ -85,7 +85,7 @@ int inode_checkflags(struct inode *inode, int oflags) int open(const char *path, int oflags, ...) { struct filelist *list; - struct inode *inode; + FAR struct inode *inode; int status; int fd; @@ -150,7 +150,7 @@ int open(const char *path, int oflags, ...) status = OK; if (inode->i_ops && inode->i_ops->open) { - status = inode->i_ops->open(&list->fl_files[fd]); + status = inode->i_ops->open((FAR struct file*)&list->fl_files[fd]); } if (status != OK || !inode->i_ops) diff --git a/nuttx/fs/fs_read.c b/nuttx/fs/fs_read.c index a092d0db6..1bbcdead0 100644 --- a/nuttx/fs/fs_read.c +++ b/nuttx/fs/fs_read.c @@ -57,7 +57,7 @@ int read(int fd, void *buf, unsigned int nbytes) { - struct filelist *list; + FAR struct filelist *list; int ret = EBADF; /* Get the thread-specific file list */ @@ -73,23 +73,23 @@ int read(int fd, void *buf, unsigned int nbytes) if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) { - struct file *this_file = &list->fl_files[fd]; + FAR struct file *this_file = &list->fl_files[fd]; /* Was this file opened for read access? */ if ((this_file->f_oflags & O_RDOK) != 0) - { + { struct inode *inode = this_file->f_inode; - /* Is a driver registered? Does it support the read method? */ + /* Is a driver registered? Does it support the read method? */ - if (inode && inode->i_ops && inode->i_ops->read) - { - /* Yes, then let it perform the read */ + if (inode && inode->i_ops && inode->i_ops->read) + { + /* Yes, then let it perform the read */ - ret = (int)inode->i_ops->read(this_file, (char*)buf, (size_t)nbytes); - } - } + ret = (int)inode->i_ops->read(this_file, (char*)buf, (size_t)nbytes); + } + } } return ret; } diff --git a/nuttx/fs/fs_write.c b/nuttx/fs/fs_write.c index d85ba61e6..3928656ad 100644 --- a/nuttx/fs/fs_write.c +++ b/nuttx/fs/fs_write.c @@ -57,7 +57,7 @@ int write(int fd, const void *buf, unsigned int nbytes) { - struct filelist *list; + FAR struct filelist *list; int ret = EBADF; /* Get the thread-specific file list */ @@ -73,7 +73,7 @@ int write(int fd, const void *buf, unsigned int nbytes) if ((unsigned int)fd < CONFIG_NFILE_DESCRIPTORS) { - struct file *this_file = &list->fl_files[fd]; + FAR struct file *this_file = &list->fl_files[fd]; /* Was this file opened for write access? */ diff --git a/nuttx/include/assert.h b/nuttx/include/assert.h index 022e343ca..4222aa2d8 100644 --- a/nuttx/include/assert.h +++ b/nuttx/include/assert.h @@ -106,8 +106,8 @@ extern "C" { #endif #ifdef __GNUC__ -EXTERN void up_assert(const ubyte *fileName, int lineNum); -EXTERN void up_assert_code(const ubyte *fileName, int lineNum, +EXTERN void up_assert(FAR const ubyte *filename, int linenum); +EXTERN void up_assert_code(FAR const ubyte *filename, int linenum, int error_code); #else EXTERN void up_assert(void); diff --git a/nuttx/include/errno.h b/nuttx/include/errno.h index d189ccaa0..6f362cfc9 100644 --- a/nuttx/include/errno.h +++ b/nuttx/include/errno.h @@ -190,13 +190,7 @@ extern "C" { /* Return a pointer to the thread specifid errno */ -extern int *get_errno_ptr(void); - -#ifndef CONFIG_CAN_CAST_POINTERS -/* Return the value ERROR cast to (void*) */ - -extern void *get_errorptr(void); -#endif +extern FAR int *get_errno_ptr(void); #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/include/mqueue.h b/nuttx/include/mqueue.h index 3e54ba6e8..7e0966d25 100644 --- a/nuttx/include/mqueue.h +++ b/nuttx/include/mqueue.h @@ -78,7 +78,7 @@ struct sigevent { /* Message queue descriptor */ -typedef struct mq_des *mqd_t; +typedef FAR struct mq_des *mqd_t; /************************************************************ * Global Variables @@ -95,8 +95,7 @@ extern "C" { #define EXTERN extern #endif -EXTERN mqd_t mq_open(const char *mq_name, - int oflags, ... ); +EXTERN mqd_t mq_open(const char *mq_name, int oflags, ... ); EXTERN int mq_close(mqd_t mqdes ); EXTERN int mq_unlink(const char *mq_name ); EXTERN int mq_send(mqd_t mqdes, const void *msg, diff --git a/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h index 5ccba7c20..11e6a96fc 100644 --- a/nuttx/include/nuttx/arch.h +++ b/nuttx/include/nuttx/arch.h @@ -127,7 +127,7 @@ EXTERN void up_idle(void); * ************************************************************/ -EXTERN void up_initial_state(_TCB *tcb); +EXTERN void up_initial_state(FAR _TCB *tcb); /************************************************************ * Name: up_create_stack @@ -150,7 +150,7 @@ EXTERN void up_initial_state(_TCB *tcb); * must be allocated. ************************************************************/ -EXTERN STATUS up_create_stack(_TCB *tcb, size_t stack_size); +EXTERN STATUS up_create_stack(FAR _TCB *tcb, size_t stack_size); /************************************************************ * Name: up_use_stack @@ -173,7 +173,7 @@ EXTERN STATUS up_create_stack(_TCB *tcb, size_t stack_size); * ************************************************************/ -EXTERN STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size); +EXTERN STATUS up_use_stack(FAR _TCB *tcb, FAR void *stack, size_t stack_size); /************************************************************ * Name: up_release_stack @@ -184,7 +184,7 @@ EXTERN STATUS up_use_stack(_TCB *tcb, void *stack, size_t stack_size); * ************************************************************/ -EXTERN void up_release_stack(_TCB *dtcb); +EXTERN void up_release_stack(FAR _TCB *dtcb); /************************************************************ * Name: up_unblock_task @@ -202,7 +202,7 @@ EXTERN void up_release_stack(_TCB *dtcb); * ************************************************************/ -EXTERN void up_unblock_task(_TCB *tcb); +EXTERN void up_unblock_task(FAR _TCB *tcb); /************************************************************ * Name: up_block_task @@ -224,7 +224,7 @@ EXTERN void up_unblock_task(_TCB *tcb); * ************************************************************/ -EXTERN void up_block_task(_TCB *tcb, tstate_t task_state); +EXTERN void up_block_task(FAR _TCB *tcb, tstate_t task_state); /************************************************************ * Name: up_release_pending @@ -259,7 +259,7 @@ EXTERN void up_release_pending(void); * ************************************************************/ -EXTERN void up_reprioritize_rtr(_TCB *tcb, ubyte priority); +EXTERN void up_reprioritize_rtr(FAR _TCB *tcb, ubyte priority); /************************************************************ * Name: _exit @@ -314,7 +314,7 @@ EXTERN void up_reprioritize_rtr(_TCB *tcb, ubyte priority); * ************************************************************/ -EXTERN void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver); +EXTERN void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver); /************************************************************ * Name: up_allocate_heap @@ -328,7 +328,7 @@ EXTERN void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver); ************************************************************/ #ifndef CONFIG_HEAP_BASE -EXTERN void up_allocate_heap(void **heap_start, size_t *heap_size); +EXTERN void up_allocate_heap(FAR void **heap_start, size_t *heap_size); #endif /************************************************************ @@ -401,7 +401,7 @@ EXTERN void sched_process_timer(void); * ***********************************************************/ -EXTERN void irq_dispatch(int irq, void *context); +EXTERN void irq_dispatch(int irq, FAR void *context); /************************************************************ * Debug interfaces exported by the architecture-specific diff --git a/nuttx/include/nuttx/compiler.h b/nuttx/include/nuttx/compiler.h index b5eafe8d9..f15902171 100644 --- a/nuttx/include/nuttx/compiler.h +++ b/nuttx/include/nuttx/compiler.h @@ -44,26 +44,128 @@ * Definitions ************************************************************/ +/* GCC-specific definitions *********************************/ + #ifdef __GNUC__ + +/* GCC supports weak symbols which can be used to reduce + * code size because unnecessary "weak" functions can be + * excluded from the link. + */ + +# define CONFIG_HAVE_WEAKFUNCTIONS 1 # define weak_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); # define weak_function __attribute__ ((weak)) # define weak_const_function __attribute__ ((weak, __const__)) + +/* The noreturn attribute informs GCC that the function will + * not return. + */ + # define noreturn_function __attribute__ ((noreturn)) + +/* GCC does not support the reentrant attribute */ + # define reentrant_function -#elif defined(__SDCC__) + +/* GCC has does not use storage classes to qualify addressing */ + +# define FAR +# define NEAR + +/* Select the large, 32-bit addressing model */ + +# undef CONFIG_SMALL_MEMORY + +/* GCC supports inlined functions */ + +# define CONFIG_HAVE_INLINE 1 + +/* GCC supports both types double and long long */ + +# define CONFIG_HAVE_DOUBLE 1 +# define CONFIG_HAVE_LONG_LONG 1 + +/* Structures and unions can be assigned and passed as values */ + +# define CONFIG_CAN_PASS_STRUCTS 1 + +/* SDCC-specific definitions ********************************/ + +#elif defined(SDCC) + +/* Disable warnings for unused function arguments */ + # pragma disable_warning 85 + +/* SDCC does not support weak symbols */ + +# undef CONFIG_HAVE_WEAKFUNCTIONS # define weak_alias(name, aliasname) # define weak_function # define weak_const_function + +/* SDCC does not support the noreturn attribute */ + # define noreturn_function + +/* The reentrant attribute informs SDCC that the function + * must be reentrant. In this case, SDCC will store input + * arguments on the stack to support reentrancy. + */ + # define reentrant_function __reentrant + +/* It is assumed that the system is build using the small + * data model with storage defaulting to internal RAM. + * The NEAR storage class can also be used to address data + * in internal RAM; FAR can be used to address data in + * external RAM. + */ + +#define FAR __xdata +#define NEAR __data + +/* Select small, 16-bit address model */ + +# define CONFIG_SMALL_MEMORY 1 + +/* SDCC does not support inline functions */ + +# undef CONFIG_HAVE_INLINE + +/* SDCC does not support type long long or type double */ + +# undef CONFIG_HAVE_LONG_LONG +# undef CONFIG_HAVE_DOUBLE + +/* Structures and unions cannot be passed as values or used + * in assignments. + */ + +# undef CONFIG_CAN_PASS_STRUCTS + +/* Unknown compiler *****************************************/ + #else + +# undef CONFIG_HAVE_WEAKFUNCTIONS # define weak_alias(name, aliasname) # define weak_function # define weak_const_function # define noreturn_function # define reentrant_function + +# define FAR +# define NEAR + +# undef CONFIG_SMALL_MEMORY +# undef CONFIG_HAVE_INLINE +# undef CONFIG_HAVE_LONG_LONG +# undef CONFIG_HAVE_DOUBLE +# undef CONFIG_CAN_PASS_STRUCTS + #endif /************************************************************ diff --git a/nuttx/include/nuttx/fs.h b/nuttx/include/nuttx/fs.h index 085c050ef..7e0eb8980 100644 --- a/nuttx/include/nuttx/fs.h +++ b/nuttx/include/nuttx/fs.h @@ -60,29 +60,27 @@ struct file; struct file_operations { - int (*open)(struct file *); - int (*close)(struct file *); -// off_t (*llseek)(struct file *, off_t, int); - ssize_t (*read)(struct file *, char *, size_t); - ssize_t (*write)(struct file *, const char *, size_t); -// unsigned int (*poll)(struct file *, struct poll_table_struct *); - int (*ioctl)(struct file *, int, unsigned long); + int (*open)(FAR struct file *); + int (*close)(FAR struct file *); + ssize_t (*read)(FAR struct file *, char *, size_t); + ssize_t (*write)(FAR struct file *, const char *, size_t); + int (*ioctl)(FAR struct file *, int, unsigned long); }; /* This structure represents one inode in the Nuttx psuedo-file system */ struct inode { - struct inode *i_peer; /* Pointer to inode at same level */ - struct inode *i_child; /* Pointer to inode at lower level */ - struct file_operations *i_ops; /* Driver file operations for inode */ - sint16 i_crefs; /* References to inode */ - uint16 i_flags; /* flags for inode */ + FAR struct inode *i_peer; /* Pointer to inode at same level */ + FAR struct inode *i_child; /* Pointer to inode at lower level */ + struct file_operations *i_ops; /* Driver file operations for inode */ + sint16 i_crefs; /* References to inode */ + uint16 i_flags; /* flags for inode */ #ifdef CONFIG_FILE_MODE - mode_t i_mode; /* Access mode flags */ + mode_t i_mode; /* Access mode flags */ #endif - void *i_private; /* Driver private data */ - char i_name[1]; /* Name of inode (variable length) */ + FAR void *i_private; /* Driver private data */ + char i_name[1]; /* Name of inode (variable length) */ }; #define FSNODE_SIZE(n) (sizeof(struct inode) + (n)) @@ -94,9 +92,9 @@ struct inode struct file { - int f_oflags; /* Open mode flags */ - off_t f_pos; /* File position */ - struct inode *f_inode; /* Driver interface */ + int f_oflags; /* Open mode flags */ + off_t f_pos; /* File position */ + FAR struct inode *f_inode; /* Driver interface */ }; /* This defines a list of files indexed by the file descriptor */ @@ -119,20 +117,20 @@ struct filelist #if CONFIG_NFILE_STREAMS > 0 struct file_struct { - int fs_filedes; /* File descriptor associated with stream */ - mode_t fs_oflags; /* Open mode flags */ + int fs_filedes; /* File descriptor associated with stream */ + mode_t fs_oflags; /* Open mode flags */ #if CONFIG_NUNGET_CHARS > 0 - uint8 fs_nungotten; /* The number of characters buffered for ungetc */ - unsigned char fs_ungotten[CONFIG_NUNGET_CHARS]; + uint8 fs_nungotten; /* The number of characters buffered for ungetc */ + unsigned char fs_ungotten[CONFIG_NUNGET_CHARS]; #endif #if CONFIG_STDIO_BUFFER_SIZE > 0 - sem_t fs_sem; /* For thread safety */ - pid_t fs_holder; /* Holder of sem */ - int fs_counts; /* Number of times sem is held */ - unsigned char *fs_bufstart; /* Pointer to start of buffer */ - unsigned char *fs_bufend; /* Pointer to 1 past end of buffer */ - unsigned char *fs_bufpos; /* Current position in buffer */ - unsigned char *fs_bufread; /* Pointer to 1 past last buffered read char. */ + sem_t fs_sem; /* For thread safety */ + pid_t fs_holder; /* Holder of sem */ + int fs_counts; /* Number of times sem is held */ + FAR unsigned char *fs_bufstart; /* Pointer to start of buffer */ + FAR unsigned char *fs_bufend; /* Pointer to 1 past end of buffer */ + FAR unsigned char *fs_bufpos; /* Current position in buffer */ + FAR unsigned char *fs_bufread; /* Pointer to 1 past last buffered read char. */ #endif }; @@ -170,15 +168,15 @@ EXTERN STATUS unregister_inode(const char *path); /* fs_open.c ************************************************/ -EXTERN int inode_checkflags(struct inode *inode, int oflags); +EXTERN int inode_checkflags(FAR struct inode *inode, int oflags); /* fs_files.c ***********************************************/ #if CONFIG_NFILE_DESCRIPTORS >0 -EXTERN struct filelist *files_alloclist(void); -EXTERN int files_addreflist(struct filelist *list); -EXTERN int files_releaselist(struct filelist *list); -EXTERN int files_dup(struct file *filep1, struct file *filep2); +EXTERN FAR struct filelist *files_alloclist(void); +EXTERN int files_addreflist(FAR struct filelist *list); +EXTERN int files_releaselist(FAR struct filelist *list); +EXTERN int files_dup(FAR struct file *filep1, FAR struct file *filep2); #endif /* lib_fopen.c **********************************************/ @@ -186,16 +184,16 @@ EXTERN int files_dup(struct file *filep1, struct file *filep2); /* Used by the OS to clone stdin, stdout, stderr */ #if CONFIG_NFILE_STREAMS > 0 -EXTERN struct file_struct *lib_fdopen(int fd, - const char *mode, - struct filelist *flist, - struct streamlist *slist); +EXTERN FAR struct file_struct *lib_fdopen(int fd, + const char *mode, + FAR struct filelist *flist, + FAR struct streamlist *slist); #endif /* lib_fflush.c *********************************************/ #if CONFIG_NFILE_STREAMS > 0 -EXTERN void lib_flushall(struct streamlist *list); +EXTERN void lib_flushall(FAR struct streamlist *list); #endif /* drivers **************************************************/ diff --git a/nuttx/include/nuttx/irq.h b/nuttx/include/nuttx/irq.h index 82a34c760..a806adb15 100644 --- a/nuttx/include/nuttx/irq.h +++ b/nuttx/include/nuttx/irq.h @@ -60,9 +60,9 @@ /* This struct defines the way the registers are stored */ #ifndef __ASSEMBLY__ -typedef int (*xcpt_t)(int irq, void *context); +typedef int (*xcpt_t)(int irq, FAR void *context); typedef int (*swint_t)(int code, int parm2, int parm3, - void *context); + FAR void *context); #endif /* Now include architecture-specific types */ diff --git a/nuttx/include/nuttx/kmalloc.h b/nuttx/include/nuttx/kmalloc.h index 5a48f33d2..29678ebc9 100644 --- a/nuttx/include/nuttx/kmalloc.h +++ b/nuttx/include/nuttx/kmalloc.h @@ -63,28 +63,28 @@ extern "C" { # include # define kmalloc(s) malloc(s) #else -KMALLOC_EXTERN void *kmalloc(size_t); +KMALLOC_EXTERN FAR void *kmalloc(size_t); #endif #ifndef CONFIG_ARCH_KZMALLOC # include # define kzmalloc(s) zalloc(s) #else -KMALLOC_EXTERN void *kzalloc(size_t); +KMALLOC_EXTERN FAR void *kzalloc(size_t); #endif #ifndef CONFIG_ARCH_KFREE # include # define kfree(p) free(p) #else -KMALLOC_EXTERN void kfree(void*); +KMALLOC_EXTERN void kfree(FAR void*); #endif /* Functions defined in os_list.c ***************************/ /* Handles memory freed from an interrupt handler */ -KMALLOC_EXTERN void sched_free(void *address); +KMALLOC_EXTERN void sched_free(FAR void *address); #undef KMALLOC_EXTERN #if defined(__cplusplus) diff --git a/nuttx/include/nuttx/lib.h b/nuttx/include/nuttx/lib.h index 52f506897..cca174aa3 100644 --- a/nuttx/include/nuttx/lib.h +++ b/nuttx/include/nuttx/lib.h @@ -64,11 +64,11 @@ extern "C" { /* Functions contained in lib_init.c ************************/ -EXTERN void weak_function lib_initialize(void); +EXTERN void weak_function lib_initialize(void); #if CONFIG_NFILE_STREAMS > 0 -EXTERN struct streamlist *lib_alloclist(void); -EXTERN void lib_addreflist(struct streamlist *list); -EXTERN void lib_releaselist(struct streamlist *list); +EXTERN FAR struct streamlist *lib_alloclist(void); +EXTERN void lib_addreflist(FAR struct streamlist *list); +EXTERN void lib_releaselist(FAR struct streamlist *list); #endif #undef EXTERN diff --git a/nuttx/include/nuttx/os_external.h b/nuttx/include/nuttx/os_external.h index 6d96b5afb..1d475d84e 100644 --- a/nuttx/include/nuttx/os_external.h +++ b/nuttx/include/nuttx/os_external.h @@ -75,7 +75,7 @@ EXTERN void os_start(void); /* OS entry point called by boot logic */ /* Functions contained in mm_init.c *************************/ -EXTERN void mm_initialize(void *heap_start, size_t heap_size); +EXTERN void mm_initialize(FAR void *heap_start, size_t heap_size); #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/include/pthread.h b/nuttx/include/pthread.h index 12f0d5365..ad907cf55 100644 --- a/nuttx/include/pthread.h +++ b/nuttx/include/pthread.h @@ -41,6 +41,7 @@ ************************************************************/ #include /* Default settings */ +#include /* Compiler settings */ #include /* Needed for general types */ #include /* Needed for sem_t */ #include /* Needed for struct timespec */ @@ -85,11 +86,7 @@ /* Thread return value when a pthread is canceled */ -#ifdef CONFIG_CAN_CAST_POINTERS -# define PTHREAD_CANCELED ((void*)ERROR) -#else -# define PTHREAD_CANCELED ((void*)pthread_create) -#endif +# define PTHREAD_CANCELED ((FAR void*)ERROR) /************************************************************ * Global Type Declarations @@ -107,7 +104,7 @@ extern "C" { *----------------------------------------------------------*/ typedef int pthread_key_t; -typedef void *pthread_addr_t; +typedef FAR void *pthread_addr_t; typedef pthread_addr_t any_t; typedef pthread_addr_t (*pthread_startroutine_t)(pthread_addr_t); @@ -115,10 +112,10 @@ typedef pthread_startroutine_t pthread_func_t; struct pthread_addr_s { - unsigned long stacksize; /* Size of the stack allocated for the pthead */ - short priority; /* Priority of the pthread */ - ubyte policy; /* Pthread scheduler policy */ - ubyte inheritsched; /* Inherit parent prio/policy? */ + size_t stacksize; /* Size of the stack allocated for the pthead */ + short priority; /* Priority of the pthread */ + ubyte policy; /* Pthread scheduler policy */ + ubyte inheritsched; /* Inherit parent prio/policy? */ }; typedef struct pthread_addr_s pthread_attr_t; @@ -173,8 +170,10 @@ EXTERN int pthread_attr_destroy(pthread_attr_t *attr); * Set or obtain the default scheduling algorithm *----------------------------------------------------------*/ -EXTERN int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy); -EXTERN int pthread_attr_getschedpolicy(pthread_attr_t *attr, int *policy); +EXTERN int pthread_attr_setschedpolicy(pthread_attr_t *attr, + int policy); +EXTERN int pthread_attr_getschedpolicy(pthread_attr_t *attr, + int *policy); EXTERN int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param); EXTERN int pthread_attr_getschedparam(pthread_attr_t *attr, @@ -188,8 +187,10 @@ EXTERN int pthread_attr_getinheritsched(const pthread_attr_t *attr, * Set or obtain the default stack size *----------------------------------------------------------*/ -EXTERN int pthread_attr_setstacksize(pthread_attr_t *attr, long stacksize); -EXTERN int pthread_attr_getstacksize(pthread_attr_t *attr, long *stackaddr); +EXTERN int pthread_attr_setstacksize(pthread_attr_t *attr, + long stacksize); +EXTERN int pthread_attr_getstacksize(pthread_attr_t *attr, + long *stackaddr); /*----------------------------------------------------------* * To create a thread object and runnable thread, a routine @@ -200,7 +201,8 @@ EXTERN int pthread_attr_getstacksize(pthread_attr_t *attr, long *stackaddr); * specify details about the kind of thread being created. *----------------------------------------------------------*/ -EXTERN int pthread_create(pthread_t *thread, pthread_attr_t *attr, +EXTERN int pthread_create(pthread_t *thread, + pthread_attr_t *attr, pthread_startroutine_t startRoutine, pthread_addr_t arg); @@ -216,7 +218,7 @@ EXTERN int pthread_detach(pthread_t thread); * execution of another thread. *----------------------------------------------------------*/ -EXTERN void pthread_exit(pthread_addr_t pvValue) noreturn_function; +EXTERN void pthread_exit(pthread_addr_t value) noreturn_function; EXTERN int pthread_cancel(pthread_t thread); EXTERN int pthread_setcancelstate(int state, int *oldstate); EXTERN void pthread_testcancel(void); @@ -226,7 +228,8 @@ EXTERN void pthread_testcancel(void); * the return value of the thread. *----------------------------------------------------------*/ -EXTERN int pthread_join(pthread_t thread, pthread_addr_t *ppvValue); +EXTERN int pthread_join(pthread_t thread, + pthread_addr_t *value); /*----------------------------------------------------------* * A thread may tell the scheduler that its processor can be @@ -245,7 +248,8 @@ EXTERN void pthread_yield(void); * Thread scheduling parameters *----------------------------------------------------------*/ -EXTERN int pthread_getschedparam(pthread_t thread, int *policy, +EXTERN int pthread_getschedparam(pthread_t thread, + int *policy, struct sched_param *param); EXTERN int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param *param); @@ -255,9 +259,9 @@ EXTERN int pthread_setschedparam(pthread_t thread, int policy, *----------------------------------------------------------*/ EXTERN int pthread_key_create(pthread_key_t *key, - void (*destructor)(void*)); -EXTERN int pthread_setspecific(pthread_key_t key, void *value); -EXTERN void *pthread_getspecific(pthread_key_t key); + FAR void (*destructor)(FAR void*)); +EXTERN int pthread_setspecific(pthread_key_t key, FAR void *value); +EXTERN FAR void *pthread_getspecific(pthread_key_t key); EXTERN int pthread_key_delete(pthread_key_t key); /*----------------------------------------------------------* @@ -294,7 +298,8 @@ EXTERN int pthread_condattr_destroy(pthread_condattr_t *attr); * A thread can create and delete condition variables. *----------------------------------------------------------*/ -EXTERN int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr); +EXTERN int pthread_cond_init(pthread_cond_t *cond, + pthread_condattr_t *attr); EXTERN int pthread_cond_destroy(pthread_cond_t *cond); /*----------------------------------------------------------* @@ -302,21 +307,23 @@ EXTERN int pthread_cond_destroy(pthread_cond_t *cond); *----------------------------------------------------------*/ EXTERN int pthread_cond_broadcast(pthread_cond_t *cond); -EXTERN int pthread_cond_signal(pthread_cond_t *dond); +EXTERN int pthread_cond_signal(pthread_cond_t *cond); /*----------------------------------------------------------* * A thread can wait for a condition variable to be signalled * or broadcast. *----------------------------------------------------------*/ -EXTERN int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); +EXTERN int pthread_cond_wait(pthread_cond_t *cond, + pthread_mutex_t *mutex); /*----------------------------------------------------------* * A thread can perform a timed wait on a condition variable. *----------------------------------------------------------*/ -EXTERN int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime); +EXTERN int pthread_cond_timedwait(pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct timespec *abstime); #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/include/queue.h b/nuttx/include/queue.h index 17f4ddec0..9e45672df 100644 --- a/nuttx/include/queue.h +++ b/nuttx/include/queue.h @@ -58,25 +58,28 @@ struct sq_entry_s { - struct sq_entry_s *flink; + FAR struct sq_entry_s *flink; }; typedef struct sq_entry_s sq_entry_t; struct dq_entry_s { - struct dq_entry_s *flink, *blink; + FAR struct dq_entry_s *flink; + FAR struct dq_entry_s *blink; }; typedef struct dq_entry_s dq_entry_t; struct sq_queue_s { - sq_entry_t *head, *tail; + FAR sq_entry_t *head; + FAR sq_entry_t *tail; }; typedef struct sq_queue_s sq_queue_t; struct dq_queue_s { - dq_entry_t *head, *tail; + FAR dq_entry_t *head; + FAR dq_entry_t *tail; }; typedef struct dq_queue_s dq_queue_t; @@ -91,23 +94,24 @@ extern "C" { #define EXTERN extern #endif -EXTERN void sq_addfirst(sq_entry_t *node, sq_queue_t *queue); -EXTERN void dq_addfirst(dq_entry_t *node, dq_queue_t *queue); -EXTERN void sq_addlast(sq_entry_t *node, sq_queue_t *queue); -EXTERN void dq_addlast(dq_entry_t *node, dq_queue_t *queue); -EXTERN void sq_addafter(sq_entry_t *prev, sq_entry_t *node, - sq_queue_t *queue); -EXTERN void dq_addafter(dq_entry_t *prev, dq_entry_t *node, - dq_queue_t *queue); -EXTERN void dq_addbefore(dq_entry_t *next, dq_entry_t *node, - dq_queue_t *queue); -EXTERN sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue); -EXTERN void sq_rem(sq_entry_t *node, sq_queue_t *queue); -EXTERN void dq_rem(dq_entry_t *node, dq_queue_t *queue); -EXTERN sq_entry_t *sq_remlast(sq_queue_t *queue); -EXTERN dq_entry_t *dq_remlast(dq_queue_t *queue); -EXTERN sq_entry_t *sq_remfirst(sq_queue_t *queue); -EXTERN dq_entry_t *dq_remfirst(dq_queue_t *queue); +EXTERN void sq_addfirst(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void dq_addfirst(FAR dq_entry_t *node, dq_queue_t *queue); +EXTERN void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue); +EXTERN void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node, + sq_queue_t *queue); +EXTERN void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node, + dq_queue_t *queue); +EXTERN void dq_addbefore(FAR dq_entry_t *next, FAR dq_entry_t *node, + dq_queue_t *queue); + +EXTERN FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue); +EXTERN void dq_rem(FAR dq_entry_t *node, dq_queue_t *queue); +EXTERN FAR sq_entry_t *sq_remlast(sq_queue_t *queue); +EXTERN FAR dq_entry_t *dq_remlast(dq_queue_t *queue); +EXTERN FAR sq_entry_t *sq_remfirst(sq_queue_t *queue); +EXTERN FAR dq_entry_t *dq_remfirst(dq_queue_t *queue); #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/include/sched.h b/nuttx/include/sched.h index 4266eb9c0..79d3b2f1d 100644 --- a/nuttx/include/sched.h +++ b/nuttx/include/sched.h @@ -147,7 +147,8 @@ struct _TCB { /* Fields used to support list management ***************************/ - struct _TCB *flink, *blink; /* link in DQ of TCBs */ + FAR struct _TCB *flink; /* link in DQ of TCBs */ + FAR struct _TCB *blink; /* Task Management Fields *******************************************/ @@ -159,7 +160,7 @@ struct _TCB tstate_t task_state; /* Current state of the thread */ uint16 flags; /* Misc. general status flags */ sint16 lockcount; /* 0=preemptable (not-locked) */ - void *joininfo; /* Detach-able info to support join */ + FAR void *joininfo; /* Detach-able info to support join */ #if CONFIG_RR_INTERVAL > 0 int timeslice; /* RR timeslice interval remaining */ #endif @@ -167,27 +168,27 @@ struct _TCB /* Values needed to restart a task **********************************/ ubyte init_priority; /* Initial priority of the task */ - char *argv[NUM_TASK_ARGS+1]; /* Name + start-up parameters */ + FAR char *argv[NUM_TASK_ARGS+1]; /* Name + start-up parameters */ /* Stack-Related Fields *********************************************/ size_t adj_stack_size; /* Stack size after adjustment */ /* for hardware, processor, etc. */ /* (for debug purposes only) */ - void *stack_alloc_ptr; /* Pointer to allocated stack */ + FAR void *stack_alloc_ptr; /* Pointer to allocated stack */ /* Need to deallocate stack */ - void *adj_stack_ptr; /* Adjusted StatckAllocPtr for HW */ + FAR void *adj_stack_ptr; /* Adjusted StatckAllocPtr for HW */ /* The initial stack pointer value */ /* POSIX thread Specific Data ***************************************/ #if CONFIG_NPTHREAD_KEYS > 0 - void *pthread_data[CONFIG_NPTHREAD_KEYS]; + FAR void *pthread_data[CONFIG_NPTHREAD_KEYS]; #endif /* POSIX Semaphore Control Fields ***********************************/ - sem_t *waitsem; /* Semaphore ID waiting on */ + sem_t *waitsem; /* Semaphore ID waiting on */ /* POSIX Signal Control Fields **************************************/ @@ -202,7 +203,7 @@ struct _TCB /* POSIX Named Message Queue Fields *********************************/ sq_queue_t msgdesq; /* List of opened message queues */ - msgq_t *msgwaitq; /* Waiting for this message queue */ + FAR msgq_t *msgwaitq; /* Waiting for this message queue */ /* Library related fields *******************************************/ @@ -211,11 +212,11 @@ struct _TCB /* File system support **********************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 - struct filelist *filelist; /* Maps file descriptor to file */ + FAR struct filelist *filelist; /* Maps file descriptor to file */ #endif #if CONFIG_NFILE_STREAMS > 0 - struct streamlist *streams; /* Holds C buffered I/O info */ + FAR struct streamlist *streams; /* Holds C buffered I/O info */ #endif /* State save areas *************************************************/ @@ -246,29 +247,31 @@ extern "C" { /* Task Control Interfaces (non-standard) */ -EXTERN STATUS task_init(_TCB *tcb , char *name, int priority, - uint32 *stack, uint32 stack_size, main_t entry, - char *arg1, char *arg2, char *arg3, char *arg4); -EXTERN STATUS task_activate(_TCB *tcb); -EXTERN int task_create(char *name, int priority, int stack_size, main_t main, - char *arg1, char *arg2, char *arg3, char *arg4); +EXTERN STATUS task_init(FAR _TCB *tcb, const char *name, int priority, + FAR uint32 *stack, uint32 stack_size, main_t entry, + FAR char *arg1, FAR char *arg2, + FAR char *arg3, FAR char *arg4); +EXTERN STATUS task_activate(FAR _TCB *tcb); +EXTERN int task_create(const char *name, int priority, int stack_size, main_t main, + FAR char *arg1, FAR char *arg2, + FAR char *arg3, FAR char *arg4); EXTERN STATUS task_delete(pid_t pid); EXTERN STATUS task_restart(pid_t pid); /* Task Scheduling Interfaces (based on POSIX APIs) */ EXTERN int sched_setparam(pid_t pid, - const struct sched_param * param); + const struct sched_param *param); EXTERN int sched_getparam(pid_t pid, - struct sched_param * param); + struct sched_param *param); EXTERN int sched_setscheduler(pid_t pid, int policy, - const struct sched_param * param); + const struct sched_param *param); EXTERN int sched_getscheduler(pid_t pid); EXTERN int sched_yield(void); EXTERN int sched_get_priority_max(int policy); EXTERN int sched_get_priority_min(int policy); EXTERN int sched_rr_get_interval(pid_t pid, - struct timespec * interval); + struct timespec *interval); /* Task Switching Interfaces (non-standard) */ @@ -282,9 +285,9 @@ EXTERN sint32 sched_lockcount(void); #ifdef CONFIG_SCHED_INSTRUMENTATION -EXTERN void sched_note_start(_TCB *tcb ); -EXTERN void sched_note_stop(_TCB *tcb ); -EXTERN void sched_note_switch(_TCB *pFromTcb, _TCB *pToTcb); +EXTERN void sched_note_start(FAR _TCB *tcb ); +EXTERN void sched_note_stop(FAR _TCB *tcb ); +EXTERN void sched_note_switch(FAR _TCB *pFromTcb, FAR _TCB *pToTcb); #else # define sched_note_start(t) @@ -295,9 +298,9 @@ EXTERN void sched_note_switch(_TCB *pFromTcb, _TCB *pToTcb); /* File system helpers */ #if CONFIG_NFILE_DESCRIPTORS > 0 -EXTERN struct filelist *sched_getfiles(void); +EXTERN FAR struct filelist *sched_getfiles(void); #if CONFIG_NFILE_STREAMS > 0 -EXTERN struct streamlist *sched_getstreams(void); +EXTERN FAR struct streamlist *sched_getstreams(void); #endif /* CONFIG_NFILE_STREAMS */ #endif /* CONFIG_NFILE_DESCRIPTORS */ diff --git a/nuttx/include/semaphore.h b/nuttx/include/semaphore.h index 92ac7ab89..f23435a1a 100644 --- a/nuttx/include/semaphore.h +++ b/nuttx/include/semaphore.h @@ -84,15 +84,15 @@ typedef struct sem_s sem_t; /* Counting Semaphore Interfaces (based on POSIX APIs) */ -EXTERN int sem_init(sem_t *sem, int pshared, unsigned int value); -EXTERN int sem_destroy(sem_t *sem); -EXTERN sem_t *sem_open(const char *name, int oflag, ...); -EXTERN int sem_close(sem_t *sem); -EXTERN int sem_unlink(const char *name); -EXTERN int sem_wait(sem_t *sem); -EXTERN int sem_trywait(sem_t *sem); -EXTERN int sem_post(sem_t *sem); -EXTERN int sem_getvalue(sem_t *sem, int *sval); +EXTERN int sem_init(sem_t *sem, int pshared, unsigned int value); +EXTERN int sem_destroy(sem_t *sem); +EXTERN FAR sem_t *sem_open(const char *name, int oflag, ...); +EXTERN int sem_close(FAR sem_t *sem); +EXTERN int sem_unlink(const char *name); +EXTERN int sem_wait(sem_t *sem); +EXTERN int sem_trywait(sem_t *sem); +EXTERN int sem_post(sem_t *sem); +EXTERN int sem_getvalue(sem_t *sem, int *sval); #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/include/signal.h b/nuttx/include/signal.h index 4ec153b51..df8fe214d 100644 --- a/nuttx/include/signal.h +++ b/nuttx/include/signal.h @@ -41,6 +41,7 @@ ************************************************************/ #include +#include #include /* Needed for struct timespec */ #include /* Needed for, e.g., sigset_t */ @@ -123,7 +124,7 @@ struct sigaction union { void (*_sa_handler)(int); - void (*_sa_sigaction)(int, siginfo_t *, void *); + void (*_sa_sigaction)(int, FAR siginfo_t *, FAR void *); } sa_u; sigset_t sa_mask; int sa_flags; @@ -155,7 +156,7 @@ EXTERN int sigaction(int sig, const struct sigaction *act, struct sigaction *oact); EXTERN int sigprocmask(int how, const sigset_t *set, - sigset_t *oset); + sigset_t *oset); EXTERN int sigpending(sigset_t *set); EXTERN int sigsuspend(const sigset_t *sigmask); EXTERN int sigwaitinfo(const sigset_t *set, diff --git a/nuttx/include/stdio.h b/nuttx/include/stdio.h index 883e32fc4..8b9a7e28e 100644 --- a/nuttx/include/stdio.h +++ b/nuttx/include/stdio.h @@ -129,12 +129,12 @@ struct _dirent { - char *d_name; /* name of directory entry */ + FAR char *d_name; /* name of directory entry */ }; struct dirent { - char *d_name; /* A pointer to szName */ - char szName[NAME_MAX+1]; /* name of the directory entry */ + FAR char *d_name; /* A pointer to d_szname */ + char d_szname[NAME_MAX+1]; /* name of the directory entry */ }; typedef struct @@ -147,7 +147,7 @@ typedef struct { unsigned long inode; int generation; - char *fileName; + FAR char *filename; } HANDLE_TO_NAME_IOCTL; struct stat @@ -186,7 +186,7 @@ struct statfs /* Streams */ -typedef struct file_struct FILE; +typedef FAR struct file_struct FILE; typedef void DIR; @@ -239,22 +239,22 @@ EXTERN int close(int fd); EXTERN int closedir(DIR *dirp); EXTERN int creat(const char *path, mode_t mode); EXTERN FILE *fdopen(int fd, const char *type); -EXTERN int fstat(int fd, struct stat *buf); -EXTERN char *getcwd(char *buf, size_t size); +EXTERN int fstat(int fd, FAR struct stat *buf); +EXTERN char *getcwd(FAR char *buf, size_t size); EXTERN int ioctl(int fd, int req, unsigned long arg); EXTERN off_t lseek(int fd, off_t offset, int whence); EXTERN int mkdir(const char *path, mode_t mode); -EXTERN int open( const char *path, int oflag, ... ); +EXTERN int open(const char *path, int oflag, ...); EXTERN DIR *opendir(const char *path); EXTERN int read(int fd, void *buf, unsigned int nbytes); -EXTERN struct _dirent *readdir(DIR *dirp); -EXTERN int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result); -EXTERN void rewinddir(DIR *dirp); +EXTERN struct _dirent *readdir(FAR DIR *dirp); +EXTERN int readdir_r(FAR DIR *dirp, struct dirent *entry, FAR struct dirent **result); +EXTERN void rewinddir(FAR DIR *dirp); EXTERN int rmdir(const char *path); -EXTERN void seekdir(DIR *dirp, int loc); -EXTERN int stat(const char *path, struct stat *buf); -EXTERN int statfs(const char *path, struct statfs *buf); -EXTERN int telldir(DIR *dirp); +EXTERN void seekdir(FAR DIR *dirp, int loc); +EXTERN int stat(const char *path, FAR struct stat *buf); +EXTERN int statfs(const char *path, FAR struct statfs *buf); +EXTERN int telldir(FAR DIR *dirp); EXTERN int unlink(const char *path); EXTERN int write(int fd, const void *buf, unsigned int nbytes); diff --git a/nuttx/include/stdlib.h b/nuttx/include/stdlib.h index ba4f2b502..4a9f2ef0d 100644 --- a/nuttx/include/stdlib.h +++ b/nuttx/include/stdlib.h @@ -83,30 +83,40 @@ extern "C" { #endif /* Random number generation */ -EXTERN void srand(unsigned int seed); -EXTERN int rand(void); + +EXTERN void srand(unsigned int seed); +EXTERN int rand(void); /* Environment variable support */ -EXTERN char *getenv(const char *name); + +EXTERN char *getenv(const char *name); /* Process exit functions */ -EXTERN void exit(int status); -EXTERN void abort(void); -EXTERN int atexit(void (*func)(void)); + +EXTERN void exit(int status); +EXTERN void abort(void); +EXTERN int atexit(void (*func)(void)); /* String to binary conversions */ -#define atoi(nptr) strtol((nptr), (char**)NULL, 10) -EXTERN long strtol(const char *, char **, int); -EXTERN double_t strtod(const char *, char **); + +#define atoi(nptr) strtol((nptr), (FAR char**)NULL, 10) +EXTERN long strtol(const char *, char **, int); +EXTERN double_t strtod(const char *, char **); /* Memory Management */ -EXTERN void *malloc(size_t); -EXTERN void free(void*); -EXTERN void *realloc(void*, size_t); -EXTERN void *memalign(size_t, size_t); -EXTERN void *zalloc(size_t); -EXTERN void *calloc(size_t, size_t); + +EXTERN FAR void *malloc(size_t); +EXTERN void free(FAR void*); +EXTERN FAR void *realloc(FAR void*, size_t); +EXTERN FAR void *memalign(size_t, size_t); +EXTERN FAR void *zalloc(size_t); +EXTERN FAR void *calloc(size_t, size_t); + +#ifdef CONFIG_CAN_PASS_STRUCTS EXTERN struct mallinfo mallinfo(void); +#else +EXTERN int mallinfo(struct mallinfo *info); +#endif #undef EXTERN #if defined(__cplusplus) diff --git a/nuttx/include/string.h b/nuttx/include/string.h index e63895188..0c8bd59b7 100644 --- a/nuttx/include/string.h +++ b/nuttx/include/string.h @@ -60,7 +60,7 @@ extern "C" { #endif EXTERN char *strchr(const char *s, int c); -EXTERN char *strdup(const char *s); +EXTERN FAR char *strdup(const char *s); EXTERN char *strerror(int); EXTERN size_t strlen(const char *); EXTERN char *strncat(char *, const char *, size_t); @@ -74,7 +74,7 @@ EXTERN char *strrchr(const char *, int); EXTERN size_t strspn(const char *, const char *); EXTERN size_t strcspn(const char *, const char *); EXTERN char *strstr(const char *, const char *); -EXTERN char *strtok(char *, const char *); +EXTERN char *strtok(FAR char *, const char *); EXTERN void *memset(void *s, int c, size_t n); EXTERN void *memcpy(void *dest, const void *src, size_t n); diff --git a/nuttx/include/unistd.h b/nuttx/include/unistd.h index e6c787ecc..faf50e3a3 100644 --- a/nuttx/include/unistd.h +++ b/nuttx/include/unistd.h @@ -67,7 +67,7 @@ extern "C" { /* Task Control Interfaces (based on ANSII APIs) */ -EXTERN pid_t getpid( void ); +EXTERN pid_t getpid(void); EXTERN void _exit(int status) noreturn_function; EXTERN unsigned int sleep(unsigned int seconds); EXTERN void usleep(unsigned long usec); diff --git a/nuttx/include/wdog.h b/nuttx/include/wdog.h index a1065eaae..fb45cb6a2 100644 --- a/nuttx/include/wdog.h +++ b/nuttx/include/wdog.h @@ -80,7 +80,7 @@ typedef void (*wdentry_t)(int argc, uint32 arg1, ...); /* Watchdog 'handle' */ -typedef struct wdog_s *WDOG_ID; +typedef FAR struct wdog_s *WDOG_ID; /************************************************************ * Global Variables diff --git a/nuttx/lib/Makefile b/nuttx/lib/Makefile index 361c0bb63..c05b9e96d 100644 --- a/nuttx/lib/Makefile +++ b/nuttx/lib/Makefile @@ -91,7 +91,7 @@ $(BIN): $(OBJS) depend: .depend clean: - rm -f $(BIN) *.o *~ + rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ distclean: clean rm -f Make.dep .depend diff --git a/nuttx/lib/dq_addafter.c b/nuttx/lib/dq_addafter.c index 5533d57a1..6be30a501 100644 --- a/nuttx/lib/dq_addafter.c +++ b/nuttx/lib/dq_addafter.c @@ -56,7 +56,7 @@ * ************************************************************/ -void dq_addafter(dq_entry_t *prev, dq_entry_t *node, +void dq_addafter(FAR dq_entry_t *prev, FAR dq_entry_t *node, dq_queue_t *queue) { if (!queue->head || prev == queue->tail) @@ -65,10 +65,10 @@ void dq_addafter(dq_entry_t *prev, dq_entry_t *node, } else { - dq_entry_t *next = prev->flink; - node->blink = prev; - node->flink = next; - next->blink = node; - prev->flink = node; + FAR dq_entry_t *next = prev->flink; + node->blink = prev; + node->flink = next; + next->blink = node; + prev->flink = node; } } diff --git a/nuttx/lib/dq_addbefore.c b/nuttx/lib/dq_addbefore.c index 916a7db61..99df05574 100644 --- a/nuttx/lib/dq_addbefore.c +++ b/nuttx/lib/dq_addbefore.c @@ -55,7 +55,7 @@ * ************************************************************/ -void dq_addbefore(dq_entry_t *next, dq_entry_t *node, +void dq_addbefore(FAR dq_entry_t *next, FAR dq_entry_t *node, dq_queue_t *queue) { if (!queue->head || next == queue->head) @@ -64,10 +64,10 @@ void dq_addbefore(dq_entry_t *next, dq_entry_t *node, } else { - dq_entry_t *prev = next->blink; - node->flink = next; - node->blink = prev; - prev->flink = node; - next->blink = node; + FAR dq_entry_t *prev = next->blink; + node->flink = next; + node->blink = prev; + prev->flink = node; + next->blink = node; } } diff --git a/nuttx/lib/dq_addfirst.c b/nuttx/lib/dq_addfirst.c index a11b1f8c3..d73f49db1 100644 --- a/nuttx/lib/dq_addfirst.c +++ b/nuttx/lib/dq_addfirst.c @@ -55,7 +55,7 @@ * ************************************************************/ -void dq_addfirst(dq_entry_t *node, dq_queue_t *queue) +void dq_addfirst(FAR dq_entry_t *node, dq_queue_t *queue) { node->blink = NULL; node->flink = queue->head; @@ -71,3 +71,4 @@ void dq_addfirst(dq_entry_t *node, dq_queue_t *queue) queue->head = node; } } + diff --git a/nuttx/lib/dq_addlast.c b/nuttx/lib/dq_addlast.c index 85c6c72a9..8d7225682 100644 --- a/nuttx/lib/dq_addlast.c +++ b/nuttx/lib/dq_addlast.c @@ -55,7 +55,7 @@ * ************************************************************/ -void dq_addlast(dq_entry_t *node, dq_queue_t *queue) +void dq_addlast(FAR dq_entry_t *node, dq_queue_t *queue) { node->flink = NULL; node->blink = queue->tail; @@ -71,3 +71,4 @@ void dq_addlast(dq_entry_t *node, dq_queue_t *queue) queue->tail = node; } } + diff --git a/nuttx/lib/dq_rem.c b/nuttx/lib/dq_rem.c index d78ac8b6d..17f2b8622 100644 --- a/nuttx/lib/dq_rem.c +++ b/nuttx/lib/dq_rem.c @@ -55,10 +55,10 @@ * ************************************************************/ -void dq_rem(dq_entry_t *node, dq_queue_t *queue) +void dq_rem(FAR dq_entry_t *node, dq_queue_t *queue) { - dq_entry_t *prev = node->blink; - dq_entry_t *next = node->flink; + FAR dq_entry_t *prev = node->blink; + FAR dq_entry_t *next = node->flink; if (!prev) { @@ -81,3 +81,4 @@ void dq_rem(dq_entry_t *node, dq_queue_t *queue) node->flink = NULL; node->blink = NULL; } + diff --git a/nuttx/lib/dq_remfirst.c b/nuttx/lib/dq_remfirst.c index 0c7381c77..ed64fe268 100644 --- a/nuttx/lib/dq_remfirst.c +++ b/nuttx/lib/dq_remfirst.c @@ -55,13 +55,13 @@ * ************************************************************/ -dq_entry_t *dq_remfirst(dq_queue_t *queue) +FAR dq_entry_t *dq_remfirst(dq_queue_t *queue) { - dq_entry_t *ret = queue->head; + FAR dq_entry_t *ret = queue->head; if (ret) { - dq_entry_t *next = ret->flink; + FAR dq_entry_t *next = ret->flink; if (!next) { queue->head = NULL; @@ -79,3 +79,4 @@ dq_entry_t *dq_remfirst(dq_queue_t *queue) return ret; } + diff --git a/nuttx/lib/dq_remlast.c b/nuttx/lib/dq_remlast.c index 476426021..812e1f701 100644 --- a/nuttx/lib/dq_remlast.c +++ b/nuttx/lib/dq_remlast.c @@ -55,13 +55,13 @@ * ************************************************************/ -dq_entry_t *dq_remlast(dq_queue_t *queue) +FAR dq_entry_t *dq_remlast(dq_queue_t *queue) { - dq_entry_t *ret = queue->tail; + FAR dq_entry_t *ret = queue->tail; if (ret) { - dq_entry_t *prev = ret->blink; + FAR dq_entry_t *prev = ret->blink; if (!prev) { queue->head = NULL; @@ -79,3 +79,4 @@ dq_entry_t *dq_remlast(dq_queue_t *queue) return ret; } + diff --git a/nuttx/lib/lib_fclose.c b/nuttx/lib/lib_fclose.c index c1cddeb69..9985c49c2 100644 --- a/nuttx/lib/lib_fclose.c +++ b/nuttx/lib/lib_fclose.c @@ -65,7 +65,7 @@ int fclose(FILE *stream) ret = close(stream->fs_filedes); } #warning REVIEW for race conditions -#if CONFIG_NFILE_STREAMS > 0 +#if CONFIG_STDIO_BUFFER_SIZE > 0 /* Destroy the semaphore */ sem_destroy(&stream->fs_sem); diff --git a/nuttx/lib/lib_fflush.c b/nuttx/lib/lib_fflush.c index b3dbb1109..dc2c99673 100644 --- a/nuttx/lib/lib_fflush.c +++ b/nuttx/lib/lib_fflush.c @@ -88,7 +88,7 @@ /* Called by the OS when a task exits */ -void lib_flushall(struct streamlist *list) +void lib_flushall(FAR struct streamlist *list) { /* Make sure that there are streams associated with this thread */ if (list) diff --git a/nuttx/lib/lib_filesem.c b/nuttx/lib/lib_filesem.c index eb2279b9d..62b45b4bc 100644 --- a/nuttx/lib/lib_filesem.c +++ b/nuttx/lib/lib_filesem.c @@ -39,14 +39,14 @@ #include -#if CONFIG_STDIO_BUFFER_SIZE > 0 - #include #include #include #include #include "lib_internal.h" +#if CONFIG_STDIO_BUFFER_SIZE > 0 + /************************************************************ * Definitions ************************************************************/ @@ -63,7 +63,7 @@ * lib_sem_initialize ************************************************************/ -void lib_sem_initialize(struct file_struct *stream) +void lib_sem_initialize(FAR struct file_struct *stream) { /* Initialize the LIB semaphore to one (to support one-at- * a-time access to private data sets. @@ -79,7 +79,7 @@ void lib_sem_initialize(struct file_struct *stream) * lib_take_semaphore ************************************************************/ -void lib_take_semaphore(struct file_struct *stream) +void lib_take_semaphore(FAR struct file_struct *stream) { pid_t my_pid = getpid(); @@ -115,7 +115,7 @@ void lib_take_semaphore(struct file_struct *stream) * lib_give_semaphore ************************************************************/ -void lib_give_semaphore(struct file_struct *stream) +void lib_give_semaphore(FAR struct file_struct *stream) { pid_t my_pid = getpid(); diff --git a/nuttx/lib/lib_fopen.c b/nuttx/lib/lib_fopen.c index 0a935ddd2..11bce38a2 100644 --- a/nuttx/lib/lib_fopen.c +++ b/nuttx/lib/lib_fopen.c @@ -130,14 +130,14 @@ static int lib_mode2oflags(const char *mode) * Public Functions ************************************************************/ -struct file_struct *lib_fdopen(int fd, const char *mode, - struct filelist *flist, - struct streamlist *slist) +FAR struct file_struct *lib_fdopen(int fd, const char *mode, + FAR struct filelist *flist, + FAR struct streamlist *slist) { - struct inode *inode = flist->fl_files[fd].f_inode; - FILE *stream; - int oflags = lib_mode2oflags(mode); - int i; + FAR struct inode *inode = flist->fl_files[fd].f_inode; + FILE *stream; + int oflags = lib_mode2oflags(mode); + int i; if (fd < 0 || !flist || !slist) { @@ -209,19 +209,19 @@ struct file_struct *lib_fdopen(int fd, const char *mode, FILE *fdopen(int fd, const char *mode) { - struct filelist *flist = sched_getfiles(); - struct streamlist *slist = sched_getstreams(); + FAR struct filelist *flist = sched_getfiles(); + FAR struct streamlist *slist = sched_getstreams(); return lib_fdopen(fd, mode, flist, slist); } FILE *fopen(const char *path, const char *mode) { - struct filelist *flist = sched_getfiles(); - struct streamlist *slist = sched_getstreams(); - int oflags = lib_mode2oflags(mode); - int fd = open(path, oflags, 0666); + FAR struct filelist *flist = sched_getfiles(); + FAR struct streamlist *slist = sched_getstreams(); + int oflags = lib_mode2oflags(mode); + int fd = open(path, oflags, 0666); - FILE *ret = lib_fdopen(fd, mode, flist, slist); + FILE *ret = lib_fdopen(fd, mode, flist, slist); if (!ret) { (void)close(fd); diff --git a/nuttx/lib/lib_getenv.c b/nuttx/lib/lib_getenv.c index 2c75a4f16..dd659393a 100644 --- a/nuttx/lib/lib_getenv.c +++ b/nuttx/lib/lib_getenv.c @@ -103,61 +103,68 @@ char *getenv(const char *name) const char *pend = &environment[size-1]; const char *ptmp; - dbg("getenv(ge): name=\"%s\"\n", name); + dbg("name=\"%s\"\n", name); - if (name) { + if (name) + { + /* Process each string in the environment. */ - /* Process each string in the environment. */ - while (penv < pend) { + while (penv < pend) + { + vdbg("Compare to=\"%s\"\n", penv); - vdbg("(ge):\tCompare to=\"%s\"\n", penv); + /* The logic below basically implements a version of + * strcmp where the strings may be terminated with = signs. + */ - /* The logic below basically implements a version of - * strcmp where the strings may be terminated with = signs. */ - ptmp = name; - for (;;) { + ptmp = name; + for (;;) + { + /* Are we at the end of the name-to-matching? */ - /* Are we at the end of the name-to-matching? */ - if ((!*ptmp) || (*ptmp == '=')) { + if (!*ptmp || *ptmp == '=') + { + /* Yes.. are we also at the end of the matching-name? */ - /* Yes.. are we also at the end of the matching-name? */ - if (*penv == '=') { + if (*penv == '=') + { + /* Yes.. return the pointer to the value. */ - /* Yes.. return the pointer to the value. */ - dbg("(ge):\tReturning \"%s\"\n", penv+1); - return ((char*)penv+1); + dbg("Returning \"%s\"\n", penv+1); + return ((char*)penv+1); + } + else + { + /* No.. Skip to the next name matching name candidate. */ - } /* end if */ - else { + while(*penv++); + break; + } + } - /* No.. Skip to the next name matching name candidate. */ - while(*penv++); - break; - - } /* end else */ - } /* end if */ + /* NO.. are we at the end of the matching name candidate? + * OR.. do the corresponding characters not match. + */ - /* NO.. are we at the end of the matching name candidate? */ - /* OR.. do the corresponding characters not match. */ - else if (*penv != *ptmp) { + else if (*penv != *ptmp) + { + /* Yes.. Skip to the next name matching name candidate. */ - /* Yes.. Skip to the next name matching name candidate. */ - while(*penv++); - break; - - } /* end else if */ - else { + while(*penv++); + break; + } + else + { + /* No.. try the next characters. */ - /* No.. try the next characters. */ - penv++; ptmp++; - - } /* end else */ - } /* end for */ - } /* end while */ - } /* end if */ + penv++; ptmp++; + } + } + } + } /* If we got here, then no matching string was found. */ - dbg("(ge):\tReturning NULL\n"); - return NULL; -} /* end getenv */ + dbg("Returning NULL\n"); + return NULL; +} diff --git a/nuttx/lib/lib_init.c b/nuttx/lib/lib_init.c index a8195937f..d1672de06 100644 --- a/nuttx/lib/lib_init.c +++ b/nuttx/lib/lib_init.c @@ -57,7 +57,7 @@ * Private Functions ************************************************************/ -static void _lib_semtake(struct streamlist *list) +static void _lib_semtake(FAR struct streamlist *list) { /* Take the semaphore (perhaps waiting) */ @@ -92,10 +92,10 @@ void weak_const_function lib_initialize(void) * creates the streamlist instance that is stored in the TCB. */ -struct streamlist *lib_alloclist(void) +FAR struct streamlist *lib_alloclist(void) { - struct streamlist *list; - list = (struct streamlist*)kzmalloc(sizeof(struct streamlist)); + FAR struct streamlist *list; + list = (FAR struct streamlist*)kzmalloc(sizeof(struct streamlist)); if (list) { int i; @@ -136,7 +136,7 @@ struct streamlist *lib_alloclist(void) * list. */ -void lib_addreflist(struct streamlist *list) +void lib_addreflist(FAR struct streamlist *list) { if (list) { @@ -153,7 +153,7 @@ void lib_addreflist(struct streamlist *list) * separately when the file descriptor list is freed. */ -void lib_releaselist(struct streamlist *list) +void lib_releaselist(FAR struct streamlist *list) { int crefs; if (list) @@ -178,7 +178,7 @@ void lib_releaselist(struct streamlist *list) sched_free(list); /* Initialize each FILE structure */ - +#if CONFIG_STDIO_BUFFER_SIZE > 0 for (i = 0; i < CONFIG_NFILE_STREAMS; i++) { /* Destroy the semaphore that protects the IO buffer */ @@ -191,6 +191,7 @@ void lib_releaselist(struct streamlist *list) free(list->sl_streams[i].fs_bufstart); } } +#endif } } } diff --git a/nuttx/lib/lib_internal.h b/nuttx/lib/lib_internal.h index 736aec54f..9d23e8bf0 100644 --- a/nuttx/lib/lib_internal.h +++ b/nuttx/lib/lib_internal.h @@ -104,8 +104,8 @@ struct lib_rawstream_s /* Defined in lib_streamsem.c */ -extern void stream_semtake(struct streamlist *list); -extern void stream_semgive(struct streamlist *list); +extern void stream_semtake(FAR struct streamlist *list); +extern void stream_semgive(FAR struct streamlist *list); /* Defined in lib_memstream.c */ @@ -135,8 +135,8 @@ extern int lib_sprintf (struct lib_stream_s *obj, /* Defined lib_libvsprintf.c */ -extern int lib_vsprintf(struct lib_stream_s *obj, - const char *src, va_list ap); +extern int lib_vsprintf(struct lib_stream_s *obj, + const char *src, va_list ap); /* Defined in lib_libwrite.c */ @@ -149,9 +149,9 @@ extern ssize_t lib_fread(void *ptr, size_t count, FILE *stream); /* Defined in lib_sem.c */ #if CONFIG_STDIO_BUFFER_SIZE > 0 -extern void lib_sem_initialize(struct file_struct *stream); -extern void lib_take_semaphore(struct file_struct *stream); -extern void lib_give_semaphore(struct file_struct *stream); +extern void lib_sem_initialize(FAR struct file_struct *stream); +extern void lib_take_semaphore(FAR struct file_struct *stream); +extern void lib_give_semaphore(FAR struct file_struct *stream); #endif /* Defined in lib_libgetbase.c */ diff --git a/nuttx/lib/lib_libvsprintf.c b/nuttx/lib/lib_libvsprintf.c index 2e60ffa22..443d17d46 100644 --- a/nuttx/lib/lib_libvsprintf.c +++ b/nuttx/lib/lib_libvsprintf.c @@ -41,6 +41,7 @@ * Included Files ************************************************************/ +#include #include #include #include diff --git a/nuttx/lib/lib_sscanf.c b/nuttx/lib/lib_sscanf.c index efd4ebcfa..13d8c3c0d 100644 --- a/nuttx/lib/lib_sscanf.c +++ b/nuttx/lib/lib_sscanf.c @@ -37,6 +37,7 @@ * Included Files ************************************************************/ +#include #include #include #include @@ -128,203 +129,214 @@ int vsscanf(char *buf, const char *s, va_list ap) /* Skip over white space */ while (isspace(*s)) - s++; + s++; /* Check for a conversion specifier */ if (*s == '%') - { - vdbg("vsscanf: Specifier found\n"); + { + vdbg("vsscanf: Specifier found\n"); - /* Check for qualifiers on the conversion specifier */ - s++; - for (; *s; s++) - { - vdbg("vsscanf: Processing %c\n", *s); + /* Check for qualifiers on the conversion specifier */ + s++; + for (; *s; s++) + { + vdbg("vsscanf: Processing %c\n", *s); - if (strchr("dibouxcsefg%", *s)) - break; - if (*s == '*') - noassign = 1; - else if (*s == 'l' || *s == 'L') - lflag = 1; - else if (*s >= '1' && *s <= '9') { - for (tc = s; isdigit(*s); s++); - strncpy(tmp, tc, s - tc); - tmp[s - tc] = '\0'; - width = atoi(tmp); - /* atob(&width, tmp, 10); */ - s--; - } - } + if (strchr("dibouxcsefg%", *s)) + break; + if (*s == '*') + noassign = 1; + else if (*s == 'l' || *s == 'L') + lflag = 1; + else if (*s >= '1' && *s <= '9') { + for (tc = s; isdigit(*s); s++); + strncpy(tmp, tc, s - tc); + tmp[s - tc] = '\0'; + width = atoi(tmp); + /* atob(&width, tmp, 10); */ + s--; + } + } - /* Process %s: String conversion */ + /* Process %s: String conversion */ - if (*s == 's') - { - vdbg("vsscanf: Performing string conversion\n"); + if (*s == 's') + { + vdbg("vsscanf: Performing string conversion\n"); - while (isspace(*buf)) - buf++; - if (!width) - { - width = strcspn(buf, spaces); - } - if (!noassign) - { - tv = va_arg(ap, char*); - strncpy(tv, buf, width); - tv[width] = '\0'; - } - buf += width; - } + while (isspace(*buf)) + buf++; + if (!width) + { + width = strcspn(buf, spaces); + } + if (!noassign) + { + tv = va_arg(ap, char*); + strncpy(tv, buf, width); + tv[width] = '\0'; + } + buf += width; + } - /* Process %c: Character conversion */ + /* Process %c: Character conversion */ - else if (*s == 'c') - { - vdbg("vsscanf: Performing character conversion\n"); + else if (*s == 'c') + { + vdbg("vsscanf: Performing character conversion\n"); - if (!width) - width = 1; - if (!noassign) - { - tv = va_arg(ap, char*); - strncpy(tv, buf, width); - tv[width] = '\0'; - } - buf += width; - } + if (!width) + width = 1; + if (!noassign) + { + tv = va_arg(ap, char*); + strncpy(tv, buf, width); + tv[width] = '\0'; + } + buf += width; + } - /* Process %d, %o, %b, %x, %u: Various integer conversions */ + /* Process %d, %o, %b, %x, %u: Various integer conversions */ - else if (strchr("dobxu", *s)) - { - vdbg("vsscanf: Performing integer conversion\n"); + else if (strchr("dobxu", *s)) + { + vdbg("vsscanf: Performing integer conversion\n"); - /* Skip over any white space before the integer string */ + /* Skip over any white space before the integer string */ - while (isspace(*buf)) - buf++; + while (isspace(*buf)) + buf++; - /* The base of the integer conversion depends on the specific - * conversion specification. - */ + /* The base of the integer conversion depends on the specific + * conversion specification. + */ - if (*s == 'd' || *s == 'u') - base = 10; - else if (*s == 'x') - base = 16; - else if (*s == 'o') - base = 8; - else if (*s == 'b') - base = 2; + if (*s == 'd' || *s == 'u') + base = 10; + else if (*s == 'x') + base = 16; + else if (*s == 'o') + base = 8; + else if (*s == 'b') + base = 2; - /* Copy the integer string into a temporary working buffer. */ + /* Copy the integer string into a temporary working buffer. */ - if (!width) - { - if (isspace(*(s + 1)) || *(s + 1) == 0) - { - width = strcspn(buf, spaces); - } - else - { - width = strchr(buf, *(s + 1)) - buf; - } - } - strncpy(tmp, buf, width); - tmp[width] = '\0'; + if (!width) + { + if (isspace(*(s + 1)) || *(s + 1) == 0) + { + width = strcspn(buf, spaces); + } + else + { + width = strchr(buf, *(s + 1)) - buf; + } + } + strncpy(tmp, buf, width); + tmp[width] = '\0'; - vdbg("vsscanf: tmp[]=\"%s\"\n", tmp); + vdbg("vsscanf: tmp[]=\"%s\"\n", tmp); - /* Perform the integer conversion */ + /* Perform the integer conversion */ - buf += width; - if (!noassign) - { - int *pint = va_arg(ap, int*); - int tmpint = strtol(tmp, NULL, base); - vdbg("vsscanf: Return %d to 0x%p\n", tmpint, pint); - *pint = tmpint; - } - } + buf += width; + if (!noassign) + { + int *pint = va_arg(ap, int*); +#ifdef SDCC + char *endptr; + int tmpint = strtol(tmp, &endptr, base); +#else + int tmpint = strtol(tmp, NULL, base); +#endif + vdbg("vsscanf: Return %d to 0x%p\n", tmpint, pint); + *pint = tmpint; + } + } - /* Process %f: Floating point conversion */ + /* Process %f: Floating point conversion */ - else if (*s == 'f') - { - vdbg("vsscanf: Performing floating point conversion\n"); + else if (*s == 'f') + { + vdbg("vsscanf: Performing floating point conversion\n"); - /* Skip over any white space before the real string */ + /* Skip over any white space before the real string */ - while (isspace(*buf)) - buf++; + while (isspace(*buf)) + { + buf++; + } - /* Copy the real string into a temporary working buffer. */ + /* Copy the real string into a temporary working buffer. */ - if (!width) - { - if (isspace(*(s + 1)) || *(s + 1) == 0) - { - width = strcspn(buf, spaces); - } - else - { - width = strchr(buf, *(s + 1)) - buf; - } - } - strncpy(tmp, buf, width); - tmp[width] = '\0'; - buf += width; + if (!width) + { + if (isspace(*(s + 1)) || *(s + 1) == 0) + { + width = strcspn(buf, spaces); + } + else + { + width = strchr(buf, *(s + 1)) - buf; + } + } + strncpy(tmp, buf, width); + tmp[width] = '\0'; + buf += width; - vdbg("vsscanf: tmp[]=\"%s\"\n", tmp); + vdbg("vsscanf: tmp[]=\"%s\"\n", tmp); - /* Perform the floating point conversion */ + /* Perform the floating point conversion */ - if (!noassign) - { - /* strtod always returns a double */ + if (!noassign) + { + /* strtod always returns a double */ +#ifdef SDCC + char *endptr; + double_t dvalue = strtod(tmp,&endptr); +#else + double_t dvalue = strtod(tmp, NULL); +#endif + void *pv = va_arg(ap, void*); - double_t dvalue = strtod(tmp, NULL); - void *pv = va_arg(ap, void*); + vdbg("vsscanf: Return %f to 0x%p\n", dvalue, pv); - vdbg("vsscanf: Return %f to 0x%p\n", dvalue, pv); - - /* But we have to check whether we need to return a - * float or a double. - */ + /* But we have to check whether we need to return a + * float or a double. + */ #ifdef CONFIG_HAVE_DOUBLE - if (lflag) - { - *((double_t*)pv) = dvalue; - } - else + if (lflag) + { + *((double_t*)pv) = dvalue; + } + else #endif - { - *((float*)pv) = (float)dvalue; - } - } - } + { + *((float*)pv) = (float)dvalue; + } + } + } - if (!noassign) - count++; - width = noassign = lflag = 0; - s++; - } + if (!noassign) + count++; + width = noassign = lflag = 0; + s++; + } /* Its is not a conversion specifier */ else - { - while (isspace(*buf)) - buf++; - if (*s != *buf) - break; - else - s++, buf++; - } + { + while (isspace(*buf)) + buf++; + if (*s != *buf) + break; + else + s++, buf++; + } } return count; } diff --git a/nuttx/lib/lib_strdup.c b/nuttx/lib/lib_strdup.c index 285d76c2c..4b3ff8aa5 100644 --- a/nuttx/lib/lib_strdup.c +++ b/nuttx/lib/lib_strdup.c @@ -46,12 +46,12 @@ * Global Functions ************************************************************/ -char *strdup(const char *s) +FAR char *strdup(const char *s) { - char *news = NULL; + FAR char *news = NULL; if (s) { - news = malloc(strlen(s) + 1); + news = (FAR char*)malloc(strlen(s) + 1); if (news) { strcpy(news, s); diff --git a/nuttx/lib/lib_streamsem.c b/nuttx/lib/lib_streamsem.c index d0dbad56d..515366766 100644 --- a/nuttx/lib/lib_streamsem.c +++ b/nuttx/lib/lib_streamsem.c @@ -76,7 +76,7 @@ * Public Functions ************************************************************/ -void stream_semtake(struct streamlist *list) +void stream_semtake(FAR struct streamlist *list) { /* Take the semaphore (perhaps waiting) */ @@ -90,7 +90,7 @@ void stream_semtake(struct streamlist *list) } } -void stream_semgive(struct streamlist *list) +void stream_semgive(FAR struct streamlist *list) { sem_post(&list->sl_sem); } diff --git a/nuttx/lib/sq_addafter.c b/nuttx/lib/sq_addafter.c index 896aed5ca..268365a18 100644 --- a/nuttx/lib/sq_addafter.c +++ b/nuttx/lib/sq_addafter.c @@ -56,7 +56,7 @@ * ************************************************************/ -void sq_addafter(sq_entry_t *prev, sq_entry_t *node, +void sq_addafter(FAR sq_entry_t *prev, FAR sq_entry_t *node, sq_queue_t *queue) { if (!queue->head || prev == queue->tail) diff --git a/nuttx/lib/sq_addfirst.c b/nuttx/lib/sq_addfirst.c index f59fbc568..d34677241 100644 --- a/nuttx/lib/sq_addfirst.c +++ b/nuttx/lib/sq_addfirst.c @@ -56,7 +56,7 @@ * ************************************************************/ -void sq_addfirst(sq_entry_t *node, sq_queue_t *queue) +void sq_addfirst(FAR sq_entry_t *node, sq_queue_t *queue) { node->flink = queue->head; if (!queue->head) diff --git a/nuttx/lib/sq_addlast.c b/nuttx/lib/sq_addlast.c index 172808b33..f3368dcae 100644 --- a/nuttx/lib/sq_addlast.c +++ b/nuttx/lib/sq_addlast.c @@ -55,7 +55,7 @@ * the 'queue' ************************************************************/ -void sq_addlast(sq_entry_t *node, sq_queue_t *queue) +void sq_addlast(FAR sq_entry_t *node, sq_queue_t *queue) { node->flink = NULL; if (!queue->head) diff --git a/nuttx/lib/sq_rem.c b/nuttx/lib/sq_rem.c index 30a49b9b1..e5d1bbed5 100644 --- a/nuttx/lib/sq_rem.c +++ b/nuttx/lib/sq_rem.c @@ -55,7 +55,7 @@ * ************************************************************/ -void sq_rem(sq_entry_t *node, sq_queue_t *queue) +void sq_rem(FAR sq_entry_t *node, sq_queue_t *queue) { if (queue->head && node) { @@ -69,8 +69,8 @@ void sq_rem(sq_entry_t *node, sq_queue_t *queue) } else { - sq_entry_t *prev; - for(prev = (sq_entry_t*)queue->head; + FAR sq_entry_t *prev; + for(prev = (FAR sq_entry_t*)queue->head; prev && prev->flink != node; prev = prev->flink); diff --git a/nuttx/lib/sq_remafter.c b/nuttx/lib/sq_remafter.c index 353e8ec0a..d876d3a56 100644 --- a/nuttx/lib/sq_remafter.c +++ b/nuttx/lib/sq_remafter.c @@ -56,9 +56,9 @@ * ************************************************************/ -sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue) +FAR sq_entry_t *sq_remafter(FAR sq_entry_t *node, sq_queue_t *queue) { - sq_entry_t *ret = node->flink; + FAR sq_entry_t *ret = node->flink; if (queue->head && ret) { if (queue->tail == ret) @@ -76,3 +76,4 @@ sq_entry_t *sq_remafter(sq_entry_t *node, sq_queue_t *queue) return ret; } + diff --git a/nuttx/lib/sq_remfirst.c b/nuttx/lib/sq_remfirst.c index dbbd5f378..3cb00c599 100644 --- a/nuttx/lib/sq_remfirst.c +++ b/nuttx/lib/sq_remfirst.c @@ -56,9 +56,9 @@ * ************************************************************/ -sq_entry_t *sq_remfirst(sq_queue_t *queue) +FAR sq_entry_t *sq_remfirst(sq_queue_t *queue) { - sq_entry_t *ret = queue->head; + FAR sq_entry_t *ret = queue->head; if (ret) { @@ -73,3 +73,4 @@ sq_entry_t *sq_remfirst(sq_queue_t *queue) return ret; } + diff --git a/nuttx/lib/sq_remlast.c b/nuttx/lib/sq_remlast.c index 35e5cda6a..0e34492a3 100644 --- a/nuttx/lib/sq_remlast.c +++ b/nuttx/lib/sq_remlast.c @@ -55,9 +55,9 @@ * ************************************************************/ -sq_entry_t *sq_remlast(sq_queue_t *queue) +FAR sq_entry_t *sq_remlast(sq_queue_t *queue) { - sq_entry_t *ret = queue->tail; + FAR sq_entry_t *ret = queue->tail; if (ret) { @@ -68,7 +68,7 @@ sq_entry_t *sq_remlast(sq_queue_t *queue) } else { - sq_entry_t *prev; + FAR sq_entry_t *prev; for(prev = queue->head; prev && prev->flink != ret; prev = prev->flink); diff --git a/nuttx/mm/Makefile b/nuttx/mm/Makefile index ce32beea5..c00a7a2ae 100644 --- a/nuttx/mm/Makefile +++ b/nuttx/mm/Makefile @@ -70,7 +70,7 @@ $(BIN): $(OBJS) depend: .depend clean: - rm -f $(BIN) *.o *~ + rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ distclean: clean rm -f Make.dep .depend diff --git a/nuttx/mm/mm_addfreechunk.c b/nuttx/mm/mm_addfreechunk.c index f59b9f59e..c3b74a07d 100644 --- a/nuttx/mm/mm_addfreechunk.c +++ b/nuttx/mm/mm_addfreechunk.c @@ -61,10 +61,10 @@ * ************************************************************/ -void mm_addfreechunk(struct mm_freenode_s *node) +void mm_addfreechunk(FAR struct mm_freenode_s *node) { - struct mm_freenode_s *next; - struct mm_freenode_s *prev; + FAR struct mm_freenode_s *next; + FAR struct mm_freenode_s *prev; /* Convert the size to a nodelist index */ diff --git a/nuttx/mm/mm_calloc.c b/nuttx/mm/mm_calloc.c index de69b881c..6c9db3440 100644 --- a/nuttx/mm/mm_calloc.c +++ b/nuttx/mm/mm_calloc.c @@ -55,9 +55,9 @@ * calloc calculates the size and calls zalloc ************************************************************/ -void *calloc(size_t n, size_t elem_size) +FAR void *calloc(size_t n, size_t elem_size) { - void *ret = NULL; + FAR void *ret = NULL; if (n > 0 && elem_size > 0) { diff --git a/nuttx/mm/mm_environment.h b/nuttx/mm/mm_environment.h index 8d4816bd0..14476957d 100644 --- a/nuttx/mm/mm_environment.h +++ b/nuttx/mm/mm_environment.h @@ -47,6 +47,7 @@ #ifndef MM_TEST # include +# include # include # include # include diff --git a/nuttx/mm/mm_free.c b/nuttx/mm/mm_free.c index 7fb2a061e..276a734d0 100644 --- a/nuttx/mm/mm_free.c +++ b/nuttx/mm/mm_free.c @@ -62,11 +62,11 @@ * ************************************************************/ -void free(void *mem) +void free(FAR void *mem) { - struct mm_freenode_s *node; - struct mm_freenode_s *prev; - struct mm_freenode_s *next; + FAR struct mm_freenode_s *node; + FAR struct mm_freenode_s *prev; + FAR struct mm_freenode_s *next; /* Protect against attempts to free a NULL reference */ @@ -83,22 +83,22 @@ void free(void *mem) /* Map the memory chunk into a free node */ - node = (struct mm_freenode_s *)((char*)mem - SIZEOF_MM_ALLOCNODE); + node = (FAR struct mm_freenode_s *)((char*)mem - SIZEOF_MM_ALLOCNODE); node->preceding &= ~MM_ALLOC_BIT; /* Check if the following node is free and, if so, merge it */ - next = (struct mm_freenode_s *)((char*)node + node->size); + next = (FAR struct mm_freenode_s *)((char*)node + node->size); if ((next->preceding & MM_ALLOC_BIT) == 0) { - struct mm_allocnode_s *andbeyond; + FAR struct mm_allocnode_s *andbeyond; /* Get the node following the next node (which will * become the new next node). We know that we can never * index past the tail chunk because it is always allocated. */ - andbeyond = (struct mm_allocnode_s*)((char*)next + next->size); + andbeyond = (FAR struct mm_allocnode_s*)((char*)next + next->size); /* Remove the next node. There must be a predecessor, * but there may not be a successor node. @@ -115,14 +115,14 @@ void free(void *mem) node->size += next->size; andbeyond->preceding = node->size | (andbeyond->preceding & MM_ALLOC_BIT); - next = (struct mm_freenode_s *)andbeyond; + next = (FAR struct mm_freenode_s *)andbeyond; } /* Check if the preceding node is also free and, if so, merge * it with this node */ - prev = (struct mm_freenode_s *)((char*)node - node->preceding); + prev = (FAR struct mm_freenode_s *)((char*)node - node->preceding); if ((prev->preceding & MM_ALLOC_BIT) == 0) { /* Remove the node. There must be a predecessor, but there may @@ -146,6 +146,5 @@ void free(void *mem) /* Add the merged node to the nodelist */ mm_addfreechunk(node); - mm_givesemaphore(); } diff --git a/nuttx/mm/mm_initialize.c b/nuttx/mm/mm_initialize.c index 4bf24a70b..6d16a5677 100644 --- a/nuttx/mm/mm_initialize.c +++ b/nuttx/mm/mm_initialize.c @@ -50,19 +50,19 @@ /* This is the size of the heap provided to mm */ -size_t g_heapsize; +size_t g_heapsize; /* This is the first and last nodes of the heap */ -struct mm_allocnode_s *g_heapstart; -struct mm_allocnode_s *g_heapend; +FAR struct mm_allocnode_s *g_heapstart; +FAR struct mm_allocnode_s *g_heapend; /* All free nodes are maintained in a doubly linked list. This * array provides some hooks into the list at various points to * speed searches for free nodes. */ -struct mm_freenode_s g_nodelist[MM_NNODES]; +FAR struct mm_freenode_s g_nodelist[MM_NNODES]; /************************************************************ * Public Functions @@ -85,9 +85,11 @@ struct mm_freenode_s g_nodelist[MM_NNODES]; * ************************************************************/ -void mm_initialize(void *heapstart, size_t heapsize) +void mm_initialize(FAR void *heapstart, size_t heapsize) { - struct mm_freenode_s *node; + FAR struct mm_freenode_s *node; + size_t heapbase; + size_t heapend; int i; CHECK_ALLOCNODE_SIZE; @@ -97,8 +99,8 @@ void mm_initialize(void *heapstart, size_t heapsize) * both aligned with the MM_MIN_CHUNK size. */ - size_t heapbase = MM_ALIGN_UP((size_t)heapstart); - size_t heapend = MM_ALIGN_DOWN((size_t)heapstart + (size_t)heapsize); + heapbase = MM_ALIGN_UP((size_t)heapstart); + heapend = MM_ALIGN_DOWN((size_t)heapstart + (size_t)heapsize); /* Save the size of the heap */ @@ -121,15 +123,15 @@ void mm_initialize(void *heapstart, size_t heapsize) * all available memory. */ - g_heapstart = (struct mm_allocnode_s *)heapbase; + g_heapstart = (FAR struct mm_allocnode_s *)heapbase; g_heapstart->size = SIZEOF_MM_ALLOCNODE; g_heapstart->preceding = MM_ALLOC_BIT; - node = (struct mm_freenode_s *)(heapbase + SIZEOF_MM_ALLOCNODE); + node = (FAR struct mm_freenode_s *)(heapbase + SIZEOF_MM_ALLOCNODE); node->size = g_heapsize - 2*SIZEOF_MM_ALLOCNODE; node->preceding = SIZEOF_MM_ALLOCNODE; - g_heapend = (struct mm_allocnode_s *)(heapend - SIZEOF_MM_ALLOCNODE); + g_heapend = (FAR struct mm_allocnode_s *)(heapend - SIZEOF_MM_ALLOCNODE); g_heapend->size = SIZEOF_MM_ALLOCNODE; g_heapend->preceding = node->size | MM_ALLOC_BIT; diff --git a/nuttx/mm/mm_internal.h b/nuttx/mm/mm_internal.h index 27c9f1f3b..e1b9f9beb 100644 --- a/nuttx/mm/mm_internal.h +++ b/nuttx/mm/mm_internal.h @@ -120,14 +120,14 @@ struct mm_allocnode_s struct mm_freenode_s { - size_t size; /* Size of this chunk */ - size_t preceding; /* Size of the preceding chunk */ - struct mm_freenode_s *flink; /* Supports a doubly linked list */ - struct mm_freenode_s *blink; + size_t size; /* Size of this chunk */ + size_t preceding; /* Size of the preceding chunk */ + FAR struct mm_freenode_s *flink; /* Supports a doubly linked list */ + FAR struct mm_freenode_s *blink; }; #ifdef CONFIG_SMALL_MEMORY -# define SIZEOF_MM_FREENODE 10 +# define SIZEOF_MM_FREENODE 8 #else # define SIZEOF_MM_FREENODE 16 #endif @@ -160,15 +160,15 @@ extern size_t g_heapsize; /* This is the first and last nodes of the heap */ -extern struct mm_allocnode_s *g_heapstart; -extern struct mm_allocnode_s *g_heapend; +extern FAR struct mm_allocnode_s *g_heapstart; +extern FAR struct mm_allocnode_s *g_heapend; /* All free nodes are maintained in a doubly linked list. This * array provides some hooks into the list at various points to * speed searches for free nodes. */ -extern struct mm_freenode_s g_nodelist[MM_NNODES]; +extern FAR struct mm_freenode_s g_nodelist[MM_NNODES]; /************************************************************ * Pulblic Function Prototypes @@ -177,23 +177,28 @@ extern struct mm_freenode_s g_nodelist[MM_NNODES]; /* Normally defined in malloc.h */ #ifdef MM_TEST - extern void *mm_malloc(size_t); - extern void mm_free(void*); - extern void *mm_realloc(void*, size_t); - extern void *mm_memalign(size_t, size_t); - extern void *mm_zalloc(size_t); - extern void *mm_calloc(size_t, size_t); + extern FAR void *mm_malloc(size_t); + extern void mm_free(void*); + extern FAR void *mm_realloc(void*, size_t); + extern FAR void *mm_memalign(size_t, size_t); + extern FAR void *mm_zalloc(size_t); + extern FAR void *mm_calloc(size_t, size_t); +#ifdef CONFIG_CAN_PASS_STRUCTS extern struct mallinfo mallinfo(void); +#else + extern int mallinfo(struct mallinfo *info); +#endif #endif -extern void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size); -extern void mm_addfreechunk(struct mm_freenode_s *node); -extern int mm_size2ndx(size_t size); -extern void mm_seminitialize(void); -extern void mm_takesemaphore(void); -extern void mm_givesemaphore(void); +extern void mm_shrinkchunk(FAR struct mm_allocnode_s *node, + size_t size); +extern void mm_addfreechunk(FAR struct mm_freenode_s *node); +extern int mm_size2ndx(size_t size); +extern void mm_seminitialize(void); +extern void mm_takesemaphore(void); +extern void mm_givesemaphore(void); #ifdef MM_TEST - extern int mm_getsemaphore(void); + extern int mm_getsemaphore(void); #endif #endif /* __MM_INTERNAL_H */ diff --git a/nuttx/mm/mm_mallinfo.c b/nuttx/mm/mm_mallinfo.c index 4aba9770c..68c2a7bb7 100644 --- a/nuttx/mm/mm_mallinfo.c +++ b/nuttx/mm/mm_mallinfo.c @@ -65,15 +65,26 @@ * ************************************************************/ +#ifdef CONFIG_CAN_PASS_STRUCTS struct mallinfo mallinfo(void) +#else +int mallinfo(struct mallinfo *info) +#endif { - static struct mallinfo stats; struct mm_allocnode_s *node; size_t mxordblk = 0; int ordblks = 0; /* Number of non-inuse chunks */ size_t uordblks = 0; /* Total allocated space */ size_t fordblks = 0; /* Total non-inuse space */ +#ifdef CONFIG_CAN_PASS_STRUCTS + static struct mallinfo info; +#else + if (!info) + { + return ERROR; + } +#endif /* Visit each node in physical memory */ for (node = g_heapstart; @@ -99,10 +110,19 @@ struct mallinfo mallinfo(void) uordblks += SIZEOF_MM_ALLOCNODE; /* account for the tail node */ DEBUGASSERT(uordblks + fordblks == g_heapsize); - stats.arena = g_heapsize; - stats.ordblks = ordblks; - stats.mxordblk = mxordblk; - stats.uordblks = uordblks; - stats.fordblks = fordblks; - return stats; +#ifdef CONFIG_CAN_PASS_STRUCTS + info.arena = g_heapsize; + info.ordblks = ordblks; + info.mxordblk = mxordblk; + info.uordblks = uordblks; + info.fordblks = fordblks; + return info; +#else + info->arena = g_heapsize; + info->ordblks = ordblks; + info->mxordblk = mxordblk; + info->uordblks = uordblks; + info->fordblks = fordblks; + return OK; +#endif } diff --git a/nuttx/mm/mm_malloc.c b/nuttx/mm/mm_malloc.c index 80a89222b..05c0f73c8 100644 --- a/nuttx/mm/mm_malloc.c +++ b/nuttx/mm/mm_malloc.c @@ -85,9 +85,9 @@ * ************************************************************/ -void *malloc(size_t size) +FAR void *malloc(size_t size) { - struct mm_freenode_s *node; + FAR struct mm_freenode_s *node; void *ret = NULL; int ndx; @@ -142,8 +142,8 @@ void *malloc(size_t size) if (node) { - struct mm_freenode_s *remainder; - struct mm_freenode_s *next; + FAR struct mm_freenode_s *remainder; + FAR struct mm_freenode_s *next; size_t remaining; /* Remove the node. There must be a predecessor, but there may @@ -169,11 +169,11 @@ void *malloc(size_t size) { /* Get a pointer to the next node in physical memory */ - next = (struct mm_freenode_s*)(((char*)node) + node->size); + next = (FAR struct mm_freenode_s*)(((char*)node) + node->size); /* Create the remainder node */ - remainder = (struct mm_freenode_s*)(((char*)node) + size); + remainder = (FAR struct mm_freenode_s*)(((char*)node) + size); remainder->size = remaining; remainder->preceding = size; diff --git a/nuttx/mm/mm_memalign.c b/nuttx/mm/mm_memalign.c index 1f5c07727..7ac192d9c 100644 --- a/nuttx/mm/mm_memalign.c +++ b/nuttx/mm/mm_memalign.c @@ -63,9 +63,9 @@ * ************************************************************/ -void *memalign(size_t alignment, size_t size) +FAR void *memalign(size_t alignment, size_t size) { - struct mm_allocnode_s *node; + FAR struct mm_allocnode_s *node; size_t rawchunk; size_t alignedchunk; size_t mask = (size_t)(alignment - 1); @@ -115,7 +115,7 @@ void *memalign(size_t alignment, size_t size) * node after the allocation. */ - node = (struct mm_allocnode_s*)(rawchunk - SIZEOF_MM_ALLOCNODE); + node = (FAR struct mm_allocnode_s*)(rawchunk - SIZEOF_MM_ALLOCNODE); /* Find the aligned subregion */ @@ -125,13 +125,13 @@ void *memalign(size_t alignment, size_t size) if (alignedchunk != rawchunk) { - struct mm_allocnode_s *newnode; - struct mm_allocnode_s *next; + FAR struct mm_allocnode_s *newnode; + FAR struct mm_allocnode_s *next; size_t precedingsize; /* Get the node the next node after the allocation. */ - next = (struct mm_allocnode_s*)((char*)node + node->size); + next = (FAR struct mm_allocnode_s*)((char*)node + node->size); /* Make sure that there is space to convert the preceding mm_allocnode_s * into an mm_freenode_s. I think that this should always be true @@ -139,7 +139,7 @@ void *memalign(size_t alignment, size_t size) DEBUGASSERT(alignedchunk >= rawchunk + 8); - newnode = (struct mm_allocnode_s*)(alignedchunk - SIZEOF_MM_ALLOCNODE); + newnode = (FAR struct mm_allocnode_s*)(alignedchunk - SIZEOF_MM_ALLOCNODE); /* Preceding size is full size of the new 'node,' including * SIZEOF_MM_ALLOCNODE @@ -158,7 +158,7 @@ void *memalign(size_t alignment, size_t size) if (precedingsize < SIZEOF_MM_FREENODE) { alignedchunk += alignment; - newnode = (struct mm_allocnode_s*)(alignedchunk - SIZEOF_MM_ALLOCNODE); + newnode = (FAR struct mm_allocnode_s*)(alignedchunk - SIZEOF_MM_ALLOCNODE); precedingsize = (size_t)newnode - (size_t)node; } @@ -184,7 +184,7 @@ void *memalign(size_t alignment, size_t size) /* Add the original, newly freed node to the free nodelist */ - mm_addfreechunk((struct mm_freenode_s *)node); + mm_addfreechunk((FAR struct mm_freenode_s *)node); /* Replace the original node with the newlay realloaced, * aligned node @@ -206,5 +206,5 @@ void *memalign(size_t alignment, size_t size) } mm_givesemaphore(); - return (void*)alignedchunk; + return (FAR void*)alignedchunk; } diff --git a/nuttx/mm/mm_realloc.c b/nuttx/mm/mm_realloc.c index b288e880a..52dd56bb7 100644 --- a/nuttx/mm/mm_realloc.c +++ b/nuttx/mm/mm_realloc.c @@ -73,11 +73,11 @@ * ************************************************************/ -void *realloc(void *oldmem, size_t size) +FAR void *realloc(FAR void *oldmem, size_t size) { - struct mm_allocnode_s *oldnode; - struct mm_freenode_s *prev; - struct mm_freenode_s *next; + FAR struct mm_allocnode_s *oldnode; + FAR struct mm_freenode_s *prev; + FAR struct mm_freenode_s *next; size_t oldsize; size_t prevsize = 0; size_t nextsize = 0; @@ -106,7 +106,7 @@ void *realloc(void *oldmem, size_t size) /* Map the memory chunk into an allocated node structure */ - oldnode = (struct mm_allocnode_s *)((char*)oldmem - SIZEOF_MM_ALLOCNODE); + oldnode = (FAR struct mm_allocnode_s *)((FAR char*)oldmem - SIZEOF_MM_ALLOCNODE); /* We need to hold the MM semaphore while we muck with the * nodelist. @@ -129,13 +129,13 @@ void *realloc(void *oldmem, size_t size) * the best decision */ - next = (struct mm_freenode_s *)((char*)oldnode + oldnode->size); + next = (FAR struct mm_freenode_s *)((FAR char*)oldnode + oldnode->size); if ((next->preceding & MM_ALLOC_BIT) == 0) { nextsize = next->size; } - prev = (struct mm_freenode_s *)((char*)oldnode - (oldnode->preceding & ~MM_ALLOC_BIT)); + prev = (FAR struct mm_freenode_s *)((FAR char*)oldnode - (oldnode->preceding & ~MM_ALLOC_BIT)); if ((prev->preceding & MM_ALLOC_BIT) == 0) { prevsize = prev->size; @@ -145,9 +145,9 @@ void *realloc(void *oldmem, size_t size) if (nextsize + prevsize + oldsize >= size) { - size_t needed = size - oldsize; - size_t takeprev; - size_t takenext; + size_t needed = size - oldsize; + size_t takeprev = 0; + size_t takenext = 0; /* Check if we can extend into the previous chunk and if the * previous chunk is smaller than the next chunk. @@ -207,7 +207,7 @@ void *realloc(void *oldmem, size_t size) if (takeprev) { - struct mm_allocnode_s *newnode; + FAR struct mm_allocnode_s *newnode; /* Remove the previous node. There must be a predecessor, * but there may not be a successor node. @@ -222,7 +222,7 @@ void *realloc(void *oldmem, size_t size) /* Extend the node into the previous free chunk */ - newnode = (struct mm_allocnode_s *)((char*)oldnode - takeprev); + newnode = (FAR struct mm_allocnode_s *)((FAR char*)oldnode - takeprev); /* Did we consume the entire preceding chunk? */ @@ -261,12 +261,12 @@ void *realloc(void *oldmem, size_t size) if (takenext) { - struct mm_freenode_s *newnode; - struct mm_allocnode_s *andbeyond; + FAR struct mm_freenode_s *newnode; + FAR struct mm_allocnode_s *andbeyond; /* Get the chunk following the next node (which could be the tail chunk) */ - andbeyond = (struct mm_allocnode_s*)((char*)next + nextsize); + andbeyond = (FAR struct mm_allocnode_s*)((char*)next + nextsize); /* Remove the next node. There must be a predecessor, * but there may not be a successor node. @@ -282,7 +282,7 @@ void *realloc(void *oldmem, size_t size) /* Extend the node into the previous next chunk */ oldnode->size = oldsize + takenext; - newnode = (struct mm_freenode_s *)((char*)oldnode + oldnode->size); + newnode = (FAR struct mm_freenode_s *)((char*)oldnode + oldnode->size); /* Did we consume the entire preceding chunk? */ @@ -310,19 +310,21 @@ void *realloc(void *oldmem, size_t size) mm_givesemaphore(); - return (void*)((char*)oldnode + SIZEOF_MM_ALLOCNODE); + return (FAR void*)((FAR char*)oldnode + SIZEOF_MM_ALLOCNODE); } /* The current chunk cannot be extended. Just allocate a new chunk and copy */ else { + FAR void *newmem; + /* Allocate a new block. On failure, realloc must return NULL but * leave the original memory in place. */ mm_givesemaphore(); - char *newmem = (char*)malloc(size); + newmem = (FAR void*)malloc(size); if (newmem) { memcpy(newmem, oldmem, oldsize); diff --git a/nuttx/mm/mm_shrinkchunk.c b/nuttx/mm/mm_shrinkchunk.c index 8869f045c..4612c426d 100644 --- a/nuttx/mm/mm_shrinkchunk.c +++ b/nuttx/mm/mm_shrinkchunk.c @@ -64,24 +64,24 @@ * ************************************************************/ -void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size) +void mm_shrinkchunk(FAR struct mm_allocnode_s *node, size_t size) { - struct mm_freenode_s *next; + FAR struct mm_freenode_s *next; /* Get a reference to the next node */ - next = (struct mm_freenode_s*)((char*)node + node->size); + next = (FAR struct mm_freenode_s*)((char*)node + node->size); /* Check if it is free */ if ((next->preceding & MM_ALLOC_BIT) == 0) { - struct mm_allocnode_s *andbeyond; - struct mm_freenode_s *newnode; + FAR struct mm_allocnode_s *andbeyond; + FAR struct mm_freenode_s *newnode; /* Get the chunk next the next node (which could be the tail chunk) */ - andbeyond = (struct mm_allocnode_s*)((char*)next + next->size); + andbeyond = (FAR struct mm_allocnode_s*)((char*)next + next->size); /* Remove the next node. There must be a predecessor, but there may * not be a successor node. @@ -98,7 +98,7 @@ void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size) * and the tailing memory from the aligned chunk. */ - newnode = (struct mm_freenode_s*)((char*)node + size); + newnode = (FAR struct mm_freenode_s*)((char*)node + size); /* Set up the size of the new node */ @@ -118,13 +118,13 @@ void mm_shrinkchunk(struct mm_allocnode_s *node, size_t size) else if (node->size >= size + SIZEOF_MM_FREENODE) { - struct mm_freenode_s *newnode; + FAR struct mm_freenode_s *newnode; /* Create a new chunk that will hold both the next chunk * and the tailing memory from the aligned chunk. */ - newnode = (struct mm_freenode_s*)((char*)node + size); + newnode = (FAR struct mm_freenode_s*)((char*)node + size); /* Set up the size of the new node */ diff --git a/nuttx/mm/mm_zalloc.c b/nuttx/mm/mm_zalloc.c index a26992b00..270839cac 100644 --- a/nuttx/mm/mm_zalloc.c +++ b/nuttx/mm/mm_zalloc.c @@ -56,9 +56,9 @@ * ************************************************************/ -void *zalloc(size_t size) +FAR void *zalloc(size_t size) { - void *alloc = malloc(size); + FAR void *alloc = malloc(size); if (alloc) { memset(alloc, 0, size); diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile index 5efa4a6f0..e5dc3881d 100644 --- a/nuttx/sched/Makefile +++ b/nuttx/sched/Makefile @@ -40,7 +40,7 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh ASRCS = AOBJS = $(ASRCS:.S=.o) -MISC_SRCS = os_start.c get_errno_ptr.c get_errorptr.c \ +MISC_SRCS = os_start.c get_errno_ptr.c \ sched_setupstreams.c sched_getfiles.c sched_getstreams.c \ sched_setupidlefiles.c sched_setuptaskfiles.c sched_setuppthreadfiles.c \ sched_releasefiles.c @@ -124,7 +124,7 @@ $(BIN): $(OBJS) depend: .depend clean: - rm -f $(BIN) *.o *.asm *.lst *.sym *~ + rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ distclean: clean rm -f Make.dep .depend diff --git a/nuttx/sched/get_errno_ptr.c b/nuttx/sched/get_errno_ptr.c index c9f0d52c8..7a8084c71 100644 --- a/nuttx/sched/get_errno_ptr.c +++ b/nuttx/sched/get_errno_ptr.c @@ -61,9 +61,9 @@ * ************************************************************/ -int *get_errno_ptr(void) +FAR int *get_errno_ptr(void) { - _TCB *ptcb = (_TCB*)g_readytorun.head; + FAR _TCB *ptcb = (FAR _TCB*)g_readytorun.head; return &ptcb->errno; } diff --git a/nuttx/sched/get_errorptr.c b/nuttx/sched/get_errorptr.c deleted file mode 100644 index 7cfad6cb1..000000000 --- a/nuttx/sched/get_errorptr.c +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************ - * get_errorptr.c - * - * Copyright (C) 2007 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 - * 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 Gregory Nutt 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 -#include - -/************************************************************ - * Global Functions - ************************************************************/ - -/************************************************************ - * Function: get_errorptr - * - * Description: - * Return a pointer that is just ERROR cast to void *. - * most fully performing processors don't need anything - * like this. Hoever, this little of nonsense is necessary - * for some processors where sizeof(pointer) < sizeof(uint32) - * and which do not support casts of integers to pointers. - * - * Parameters: - * None - * - * Return Value: - * ERROR cast as a pointer value - * - * Assumptions: - * - ************************************************************/ - -void *get_errnorptr(void) -{ -#ifdef CONFIG_CAN_CAST_POINTERS - return (void*)ERROR; -#else - union - { - void *verror; - sint32 ierror; - } u; - - u.ierror = ERROR; - return u.verror; -#endif -} - - diff --git a/nuttx/sched/irq_attach.c b/nuttx/sched/irq_attach.c index d67a04a49..3032bf1b6 100644 --- a/nuttx/sched/irq_attach.c +++ b/nuttx/sched/irq_attach.c @@ -76,6 +76,7 @@ int irq_attach(int irq, xcpt_t isr) { +#if NR_IRQS > 0 int ret = ERROR; if ((unsigned)irq < NR_IRQS) @@ -102,6 +103,9 @@ int irq_attach(int irq, xcpt_t isr) } return ret; +#else + return OK; +#endif } diff --git a/nuttx/sched/irq_dispatch.c b/nuttx/sched/irq_dispatch.c index d6466cbc0..1dc388a40 100644 --- a/nuttx/sched/irq_dispatch.c +++ b/nuttx/sched/irq_dispatch.c @@ -76,12 +76,13 @@ * ***********************************************************/ -void irq_dispatch(int irq, void *context) +void irq_dispatch(int irq, FAR void *context) { xcpt_t vector; /* Perform some sanity checks */ +#if NR_IRQS > 0 if ((unsigned)irq >= NR_IRQS || g_irqvector[irq] == NULL) { vector = irq_unexpected_isr; @@ -90,6 +91,9 @@ void irq_dispatch(int irq, void *context) { vector = g_irqvector[irq]; } +#else + vector = irq_unexpected_isr; +#endif /* Then dispatch to the interrupt handler */ diff --git a/nuttx/sched/irq_internal.h b/nuttx/sched/irq_internal.h index 211779bc3..a1216fa9d 100644 --- a/nuttx/sched/irq_internal.h +++ b/nuttx/sched/irq_internal.h @@ -71,7 +71,7 @@ extern "C" { #endif EXTERN void weak_function irq_initialize(void); -EXTERN int irq_unexpected_isr(int irq, void *context); +EXTERN int irq_unexpected_isr(int irq, FAR void *context); #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/sched/irq_unexpectedisr.c b/nuttx/sched/irq_unexpectedisr.c index 6ca3e1da8..b7b6b4ae2 100644 --- a/nuttx/sched/irq_unexpectedisr.c +++ b/nuttx/sched/irq_unexpectedisr.c @@ -75,7 +75,7 @@ * ************************************************************/ -int irq_unexpected_isr(int irq, void *context) +int irq_unexpected_isr(int irq, FAR void *context) { (void)irqsave(); PANIC(OSERR_UNEXPECTEDISR); diff --git a/nuttx/sched/mq_close.c b/nuttx/sched/mq_close.c index 88fe0e043..6643cc5e9 100644 --- a/nuttx/sched/mq_close.c +++ b/nuttx/sched/mq_close.c @@ -75,7 +75,7 @@ * ************************************************************/ -#define mq_desfree(mqdes) sq_addlast((sq_entry_t*)mqdes, &g_desfree) +#define mq_desfree(mqdes) sq_addlast((FAR sq_entry_t*)mqdes, &g_desfree) /************************************************************ * Public Functions @@ -113,10 +113,10 @@ int mq_close(mqd_t mqdes) { - _TCB *rtcb = (_TCB*)g_readytorun.head; - msgq_t *msgq; - irqstate_t saved_state; - int ret = ERROR; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + FAR msgq_t *msgq; + irqstate_t saved_state; + int ret = ERROR; /* Verify the inputs */ @@ -128,7 +128,7 @@ int mq_close(mqd_t mqdes) * list of message descriptors. */ - sq_rem((sq_entry_t*)mqdes, &rtcb->msgdesq); + sq_rem((FAR sq_entry_t*)mqdes, &rtcb->msgdesq); /* Find the message queue associated with the message descriptor */ @@ -165,7 +165,7 @@ int mq_close(mqd_t mqdes) */ saved_state = irqsave(); - (void)sq_rem((sq_entry_t*)msgq, &g_msgqueues); + (void)sq_rem((FAR sq_entry_t*)msgq, &g_msgqueues); irqrestore(saved_state); /* Then deallocate it (and any messages left in it) */ @@ -183,3 +183,4 @@ int mq_close(mqd_t mqdes) return ret; } + diff --git a/nuttx/sched/mq_descreate.c b/nuttx/sched/mq_descreate.c index f631cfd2b..98026ad19 100644 --- a/nuttx/sched/mq_descreate.c +++ b/nuttx/sched/mq_descreate.c @@ -132,7 +132,7 @@ static mqd_t mq_desalloc(void) * ************************************************************/ -mqd_t mq_descreate(_TCB* mtcb, msgq_t* msgq, int oflags) +mqd_t mq_descreate(FAR _TCB* mtcb, FAR msgq_t* msgq, int oflags) { mqd_t mqdes; @@ -149,7 +149,7 @@ mqd_t mq_descreate(_TCB* mtcb, msgq_t* msgq, int oflags) /* And add it to the specified tasks's TCB */ - sq_addlast((sq_entry_t*)mqdes, &mtcb->msgdesq); + sq_addlast((FAR sq_entry_t*)mqdes, &mtcb->msgdesq); } return mqdes; diff --git a/nuttx/sched/mq_findnamed.c b/nuttx/sched/mq_findnamed.c index f01e24d1f..a74caba7b 100644 --- a/nuttx/sched/mq_findnamed.c +++ b/nuttx/sched/mq_findnamed.c @@ -81,13 +81,13 @@ * ************************************************************/ -msgq_t *mq_findnamed(const char *mq_name) +FAR msgq_t *mq_findnamed(const char *mq_name) { - msgq_t *msgq; + FAR msgq_t *msgq; /* Search the list of named message queues */ - for (msgq = (msgq_t*)g_msgqueues.head; (msgq); msgq = msgq->flink) + for (msgq = (FAR msgq_t*)g_msgqueues.head; (msgq); msgq = msgq->flink) { /* Break out of the lloop with a non-NULL msgq if the * name matches. diff --git a/nuttx/sched/mq_initialize.c b/nuttx/sched/mq_initialize.c index deff6a254..df8e981e6 100644 --- a/nuttx/sched/mq_initialize.c +++ b/nuttx/sched/mq_initialize.c @@ -144,7 +144,7 @@ static mqmsg_t *mq_msgblockalloc(sq_queue_t *queue, uint16 nmsgs, for (i = 0; i < nmsgs; i++) { mqmsg->type = alloc_type; - sq_addlast((sq_entry_t*)mqmsg++, queue); + sq_addlast((FAR sq_entry_t*)mqmsg++, queue); } } @@ -233,13 +233,13 @@ void mq_desblockalloc(void) * we ever need to reclaim the memory. */ - sq_addlast(&mqdesblock->queue, &g_desalloc); + sq_addlast((FAR sq_entry_t*)&mqdesblock->queue, &g_desalloc); /* Then add each message queue descriptor to the free list */ for (i = 0; i < NUM_MSG_DESCRIPTORS; i++) { - sq_addlast((sq_entry_t*)&mqdesblock->mqdes[i], &g_desfree); + sq_addlast((FAR sq_entry_t*)&mqdesblock->mqdes[i], &g_desfree); } } } diff --git a/nuttx/sched/mq_internal.h b/nuttx/sched/mq_internal.h index ba2368e43..4e55a9316 100644 --- a/nuttx/sched/mq_internal.h +++ b/nuttx/sched/mq_internal.h @@ -95,13 +95,12 @@ struct mqmsg * MQ_type. */ - struct mqmsg *next; /* Forward link to next message */ - ubyte type; /* (Used to manage allocations) */ + FAR struct mqmsg *next; /* Forward link to next message */ + ubyte type; /* (Used to manage allocations) */ - ubyte priority; /* priority of message */ - ubyte msglen; /* Message data length */ - ubyte pad; /* Not used */ - uint16 mail[MQ_MAX_HWORDS]; /* Message data */ + ubyte priority; /* priority of message */ + ubyte msglen; /* Message data length */ + uint16 mail[MQ_MAX_HWORDS]; /* Message data */ }; typedef struct mqmsg mqmsg_t; @@ -111,20 +110,20 @@ struct mq_des; /* forward reference */ struct msgq_s { - struct msgq_s *flink; /* Forward link to next message queue */ - sq_queue_t msglist; /* Prioritized message list */ - sint16 maxmsgs; /* Maximum number of messages in the queue */ - sint16 nmsgs; /* Number of message in the queue */ - sint16 nconnect; /* Number of connections to message queue */ - sint16 nwaitnotfull; /* Number tasks waiting for not full */ - sint16 nwaitnotempty; /* Number tasks waiting for not empty */ - ubyte maxmsgsize; /* Max size of message in message queue */ - boolean unlinked; /* TRUE if the msg queue has been unlinked */ - struct mq_des *ntmqdes; /* Notification: Owning mqdes (NULL if none) */ - pid_t ntpid; /* Notification: Receiving Task's PID */ - int ntsigno; /* Notification: Signal number */ - union sigval ntvalue; /* Notification: Signal value */ - char name[1]; /* Start of the queue name */ + FAR struct msgq_s *flink; /* Forward link to next message queue */ + sq_queue_t msglist; /* Prioritized message list */ + sint16 maxmsgs; /* Maximum number of messages in the queue */ + sint16 nmsgs; /* Number of message in the queue */ + sint16 nconnect; /* Number of connections to message queue */ + sint16 nwaitnotfull; /* Number tasks waiting for not full */ + sint16 nwaitnotempty; /* Number tasks waiting for not empty */ + ubyte maxmsgsize; /* Max size of message in message queue */ + boolean unlinked; /* TRUE if the msg queue has been unlinked */ + FAR struct mq_des *ntmqdes; /* Notification: Owning mqdes (NULL if none) */ + pid_t ntpid; /* Notification: Receiving Task's PID */ + int ntsigno; /* Notification: Signal number */ + union sigval ntvalue; /* Notification: Signal value */ + char name[1]; /* Start of the queue name */ }; #define SIZEOF_MQ_HEADER ((int)(((msgq_t*)NULL)->name)) @@ -135,9 +134,9 @@ struct msgq_s struct mq_des { - struct mq_des *flink; /* Forward link to next message descriptor */ - msgq_t *msgq; /* Pointer to associated message queue */ - int oflags; /* Flags set when message queue was opened */ + FAR struct mq_des *flink; /* Forward link to next message descriptor */ + FAR msgq_t *msgq; /* Pointer to associated message queue */ + int oflags; /* Flags set when message queue was opened */ }; /************************************************************ @@ -182,12 +181,12 @@ extern "C" { /* Functions defined in mq_initialized.c *******************/ EXTERN void weak_function mq_initialize(void); -EXTERN void mq_desblockalloc(void); +EXTERN void mq_desblockalloc(void); -EXTERN mqd_t mq_descreate(_TCB* mtcb, msgq_t* msgq, int oflags); -EXTERN msgq_t *mq_findnamed(const char *mq_name); -EXTERN void mq_msgfree(mqmsg_t *mqmsg); -EXTERN void mq_msgqfree(msgq_t *msgq); +EXTERN mqd_t mq_descreate(FAR _TCB* mtcb, FAR msgq_t* msgq, int oflags); +EXTERN FAR msgq_t *mq_findnamed(const char *mq_name); +EXTERN void mq_msgfree(FAR mqmsg_t *mqmsg); +EXTERN void mq_msgqfree(FAR msgq_t *msgq); #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/sched/mq_msgfree.c b/nuttx/sched/mq_msgfree.c index f9246d8fc..f7a236f15 100644 --- a/nuttx/sched/mq_msgfree.c +++ b/nuttx/sched/mq_msgfree.c @@ -84,7 +84,7 @@ * ************************************************************/ -void mq_msgfree(mqmsg_t * mqmsg) +void mq_msgfree(FAR mqmsg_t *mqmsg) { irqstate_t saved_state; @@ -99,7 +99,7 @@ void mq_msgfree(mqmsg_t * mqmsg) */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)mqmsg, &g_msgfree); + sq_addlast((FAR sq_entry_t*)mqmsg, &g_msgfree); irqrestore(saved_state); } @@ -114,7 +114,7 @@ void mq_msgfree(mqmsg_t * mqmsg) */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)mqmsg, &g_msgfreeirq); + sq_addlast((FAR sq_entry_t*)mqmsg, &g_msgfreeirq); irqrestore(saved_state); } diff --git a/nuttx/sched/mq_msgqfree.c b/nuttx/sched/mq_msgqfree.c index 59a27603e..06d5da815 100644 --- a/nuttx/sched/mq_msgqfree.c +++ b/nuttx/sched/mq_msgqfree.c @@ -84,14 +84,14 @@ * ************************************************************/ -void mq_msgqfree(msgq_t *msgq) +void mq_msgqfree(FAR msgq_t *msgq) { - mqmsg_t *curr; - mqmsg_t *next; + FAR mqmsg_t *curr; + FAR mqmsg_t *next; /* Deallocate any stranded messages in the message queue. */ - curr = (mqmsg_t*)msgq->msglist.head; + curr = (FAR mqmsg_t*)msgq->msglist.head; while (curr) { /* Deallocate the message structure. */ diff --git a/nuttx/sched/mq_open.c b/nuttx/sched/mq_open.c index d4ad2a322..e3e239180 100644 --- a/nuttx/sched/mq_open.c +++ b/nuttx/sched/mq_open.c @@ -103,8 +103,8 @@ mqd_t mq_open(const char *mq_name, int oflags, ...) { - _TCB *rtcb = (_TCB*)g_readytorun.head; - msgq_t *msgq; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + FAR msgq_t *msgq; mqd_t mqdes = NULL; va_list arg; /* Points to each un-named argument */ mode_t mode; /* MQ creation mode parameter (ignored) */ @@ -151,7 +151,7 @@ mqd_t mq_open(const char *mq_name, int oflags, ...) * of the message queue name+1. */ - msgq = (msgq_t*)kzmalloc(SIZEOF_MQ_HEADER + namelen + 1); + msgq = (FAR msgq_t*)kzmalloc(SIZEOF_MQ_HEADER + namelen + 1); if (msgq) { /* Create a message queue descriptor for the TCB */ @@ -196,7 +196,7 @@ mqd_t mq_open(const char *mq_name, int oflags, ...) * message queues */ - sq_addlast((sq_entry_t*)msgq, &g_msgqueues); + sq_addlast((FAR sq_entry_t*)msgq, &g_msgqueues); /* Clean-up variable argument stuff */ @@ -218,11 +218,7 @@ mqd_t mq_open(const char *mq_name, int oflags, ...) if (mqdes == NULL) { -#ifdef CONFIG_CAN_CAST_POINTERS return (mqd_t)ERROR; -#else - return get_errorptr(); -#endif } else { diff --git a/nuttx/sched/mq_receive.c b/nuttx/sched/mq_receive.c index 4e7555e13..649dfae7a 100644 --- a/nuttx/sched/mq_receive.c +++ b/nuttx/sched/mq_receive.c @@ -114,13 +114,13 @@ int mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio) { - _TCB *rtcb; - _TCB *btcb; - msgq_t *msgq; - mqmsg_t *curr; - irqstate_t saved_state; - ubyte rcvmsglen; - int ret = ERROR; + FAR _TCB *rtcb; + FAR _TCB *btcb; + FAR msgq_t *msgq; + FAR mqmsg_t *curr; + irqstate_t saved_state; + ubyte rcvmsglen; + int ret = ERROR; /* Verify the input parameters */ @@ -142,7 +142,7 @@ int mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio) /* Get the message from the head of the queue */ - while ((curr = (mqmsg_t*)sq_remfirst(&msgq->msglist)) == NULL) + while ((curr = (FAR mqmsg_t*)sq_remfirst(&msgq->msglist)) == NULL) { /* Should we block until there the above condition has been * satisfied? @@ -152,7 +152,7 @@ int mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio) { /* Block and try again */ - rtcb = (_TCB*)g_readytorun.head; + rtcb = (FAR _TCB*)g_readytorun.head; rtcb->msgwaitq = msgq; msgq->nwaitnotempty++; up_block_task(rtcb, TSTATE_WAIT_MQNOTEMPTY); @@ -207,7 +207,7 @@ int mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio) */ saved_state = irqsave(); - for (btcb = (_TCB*)g_waitingformqnotfull.head; + for (btcb = (FAR _TCB*)g_waitingformqnotfull.head; btcb && btcb->msgwaitq != msgq; btcb = btcb->flink); diff --git a/nuttx/sched/mq_send.c b/nuttx/sched/mq_send.c index 0a9a12515..aaf700a45 100644 --- a/nuttx/sched/mq_send.c +++ b/nuttx/sched/mq_send.c @@ -37,6 +37,7 @@ * Included Files ************************************************************/ +#include #include #include /* uint32, etc. */ #include @@ -92,10 +93,10 @@ * ************************************************************/ -mqmsg_t *mq_msgalloc(void) +FAR mqmsg_t *mq_msgalloc(void) { - mqmsg_t *mqmsg; - irqstate_t saved_state; + FAR mqmsg_t *mqmsg; + irqstate_t saved_state; /* If we were called from an interrupt handler, then try to * get the message from generally available list of messages. @@ -107,12 +108,12 @@ mqmsg_t *mq_msgalloc(void) { /* Try the general free list */ - mqmsg = (mqmsg_t*)sq_remfirst(&g_msgfree); + mqmsg = (FAR mqmsg_t*)sq_remfirst(&g_msgfree); if (!mqmsg) { /* Try the free list reserved for interrupt handlers */ - mqmsg = (mqmsg_t*)sq_remfirst(&g_msgfreeirq); + mqmsg = (FAR mqmsg_t*)sq_remfirst(&g_msgfreeirq); } } @@ -125,14 +126,14 @@ mqmsg_t *mq_msgalloc(void) */ saved_state = irqsave(); - mqmsg = (mqmsg_t*)sq_remfirst(&g_msgfree); + mqmsg = (FAR mqmsg_t*)sq_remfirst(&g_msgfree); irqrestore(saved_state); /* If we cannot a message from the free list, then we will have to allocate one. */ if (!mqmsg) { - mqmsg = (mqmsg_t *)kmalloc((sizeof (mqmsg_t))); + mqmsg = (FAR mqmsg_t *)kmalloc((sizeof (mqmsg_t))); /* Check if we got an allocated message */ @@ -152,7 +153,6 @@ mqmsg_t *mq_msgalloc(void) } return(mqmsg); - } /************************************************************ @@ -202,14 +202,14 @@ mqmsg_t *mq_msgalloc(void) int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio) { - _TCB *rtcb; - _TCB *btcb; - msgq_t *msgq; - mqmsg_t *curr; - mqmsg_t *next; - mqmsg_t *prev; - irqstate_t saved_state; - int ret = ERROR; + FAR _TCB *rtcb; + FAR _TCB *btcb; + FAR msgq_t *msgq; + FAR mqmsg_t *curr; + FAR mqmsg_t *next; + FAR mqmsg_t *prev; + irqstate_t saved_state; + int ret = ERROR; /* Verify the input parameters */ @@ -267,7 +267,7 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio) * When we are unblocked, we will try again */ - rtcb = (_TCB*)g_readytorun.head; + rtcb = (FAR _TCB*)g_readytorun.head; rtcb->msgwaitq = msgq; (msgq->nwaitnotfull)++; up_block_task(rtcb, TSTATE_WAIT_MQNOTFULL); @@ -314,7 +314,7 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio) * message. Each is list is maintained in ascending priority order. */ - for (prev = NULL, next = (mqmsg_t*)msgq->msglist.head; + for (prev = NULL, next = (FAR mqmsg_t*)msgq->msglist.head; next && prio <= next->priority; prev = next, next = next->next); @@ -322,12 +322,12 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio) if (prev) { - sq_addafter((sq_entry_t*)prev, (sq_entry_t*)curr, + sq_addafter((FAR sq_entry_t*)prev, (FAR sq_entry_t*)curr, &msgq->msglist); } else { - sq_addfirst((sq_entry_t*)curr, &msgq->msglist); + sq_addfirst((FAR sq_entry_t*)curr, &msgq->msglist); } /* Increment the count of message in the queue */ @@ -378,7 +378,7 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio) * interrupts should never cause a change in this list */ - for (btcb = (_TCB*)g_waitingformqnotempty.head; + for (btcb = (FAR _TCB*)g_waitingformqnotempty.head; btcb && btcb->msgwaitq != msgq; btcb = btcb->flink); diff --git a/nuttx/sched/mq_unlink.c b/nuttx/sched/mq_unlink.c index 066bcacab..17b5767ae 100644 --- a/nuttx/sched/mq_unlink.c +++ b/nuttx/sched/mq_unlink.c @@ -89,9 +89,9 @@ int mq_unlink(const char *mq_name) { - msgq_t *msgq; - irqstate_t saved_state; - int ret = ERROR; + FAR msgq_t *msgq; + irqstate_t saved_state; + int ret = ERROR; /* Verify the input values */ @@ -115,7 +115,7 @@ int mq_unlink(const char *mq_name) */ saved_state = irqsave(); - (void)sq_rem((sq_entry_t*)msgq, &g_msgqueues); + (void)sq_rem((FAR sq_entry_t*)msgq, &g_msgqueues); irqrestore(saved_state); /* Then deallocate it (and any messages left in it) */ @@ -140,3 +140,4 @@ int mq_unlink(const char *mq_name) return ret; } + diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h index 4e4cdf7d6..75807e930 100644 --- a/nuttx/sched/os_internal.h +++ b/nuttx/sched/os_internal.h @@ -123,8 +123,8 @@ enum os_crash_codes_e struct pidhash_s { - _TCB *tcb; - pid_t pid; + FAR _TCB *tcb; + pid_t pid; }; typedef struct pidhash_s pidhash_t; @@ -135,8 +135,8 @@ typedef struct pidhash_s pidhash_t; struct tasklist_s { - dq_queue_t *list; /* Pointer to the task list */ - boolean prioritized; /* TRUE if the list is prioritized */ + NEAR dq_queue_t *list; /* Pointer to the task list */ + boolean prioritized; /* TRUE if the list is prioritized */ }; typedef struct tasklist_s tasklist_t; @@ -232,32 +232,32 @@ extern const tasklist_t g_tasklisttable[NUM_TASK_STATES]; * Public Function Prototypes ************************************************************/ -extern STATUS _task_init(_TCB *tcb, char *name, int priority, +extern STATUS _task_init(FAR _TCB *tcb, const char *name, int priority, start_t start, main_t main, boolean pthread, - char *arg1, char *arg2, - char *arg3, char *arg4); + FAR char *arg1, FAR char *arg2, + FAR char *arg3, FAR char *arg4); -extern boolean sched_addreadytorun(_TCB *rtrtcb); -extern boolean sched_removereadytorun(_TCB *rtrtcb); -extern boolean sched_addprioritized(_TCB *newTcb, - dq_queue_t *list); +extern boolean sched_addreadytorun(FAR _TCB *rtrtcb); +extern boolean sched_removereadytorun(FAR _TCB *rtrtcb); +extern boolean sched_addprioritized(FAR _TCB *newTcb, + NEAR dq_queue_t *list); extern boolean sched_mergepending(void); -extern void sched_addblocked(_TCB *btcb, tstate_t task_state); -extern void sched_removeblocked(_TCB *btcb); -extern _TCB *sched_gettcb(pid_t pid); +extern void sched_addblocked(FAR _TCB *btcb, tstate_t task_state); +extern void sched_removeblocked(FAR _TCB *btcb); +extern FAR _TCB *sched_gettcb(pid_t pid); #if CONFIG_NFILE_DESCRIPTORS > 0 -extern int sched_setupidlefiles(_TCB *tcb); -extern int sched_setuptaskfiles(_TCB *tcb); -extern int sched_setuppthreadfiles(_TCB *tcb); +extern int sched_setupidlefiles(FAR _TCB *tcb); +extern int sched_setuptaskfiles(FAR _TCB *tcb); +extern int sched_setuppthreadfiles(FAR _TCB *tcb); #if CONFIG_NFILE_STREAMS > 0 -extern int sched_setupstreams(_TCB *tcb); -extern int sched_flushfiles(_TCB *tcb); +extern int sched_setupstreams(FAR _TCB *tcb); +extern int sched_flushfiles(FAR _TCB *tcb); #endif -extern int sched_releasefiles(_TCB *tcb); +extern int sched_releasefiles(FAR _TCB *tcb); #endif -extern int sched_releasetcb(_TCB *tcb); +extern int sched_releasetcb(FAR _TCB *tcb); #endif /* __OS_INTERNAL_H */ diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c index 09de22ce3..249134a98 100644 --- a/nuttx/sched/os_start.c +++ b/nuttx/sched/os_start.c @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -170,7 +171,7 @@ const tasklist_t g_tasklisttable[NUM_TASK_STATES] = * for bringing up the rest of the system */ -static _TCB g_idletcb; +static FAR _TCB g_idletcb; /************************************************************ * Private Function Prototypes @@ -239,7 +240,7 @@ void os_start(void) /* Then add the idle task's TCB to the head of the ready to run list */ - dq_addfirst((dq_entry_t*)&g_idletcb, &g_readytorun); + dq_addfirst((FAR dq_entry_t*)&g_idletcb, &g_readytorun); /* Initialize the processor-specific portion of the TCB */ @@ -249,7 +250,7 @@ void os_start(void) #ifndef CONFIG_HEAP_BASE { - void *heap_start; + FAR void *heap_start; size_t heap_size; up_allocate_heap(&heap_start, &heap_size); mm_initialize(heap_start, heap_size); diff --git a/nuttx/sched/pthread_completejoin.c b/nuttx/sched/pthread_completejoin.c index 8e57ada8b..571bb6862 100644 --- a/nuttx/sched/pthread_completejoin.c +++ b/nuttx/sched/pthread_completejoin.c @@ -74,7 +74,7 @@ * ************************************************************/ -static void pthread_destroyjoininfo(join_t *pjoin) +static void pthread_destroyjoininfo(FAR join_t *pjoin) { int ntasks_waiting; int status; @@ -145,9 +145,9 @@ static void pthread_destroyjoininfo(join_t *pjoin) * ************************************************************/ -int pthread_completejoin(pid_t pid, void *exit_value) +int pthread_completejoin(pid_t pid, FAR void *exit_value) { - join_t *pjoin; + FAR join_t *pjoin; boolean detached = FALSE; dbg("process_id=%d exit_value=%p\n", pid, exit_value); @@ -186,7 +186,7 @@ int pthread_completejoin(pid_t pid, void *exit_value) /* Deallocate the join entry if it was detached. */ - sched_free((void*)pjoin); + sched_free((FAR void*)pjoin); } /* No, then we can assume that some other thread is waiting for the join info */ diff --git a/nuttx/sched/pthread_condtimedwait.c b/nuttx/sched/pthread_condtimedwait.c index 9ebaf6917..43cd1501c 100644 --- a/nuttx/sched/pthread_condtimedwait.c +++ b/nuttx/sched/pthread_condtimedwait.c @@ -37,6 +37,7 @@ * Included Files ************************************************************/ +#include #include #include #include @@ -71,6 +72,25 @@ * Private Functions ************************************************************/ +/************************************************************ + * Function: pthread_condtimedout + * + * Description: + * This function is called if the timeout elapses before + * the condition is signaled. + * + * Parameters: + * argc - the number of arguments (should be 2) + * pid - the task ID of the task to wateup + * signo - The signal to use to wake up the task + * + * Return Value: + * None + * + * Assumptions: + * + ************************************************************/ + static void pthread_condtimedout(int argc, uint32 pid, uint32 signo, ...) { #ifdef CONFIG_CAN_PASS_STRUCTS @@ -85,6 +105,70 @@ static void pthread_condtimedout(int argc, uint32 pid, uint32 signo, ...) #endif } +/************************************************************ + * Function: pthread_timeoutticks + * + * Description: + * Convert a timespec delay to system timer ticks. + * + * Parameters: + * abstime - wait until this absolute time + * + * Return Value: + * The relative number of ticks to wait (or ERROR on + * failure; + * + * Assumptions: + * Interrupts should be disabled so that the time is + * not changing during the calculation + * + ************************************************************/ + +int pthread_timeouticks(const struct timespec *abstime, int *ticks) +{ + struct timespec currtime; + struct timespec reltime; + sint32 relusec; + int ret; + + /* Convert the timespec to clock ticks. NOTE: Here we use + * internal knowledge that CLOCK_REALTIME is defined to be zero! + */ + + ret = clock_gettime(0, &currtime); + if (ret) + { + return EINVAL; + } + + /* The relative time to wait is the absolute time minus the + * current time. + */ + + reltime.tv_nsec = (abstime->tv_nsec - currtime.tv_nsec); + reltime.tv_sec = (abstime->tv_sec - currtime.tv_sec); + + /* Check if we were supposed to borrow from the seconds to + * borrow from the seconds + */ + + if (reltime.tv_nsec < 0) + { + reltime.tv_nsec += NSEC_PER_SEC; + reltime.tv_sec -= 1; + } + + /* Convert this relative time into microseconds.*/ + + relusec = reltime.tv_sec * USEC_PER_SEC + + reltime.tv_nsec / NSEC_PER_USEC; + + /* Convert microseconds to clock ticks */ + + *ticks = relusec / USEC_PER_TICK; + return OK; +} + /************************************************************ * Public Functions ************************************************************/ @@ -96,10 +180,13 @@ static void pthread_condtimedout(int argc, uint32 pid, uint32 signo, ...) * A thread can perform a timed wait on a condition variable. * * Parameters: - * None + * cond - the condition variable to wait on + * mutex - the mutex that protects the condition variable + * abstime - wait until this absolute time * * Return Value: - * None + * OK (0) on success; ERROR (-1) on failure with errno + * set appropriately. * * Assumptions: * Timing is of resolution 1 msec, with +/-1 millisecond @@ -110,10 +197,7 @@ static void pthread_condtimedout(int argc, uint32 pid, uint32 signo, ...) int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) { - struct timespec currtime; - struct timespec reltime; WDOG_ID wdog; - sint32 relusec; sint32 ticks; int mypid = (int)getpid(); irqstate_t int_state; @@ -169,11 +253,9 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, /* Convert the timespec to clock ticks. We must disable pre-emption * here so that this time stays valid until the wait begins. - * NOTE: Here we use internal knowledge that CLOCK_REALTIME is - * defined to be zero! */ - ret = clock_gettime(0, &currtime); + ret = pthread_timeouticks(abstime, &ticks); if (ret) { /* Restore interrupts (pre-emption will be enabled when @@ -184,33 +266,6 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, } else { - /* The relative time to wait is the absolute time minus the - * the current time. - */ - - reltime.tv_nsec = (abstime->tv_nsec - currtime.tv_nsec); - reltime.tv_sec = (abstime->tv_sec - currtime.tv_sec); - - /* Check if we were supposed to borrow from the seconds - * to borrow from the seconds - */ - - if (reltime.tv_nsec < 0) - { - reltime.tv_nsec += NSEC_PER_SEC; - reltime.tv_sec -= 1; - } - - /* Convert this relative time into microseconds.*/ - - relusec = - reltime.tv_sec * USEC_PER_SEC + - reltime.tv_nsec / NSEC_PER_USEC; - - /* Convert microseconds to clock ticks */ - - ticks = relusec / USEC_PER_TICK; - /* Check the absolute time to wait. If it is now or in the past, then * just return with the timedout condition. */ diff --git a/nuttx/sched/pthread_create.c b/nuttx/sched/pthread_create.c index a369f0b49..ebf212516 100644 --- a/nuttx/sched/pthread_create.c +++ b/nuttx/sched/pthread_create.c @@ -63,7 +63,7 @@ /* Default pthread attributes */ -pthread_attr_t g_default_pthread_attr = +FAR pthread_attr_t g_default_pthread_attr = { PTHREAD_STACK_DEFAULT, /* stacksize */ PTHREAD_DEFAULT_PRIORITY, /* priority */ @@ -96,7 +96,7 @@ pthread_attr_t g_default_pthread_attr = * ************************************************************/ -static void pthread_addjoininfo(join_t *pjoin) +static void pthread_addjoininfo(FAR join_t *pjoin) { pjoin->next = NULL; if (!g_pthread_tail) @@ -124,8 +124,8 @@ static void pthread_addjoininfo(join_t *pjoin) static void pthread_start(void) { - _TCB *ptcb = (_TCB*)g_readytorun.head; - join_t *pjoin = (join_t*)ptcb->joininfo; + FAR _TCB *ptcb = (FAR _TCB*)g_readytorun.head; + FAR join_t *pjoin = (FAR join_t*)ptcb->joininfo; pthread_addr_t exit_status; /* Sucessfully spawned, add the pjoin to our data set. @@ -175,8 +175,8 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, pthread_startroutine_t startRoutine, pthread_addr_t arg) { - _TCB *ptcb; - join_t *pjoin; + FAR _TCB *ptcb; + FAR join_t *pjoin; STATUS status; int priority; #if CONFIG_RR_INTERVAL > 0 @@ -193,7 +193,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, /* Allocate a TCB for the new task. */ - ptcb = (_TCB*)kzmalloc(sizeof(_TCB)); + ptcb = (FAR _TCB*)kzmalloc(sizeof(_TCB)); if (!ptcb) { *get_errno_ptr() = ENOMEM; @@ -210,7 +210,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, /* Allocate a detachable structure to support pthread_join logic */ - pjoin = (join_t*)kzmalloc(sizeof(join_t)); + pjoin = (FAR join_t*)kzmalloc(sizeof(join_t)); if (!pjoin) { sched_releasetcb(ptcb); @@ -242,6 +242,10 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, { priority = param.sched_priority; } + else + { + priority = SCHED_FIFO; + } /* Get the scheduler policy for this thread */ @@ -266,7 +270,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, /* Initialize the task */ status = _task_init(ptcb, NULL, priority, pthread_start, (main_t)startRoutine, - TRUE, (char*)arg, NULL, NULL, NULL); + TRUE, (FAR char*)arg, NULL, NULL, NULL); if (status != OK) { @@ -331,7 +335,7 @@ int pthread_create(pthread_t *thread, pthread_attr_t *attr, else { sched_unlock(); - dq_rem((dq_entry_t*)ptcb, &g_inactivetasks); + dq_rem((FAR dq_entry_t*)ptcb, &g_inactivetasks); (void)sem_destroy(&pjoin->data_sem); (void)sem_destroy(&pjoin->exit_sem); sched_releasetcb(ptcb); diff --git a/nuttx/sched/pthread_detach.c b/nuttx/sched/pthread_detach.c index 4306b28e4..ca3f732f4 100644 --- a/nuttx/sched/pthread_detach.c +++ b/nuttx/sched/pthread_detach.c @@ -87,7 +87,7 @@ int pthread_detach(pthread_t thread) { - join_t *pjoin; + FAR join_t *pjoin; int ret; dbg("Thread=%d\n", thread); diff --git a/nuttx/sched/pthread_exit.c b/nuttx/sched/pthread_exit.c index e6ed040d4..cd0833ba6 100644 --- a/nuttx/sched/pthread_exit.c +++ b/nuttx/sched/pthread_exit.c @@ -86,7 +86,7 @@ * ************************************************************/ -void pthread_exit(void *exit_value) +void pthread_exit(FAR void *exit_value) { int error_code = (int)exit_value; int status; @@ -117,3 +117,4 @@ void pthread_exit(void *exit_value) _exit(error_code); } + diff --git a/nuttx/sched/pthread_findjoininfo.c b/nuttx/sched/pthread_findjoininfo.c index 1d33c50e0..893e06551 100644 --- a/nuttx/sched/pthread_findjoininfo.c +++ b/nuttx/sched/pthread_findjoininfo.c @@ -81,9 +81,9 @@ * ************************************************************/ -join_t *pthread_findjoininfo(pid_t pid) +FAR join_t *pthread_findjoininfo(pid_t pid) { - join_t *pjoin; + FAR join_t *pjoin; /* Find the entry with the matching pid */ diff --git a/nuttx/sched/pthread_getspecific.c b/nuttx/sched/pthread_getspecific.c index afcfba55c..c3eec886f 100644 --- a/nuttx/sched/pthread_getspecific.c +++ b/nuttx/sched/pthread_getspecific.c @@ -103,11 +103,11 @@ * ************************************************************/ -void *pthread_getspecific(pthread_key_t key) +FAR void *pthread_getspecific(pthread_key_t key) { #if CONFIG_NPTHREAD_KEYS > 0 - _TCB *rtcb = (_TCB*)g_readytorun.head; - void *ret = NULL; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + FAR void *ret = NULL; /* Check if the key is valid. */ @@ -123,3 +123,4 @@ void *pthread_getspecific(pthread_key_t key) return NULL; #endif } + diff --git a/nuttx/sched/pthread_initialize.c b/nuttx/sched/pthread_initialize.c index e1b24f432..599d63ebf 100644 --- a/nuttx/sched/pthread_initialize.c +++ b/nuttx/sched/pthread_initialize.c @@ -58,8 +58,8 @@ * is used to retain information about the spawned threads. */ -join_t *g_pthread_head = NULL; -join_t *g_pthread_tail = NULL; +FAR join_t *g_pthread_head = NULL; +FAR join_t *g_pthread_tail = NULL; /* Mutually exclusive access to this data set is enforced with * the following (un-named) semaphore. @@ -191,3 +191,4 @@ int pthread_givesemaphore(sem_t *sem) return ERROR; } } + diff --git a/nuttx/sched/pthread_internal.h b/nuttx/sched/pthread_internal.h index f23bafe5c..34a2f518d 100644 --- a/nuttx/sched/pthread_internal.h +++ b/nuttx/sched/pthread_internal.h @@ -63,7 +63,7 @@ struct join_s { - struct join_s *next; /* Implements link list */ + FAR struct join_s *next; /* Implements link list */ boolean started; /* TRUE: pthread started. */ boolean detached; /* TRUE: pthread_detached'ed */ boolean terminated; /* TRUE: detach'ed+exit'ed */ @@ -83,8 +83,8 @@ typedef struct join_s join_t; * is used to retain information about the spawned threads. */ -extern join_t *g_pthread_head; -extern join_t *g_pthread_tail; +extern FAR join_t *g_pthread_head; +extern FAR join_t *g_pthread_tail; /* Mutually exclusive access to this data set is enforced with * the following (un-named) semaphore. @@ -100,7 +100,7 @@ extern ubyte g_pthread_num_keys; /* Default pthread attributes */ -extern pthread_attr_t g_default_pthread_attr; +extern FAR pthread_attr_t g_default_pthread_attr; /************************************************************ * Public Function Prototypes @@ -114,10 +114,10 @@ extern "C" { #endif EXTERN void weak_function pthread_initialize(void); -EXTERN int pthread_completejoin(pid_t pid, void *exit_value); -EXTERN join_t *pthread_findjoininfo(pid_t pid); +EXTERN int pthread_completejoin(pid_t pid, FAR void *exit_value); +EXTERN FAR join_t *pthread_findjoininfo(pid_t pid); EXTERN int pthread_givesemaphore(sem_t *sem); -EXTERN join_t *pthread_removejoininfo(pid_t pid); +EXTERN FAR join_t *pthread_removejoininfo(pid_t pid); EXTERN int pthread_takesemaphore(sem_t *sem); #undef EXTERN diff --git a/nuttx/sched/pthread_join.c b/nuttx/sched/pthread_join.c index 28c8bf1c9..2754a35fe 100644 --- a/nuttx/sched/pthread_join.c +++ b/nuttx/sched/pthread_join.c @@ -95,7 +95,7 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) { - join_t *pjoin; + FAR join_t *pjoin; int ret; dbg("thread=%d\n", thread); @@ -129,7 +129,7 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) { /* Determine what kind of error to return */ - _TCB *tcb = sched_gettcb((pthread_t)thread); + FAR _TCB *tcb = sched_gettcb((pthread_t)thread); dbg("Could not find thread data\n"); @@ -211,3 +211,4 @@ int pthread_join(pthread_t thread, pthread_addr_t *pexit_value) dbg("Returning %d\n", ret); return ret; } + diff --git a/nuttx/sched/pthread_removejoininfo.c b/nuttx/sched/pthread_removejoininfo.c index 33fb24391..e989d9ab8 100644 --- a/nuttx/sched/pthread_removejoininfo.c +++ b/nuttx/sched/pthread_removejoininfo.c @@ -81,10 +81,10 @@ * ************************************************************/ -join_t *pthread_removejoininfo(pid_t pid) +FAR join_t *pthread_removejoininfo(pid_t pid) { - join_t *prev; - join_t *join; + FAR join_t *prev; + FAR join_t *join; /* Find the entry with the matching pid */ @@ -134,3 +134,4 @@ join_t *pthread_removejoininfo(pid_t pid) return join; } + diff --git a/nuttx/sched/pthread_setspecific.c b/nuttx/sched/pthread_setspecific.c index 5e9ba7fb6..4e8414dcf 100644 --- a/nuttx/sched/pthread_setspecific.c +++ b/nuttx/sched/pthread_setspecific.c @@ -111,10 +111,10 @@ * ************************************************************/ -int pthread_setspecific(pthread_key_t key, void *value) +int pthread_setspecific(pthread_key_t key, FAR void *value) { #if CONFIG_NPTHREAD_KEYS > 0 - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; int ret = EINVAL; /* Check if the key is valid. */ @@ -136,4 +136,3 @@ int pthread_setspecific(pthread_key_t key, void *value) #endif } - diff --git a/nuttx/sched/sched_addblocked.c b/nuttx/sched/sched_addblocked.c index 195937832..648d3f581 100644 --- a/nuttx/sched/sched_addblocked.c +++ b/nuttx/sched/sched_addblocked.c @@ -86,7 +86,7 @@ * ************************************************************/ -void sched_addblocked(_TCB *btcb, tstate_t task_state) +void sched_addblocked(FAR _TCB *btcb, tstate_t task_state) { /* Make sure that we received a valid blocked state */ @@ -108,10 +108,11 @@ void sched_addblocked(_TCB *btcb, tstate_t task_state) { /* Add the task to a non-prioritized list */ - dq_addlast((dq_entry_t*)btcb, g_tasklisttable[task_state].list); + dq_addlast((FAR dq_entry_t*)btcb, g_tasklisttable[task_state].list); } /* Make sure the TCB's state corresponds to the list */ btcb->task_state = task_state; } + diff --git a/nuttx/sched/sched_addprioritized.c b/nuttx/sched/sched_addprioritized.c index 54e792048..9b0c89e81 100644 --- a/nuttx/sched/sched_addprioritized.c +++ b/nuttx/sched/sched_addprioritized.c @@ -91,10 +91,10 @@ * match the state associated with the list. ************************************************************/ -boolean sched_addprioritized(_TCB *tcb, dq_queue_t *list) +boolean sched_addprioritized(FAR _TCB *tcb, NEAR dq_queue_t *list) { - _TCB *next; - _TCB *prev; + FAR _TCB *next; + FAR _TCB *prev; ubyte sched_priority = tcb->sched_priority; boolean ret = FALSE; @@ -106,7 +106,7 @@ boolean sched_addprioritized(_TCB *tcb, dq_queue_t *list) * Each is list is maintained in ascending sched_priority order. */ - for (next = (_TCB*)list->head; + for (next = (FAR _TCB*)list->head; (next && sched_priority <= next->sched_priority); next = next->flink); @@ -119,15 +119,15 @@ boolean sched_addprioritized(_TCB *tcb, dq_queue_t *list) { /* The tcb goes at the end of the list. */ - prev = (_TCB*)list->tail; + prev = (FAR _TCB*)list->tail; if (!prev) { /* Special case: The list is empty */ tcb->flink = NULL; tcb->blink = NULL; - list->head = (dq_entry_t*)tcb; - list->tail = (dq_entry_t*)tcb; + list->head = (FAR dq_entry_t*)tcb; + list->tail = (FAR dq_entry_t*)tcb; ret = TRUE; } else @@ -137,22 +137,22 @@ boolean sched_addprioritized(_TCB *tcb, dq_queue_t *list) tcb->flink = NULL; tcb->blink = prev; prev->flink = tcb; - list->tail = (dq_entry_t*)tcb; + list->tail = (FAR dq_entry_t*)tcb; } } else { /* The tcb goes just before next */ - prev = (_TCB*)next->blink; + prev = (FAR _TCB*)next->blink; if (!prev) { /* Special case: Insert at the head of the list */ - tcb->flink = next; - tcb->blink = NULL; + tcb->flink = next; + tcb->blink = NULL; next->blink = tcb; - list->head = (dq_entry_t*)tcb; + list->head = (FAR dq_entry_t*)tcb; ret = TRUE; } else @@ -168,3 +168,4 @@ boolean sched_addprioritized(_TCB *tcb, dq_queue_t *list) return ret; } + diff --git a/nuttx/sched/sched_addreadytorun.c b/nuttx/sched/sched_addreadytorun.c index c52da3670..3192fc7f9 100644 --- a/nuttx/sched/sched_addreadytorun.c +++ b/nuttx/sched/sched_addreadytorun.c @@ -94,9 +94,9 @@ * the head of the g_readytorun list is changed. ************************************************************/ -boolean sched_addreadytorun(_TCB *btcb) +boolean sched_addreadytorun(FAR _TCB *btcb) { - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; boolean ret; /* Check if pre-emption is disabled for the current running task and diff --git a/nuttx/sched/sched_free.c b/nuttx/sched/sched_free.c index dc1d34789..96292426e 100644 --- a/nuttx/sched/sched_free.c +++ b/nuttx/sched/sched_free.c @@ -80,7 +80,7 @@ * ************************************************************/ -void sched_free(void *address) +void sched_free(FAR void *address) { /* Check if this is an attempt to deallocate memory from * an exception handler. @@ -91,7 +91,7 @@ void sched_free(void *address) /* Yes.. Delay the deallocation until a more appropriate time. */ irqstate_t saved_state = irqsave(); - sq_addlast((sq_entry_t*)address, &g_delayeddeallocations); + sq_addlast((FAR sq_entry_t*)address, &g_delayeddeallocations); irqrestore(saved_state); } else @@ -101,3 +101,4 @@ void sched_free(void *address) kfree(address); } } + diff --git a/nuttx/sched/sched_getfiles.c b/nuttx/sched/sched_getfiles.c index d6986a5bc..7478e7cf0 100644 --- a/nuttx/sched/sched_getfiles.c +++ b/nuttx/sched/sched_getfiles.c @@ -68,9 +68,9 @@ * ************************************************************/ -struct filelist *sched_getfiles(void) +FAR struct filelist *sched_getfiles(void) { - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; return rtcb->filelist; } diff --git a/nuttx/sched/sched_getparam.c b/nuttx/sched/sched_getparam.c index 85d8c55c7..e78c07fc5 100644 --- a/nuttx/sched/sched_getparam.c +++ b/nuttx/sched/sched_getparam.c @@ -96,8 +96,8 @@ int sched_getparam (pid_t pid, struct sched_param * param) { - _TCB *rtcb; - _TCB *tcb; + FAR _TCB *rtcb; + FAR _TCB *tcb; int ret = OK; if (!param) @@ -107,7 +107,7 @@ int sched_getparam (pid_t pid, struct sched_param * param) /* Check if the task to restart is the calling task */ - rtcb = (_TCB*)g_readytorun.head; + rtcb = (FAR _TCB*)g_readytorun.head; if ((pid == 0) || (pid == rtcb->pid)) { /* Return the priority if the calling task. */ @@ -140,3 +140,4 @@ int sched_getparam (pid_t pid, struct sched_param * param) return ret; } + diff --git a/nuttx/sched/sched_getstreams.c b/nuttx/sched/sched_getstreams.c index fef913bc4..ba7f3a23d 100644 --- a/nuttx/sched/sched_getstreams.c +++ b/nuttx/sched/sched_getstreams.c @@ -68,9 +68,9 @@ * ************************************************************/ -struct streamlist *sched_getstreams(void) +FAR struct streamlist *sched_getstreams(void) { - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; return rtcb->streams; } diff --git a/nuttx/sched/sched_gettcb.c b/nuttx/sched/sched_gettcb.c index 7073b796a..7f65f9342 100644 --- a/nuttx/sched/sched_gettcb.c +++ b/nuttx/sched/sched_gettcb.c @@ -75,9 +75,9 @@ * ************************************************************/ -_TCB *sched_gettcb(pid_t pid) +FAR _TCB *sched_gettcb(pid_t pid) { - _TCB *ret = NULL; + FAR _TCB *ret = NULL; int hash_ndx; /* Verify that the PID is within range */ @@ -102,3 +102,4 @@ _TCB *sched_gettcb(pid_t pid) return ret; } + diff --git a/nuttx/sched/sched_mergepending.c b/nuttx/sched/sched_mergepending.c index db03bccc3..ab61db6ef 100644 --- a/nuttx/sched/sched_mergepending.c +++ b/nuttx/sched/sched_mergepending.c @@ -90,19 +90,19 @@ boolean sched_mergepending(void) { - _TCB *pndtcb; - _TCB *pndnext; - _TCB *rtrtcb; - _TCB *rtrprev; + FAR _TCB *pndtcb; + FAR _TCB *pndnext; + FAR _TCB *rtrtcb; + FAR _TCB *rtrprev; boolean ret = FALSE; /* Initialize the inner search loop */ - rtrtcb = (_TCB*)g_readytorun.head; + rtrtcb = (FAR _TCB*)g_readytorun.head; /* Process every TCB in the g_pendingtasks list */ - for (pndtcb = (_TCB*)g_pendingtasks.head; pndtcb; pndtcb = pndnext) + for (pndtcb = (FAR _TCB*)g_pendingtasks.head; pndtcb; pndtcb = pndnext) { pndnext = pndtcb->flink; @@ -137,7 +137,7 @@ boolean sched_mergepending(void) pndtcb->flink = rtrtcb; pndtcb->blink = NULL; rtrtcb->blink = pndtcb; - g_readytorun.head = (dq_entry_t*)pndtcb; + g_readytorun.head = (FAR dq_entry_t*)pndtcb; rtrtcb->task_state = TSTATE_TASK_READYTORUN; pndtcb->task_state = TSTATE_TASK_RUNNING; ret = TRUE; diff --git a/nuttx/sched/sched_processtimer.c b/nuttx/sched/sched_processtimer.c index bb56dbacb..eff439a5b 100644 --- a/nuttx/sched/sched_processtimer.c +++ b/nuttx/sched/sched_processtimer.c @@ -42,6 +42,7 @@ ************************************************************/ #include +#include #include #if CONFIG_RR_INTERVAL > 0 diff --git a/nuttx/sched/sched_releasetcb.c b/nuttx/sched/sched_releasetcb.c index ffbfc6c58..5e644839d 100644 --- a/nuttx/sched/sched_releasetcb.c +++ b/nuttx/sched/sched_releasetcb.c @@ -90,7 +90,7 @@ static void sched_releasepid(pid_t pid) * ************************************************************/ -int sched_releasetcb(_TCB *tcb) +int sched_releasetcb(FAR _TCB *tcb) { int ret = OK; int i; @@ -138,5 +138,3 @@ int sched_releasetcb(_TCB *tcb) return ret; } - - diff --git a/nuttx/sched/sched_removeblocked.c b/nuttx/sched/sched_removeblocked.c index f3ed363ae..2b9294003 100644 --- a/nuttx/sched/sched_removeblocked.c +++ b/nuttx/sched/sched_removeblocked.c @@ -90,7 +90,7 @@ * ************************************************************/ -void sched_removeblocked(_TCB *btcb) +void sched_removeblocked(FAR _TCB *btcb) { tstate_t task_state = btcb->task_state; @@ -103,7 +103,7 @@ void sched_removeblocked(_TCB *btcb) * with this state */ - dq_rem((dq_entry_t*)btcb, g_tasklisttable[task_state].list); + dq_rem((FAR dq_entry_t*)btcb, g_tasklisttable[task_state].list); /* Make sure the TCB's state corresponds to not being in * any list @@ -111,3 +111,4 @@ void sched_removeblocked(_TCB *btcb) btcb->task_state = TSTATE_TASK_INVALID; } + diff --git a/nuttx/sched/sched_removereadytorun.c b/nuttx/sched/sched_removereadytorun.c index 24057f3b7..1c17feba0 100644 --- a/nuttx/sched/sched_removereadytorun.c +++ b/nuttx/sched/sched_removereadytorun.c @@ -87,7 +87,7 @@ * the head of the g_readytorun list is changed. ************************************************************/ -boolean sched_removereadytorun(_TCB *rtcb) +boolean sched_removereadytorun(FAR _TCB *rtcb) { boolean ret = FALSE; @@ -110,7 +110,7 @@ boolean sched_removereadytorun(_TCB *rtcb) /* Remove the TCB from the ready-to-run list */ - dq_rem((dq_entry_t*)rtcb, &g_readytorun); + dq_rem((FAR dq_entry_t*)rtcb, &g_readytorun); rtcb->task_state = TSTATE_TASK_INVALID; return ret; diff --git a/nuttx/sched/sched_rrgetinterval.c b/nuttx/sched/sched_rrgetinterval.c index 8dfe99ff3..dff4ebb4c 100644 --- a/nuttx/sched/sched_rrgetinterval.c +++ b/nuttx/sched/sched_rrgetinterval.c @@ -106,7 +106,7 @@ int sched_rr_get_interval(pid_t pid, struct timespec *interval) { #if CONFIG_RR_INTERVAL > 0 - _TCB *rrtcb; + FAR _TCB *rrtcb; /* If pid is zero, the timeslice for the calling process is * written into 'interval.' @@ -114,7 +114,7 @@ int sched_rr_get_interval(pid_t pid, struct timespec *interval) if (!pid) { - rrtcb = (_TCB*)g_readytorun.head; + rrtcb = (FAR _TCB*)g_readytorun.head; } /* Return a special error code on invalid PID */ diff --git a/nuttx/sched/sched_setparam.c b/nuttx/sched/sched_setparam.c index a1e5af97f..c9a935a4d 100644 --- a/nuttx/sched/sched_setparam.c +++ b/nuttx/sched/sched_setparam.c @@ -105,8 +105,8 @@ int sched_setparam(pid_t pid, const struct sched_param *param) { - _TCB *rtcb; - _TCB *tcb; + FAR _TCB *rtcb; + FAR _TCB *tcb; tstate_t task_state; irqstate_t saved_state; int sched_priority = param->sched_priority; @@ -129,7 +129,7 @@ int sched_setparam(pid_t pid, const struct sched_param *param) /* Check if the task to reprioritize is the calling task */ - rtcb = (_TCB*)g_readytorun.head; + rtcb = (FAR _TCB*)g_readytorun.head; if (pid == 0 || pid == rtcb->pid) { tcb = rtcb; @@ -236,7 +236,7 @@ int sched_setparam(pid_t pid, const struct sched_param *param) { /* Remove the TCB from the prioritized task list */ - dq_rem((dq_entry_t*)tcb, g_tasklisttable[task_state].list); + dq_rem((FAR dq_entry_t*)tcb, g_tasklisttable[task_state].list); /* Change the task priority */ diff --git a/nuttx/sched/sched_setscheduler.c b/nuttx/sched/sched_setscheduler.c index 7d1b11ba4..4d4978a62 100644 --- a/nuttx/sched/sched_setscheduler.c +++ b/nuttx/sched/sched_setscheduler.c @@ -110,7 +110,7 @@ int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param) { - _TCB *tcb; + FAR _TCB *tcb; #if CONFIG_RR_INTERVAL > 0 irqstate_t saved_state; #endif @@ -186,3 +186,4 @@ int sched_setscheduler(pid_t pid, int policy, return SCHED_FIFO; } } + diff --git a/nuttx/sched/sched_setupidlefiles.c b/nuttx/sched/sched_setupidlefiles.c index c8be5478c..29d5dd3e0 100644 --- a/nuttx/sched/sched_setupidlefiles.c +++ b/nuttx/sched/sched_setupidlefiles.c @@ -71,7 +71,7 @@ * ************************************************************/ -int sched_setupidlefiles(_TCB *tcb) +int sched_setupidlefiles(FAR _TCB *tcb) { int fd; diff --git a/nuttx/sched/sched_setuppthreadfiles.c b/nuttx/sched/sched_setuppthreadfiles.c index 0935b487d..5cc20c6d1 100644 --- a/nuttx/sched/sched_setuppthreadfiles.c +++ b/nuttx/sched/sched_setuppthreadfiles.c @@ -71,9 +71,9 @@ * ************************************************************/ -int sched_setuppthreadfiles(_TCB *tcb) +int sched_setuppthreadfiles(FAR _TCB *tcb) { - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; /* The child thread inherits the parent file descriptors */ diff --git a/nuttx/sched/sched_setupstreams.c b/nuttx/sched/sched_setupstreams.c index 325ba92e9..97509fc68 100644 --- a/nuttx/sched/sched_setupstreams.c +++ b/nuttx/sched/sched_setupstreams.c @@ -53,7 +53,7 @@ * Public Functions ************************************************************/ -int sched_setupstreams(_TCB *tcb) +int sched_setupstreams(FAR _TCB *tcb) { /* Allocate file strems for the TCB */ diff --git a/nuttx/sched/sched_setuptaskfiles.c b/nuttx/sched/sched_setuptaskfiles.c index 269e98e51..175398031 100644 --- a/nuttx/sched/sched_setuptaskfiles.c +++ b/nuttx/sched/sched_setuptaskfiles.c @@ -71,10 +71,10 @@ * ************************************************************/ -int sched_setuptaskfiles(_TCB *tcb) +int sched_setuptaskfiles(FAR _TCB *tcb) { #ifdef CONFIG_DEV_CONSOLE - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; int i; #endif /* CONFIG_DEV_CONSOLE */ diff --git a/nuttx/sched/sched_yield.c b/nuttx/sched/sched_yield.c index e91f8ecf6..ae4db7178 100644 --- a/nuttx/sched/sched_yield.c +++ b/nuttx/sched/sched_yield.c @@ -90,7 +90,7 @@ int sched_yield (void) { - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; struct sched_param param; /* This equivalent to just resetting the task priority to diff --git a/nuttx/sched/sem_close.c b/nuttx/sched/sem_close.c index 3113b5156..9c278fb58 100644 --- a/nuttx/sched/sem_close.c +++ b/nuttx/sched/sem_close.c @@ -101,9 +101,9 @@ * ************************************************************/ -int sem_close (sem_t *sem) +int sem_close(FAR sem_t *sem) { - nsem_t *psem; + FAR nsem_t *psem; int ret = ERROR; /* Verify the inputs */ @@ -114,7 +114,7 @@ int sem_close (sem_t *sem) /* Search the list of named semaphores */ - for (psem = (nsem_t*)g_nsems.head; + for (psem = (FAR nsem_t*)g_nsems.head; ((psem) && (sem != &psem->sem)); psem = psem->flink); @@ -132,7 +132,7 @@ int sem_close (sem_t *sem) if (!psem->nconnect && psem->unlinked) { - dq_rem((dq_entry_t*)psem, &g_nsems); + dq_rem((FAR dq_entry_t*)psem, &g_nsems); sched_free(psem); } ret = OK; @@ -142,3 +142,4 @@ int sem_close (sem_t *sem) return ret; } + diff --git a/nuttx/sched/sem_findnamed.c b/nuttx/sched/sem_findnamed.c index d513f7a31..f626da42d 100644 --- a/nuttx/sched/sem_findnamed.c +++ b/nuttx/sched/sem_findnamed.c @@ -84,13 +84,13 @@ * ************************************************************/ -nsem_t *sem_findnamed(const char *name) +FAR nsem_t *sem_findnamed(const char *name) { - nsem_t *psem; + FAR nsem_t *psem; /* Search the list of named semaphores */ - for (psem = (nsem_t*)g_nsems.head; (psem); psem = psem->flink) + for (psem = (FAR nsem_t*)g_nsems.head; (psem); psem = psem->flink) { if (!strcmp(name, psem->name)) { diff --git a/nuttx/sched/sem_internal.h b/nuttx/sched/sem_internal.h index 460b358fc..9908d6e4c 100644 --- a/nuttx/sched/sem_internal.h +++ b/nuttx/sched/sem_internal.h @@ -58,12 +58,12 @@ struct nsem_s { - struct nsem_s *flink; /* Forward link */ - struct nsem_s *blink; /* Backward link */ - uint16 nconnect; /* Number of connections to semaphore */ - char *name; /* Semaphore name (NULL if un-named) */ - boolean unlinked; /* TRUE if the semaphore has been unlinked */ - sem_t sem; /* The semaphore itself */ + FAR struct nsem_s *flink; /* Forward link */ + FAR struct nsem_s *blink; /* Backward link */ + uint16 nconnect; /* Number of connections to semaphore */ + FAR char *name; /* Semaphore name (NULL if un-named) */ + boolean unlinked; /* TRUE if the semaphore has been unlinked */ + sem_t sem; /* The semaphore itself */ }; typedef struct nsem_s nsem_t; @@ -87,8 +87,8 @@ extern "C" { #endif EXTERN void weak_function sem_initialize(void); -EXTERN void sem_waitirq(_TCB *wtcb); -EXTERN nsem_t *sem_findnamed(const char *name); +EXTERN void sem_waitirq(FAR _TCB *wtcb); +EXTERN FAR nsem_t *sem_findnamed(const char *name); #undef EXTERN #ifdef __cplusplus diff --git a/nuttx/sched/sem_open.c b/nuttx/sched/sem_open.c index 6a8c38a4c..e9f6335c6 100644 --- a/nuttx/sched/sem_open.c +++ b/nuttx/sched/sem_open.c @@ -114,15 +114,11 @@ * ************************************************************/ -sem_t *sem_open (const char *name, int oflag, ...) +FAR sem_t *sem_open (const char *name, int oflag, ...) { int namelen; - nsem_t *psem; -#ifdef CONFIG_CAN_CAST_POINTERS - sem_t *sem = (sem_t*)ERROR; -#else - sem_t *sem = get_errorptr(); -#endif + FAR nsem_t *psem; + FAR sem_t *sem = (FAR sem_t*)ERROR; va_list arg; /* Points to each un-named argument */ mode_t mode; /* Creation mode parameter (ignored) */ unsigned int value; /* Semaphore value parameter */ @@ -178,7 +174,7 @@ sem_t *sem_open (const char *name, int oflag, ...) { /* Allocate memory for the new semaphore */ - psem = (nsem_t*)kmalloc((sizeof(nsem_t) + namelen + 1)); + psem = (FAR nsem_t*)kmalloc((sizeof(nsem_t) + namelen + 1)); if (psem) { /* Initialize the named semaphore */ @@ -188,14 +184,14 @@ sem_t *sem_open (const char *name, int oflag, ...) psem->nconnect = 1; psem->unlinked = FALSE; - psem->name = (char*)psem + sizeof(nsem_t); + psem->name = (FAR char*)psem + sizeof(nsem_t); strcpy(psem->name, name); /* Add the new semaphore to the list of named * semaphores */ - dq_addfirst((dq_entry_t*)psem, &g_nsems); + dq_addfirst((FAR dq_entry_t*)psem, &g_nsems); } /* Clean-up variable argument stuff */ @@ -209,3 +205,4 @@ sem_t *sem_open (const char *name, int oflag, ...) return sem; } + diff --git a/nuttx/sched/sem_post.c b/nuttx/sched/sem_post.c index 348e88c80..3b4fac368 100644 --- a/nuttx/sched/sem_post.c +++ b/nuttx/sched/sem_post.c @@ -104,9 +104,9 @@ * ************************************************************/ -int sem_post (sem_t *sem) +int sem_post(sem_t *sem) { - _TCB *stcb; + FAR _TCB *stcb; STATUS ret = ERROR; irqstate_t saved_state; @@ -138,7 +138,7 @@ int sem_post (sem_t *sem) * that we want. */ - for (stcb = (_TCB*)g_waitingforsemaphore.head; + for (stcb = (FAR _TCB*)g_waitingforsemaphore.head; ((stcb) && (stcb->waitsem != sem)); stcb = stcb->flink); diff --git a/nuttx/sched/sem_unlink.c b/nuttx/sched/sem_unlink.c index 467db622e..cc249ff8d 100644 --- a/nuttx/sched/sem_unlink.c +++ b/nuttx/sched/sem_unlink.c @@ -95,10 +95,10 @@ * ************************************************************/ -int sem_unlink (const char *name) +int sem_unlink(const char *name) { - nsem_t *psem; - int ret = ERROR; + FAR nsem_t *psem; + int ret = ERROR; /* Verify the input values */ @@ -119,7 +119,7 @@ int sem_unlink (const char *name) */ if (!psem->nconnect) { - dq_rem((dq_entry_t*)psem, &g_nsems); + dq_rem((FAR dq_entry_t*)psem, &g_nsems); sched_free(psem); } @@ -139,3 +139,4 @@ int sem_unlink (const char *name) return ret; } + diff --git a/nuttx/sched/sem_wait.c b/nuttx/sched/sem_wait.c index 78aa7d5e9..7893b39ba 100644 --- a/nuttx/sched/sem_wait.c +++ b/nuttx/sched/sem_wait.c @@ -97,9 +97,9 @@ * ************************************************************/ -int sem_wait (sem_t *sem) +int sem_wait(sem_t *sem) { - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; int ret = ERROR; irqstate_t saved_state; @@ -172,3 +172,4 @@ int sem_wait (sem_t *sem) return ret; } + diff --git a/nuttx/sched/sem_waitirq.c b/nuttx/sched/sem_waitirq.c index 810663732..b7cbdce21 100644 --- a/nuttx/sched/sem_waitirq.c +++ b/nuttx/sched/sem_waitirq.c @@ -92,7 +92,7 @@ * ************************************************************/ -void sem_waitirq (_TCB *wtcb) +void sem_waitirq(FAR _TCB *wtcb) { irqstate_t saved_state; @@ -126,3 +126,4 @@ void sem_waitirq (_TCB *wtcb) irqrestore(saved_state); } + diff --git a/nuttx/sched/sig_action.c b/nuttx/sched/sig_action.c index 7f9a1c343..f7fe7cdb5 100644 --- a/nuttx/sched/sig_action.c +++ b/nuttx/sched/sig_action.c @@ -77,13 +77,13 @@ * ************************************************************/ -static sigactq_t *sig_allocateaction(void) +static FAR sigactq_t *sig_allocateaction(void) { - sigactq_t *sigact; + FAR sigactq_t *sigact; /* Try to get the signal action structure from the free list */ - sigact = (sigactq_t*)sq_remfirst(&g_sigfreeaction); + sigact = (FAR sigactq_t*)sq_remfirst(&g_sigfreeaction); /* Check if we got one. */ @@ -95,7 +95,7 @@ static sigactq_t *sig_allocateaction(void) /* And try again */ - sigact = (sigactq_t*)sq_remfirst(&g_sigfreeaction); + sigact = (FAR sigactq_t*)sq_remfirst(&g_sigfreeaction); if (!sigact) { PANIC(OSERR_OUTOFMEMORY); @@ -171,9 +171,9 @@ static sigactq_t *sig_allocateaction(void) int sigaction(int signo, const struct sigaction *act, struct sigaction *oact) { - _TCB *rtcb = (_TCB*)g_readytorun.head; - sigactq_t *sigact; - int ret = ERROR; /* Assume failure */ + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + FAR sigactq_t *sigact; + int ret = ERROR; /* Assume failure */ /* Since sigactions can only be installed from the running * thread of execution, no special precautions should be @@ -229,7 +229,7 @@ int sigaction(int signo, const struct sigaction *act, /* Add the new sigaction to sigactionq */ - sq_addlast((sq_entry_t*)sigact, &rtcb->sigactionq); + sq_addlast((FAR sq_entry_t*)sigact, &rtcb->sigactionq); } } @@ -250,7 +250,7 @@ int sigaction(int signo, const struct sigaction *act, { /* Remove the old sigaction from sigactionq */ - sq_rem((sq_entry_t*)sigact, &rtcb->sigactionq); + sq_rem((FAR sq_entry_t*)sigact, &rtcb->sigactionq); /* And deallocate it */ @@ -270,9 +270,9 @@ int sigaction(int signo, const struct sigaction *act, * ************************************************************/ -void sig_releaseaction(sigactq_t *sigact) +void sig_releaseaction(FAR sigactq_t *sigact) { /* Just put it back on the free list */ - sq_addlast((sq_entry_t*)sigact, &g_sigfreeaction); + sq_addlast((FAR sq_entry_t*)sigact, &g_sigfreeaction); } diff --git a/nuttx/sched/sig_allocatependingsigaction.c b/nuttx/sched/sig_allocatependingsigaction.c index 610596457..5356058cf 100644 --- a/nuttx/sched/sig_allocatependingsigaction.c +++ b/nuttx/sched/sig_allocatependingsigaction.c @@ -75,9 +75,9 @@ * Allocate a new element for the pending signal action queue ************************************************************/ -sigq_t *sig_allocatependingsigaction(void) +FAR sigq_t *sig_allocatependingsigaction(void) { - sigq_t *sigq; + FAR sigq_t *sigq; irqstate_t saved_state; /* Check if we were called from an interrupt handler. */ @@ -86,7 +86,7 @@ sigq_t *sig_allocatependingsigaction(void) { /* Try to get the pending signal action structure from the free list */ - sigq = (sigq_t*)sq_remfirst(&g_sigpendingaction); + sigq = (FAR sigq_t*)sq_remfirst(&g_sigpendingaction); /* If so, then try the special list of structures reserved for * interrupt handlers @@ -94,7 +94,7 @@ sigq_t *sig_allocatependingsigaction(void) if (!sigq) { - sigq = (sigq_t*)sq_remfirst(&g_sigpendingirqaction); + sigq = (FAR sigq_t*)sq_remfirst(&g_sigpendingirqaction); } } @@ -106,7 +106,7 @@ sigq_t *sig_allocatependingsigaction(void) /* Try to get the pending signal action structure from the free list */ saved_state = irqsave(); - sigq = (sigq_t*)sq_remfirst(&g_sigpendingaction); + sigq = (FAR sigq_t*)sq_remfirst(&g_sigpendingaction); irqrestore(saved_state); /* Check if we got one. */ @@ -117,7 +117,7 @@ sigq_t *sig_allocatependingsigaction(void) if (!sigq) { - sigq = (sigq_t *)kmalloc((sizeof (sigq_t))); + sigq = (FAR sigq_t *)kmalloc((sizeof (sigq_t))); } /* Check if we got an allocated message */ diff --git a/nuttx/sched/sig_cleanup.c b/nuttx/sched/sig_cleanup.c index d9e1073df..019e7fbe5 100644 --- a/nuttx/sched/sig_cleanup.c +++ b/nuttx/sched/sig_cleanup.c @@ -76,36 +76,36 @@ * to perform this action. ************************************************************/ -void sig_cleanup(_TCB *stcb) +void sig_cleanup(FAR _TCB *stcb) { - sigactq_t *sigact; - sigq_t *sigq; - sigpendq_t *sigpend; + FAR sigactq_t *sigact; + FAR sigq_t *sigq; + FAR sigpendq_t *sigpend; /* Deallocate all entries in the list of signal actions */ - while ((sigact = (sigactq_t*)sq_remfirst(&stcb->sigactionq)) != NULL) + while ((sigact = (FAR sigactq_t*)sq_remfirst(&stcb->sigactionq)) != NULL) { sig_releaseaction(sigact); } /* Deallocate all entries in the list of pending signals */ - while ((sigpend = (sigpendq_t*)sq_remfirst(&stcb->sigpendingq)) != NULL) + while ((sigpend = (FAR sigpendq_t*)sq_remfirst(&stcb->sigpendingq)) != NULL) { sig_releasependingsignal(sigpend); } /* Deallocate all entries in the list of pending signal actions */ - while ((sigq = (sigq_t*)sq_remfirst(&stcb->sigpendactionq)) != NULL) + while ((sigq = (FAR sigq_t*)sq_remfirst(&stcb->sigpendactionq)) != NULL) { sig_releasependingsigaction(sigq); } /* Deallocate all entries in the list of posted signal actions */ - while ((sigq = (sigq_t*)sq_remfirst(&stcb->sigpostedq)) != NULL) + while ((sigq = (FAR sigq_t*)sq_remfirst(&stcb->sigpostedq)) != NULL) { sig_releasependingsigaction(sigq); } diff --git a/nuttx/sched/sig_deliver.c b/nuttx/sched/sig_deliver.c index c10633797..5eb24d307 100644 --- a/nuttx/sched/sig_deliver.c +++ b/nuttx/sched/sig_deliver.c @@ -81,14 +81,14 @@ * ************************************************************/ -void sig_deliver(_TCB *stcb) +void sig_deliver(FAR _TCB *stcb) { - pid_t rpid; - sigq_t *sigq; - sigq_t *next; - sigset_t savesigprocmask; - irqstate_t saved_state; - int saved_errno; + pid_t rpid; + FAR sigq_t *sigq; + FAR sigq_t *next; + sigset_t savesigprocmask; + irqstate_t saved_state; + int saved_errno; sched_lock(); @@ -100,7 +100,7 @@ void sig_deliver(_TCB *stcb) */ saved_errno = stcb->errno; - for (sigq = (sigq_t*)stcb->sigpendactionq.head; (sigq); sigq = next) + for (sigq = (FAR sigq_t*)stcb->sigpendactionq.head; (sigq); sigq = next) { next = sigq->flink; dbg("sig_deliver: Sending signal sigq=0x%x\n", sigq); @@ -111,8 +111,8 @@ void sig_deliver(_TCB *stcb) */ saved_state = irqsave(); - sq_rem((sq_entry_t*)sigq, &(stcb->sigpendactionq)); - sq_addlast((sq_entry_t*)sigq, &(stcb->sigpostedq)); + sq_rem((FAR sq_entry_t*)sigq, &(stcb->sigpendactionq)); + sq_addlast((FAR sq_entry_t*)sigq, &(stcb->sigpostedq)); irqrestore(saved_state); /* Call the signal handler (unless the signal was cancelled) @@ -150,7 +150,7 @@ void sig_deliver(_TCB *stcb) /* Remove the signal from the sigpostedq */ saved_state = irqsave(); - sq_rem((sq_entry_t*)sigq, &(stcb->sigpostedq)); + sq_rem((FAR sq_entry_t*)sigq, &(stcb->sigpostedq)); irqrestore(saved_state); /* Then deallocate it */ diff --git a/nuttx/sched/sig_findaction.c b/nuttx/sched/sig_findaction.c index 98df313ec..be5675d62 100644 --- a/nuttx/sched/sig_findaction.c +++ b/nuttx/sched/sig_findaction.c @@ -72,28 +72,28 @@ * ************************************************************/ -sigactq_t *sig_findaction(_TCB *stcb, int signo) +FAR sigactq_t *sig_findaction(FAR _TCB *stcb, int signo) { - sigactq_t *sigact = NULL; + FAR sigactq_t *sigact = NULL; - /* Verify the caller's sanity */ + /* Verify the caller's sanity */ - if (stcb) - { - /* Sigactions can only be assigned to the currently executing - * thread. So, a simple lock ought to give us sufficient - * protection. - */ + if (stcb) + { + /* Sigactions can only be assigned to the currently executing + * thread. So, a simple lock ought to give us sufficient + * protection. + */ - sched_lock(); + sched_lock(); - /* Seach the list for a sigaction on this signal */ + /* Seach the list for a sigaction on this signal */ - for(sigact = (sigactq_t*)stcb->sigactionq.head; - ((sigact) && (sigact->signo != signo)); - sigact = sigact->flink); + for(sigact = (FAR sigactq_t*)stcb->sigactionq.head; + ((sigact) && (sigact->signo != signo)); + sigact = sigact->flink); - sched_unlock(); + sched_unlock(); } return sigact; diff --git a/nuttx/sched/sig_initialize.c b/nuttx/sched/sig_initialize.c index 1c1e8c23c..d3bd10860 100644 --- a/nuttx/sched/sig_initialize.c +++ b/nuttx/sched/sig_initialize.c @@ -124,10 +124,10 @@ static sigpendq_t *g_sigpendingirqsignalalloc; * Private Function Prototypes ************************************************************/ -static sigq_t *sig_allocateblock(sq_queue_t *sigList, uint16 nSigs, - ubyte sigType); -static sigpendq_t *sig_allocatependingsignalblock(sq_queue_t *sigList, - uint16 nSigs, ubyte sigType); +static sigq_t *sig_allocateblock(sq_queue_t *siglist, uint16 nsigs, + ubyte sigtype); +static sigpendq_t *sig_allocatependingsignalblock(sq_queue_t *siglist, + uint16 nsigs, ubyte sigtype); /************************************************************ * Private Functions @@ -142,8 +142,8 @@ static sigpendq_t *sig_allocatependingsignalblock(sq_queue_t *sigList, * ************************************************************/ -static sigq_t *sig_allocateblock(sq_queue_t *sigList, uint16 nSigs, - ubyte sigType) +static sigq_t *sig_allocateblock(sq_queue_t *siglist, uint16 nsigs, + ubyte sigtype) { sigq_t *sigqalloc; sigq_t *sigq; @@ -151,13 +151,13 @@ static sigq_t *sig_allocateblock(sq_queue_t *sigList, uint16 nSigs, /* Allocate a block of pending signal actions */ - sigqalloc = (sigq_t*)kmalloc((sizeof(sigq_t)) * nSigs); + sigqalloc = (sigq_t*)kmalloc((sizeof(sigq_t)) * nsigs); sigq = sigqalloc; - for (i = 0; i < nSigs; i++) + for (i = 0; i < nsigs; i++) { - sigq->type = sigType; - sq_addlast((sq_entry_t*)sigq++, sigList); + sigq->type = sigtype; + sq_addlast((FAR sq_entry_t*)sigq++, siglist); } return sigqalloc; @@ -171,8 +171,8 @@ static sigq_t *sig_allocateblock(sq_queue_t *sigList, uint16 nSigs, * on the free list. ************************************************************/ -static sigpendq_t *sig_allocatependingsignalblock(sq_queue_t *sigList, - uint16 nSigs, ubyte sigType) +static sigpendq_t *sig_allocatependingsignalblock(sq_queue_t *siglist, + uint16 nsigs, ubyte sigtype) { sigpendq_t *sigpendalloc; sigpendq_t *sigpend; @@ -181,13 +181,13 @@ static sigpendq_t *sig_allocatependingsignalblock(sq_queue_t *sigList, /* Allocate a block of pending signal structures */ sigpendalloc = - (sigpendq_t*)kmalloc((sizeof(sigpendq_t)) * nSigs); + (sigpendq_t*)kmalloc((sizeof(sigpendq_t)) * nsigs); sigpend = sigpendalloc; - for (i = 0; i < nSigs; i++) + for (i = 0; i < nsigs; i++) { - sigpend->type = sigType; - sq_addlast((sq_entry_t*)sigpend++, sigList); + sigpend->type = sigtype; + sq_addlast((FAR sq_entry_t*)sigpend++, siglist); } return sigpendalloc; @@ -255,7 +255,7 @@ void sig_allocateactionblock(void) sigact = g_sigactionalloc; for (i = 0; i < NUM_SIGNAL_ACTIONS; i++) { - sq_addlast((sq_entry_t*)sigact++, &g_sigfreeaction); + sq_addlast((FAR sq_entry_t*)sigact++, &g_sigfreeaction); } } diff --git a/nuttx/sched/sig_internal.h b/nuttx/sched/sig_internal.h index b03b2ec0e..8ae975e42 100644 --- a/nuttx/sched/sig_internal.h +++ b/nuttx/sched/sig_internal.h @@ -40,6 +40,7 @@ * Included Files ************************************************************/ +#include #include #include #include @@ -75,9 +76,9 @@ typedef enum sigalloc_e sigalloc_t; struct sigactq { - struct sigactq *flink; /* Forward link */ - struct sigaction act; /* Sigaction data */ - ubyte signo; /* Signal associated with action */ + FAR struct sigactq *flink; /* Forward link */ + struct sigaction act; /* Sigaction data */ + ubyte signo; /* Signal associated with action */ }; typedef struct sigactq sigactq_t; @@ -89,9 +90,9 @@ typedef struct sigactq sigactq_t; struct sigpendq { - struct sigpendq *flink; /* Forward link */ - siginfo_t info; /* Signal information */ - ubyte type; /* (Used to manage allocations) */ + FAR struct sigpendq *flink; /* Forward link */ + siginfo_t info; /* Signal information */ + ubyte type; /* (Used to manage allocations) */ }; typedef struct sigpendq sigpendq_t; @@ -101,15 +102,15 @@ typedef struct sigpendq sigpendq_t; struct sigq_s { - struct sigq_s *flink; /* Forward link */ + FAR struct sigq_s *flink; /* Forward link */ union { void (*sighandler)(int signo, siginfo_t *info, void *context); } action; /* Signal action */ - sigset_t mask; /* Additional signals to mask while the + sigset_t mask; /* Additional signals to mask while the * the signal-catching functin executes */ - siginfo_t info; /* Signal information */ - ubyte type; /* (Used to manage allocations) */ + siginfo_t info; /* Signal information */ + ubyte type; /* (Used to manage allocations) */ }; typedef struct sigq_s sigq_t; @@ -162,18 +163,18 @@ extern void sig_allocateactionblock(void); /* sig_action.c */ -extern void sig_releaseaction(sigactq_t *sigact); +extern void sig_releaseaction(FAR sigactq_t *sigact); /* sig_pending.c */ -extern sigset_t sig_pendingset(_TCB *stcb); +extern sigset_t sig_pendingset(FAR _TCB *stcb); /* In files of the same name */ -extern sigq_t *sig_allocatependingsigaction(void); -extern void sig_cleanup(_TCB *stcb); -extern void sig_deliver(_TCB *stcb); -extern sigactq_t *sig_findaction(_TCB *stcb, int signo); +extern FAR sigq_t *sig_allocatependingsigaction(void); +extern void sig_cleanup(FAR _TCB *stcb); +extern void sig_deliver(FAR _TCB *stcb); +extern FAR sigactq_t *sig_findaction(FAR _TCB *stcb, int signo); extern int sig_lowest(sigset_t *set); #ifdef CONFIG_CAN_PASS_STRUCTS extern int sig_mqnotempty(int tid, int signo, @@ -182,10 +183,10 @@ extern int sig_mqnotempty(int tid, int signo, extern int sig_mqnotempty(int tid, int signo, void *sival_ptr); #endif -extern int sig_received(_TCB *stcb, siginfo_t *info); -extern void sig_releasependingsigaction(sigq_t *sigq); -extern void sig_releasependingsignal(sigpendq_t *sigpend); -extern sigpendq_t *sig_removependingsignal(_TCB *stcb, int signo); +extern int sig_received(FAR _TCB *stcb, siginfo_t *info); +extern void sig_releasependingsigaction(FAR sigq_t *sigq); +extern void sig_releasependingsignal(FAR sigpendq_t *sigpend); +extern FAR sigpendq_t *sig_removependingsignal(FAR _TCB *stcb, int signo); extern void sig_unmaskpendingsignal(void); #endif /* __SIG_INTERNAL_H */ diff --git a/nuttx/sched/sig_mqnotempty.c b/nuttx/sched/sig_mqnotempty.c index ab395db2e..a55d3138e 100644 --- a/nuttx/sched/sig_mqnotempty.c +++ b/nuttx/sched/sig_mqnotempty.c @@ -37,6 +37,7 @@ * Included Files ************************************************************/ +#include #include #include #include @@ -86,7 +87,7 @@ int sig_mqnotempty (int pid, int signo, const union sigval value) int sig_mqnotempty (int pid, int signo, void *sival_ptr) #endif { - _TCB *stcb; + FAR _TCB *stcb; siginfo_t info; int ret = ERROR; diff --git a/nuttx/sched/sig_pending.c b/nuttx/sched/sig_pending.c index 62b98f3ca..a2ee01d4e 100644 --- a/nuttx/sched/sig_pending.c +++ b/nuttx/sched/sig_pending.c @@ -87,8 +87,8 @@ int sigpending(sigset_t *set) { - _TCB *rtcb = (_TCB*)g_readytorun.head; - int ret = ERROR; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + int ret = ERROR; if (set) { @@ -106,16 +106,16 @@ int sigpending(sigset_t *set) * Convert the list of pending signals into a signal set ************************************************************/ -sigset_t sig_pendingset(_TCB *stcb) +sigset_t sig_pendingset(FAR _TCB *stcb) { - sigset_t sigpendset; - sigpendq_t *sigpend; - irqstate_t saved_state; + sigset_t sigpendset; + FAR sigpendq_t *sigpend; + irqstate_t saved_state; sigpendset = NULL_SIGNAL_SET; saved_state = irqsave(); - for (sigpend = (sigpendq_t*)stcb->sigpendingq.head; + for (sigpend = (FAR sigpendq_t*)stcb->sigpendingq.head; (sigpend); sigpend = sigpend->flink) { sigaddset(&sigpendset, sigpend->info.si_signo); diff --git a/nuttx/sched/sig_procmask.c b/nuttx/sched/sig_procmask.c index dd5dd9eb8..339e6dda5 100644 --- a/nuttx/sched/sig_procmask.c +++ b/nuttx/sched/sig_procmask.c @@ -114,7 +114,7 @@ int sigprocmask(int how, const sigset_t *set, sigset_t *oset) { - _TCB *rtcb = (_TCB*)g_readytorun.head; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; sigset_t oldsigprocmask; irqstate_t saved_state; int ret = OK; @@ -124,48 +124,57 @@ int sigprocmask(int how, const sigset_t *set, sigset_t *oset) /* Return the old signal mask if requested */ oldsigprocmask = rtcb->sigprocmask; - if (oset) *oset = oldsigprocmask; + if (oset) + { + *oset = oldsigprocmask; + } /* Modify the current signal mask if so requested */ - if (set) { - /* Some of these operations are non-atomic. We need to protect - * ourselves from attempts to process signals from interrupts */ - saved_state = irqsave(); + if (set) + { + /* Some of these operations are non-atomic. We need to protect + * ourselves from attempts to process signals from interrupts + */ - /* Okay, determine what we are supposed to do */ + saved_state = irqsave(); - switch (how) { - /* The resulting set is the union of the current set and the - * signal set pointed to by set. */ + /* Okay, determine what we are supposed to do */ - case SIG_BLOCK: - rtcb->sigprocmask |= *set; - break; + switch (how) + { + /* The resulting set is the union of the current set and the + * signal set pointed to by set. + */ - /* The resulting set is the intersection of the current set and - * the complement of the signal set pointed to by _set. */ + case SIG_BLOCK: + rtcb->sigprocmask |= *set; + break; - case SIG_UNBLOCK: - rtcb->sigprocmask &= ~(*set); - break; + /* The resulting set is the intersection of the current set and + * the complement of the signal set pointed to by _set. + */ - /* The resulting set is the signal set pointed to by set. */ + case SIG_UNBLOCK: + rtcb->sigprocmask &= ~(*set); + break; - case SIG_SETMASK: - rtcb->sigprocmask = *set; - break; + /* The resulting set is the signal set pointed to by set. */ - default: - ret = ERROR; - break; - } /* end switch */ + case SIG_SETMASK: + rtcb->sigprocmask = *set; + break; + + default: + ret = ERROR; + break; + } irqrestore(saved_state); /* Now, process any pending signals that were just unmasked */ sig_unmaskpendingsignal(); - } /* end if */ + } sched_unlock(); return ret; diff --git a/nuttx/sched/sig_queue.c b/nuttx/sched/sig_queue.c index b9d71efcc..dcae4e0a5 100644 --- a/nuttx/sched/sig_queue.c +++ b/nuttx/sched/sig_queue.c @@ -38,6 +38,7 @@ ************************************************************/ #include +#include #include #include #include @@ -103,7 +104,7 @@ int sigqueue (int pid, int signo, const union sigval value) int sigqueue(int pid, int signo, void *sival_ptr) #endif { - _TCB *stcb; + FAR _TCB *stcb; siginfo_t info; int ret = ERROR; diff --git a/nuttx/sched/sig_received.c b/nuttx/sched/sig_received.c index 922d4b778..9df9e797c 100644 --- a/nuttx/sched/sig_received.c +++ b/nuttx/sched/sig_received.c @@ -76,12 +76,12 @@ * ************************************************************/ -static int sig_queueaction(_TCB *stcb, siginfo_t *info) +static int sig_queueaction(FAR _TCB *stcb, siginfo_t *info) { - sigactq_t *sigact; - sigq_t *sigq; - irqstate_t saved_state; - int ret = OK; + FAR sigactq_t *sigact; + FAR sigq_t *sigq; + irqstate_t saved_state; + int ret = OK; sched_lock(); @@ -112,7 +112,7 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info) /* Put it at the end of the pending signals list */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)sigq, &(stcb->sigpendactionq)); + sq_addlast((FAR sq_entry_t*)sigq, &(stcb->sigpendactionq)); irqrestore(saved_state); } } @@ -129,10 +129,10 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info) * ************************************************************/ -static sigpendq_t *sig_findpendingsignal(_TCB *stcb, int signo) +static FAR sigpendq_t *sig_findpendingsignal(FAR _TCB *stcb, int signo) { - sigpendq_t *sigpend = NULL; - irqstate_t saved_state; + FAR sigpendq_t *sigpend = NULL; + irqstate_t saved_state; /* Verify the caller's sanity */ @@ -144,7 +144,7 @@ static sigpendq_t *sig_findpendingsignal(_TCB *stcb, int signo) /* Seach the list for a sigpendion on this signal */ - for(sigpend = (sigpendq_t*)stcb->sigpendingq.head; + for(sigpend = (FAR sigpendq_t*)stcb->sigpendingq.head; (sigpend && sigpend->info.si_signo != signo); sigpend = sigpend->flink); irqrestore(saved_state); @@ -161,10 +161,10 @@ static sigpendq_t *sig_findpendingsignal(_TCB *stcb, int signo) * ************************************************************/ -static sigpendq_t *sig_allocatependingsignal(void) +static FAR sigpendq_t *sig_allocatependingsignal(void) { - sigpendq_t *sigpend; - irqstate_t saved_state; + FAR sigpendq_t *sigpend; + irqstate_t saved_state; /* Check if we were called from an interrupt handler. */ @@ -172,13 +172,13 @@ static sigpendq_t *sig_allocatependingsignal(void) { /* Try to get the pending signal structure from the free list */ - sigpend = (sigpendq_t*)sq_remfirst(&g_sigpendingsignal); + sigpend = (FAR sigpendq_t*)sq_remfirst(&g_sigpendingsignal); /* If so, then try the special list of structures reserved for * interrupt handlers */ - sigpend = (sigpendq_t*)sq_remfirst(&g_sigpendingirqsignal); + sigpend = (FAR sigpendq_t*)sq_remfirst(&g_sigpendingirqsignal); } /* If we were not called from an interrupt handler, then we are @@ -189,18 +189,18 @@ static sigpendq_t *sig_allocatependingsignal(void) /* Try to get the pending signal structure from the free list */ saved_state = irqsave(); - sigpend = (sigpendq_t*)sq_remfirst(&g_sigpendingsignal); + sigpend = (FAR sigpendq_t*)sq_remfirst(&g_sigpendingsignal); irqrestore(saved_state); /* Check if we got one. */ if (!sigpend) { - /* No...Try the resource pool */ + /* No... Allocate the pending signal */ if (!sigpend) { - sigpend = (sigpendq_t *)kmalloc((sizeof (sigpendq_t))); + sigpend = (FAR sigpendq_t *)kmalloc((sizeof (sigpendq_t))); } /* Check if we got an allocated message */ @@ -225,10 +225,10 @@ static sigpendq_t *sig_allocatependingsignal(void) * run-away sender cannot consume all of memory. ************************************************************/ -static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info) +static FAR sigpendq_t *sig_addpendingsignal(FAR _TCB *stcb, siginfo_t *info) { - sigpendq_t *sigpend; - irqstate_t saved_state; + FAR sigpendq_t *sigpend; + irqstate_t saved_state; /* Check if the signal is already pending */ @@ -256,7 +256,7 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info) /* Add the structure to the pending signal list */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)sigpend, &stcb->sigpendingq); + sq_addlast((FAR sq_entry_t*)sigpend, &stcb->sigpendingq); irqrestore(saved_state); } } @@ -283,7 +283,7 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info) * ************************************************************/ -int sig_received(_TCB *stcb, siginfo_t *info) +int sig_received(FAR _TCB *stcb, siginfo_t *info) { irqstate_t saved_state; int ret = ERROR; diff --git a/nuttx/sched/sig_releasependingsigaction.c b/nuttx/sched/sig_releasependingsigaction.c index b25ee79e3..9ddedc711 100644 --- a/nuttx/sched/sig_releasependingsigaction.c +++ b/nuttx/sched/sig_releasependingsigaction.c @@ -74,7 +74,7 @@ * ************************************************************/ -void sig_releasependingsigaction(sigq_t *sigq) +void sig_releasependingsigaction(FAR sigq_t *sigq) { irqstate_t saved_state; @@ -88,7 +88,7 @@ void sig_releasependingsigaction(sigq_t *sigq) * list from interrupt handlers. */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)sigq, &g_sigpendingaction); + sq_addlast((FAR sq_entry_t*)sigq, &g_sigpendingaction); irqrestore(saved_state); } @@ -102,7 +102,7 @@ void sig_releasependingsigaction(sigq_t *sigq) * list from interrupt handlers. */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)sigq, &g_sigpendingirqaction); + sq_addlast((FAR sq_entry_t*)sigq, &g_sigpendingirqaction); irqrestore(saved_state); } diff --git a/nuttx/sched/sig_releasependingsignal.c b/nuttx/sched/sig_releasependingsignal.c index 43601d7db..198c145df 100644 --- a/nuttx/sched/sig_releasependingsignal.c +++ b/nuttx/sched/sig_releasependingsignal.c @@ -82,7 +82,7 @@ * Deallocate a pending signal list entry ************************************************************/ -void sig_releasependingsignal(sigpendq_t *sigpend) +void sig_releasependingsignal(FAR sigpendq_t *sigpend) { irqstate_t saved_state; @@ -96,7 +96,7 @@ void sig_releasependingsignal(sigpendq_t *sigpend) * list from interrupt handlers. */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)sigpend, &g_sigpendingsignal); + sq_addlast((FAR sq_entry_t*)sigpend, &g_sigpendingsignal); irqrestore(saved_state); } @@ -111,7 +111,7 @@ void sig_releasependingsignal(sigpendq_t *sigpend) */ saved_state = irqsave(); - sq_addlast((sq_entry_t*)sigpend, &g_sigpendingirqsignal); + sq_addlast((FAR sq_entry_t*)sigpend, &g_sigpendingirqsignal); irqrestore(saved_state); } diff --git a/nuttx/sched/sig_removependingsignal.c b/nuttx/sched/sig_removependingsignal.c index 917d6d7e1..c31c0bbe7 100644 --- a/nuttx/sched/sig_removependingsignal.c +++ b/nuttx/sched/sig_removependingsignal.c @@ -82,21 +82,21 @@ * Remove the specified signal from the signal pending list ************************************************************/ -sigpendq_t *sig_removependingsignal(_TCB *stcb, int signo) +FAR sigpendq_t *sig_removependingsignal(FAR _TCB *stcb, int signo) { - sigpendq_t *currsig; - sigpendq_t *prevsig; + FAR sigpendq_t *currsig; + FAR sigpendq_t *prevsig; irqstate_t saved_state; saved_state = irqsave(); - for (prevsig = NULL, currsig = (sigpendq_t*)stcb->sigpendingq.head; + for (prevsig = NULL, currsig = (FAR sigpendq_t*)stcb->sigpendingq.head; (currsig && currsig->info.si_signo != signo); prevsig = currsig, currsig = currsig->flink); if (currsig) { if (prevsig) { - sq_remafter((sq_entry_t*)prevsig, &stcb->sigpendingq); + sq_remafter((FAR sq_entry_t*)prevsig, &stcb->sigpendingq); } else { diff --git a/nuttx/sched/sig_suspend.c b/nuttx/sched/sig_suspend.c index 92771578f..7f7acfce2 100644 --- a/nuttx/sched/sig_suspend.c +++ b/nuttx/sched/sig_suspend.c @@ -111,12 +111,12 @@ int sigsuspend(const sigset_t *set) { - _TCB *rtcb = (_TCB*)g_readytorun.head; - sigset_t intersection; - sigset_t saved_sigprocmask; - sigpendq_t *sigpend; - irqstate_t saved_state; - int unblocksigno; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + sigset_t intersection; + sigset_t saved_sigprocmask; + FAR sigpendq_t *sigpend; + irqstate_t saved_state; + int unblocksigno; /* Several operations must be performed below: We must determine if any * signal is pending and, if not, wait for the signal. Since signals can diff --git a/nuttx/sched/sig_timedwait.c b/nuttx/sched/sig_timedwait.c index bba138fa7..eb3151dfa 100644 --- a/nuttx/sched/sig_timedwait.c +++ b/nuttx/sched/sig_timedwait.c @@ -88,8 +88,8 @@ static void sig_timeout(int argc, uint32 itcb, ...) union { - _TCB *wtcb; - uint32 itcb; + FAR _TCB *wtcb; + uint32 itcb; } u; u.itcb = itcb; @@ -160,13 +160,13 @@ static void sig_timeout(int argc, uint32 itcb, ...) int sigtimedwait(const sigset_t *set, struct siginfo *info, const struct timespec *timeout) { - _TCB *rtcb = (_TCB*)g_readytorun.head; - sigset_t intersection; - sigpendq_t *sigpend; - WDOG_ID wdog; - irqstate_t saved_state; - sint32 waitticks; - int ret = ERROR; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + sigset_t intersection; + FAR sigpendq_t *sigpend; + WDOG_ID wdog; + irqstate_t saved_state; + sint32 waitticks; + int ret = ERROR; sched_lock(); /* Not necessary */ diff --git a/nuttx/sched/sig_unmaskpendingsignal.c b/nuttx/sched/sig_unmaskpendingsignal.c index c27ad1266..77892dfc9 100644 --- a/nuttx/sched/sig_unmaskpendingsignal.c +++ b/nuttx/sched/sig_unmaskpendingsignal.c @@ -78,10 +78,10 @@ void sig_unmaskpendingsignal(void) { - _TCB *rtcb = (_TCB*)g_readytorun.head; - sigset_t unmaskedset; - sigpendq_t *pendingsig; - int signo; + FAR _TCB *rtcb = (FAR _TCB*)g_readytorun.head; + sigset_t unmaskedset; + FAR sigpendq_t *pendingsig; + int signo; /* Prohibit any context switches until we are done with this. * We may still be performing signal operations from interrupt @@ -133,3 +133,4 @@ void sig_unmaskpendingsignal(void) sched_unlock(); } + diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c index 79f487a11..fe449b85f 100644 --- a/nuttx/sched/task_create.c +++ b/nuttx/sched/task_create.c @@ -67,7 +67,7 @@ ************************************************************/ static void task_start(void); -static STATUS task_assignpid(_TCB* tcb); +static STATUS task_assignpid(FAR _TCB* tcb); /************************************************************ * Private Functions @@ -92,7 +92,7 @@ static STATUS task_assignpid(_TCB* tcb); static void task_start(void) { - _TCB *tcb = (_TCB*)g_readytorun.head; + FAR _TCB *tcb = (FAR _TCB*)g_readytorun.head; int argc; /* Count how many non-null arguments we are passing */ @@ -127,7 +127,7 @@ static void task_start(void) * ************************************************************/ -static STATUS task_assignpid(_TCB *tcb) +static STATUS task_assignpid(FAR _TCB *tcb) { pid_t next_pid; int hash_ndx; @@ -220,9 +220,10 @@ static STATUS task_assignpid(_TCB *tcb) * ************************************************************/ -STATUS _task_init(_TCB *tcb, char *name, int priority, +STATUS _task_init(FAR _TCB *tcb, const char *name, int priority, start_t start, main_t main, boolean pthread, - char *arg1, char *arg2, char *arg3, char *arg4) + FAR char *arg1, FAR char *arg2, + FAR char *arg3, FAR char *arg4) { STATUS ret; @@ -317,7 +318,7 @@ STATUS _task_init(_TCB *tcb, char *name, int priority, /* Add the task to the inactive task list */ sched_lock(); - dq_addfirst((dq_entry_t*)tcb, &g_inactivetasks); + dq_addfirst((FAR dq_entry_t*)tcb, &g_inactivetasks); tcb->task_state = TSTATE_TASK_INACTIVE; sched_unlock(); } @@ -348,9 +349,10 @@ STATUS _task_init(_TCB *tcb, char *name, int priority, * ************************************************************/ -STATUS task_init(_TCB *tcb, char *name, int priority, - uint32 *stack, uint32 stack_size, main_t entry, - char *arg1, char *arg2, char *arg3, char *arg4) +STATUS task_init(FAR _TCB *tcb, const char *name, int priority, + FAR uint32 *stack, uint32 stack_size, main_t entry, + FAR char *arg1, FAR char *arg2, + FAR char *arg3, FAR char *arg4) { up_use_stack(tcb, stack, stack_size); return _task_init(tcb, name, priority, task_start, entry, @@ -374,7 +376,7 @@ STATUS task_init(_TCB *tcb, char *name, int priority, * ************************************************************/ -STATUS task_activate(_TCB *tcb) +STATUS task_activate(FAR _TCB *tcb) { #ifdef CONFIG_SCHED_INSTRUMENTATION irqstate_t flags = irqsave(); @@ -433,17 +435,18 @@ STATUS task_activate(_TCB *tcb) * ************************************************************/ -int task_create(char *name, int priority, +int task_create(const char *name, int priority, int stack_size, main_t entry, - char *arg1, char *arg2, char *arg3, char *arg4) + FAR char *arg1, FAR char *arg2, + FAR char *arg3, FAR char *arg4) { - _TCB *tcb; + FAR _TCB *tcb; STATUS status; pid_t pid; /* Allocate a TCB for the new task. */ - tcb = (_TCB*)kzmalloc(sizeof(_TCB)); + tcb = (FAR _TCB*)kzmalloc(sizeof(_TCB)); if (!tcb) { *get_errno_ptr() = ENOMEM; @@ -486,7 +489,7 @@ int task_create(char *name, int priority, status = task_activate(tcb); if (status != OK) { - dq_rem((dq_entry_t*)tcb, &g_inactivetasks); + dq_rem((FAR dq_entry_t*)tcb, &g_inactivetasks); sched_releasetcb(tcb); return ERROR; } diff --git a/nuttx/sched/task_delete.c b/nuttx/sched/task_delete.c index ed169217d..47d9a868f 100644 --- a/nuttx/sched/task_delete.c +++ b/nuttx/sched/task_delete.c @@ -95,14 +95,14 @@ STATUS task_delete(pid_t pid) { - _TCB *rtcb; - _TCB *dtcb; + FAR _TCB *rtcb; + FAR _TCB *dtcb; irqstate_t saved_state; STATUS ret = ERROR; /* Check if the task to delete is the calling task */ - rtcb = (_TCB*)g_readytorun.head; + rtcb = (FAR _TCB*)g_readytorun.head; if (pid == 0 || pid == rtcb->pid) { /* If it is, then what we really wanted to do was exit. @@ -146,7 +146,7 @@ STATUS task_delete(pid_t pid) /* Remove the task from the OS's tasks lists. */ - dq_rem((dq_entry_t*)dtcb, g_tasklisttable[dtcb->task_state].list); + dq_rem((FAR dq_entry_t*)dtcb, g_tasklisttable[dtcb->task_state].list); dtcb->task_state = TSTATE_TASK_INVALID; irqrestore(saved_state); @@ -163,3 +163,4 @@ STATUS task_delete(pid_t pid) sched_releasetcb(dtcb); return ret; } + diff --git a/nuttx/sched/task_restart.c b/nuttx/sched/task_restart.c index 60478c258..eb6ef8d72 100644 --- a/nuttx/sched/task_restart.c +++ b/nuttx/sched/task_restart.c @@ -99,8 +99,8 @@ STATUS task_restart(pid_t pid) { - _TCB *rtcb; - _TCB *tcb; + FAR _TCB *rtcb; + FAR _TCB *tcb; STATUS status; irqstate_t state; @@ -112,7 +112,7 @@ STATUS task_restart(pid_t pid) /* Check if the task to restart is the calling task */ - rtcb = (_TCB*)g_readytorun.head; + rtcb = (FAR _TCB*)g_readytorun.head; if ((pid == 0) || (pid == rtcb->pid)) { /* Not implemented */ @@ -139,7 +139,7 @@ STATUS task_restart(pid_t pid) */ state = irqsave(); - dq_rem((dq_entry_t*)tcb, g_tasklisttable[tcb->task_state].list); + dq_rem((FAR dq_entry_t*)tcb, g_tasklisttable[tcb->task_state].list); tcb->task_state = TSTATE_TASK_INVALID; irqrestore(state); @@ -159,7 +159,7 @@ STATUS task_restart(pid_t pid) /* Add the task to the inactive task list */ - dq_addfirst((dq_entry_t*)tcb, &g_inactivetasks); + dq_addfirst((FAR dq_entry_t*)tcb, &g_inactivetasks); tcb->task_state = TSTATE_TASK_INACTIVE; /* Activate the task */ @@ -167,7 +167,7 @@ STATUS task_restart(pid_t pid) status = task_activate(tcb); if (status != OK) { - dq_rem((dq_entry_t*)tcb, &g_inactivetasks); + dq_rem((FAR dq_entry_t*)tcb, &g_inactivetasks); sched_releasetcb(tcb); return ERROR; } diff --git a/nuttx/sched/wd_cancel.c b/nuttx/sched/wd_cancel.c index c0181e43b..2872ce052 100644 --- a/nuttx/sched/wd_cancel.c +++ b/nuttx/sched/wd_cancel.c @@ -135,7 +135,7 @@ STATUS wd_cancel (WDOG_ID wdid) /* Now, remove the watchdog from the timer queue */ if (prev) - (void)sq_remafter((sq_entry_t*)prev, &g_wdactivelist); + (void)sq_remafter((FAR sq_entry_t*)prev, &g_wdactivelist); else (void)sq_remfirst(&g_wdactivelist); wdid->next = NULL; diff --git a/nuttx/sched/wd_delete.c b/nuttx/sched/wd_delete.c index 96168ec2c..7e2a4328e 100644 --- a/nuttx/sched/wd_delete.c +++ b/nuttx/sched/wd_delete.c @@ -88,7 +88,7 @@ * ************************************************************/ -STATUS wd_delete (WDOG_ID wdId) +STATUS wd_delete(WDOG_ID wdId) { irqstate_t saved_state; @@ -99,7 +99,7 @@ STATUS wd_delete (WDOG_ID wdId) /* Put the watchdog back on the free list */ - sq_addlast((sq_entry_t*)wdId, &g_wdfreelist); + sq_addlast((FAR sq_entry_t*)wdId, &g_wdfreelist); irqrestore(saved_state); /* Return success */ diff --git a/nuttx/sched/wd_initialize.c b/nuttx/sched/wd_initialize.c index 5d979bb3d..a1d943079 100644 --- a/nuttx/sched/wd_initialize.c +++ b/nuttx/sched/wd_initialize.c @@ -67,7 +67,7 @@ sq_queue_t g_wdfreelist; * item. */ -wdog_t *g_wdpool; +FAR wdog_t *g_wdpool; /* The g_wdactivelist data structure is a singly linked list * ordered by watchdog expiration time. When watchdog timers @@ -118,15 +118,15 @@ void wd_initialize(void) * configured number of watchdogs. */ - g_wdpool = (wdog_t*)kmalloc(sizeof(wdog_t) * CONFIG_PREALLOC_WDOGS); + g_wdpool = (FAR wdog_t*)kmalloc(sizeof(wdog_t) * CONFIG_PREALLOC_WDOGS); if (g_wdpool) { - wdog_t *wdog = g_wdpool; + FAR wdog_t *wdog = g_wdpool; int i; for (i = 0; i < CONFIG_PREALLOC_WDOGS; i++) { - sq_addlast((sq_entry_t*)wdog++, &g_wdfreelist); + sq_addlast((FAR sq_entry_t*)wdog++, &g_wdfreelist); } } diff --git a/nuttx/sched/wd_internal.h b/nuttx/sched/wd_internal.h index 7794d8c12..26ee264ad 100644 --- a/nuttx/sched/wd_internal.h +++ b/nuttx/sched/wd_internal.h @@ -88,7 +88,7 @@ extern sq_queue_t g_wdfreelist; * item. */ -extern wdog_t *g_wdpool; +extern FAR wdog_t *g_wdpool; /* The g_wdactivelist data structure is a singly linked list * ordered by watchdog expiration time. When watchdog timers diff --git a/nuttx/sched/wd_start.c b/nuttx/sched/wd_start.c index b3534593d..a0fb469de 100644 --- a/nuttx/sched/wd_start.c +++ b/nuttx/sched/wd_start.c @@ -185,7 +185,7 @@ STATUS wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, if (g_wdactivelist.head == NULL) { - sq_addlast((sq_entry_t*)wdog,&g_wdactivelist); + sq_addlast((FAR sq_entry_t*)wdog,&g_wdactivelist); } /* There are other active watchdogs in the timer queue */ @@ -228,11 +228,11 @@ STATUS wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, if (curr == (wdog_t*)g_wdactivelist.head) { - sq_addfirst((sq_entry_t*)wdog, &g_wdactivelist); + sq_addfirst((FAR sq_entry_t*)wdog, &g_wdactivelist); } else { - sq_addafter((sq_entry_t*)prev, (sq_entry_t*)wdog, + sq_addafter((FAR sq_entry_t*)prev, (FAR sq_entry_t*)wdog, &g_wdactivelist); } } @@ -247,13 +247,13 @@ STATUS wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry, delay -= now; if (!curr->next) { - sq_addlast((sq_entry_t*)wdog, &g_wdactivelist); + sq_addlast((FAR sq_entry_t*)wdog, &g_wdactivelist); } else { next = curr->next; next->lag -= delay; - sq_addafter((sq_entry_t*)curr, (sq_entry_t*)wdog, + sq_addafter((FAR sq_entry_t*)curr, (FAR sq_entry_t*)wdog, &g_wdactivelist); } } diff --git a/nuttx/tools/mkdeps.sh b/nuttx/tools/mkdeps.sh index 54ffbb1ee..c2b81ec2e 100755 --- a/nuttx/tools/mkdeps.sh +++ b/nuttx/tools/mkdeps.sh @@ -53,7 +53,7 @@ for i in $* ; do cflags=$args args= ;; - --debug ) + --dep-debug ) set -x ;; *) @@ -75,6 +75,6 @@ fi for file in $files ; do $cc -M $cflags $file || \ - { echo "$cc -M $cflags $file FAILED" ; exit 3 ; } + { echo "# $cc -M $cflags $file FAILED" ; exit 3 ; } done