Move more functions out of sched/ to lib/; proxies almost build

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3453 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-04-02 01:23:08 +00:00
parent 2aab150a39
commit 46314eb2a9
16 changed files with 441 additions and 156 deletions

View File

@ -1,7 +1,7 @@
/************************************************************************
* include/errno.h
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -49,6 +49,10 @@
/* Convenience/compatibility definition */
#define errno *get_errno_ptr()
#ifndef CONFIG_NUTTX_KERNEL
# define set_errno(e) do { errno = (int)(a); } while (0)
# define get_errno(e) errno
#endif
/* Definitions of error numbers and the string that would be
* returned by strerror().
@ -317,10 +321,21 @@ extern "C" {
#define EXTERN extern
#endif
/* Return a pointer to the thread specifid errno */
/* Return a pointer to the thread specifid errno. NOTE: When doing a
* kernel-/user-mode build, this function can only be used within the
* kernel-mode space.
*
* In the user-mode space, set_errno() and get_errno() are always available,
* either as macros or via syscalls.
*/
EXTERN FAR int *get_errno_ptr(void);
#ifdef CONFIG_NUTTX_KERNEL
EXTERN void set_errno(int errcode);
EXTERN int get_errno(void);
#endif
#undef EXTERN
#if defined(__cplusplus)
}

124
include/nuttx/mqueue.h Normal file
View File

@ -0,0 +1,124 @@
/****************************************************************************
* include/nuttx/mqueue.h
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef ___INCLUDE_NUTTX_MQUEUE_H
#define ___INCLUDE_NUTTX_MQUEUE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <mqueue.h>
#include <queue.h>
#include <signal.h>
#if CONFIG_MQ_MAXMSGSIZE > 0
/****************************************************************************
* Definitions
****************************************************************************/
/****************************************************************************
* Global Type Declarations
****************************************************************************/
/* This structure defines a message queue */
struct mq_des; /* forward reference */
struct msgq_s
{
FAR struct msgq_s *flink; /* Forward link to next message queue */
sq_queue_t msglist; /* Prioritized message list */
int16_t maxmsgs; /* Maximum number of messages in the queue */
int16_t nmsgs; /* Number of message in the queue */
int16_t nconnect; /* Number of connections to message queue */
int16_t nwaitnotfull; /* Number tasks waiting for not full */
int16_t nwaitnotempty; /* Number tasks waiting for not empty */
uint8_t maxmsgsize; /* Max size of message in message queue */
bool unlinked; /* true if the msg queue has been unlinked */
#ifndef CONFIG_DISABLE_SIGNALS
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 */
#endif
char name[1]; /* Start of the queue name */
};
typedef struct msgq_s msgq_t;
#define SIZEOF_MQ_HEADER ((int)(((msgq_t*)NULL)->name))
/* This describes the message queue descriptor that is held in the
* task's TCB
*/
struct mq_des
{
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 */
};
/****************************************************************************
* Global Variables
****************************************************************************/
/****************************************************************************
* Global Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_MQ_MAXMSGSIZE > 0 */
#endif /* ___INCLUDE_NUTTX_MQUEUE_H */

View File

