Finally, a clean SDCC compile

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@20 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-02-27 21:17:21 +00:00
parent ff0207cf9a
commit a60059d9d0
171 changed files with 1513 additions and 1325 deletions
-5
View File
@@ -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-
-26
View File
@@ -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
#
-26
View File
@@ -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
#
+1 -1
View File
@@ -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
+5 -2
View File
@@ -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 */
};
/************************************************************
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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);
+7
View File
@@ -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);
+7 -7
View File
@@ -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");
+9 -5
View File
@@ -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)
+23 -2
View File
@@ -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]);
+12 -3
View File
@@ -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
}
+6
View File
@@ -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" );
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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);
+2 -2
View File
@@ -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 */
+26 -26
View File
@@ -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)
+36 -31
View File
@@ -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] == '/')
{
+6 -11
View File
@@ -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 */
+13 -3
View File
@@ -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? */
+3 -3
View File
@@ -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)
+10 -10
View File
@@ -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;
}
+2 -2
View File
@@ -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? */
+2 -2
View File
@@ -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);
+1 -7
View File
@@ -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)
+2 -3
View File
@@ -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,
+10 -10
View File
@@ -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
+103 -1
View File
@@ -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
/************************************************************
+37 -39
View File
@@ -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 **************************************************/
+2 -2
View File
@@ -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 */
+4 -4
View File
@@ -63,28 +63,28 @@ extern "C" {
# include <stdlib.h>
# 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 <stdlib.h>
# 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 <stdlib.h>
# 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)
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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
+33 -26
View File
@@ -41,6 +41,7 @@
************************************************************/
#include <nuttx/config.h> /* Default settings */
#include <nuttx/compiler.h> /* Compiler settings */
#include <sys/types.h> /* Needed for general types */
#include <semaphore.h> /* Needed for sem_t */
#include <time.h> /* 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
+25 -21
View File
@@ -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
+28 -25
View File
@@ -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 */
+9 -9
View File
@@ -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
+3 -2
View File
@@ -41,6 +41,7 @@
************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <time.h> /* Needed for struct timespec */
#include <sys/types.h> /* 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,
+15 -15
View File
@@ -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);
+25 -15
View File
@@ -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)
+2 -2
View File
@@ -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);
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+6 -6
View File
@@ -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;
}
}
+6 -6
View File
@@ -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;
}
}
+2 -1
View File
@@ -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;
}
}
+2 -1
View File
@@ -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;
}
}
+4 -3
View File
@@ -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;
}

Some files were not shown because too many files have changed in this diff Show More