@ -73,65 +73,105 @@
#define SYS_fstat (CONFIG_SYS_RESERVED+15)
#define SYS_fstatfs (CONFIG_SYS_RESERVED+16)
#define SYS_fsync (CONFIG_SYS_RESERVED+17)
#define SYS_getcwd (CONFIG_SYS_RESERVED+18)
#define SYS_getpid (CONFIG_SYS_RESERVED+19)
#define SYS_getsockopt (CONFIG_SYS_RESERVED+20)
#define SYS_gettimeofday (CONFIG_SYS_RESERVED+21)
#define SYS_ioctl (CONFIG_SYS_RESERVED+22)
#define SYS_kill (CONFIG_SYS_RESERVED+23)
#define SYS_listen (CONFIG_SYS_RESERVED+24)
#define SYS_lseek (CONFIG_SYS_RESERVED+25)
#define SYS_mkdir (CONFIG_SYS_RESERVED+26)
#define SYS_mmap (CONF6G_SYS_RESERVED+27)
#define SYS_mount (CONF7G_SYS_RESERVED+28)
#define SYS_mq_notify (CONFIG_SYS_RESERVED+29)
#define SYS_mq_open (CONFIG_SYS_RESERVED+30)
#define SYS_mq_timedreceive (CONFIG_SYS_RESERVED+31)
#define SYS_mq_timedsend (CONFIG_SYS_RESERVED+32)
#define SYS_mq_unlink (CONFIG_SYS_RESERVED+33)
#define SYS_munmap (CONFIG_SYS_RESERVED+34)
#define SYS_open (CONFIG_SYS_RESERVED+35)
#define SYS_pipe (CONFIG_SYS_RESERVED+36)
#define SYS_poll (CONFIG_SYS_RESERVED+37)
#define SYS_read (CONFIG_SYS_RESERVED+38)
#define SYS_readdir (CONFIG_SYS_RESERVED+39)
#define SYS_reboot (CONFIG_SYS_RESERVED+40)
#define SYS_recvfrom (CONFIG_SYS_RESERVED+41)
#define SYS_rename (CONFIG_SYS_RESERVED+42)
#define SYS_rmdir (CONFIG_SYS_RESERVED+43)
#define SYS_sched_getparam (CONFIG_SYS_RESERVED+44)
#define SYS_sched_get_priority_max (CONFIG_SYS_RESERVED+45)
#define SYS_sched_get_priority_min (CONFIG_SYS_RESERVED+46)
#define SYS_sched_getscheduler (CONFIG_SYS_RESERVED+47)
#define SYS_sched_rr_get_interval (CONFIG_SYS_RESERVED+48)
#define SYS_sched_setparam (CONFIG_SYS_RESERVED+49)
#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED+50)
#define SYS_sched_yield (CONFIG_SYS_RESERVED+51)
#define SYS_select (CONFIG_SYS_RESERVED+52)
#define SYS_sendto (CONFIG_SYS_RESERVED+53)
#define SYS_setsockopt (CONFIG_SYS_RESERVED+54)
#define SYS_sigaction (CONFIG_SYS_RESERVED+55)
#define SYS_signal (CONFIG_SYS_RESERVED+56)
#define SYS_sigpending (CONFIG_SYS_RESERVED+57)
#define SYS_sigprocmask (CONFIG_SYS_RESERVED+58)
#define SYS_sigsuspend (CONFIG_SYS_RESERVED+59)
#define SYS_socket (CONFIG_SYS_RESERVED+60)
#define SYS_stat (CONFIG_SYS_RESERVED+61)
#define SYS_statfs (CONFIG_SYS_RESERVED+62)
#define SYS_task_create (CONFIG_SYS_RESERVED+63)
#define SYS_task_delete (CONFIG_SYS_RESERVED+64)
#define SYS_task_init (CONFIG_SYS_RESERVED+65)
#define SYS_task_restart (CONFIG_SYS_RESERVED+66)
#define SYS_timer_create (CONFIG_SYS_RESERVED+67)
#define SYS_timer_delete (CONFIG_SYS_RESERVED+68)
#define SYS_timer_getoverrun (CONFIG_SYS_RESERVED+69)
#define SYS_timer_gettime (CONFIG_SYS_RESERVED+70)
#define SYS_timer_settime (CONFIG_SYS_RESERVED+71)
#define SYS_umount (CONFIG_SYS_RESERVED+72)
#define SYS_unlink (CONFIG_SYS_RESERVED+73)
#define SYS_waitid (CONFIG_SYS_RESERVED+74)
#define SYS_waitpid (CONFIG_SYS_RESERVED+75)
#define SYS_write (CONFIG_SYS_RESERVED+76)
#define SYS_get_errno (CONFIG_SYS_RESERVED+18)
#define SYS_getenv (CONFIG_SYS_RESERVED+19)
#define SYS_getpid (CONFIG_SYS_RESERVED+20)
#define SYS_getsockopt (CONFIG_SYS_RESERVED+21)
#define SYS_gettimeofday (CONFIG_SYS_RESERVED+22)
#define SYS_ioctl (CONFIG_SYS_RESERVED+23)
#define SYS_kill (CONFIG_SYS_RESERVED+24)
#define SYS_listen (CONFIG_SYS_RESERVED+25)
#define SYS_lseek (CONFIG_SYS_RESERVED+26)
#define SYS_mkdir (CONFIG_SYS_RESERVED+27)
#define SYS_mkfifo (CONFIG_SYS_RESERVED+28)
#define SYS_mmap (CONFIG_SYS_RESERVED+29)
#define SYS_mount (CONFIG_SYS_RESERVED+30)
#define SYS_mq_notify (CONFIG_SYS_RESERVED+31)
#define SYS_mq_open (CONFIG_SYS_RESERVED+32)
#define SYS_mq_close (CONFIG_SYS_RESERVED+33)
#define SYS_mq_receive (CONFIG_SYS_RESERVED+34)
#define SYS_mq_send (CONFIG_SYS_RESERVED+35)
#define SYS_mq_timedreceive (CONFIG_SYS_RESERVED+36)
#define SYS_mq_timedsend (CONFIG_SYS_RESERVED+37)
#define SYS_mq_unlink (CONFIG_SYS_RESERVED+38)
#define SYS_open (CONFIG_SYS_RESERVED+39)
#define SYS_opendir (CONFIG_SYS_RESERVED+40)
#define SYS_pipe (CONFIG_SYS_RESERVED+41)
#define SYS_poll (CONFIG_SYS_RESERVED+42)
#define SYS_pthread_barrier_destroy (CONFIG_SYS_RESERVED+43)
#define SYS_pthread_barrier_init (CONFIG_SYS_RESERVED+44)
#define SYS_pthread_barrier_wait (CONFIG_SYS_RESERVED+45)
#define SYS_pthread_cancel (CONFIG_SYS_RESERVED+46)
#define SYS_pthread_cond_broadcast (CONFIG_SYS_RESERVED+47)
#define SYS_pthread_cond_destroy (CONFIG_SYS_RESERVED+48)
#define SYS_pthread_cond_init (CONFIG_SYS_RESERVED+49)
#define SYS_pthread_cond_signal (CONFIG_SYS_RESERVED+50)
#define SYS_pthread_cond_timedwait (CONFIG_SYS_RESERVED+51)
#define SYS_pthread_cond_wait (CONFIG_SYS_RESERVED+52)
#define SYS_pthread_create (CONFIG_SYS_RESERVED+53)
#define SYS_pthread_detach (CONFIG_SYS_RESERVED+54)
#define SYS_pthread_exit (CONFIG_SYS_RESERVED+55)
#define SYS_pthread_getschedparam (CONFIG_SYS_RESERVED+56)
#define SYS_pthread_getspecific (CONFIG_SYS_RESERVED+57)
#define SYS_pthread_join (CONFIG_SYS_RESERVED+58)
#define SYS_pthread_key_create (CONFIG_SYS_RESERVED+59)
#define SYS_pthread_key_delete (CONFIG_SYS_RESERVED+60)
#define SYS_pthread_kill (CONFIG_SYS_RESERVED+61)
#define SYS_pthread_mutex_destroy (CONFIG_SYS_RESERVED+62)
#define SYS_pthread_mutex_init (CONFIG_SYS_RESERVED+63)
#define SYS_pthread_mutex_lock (CONFIG_SYS_RESERVED+64)
#define SYS_pthread_mutex_trylock (CONFIG_SYS_RESERVED+65)
#define SYS_pthread_mutex_unlock (CONFIG_SYS_RESERVED+66)
#define SYS_pthread_once (CONFIG_SYS_RESERVED+67)
#define SYS_pthread_setcancelstate (CONFIG_SYS_RESERVED+68)
#define SYS_pthread_setschedparam (CONFIG_SYS_RESERVED+69)
#define SYS_pthread_setschedprio (CONFIG_SYS_RESERVED+70)
#define SYS_pthread_setspecific (CONFIG_SYS_RESERVED+71)
#define SYS_pthread_sigmask (CONFIG_SYS_RESERVED+72)
#define SYS_pthread_testcancel (CONFIG_SYS_RESERVED+73)
#define SYS_pthread_yield (CONFIG_SYS_RESERVED+74)
#define SYS_putenv (CONFIG_SYS_RESERVED+75)
#define SYS_read (CONFIG_SYS_RESERVED+76)
#define SYS_readdir (CONFIG_SYS_RESERVED+77)
#define SYS_reboot (CONFIG_SYS_RESERVED+78)
#define SYS_recvfrom (CONFIG_SYS_RESERVED+79)
#define SYS_rename (CONFIG_SYS_RESERVED+80)
#define SYS_rmdir (CONFIG_SYS_RESERVED+81)
#define SYS_sched_getparam (CONFIG_SYS_RESERVED+82)
#define SYS_sched_get_priority_max (CONFIG_SYS_RESERVED+83)
#define SYS_sched_get_priority_min (CONFIG_SYS_RESERVED+84)
#define SYS_sched_getscheduler (CONFIG_SYS_RESERVED+85)
#define SYS_sched_rr_get_interval (CONFIG_SYS_RESERVED+86)
#define SYS_sched_setparam (CONFIG_SYS_RESERVED+87)
#define SYS_sched_setscheduler (CONFIG_SYS_RESERVED+88)
#define SYS_sched_yield (CONFIG_SYS_RESERVED+89)
#define SYS_select (CONFIG_SYS_RESERVED+90)
#define SYS_sendto (CONFIG_SYS_RESERVED+91)
#define SYS_set_errno (CONFIG_SYS_RESERVED+92)
#define SYS_setenv (CONFIG_SYS_RESERVED+93)
#define SYS_setsockopt (CONFIG_SYS_RESERVED+94)
#define SYS_sigaction (CONFIG_SYS_RESERVED+95)
#define SYS_signal (CONFIG_SYS_RESERVED+96)
#define SYS_sigpending (CONFIG_SYS_RESERVED+97)
#define SYS_sigprocmask (CONFIG_SYS_RESERVED+98)
#define SYS_sigsuspend (CONFIG_SYS_RESERVED+99)
#define SYS_socket (CONFIG_SYS_RESERVED+100)
#define SYS_stat (CONFIG_SYS_RESERVED+101)
#define SYS_statfs (CONFIG_SYS_RESERVED+102)
#define SYS_task_create (CONFIG_SYS_RESERVED+103)
#define SYS_task_delete (CONFIG_SYS_RESERVED+104)
#define SYS_task_init (CONFIG_SYS_RESERVED+105)
#define SYS_task_restart (CONFIG_SYS_RESERVED+106)
#define SYS_timer_create (CONFIG_SYS_RESERVED+107)
#define SYS_timer_delete (CONFIG_SYS_RESERVED+108)
#define SYS_timer_getoverrun (CONFIG_SYS_RESERVED+109)
#define SYS_timer_gettime (CONFIG_SYS_RESERVED+110)
#define SYS_timer_settime (CONFIG_SYS_RESERVED+111)
#define SYS_umount (CONFIG_SYS_RESERVED+112)
#define SYS_unlink (CONFIG_SYS_RESERVED+113)
#define SYS_waitid (CONFIG_SYS_RESERVED+114)
#define SYS_waitpid (CONFIG_SYS_RESERVED+115)
#define SYS_write (CONFIG_SYS_RESERVED+116)
/****************************************************************************
* Public Type Definitions

View File

@ -37,9 +37,11 @@
include stdio/Make.defs
include stdlib/Make.defs
include unistd/Make.defs
include sched/Make.defs
include string/Make.defs
include pthread/Make.defs
include semaphore/Make.defs
include mqueue/Make.defs
include math/Make.defs
include net/Make.defs
include time/Make.defs
@ -50,10 +52,10 @@ include misc/Make.defs
ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = $(STDIO_SRCS) $(STDLIB_SRCS) $(UNISTD_SRCS) $(STRING_SRCS) \
$(PTHREAD_SRCS) $(SEM_SRCS) $(MATH_SRCS) $(NET_SRCS) \
$(TIME_SRCS) $(LIBGEN_SRCS) $(QUEUE_SRCS) $(MISC_SRCS) \
$(REGEX_SRCS) $(CRC_SRCS) $(DBG_SRCS)
CSRCS = $(STDIO_SRCS) $(STDLIB_SRCS) $(UNISTD_SRCS) $(SCHED_SRCS) \
$(STRING_SRCS) $(PTHREAD_SRCS) $(SEM_SRCS) $(MQUEUE_SRCS) \
$(MATH_SRCS) $(NET_SRCS) $(TIME_SRCS) $(LIBGEN_SRCS) \
$(QUEUE_SRCS) $(MISC_SRCS) $(REGEX_SRCS) $(CRC_SRCS) $(DBG_SRCS)
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS)
@ -63,16 +65,18 @@ ROOTDEPPATH = --dep-path .
STDIODEPPATH = --dep-path stdio
STDLIBDEPPATH = --dep-path stdlib
UNISTDDEPPATH = --dep-path unistd
SCHEDDEPPATH = --dep-path sched
STRINGDEPPATH = --dep-path string
PTHREADDEPPATH = --dep-path pthread
SEMDEPPATH = --dep-path semaphore
MQDEPPATH = --dep-path mqueue
MATHDEPPATH = --dep-path math
NETDEPPATH = --dep-path net
TIMEDEPPATH = --dep-path time
LIBGENDEPPATH = --dep-path libgen
QUEUEDEPPATH = --dep-path queue
MISCDEPPATH = --dep-path misc
VPATH = stdio:stdlib:unistd:string:pthread:semaphore:math:net:time:libgen:queue:misc
VPATH = stdio:stdlib:unistd:sched:string:pthread:semaphore:mqueue:math:net:time:libgen:queue:misc
BIN = liblib$(LIBEXT)
@ -91,9 +95,9 @@ $(BIN): $(OBJS)
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) $(STDIODEPPATH) $(STDLIBDEPPATH) \
$(UNISTDDEPPATH) $(STRINGDEPPATH) $(PTHREADDEPPATH) $(SEMDEPPATH) \
$(MATHDEPPATH) $(NETDEPPATH) $(TIMEDEPPATH) $(LIBGENDEPPATH) \
$(QUEUEDEPPATH) $(MISCDEPPATH) \
$(UNISTDDEPPATH) $(SCHEDDEPPATH) $(STRINGDEPPATH) $(PTHREADDEPPATH) \
$(SEMDEPPATH) $(MQDEPPATH) $(MATHDEPPATH) $(NETDEPPATH) $(TIMEDEPPATH) \
$(LIBGENDEPPATH) $(QUEUEDEPPATH) $(MISCDEPPATH) \
$(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@

39
lib/mqueue/Make.defs Normal file
View File

@ -0,0 +1,39 @@
############################################################################
# lib/mqueue/Make.defs
#
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
MQUEUE_SRCS = mq_setattr.c mq_getattr.c
endif

View File

@ -1,7 +1,7 @@
/************************************************************************
* sched/mq_getattr.c
* lib/mqueue/mq_getattr.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -39,18 +39,8 @@
#include <nuttx/config.h>
#include <stdarg.h> /* va_list */
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <mqueue.h>
#include <sched.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
#include "os_internal.h"
#include "sig_internal.h"
#include "mq_internal.h"
#include <nuttx/mqueue.h>
/************************************************************************
* Definitions

View File

@ -1,7 +1,7 @@
/************************************************************************
* sched/mq_setattr.c
* lib/mqueue/mq_setattr.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -41,7 +41,8 @@
#include <fcntl.h> /* O_NONBLOCK */
#include <mqueue.h>
#include "mq_internal.h"
#include <nuttx/mqueue.h>
/************************************************************************
* Definitions

38
lib/sched/Make.defs Normal file
View File

@ -0,0 +1,38 @@
############################################################################
# lib/sched/Make.defs
#
# Copyright (C) 2011 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
SCHED_SRCS = sched_getprioritymax.c sched_getprioritymin.c

View File

@ -1,7 +1,7 @@
/************************************************************************
* sched/sched_getprioritymax.c
* lib/sched/sched_getprioritymax.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -41,8 +41,6 @@
#include <nuttx/arch.h>
#include "os_internal.h"
/************************************************************************
* Definitions
************************************************************************/

View File

@ -1,7 +1,7 @@
/************************************************************************
* sched/sched_getprioritymin.c
* lib/sched/sched_getprioritymin.c
*
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -41,8 +41,6 @@
#include <nuttx/arch.h>
#include "os_internal.h"
/************************************************************************
* Definitions
************************************************************************/

View File

@ -33,4 +33,6 @@
#
############################################################################
STDLIB_SRCS = lib_abs.c lib_imaxabs.c lib_labs.c lib_llabs.c lib_rand.c lib_qsort.c
STDLIB_SRCS = lib_abs.c lib_abort.c lib_imaxabs.c lib_labs.c lib_llabs.c \
lib_rand.c lib_qsort.c

View File

@ -53,7 +53,6 @@ TSK_SRCS = task_create.c task_init.c task_setup.c task_activate.c \
SCHED_SRCS = sched_setparam.c sched_setpriority.c sched_getparam.c \
sched_setscheduler.c sched_getscheduler.c \
sched_yield.c sched_rrgetinterval.c sched_foreach.c \
sched_getprioritymax.c sched_getprioritymin.c \
sched_lock.c sched_unlock.c sched_lockcount.c
ifeq ($(CONFIG_PRIORITY_INHERITANCE),y)
SCHED_SRCS += sched_reprioritize.c
@ -88,11 +87,9 @@ SIGNAL_SRCS = sig_initialize.c \
sig_releasependingsignal.c sig_lowest.c sig_mqnotempty.c \
sig_cleanup.c sig_received.c sig_deliver.c
MQUEUE_SRCS = mq_open.c mq_close.c mq_unlink.c \
mq_send.c mq_timedsend.c mq_sndinternal.c \
mq_receive.c mq_timedreceive.c mq_rcvinternal.c \
mq_setattr.c mq_getattr.c mq_initialize.c mq_descreate.c \
mq_findnamed.c mq_msgfree.c mq_msgqfree.c
MQUEUE_SRCS = mq_open.c mq_close.c mq_unlink.c mq_send.c mq_timedsend.c\
mq_sndinternal.c mq_receive.c mq_timedreceive.c mq_rcvinternal.c \
mq_initialize.c mq_descreate.c mq_findnamed.c mq_msgfree.c mq_msgqfree.c
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
MQUEUE_SRCS += mq_waitirq.c
endif

View File

@ -51,6 +51,8 @@
#include <sched.h>
#include <signal.h>
#include <nuttx/mqueue.h>
#if CONFIG_MQ_MAXMSGSIZE > 0
/****************************************************************************
@ -101,43 +103,6 @@ struct mqmsg
};
typedef struct mqmsg mqmsg_t;
/* This structure defines a message queue */
struct mq_des; /* forward reference */
struct msgq_s
{
FAR struct msgq_s *flink; /* Forward link to next message queue */
sq_queue_t msglist; /* Prioritized message list */
int16_t maxmsgs; /* Maximum number of messages in the queue */
int16_t nmsgs; /* Number of message in the queue */
int16_t nconnect; /* Number of connections to message queue */
int16_t nwaitnotfull; /* Number tasks waiting for not full */
int16_t nwaitnotempty; /* Number tasks waiting for not empty */
uint8_t maxmsgsize; /* Max size of message in message queue */
bool unlinked; /* true if the msg queue has been unlinked */
#ifndef CONFIG_DISABLE_SIGNALS
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 */
#endif
char name[1]; /* Start of the queue name */
};
#define SIZEOF_MQ_HEADER ((int)(((msgq_t*)NULL)->name))
/* This describes the message queue descriptor that is held in the
* task's TCB
*/
struct mq_des
{
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 */
};
/****************************************************************************
* Global Variables
****************************************************************************/

View File

@ -97,7 +97,9 @@ context: .context
clean:
@rm -f $(BIN1) $(BIN2) *~ .*.swp
ifneq ($(OBJECT),)
@rm -f proxies/*$(OBJEXT) stubs/*$(OBJEXT)
endif
$(call CLEAN)
distclean: clean

View File

@ -17,10 +17,11 @@
"fstat","sys/stat.h","","int","int","FAR struct stat*"
"fstatfs","sys/statfs.h","","int","int","struct statfs*"
"fsync","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","int"
"get_environ_ptr","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char**"
"get_errno_ptr","errno.h","","FAR int*"
#"get_environ_ptr","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char**"
#"get_errno_ptr","errno.h","","FAR int*"
"get_errno","errno.h","","int"
"getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*"
"getpid","unistd.h","","pidt_t"
"getpid","unistd.h","","pid_t"
"getsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR void*","FAR socklen_t*"
"gettimeofday","sys/time.h","","int","struct timeval*","FAR void*"
"ioctl","sys/ioctl.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","int","int","int","unsigned long"
@ -32,12 +33,10 @@
"mmap","sys/mman.h","CONFIG_NFILE_DESCRIPTORS > 0","FAR void*","FAR void*","size_t","int","int","int","off_t"
"mount","sys/mount.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","const char*","const char*","const char*","unsigned long","const void*"
"mq_close","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t"
"mq_getattr","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","struct mq_attr*"
"mq_notify","mqueue.h","!defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","const struct sigevent*"
"mq_open","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","mqd_t","const char*","int","..."
"mq_receive","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","ssize_t","mqd_t","void*","size_t","int*"
"mq_send","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","const void*","size_t","int"
"mq_setattr","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","const struct mq_attr*","struct mq_attr*"
"mq_timedreceive","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","ssize_t","mqd_t","void*","size_t","int*","const struct timespec*"
"mq_timedsend","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","mqd_t","const char*","size_t","int","const struct timespec*"
"mq_unlink","mqueue.h","!defined(CONFIG_DISABLE_MQUEUE)","int","const char*"
@ -86,8 +85,6 @@
"rename","stdio.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*","FAR const char*"
"rewinddir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","void","FAR DIR*"
"rmdir","unistd.h","CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char*"
"sched_get_priority_max","sched.h","","int","int"
"sched_get_priority_min","sched.h","","int","int"
"sched_getparam","sched.h","","int","pid_t","struct sched_param*"
"sched_getscheduler","sched.h","","int","pid_t"
"sched_lock","sched.h","","int"
@ -111,6 +108,7 @@
"sem_wait","semaphore.h","","int","FAR sem_t*"
"send","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR const void*","size_t","int"
"sendto","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","ssize_t","int","FAR const void*","size_t","int","FAR const struct sockaddr*","socklen_t"
"set_errno","errno.h","","void","int"
"setenv","stdlib.h","","int","const char*","const char*","int"
"setsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR const void*","socklen_t"
"sigaction","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","int","FAR const struct sigaction*","FAR struct sigaction*"
@ -153,7 +151,7 @@
"up_assert_code","assert.h","","void","FAR const uint8_t*","int","int"
#"up_assert_code","assert.h","","void","int"
"usleep","unistd.h","!defined(CONFIG_DISABLE_SIGNALS)","void","useconds_t"
#"wait","sys/wait.h","","pidt_t","int*"
#"wait","sys/wait.h","","pid_t","int*"
#"waitid","sys/wait.h","","int","idtype_t","id_t id","siginfo_t*","int"
"waitpid","sys/wait.h","defined(CONFIG_SCHED_WAITPID)","pidt_t","pid_t","int*","int"
"waitpid","sys/wait.h","defined(CONFIG_SCHED_WAITPID)","pid_t","pid_t","int*","int"
"write","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","ssize_t","int","FAR const void*","size_t"

Can't render this file because it has a wrong number of fields in line 2.

View File

@ -218,6 +218,11 @@ static bool is_vararg(const char *type, int index, int nparms)
fprintf(stderr, "%d: ... is not the last in the argument list\n", g_lineno);
exit(11);
}
else if (nparms < 2)
{
fprintf(stderr, "%d: Need one parameter before ...\n", g_lineno);
exit(14);
}
return true;
}
return false;
@ -321,12 +326,31 @@ static void generate_proxy(int nparms)
{
FILE *stream = open_proxy();
char formal[MAX_PARMSIZE];
bool bvarargs = false;
int nformal;
int nactual;
int i;
/* Generate "up-front" information, include correct header files */
fprintf(stream, "/* Auto-generated %s proxy file -- do not edit */\n\n", g_parm[NAME_INDEX]);
fprintf(stream, "#include <nuttx/config.h>\n");
/* Does this function have a variable number of parameters? If so then the
* final parameter type will be encoded as "..."
*/
if (is_vararg(g_parm[PARM1_INDEX+nparms-1], nparms-1, nparms))
{
nformal = nparms-1;
bvarargs = true;
fprintf(stream, "#include <stdarg.h>\n");
}
else
{
nformal = nparms;
}
fprintf(stream, "#include <%s>\n", g_parm[HEADER_INDEX]);
fprintf(stream, "#include <syscall.h>\n\n");
@ -339,15 +363,26 @@ static void generate_proxy(int nparms)
fprintf(stream, "%s %s(", g_parm[RETTYPE_INDEX], g_parm[NAME_INDEX]);
if (nparms <= 0)
/* Generate the formal parameter list */
if (nformal <= 0)
{
fprintf(stream, "void");
}
else
{
for (i = 0; i < nparms; i++)
for (i = 0; i < nformal; i++)
{
/* The formal and actual parameter types may be encoded.. extra the
* formal parameter type.
*/
get_formalparmtype(g_parm[PARM1_INDEX+i], formal);
/* Arguments after the first must be separated from the preceding
* parameter with a comma.
*/
if (i > 0)
{
fprintf(stream, ", ");
@ -355,24 +390,59 @@ static void generate_proxy(int nparms)
print_formalparm(stream, formal, i+1);
}
}
fprintf(stream, ")\n{\n");
/* Generate the system call. Functions that do not return or return void are special cases */
/* Handle the end of the formal parameter list */
if (strcmp(g_parm[RETTYPE_INDEX], "void") == 0)
if (bvarargs)
{
fprintf(stream, " (void)sys_call%d(", nparms);
fprintf(stream, ", ...)\n{\n");
/* Get parm variables .. some from the parameter list and others from
* the varargs.
*/
if (nparms < 7)
{
fprintf(stream, " va_list ap;\n");
for (i = nparms; i < 7; i++)
{
fprintf(stream, " uintptr_t parm%d;\n", i);
}
fprintf(stream, "\n va_start(ap, parm%d);\n", nparms-1);
for (i = nparms; i < 7; i++)
{
fprintf(stream, " parm%d = va_arg(ap, uintptr_t);\n", i);
}
fprintf(stream, " va_end(ap);\n\n");
}
}
else
{
fprintf(stream, " return (%s)sys_call%d(", g_parm[RETTYPE_INDEX], nparms);
fprintf(stream, ")\n{\n");
}
/* Create the parameter list with the matching types. The first parametr is always the syscall number. */
/* Generate the system call. Functions that do not return or return void
* are special cases.
*/
nactual = bvarargs ? 6 : nparms;
if (strcmp(g_parm[RETTYPE_INDEX], "void") == 0)
{
fprintf(stream, " (void)sys_call%d(", nactual);
}
else
{
fprintf(stream, " return (%s)sys_call%d(", g_parm[RETTYPE_INDEX], nactual);
}
/* Create the parameter list with the matching types. The first parameter
* is always the syscall number.
*/
fprintf(stream, "(unsigned int)SYS_%s", g_parm[NAME_INDEX]);
for (i = 0; i < nparms; i++)
for (i = 0; i < nactual; i++)
{
fprintf(stream, ", (uintptr_t)parm%d", i+1);
}
@ -455,6 +525,10 @@ static void generate_stub(int nparms)
/* Generate the function definition that matches standard function prototype */
if (g_inline)
{
fprintf(stream, "static inline ");
}
fprintf(stream, "uintptr_t STUB_%s(", g_parm[NAME_INDEX]);
/* Generate the formal parameter list. A function received no parameters is a special case. */