mirror of
https://git.busybox.net/uClibc
synced 2025-10-14 01:32:00 +08:00
run through Lindent
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
int mq_close(mqd_t mqdes)
|
||||
{
|
||||
return close(mqdes);
|
||||
return close(mqdes);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -11,26 +11,26 @@
|
||||
#ifdef __NR_mq_getsetattr
|
||||
|
||||
librt_hidden_proto(mq_setattr)
|
||||
|
||||
#define __NR___syscall_mq_getsetattr __NR_mq_getsetattr
|
||||
static inline _syscall3(int, __syscall_mq_getsetattr, int, mqdes,
|
||||
const void *, mqstat, void *, omqstat);
|
||||
const void *, mqstat, void *, omqstat);
|
||||
|
||||
/*
|
||||
* Set attributes associated with message queue (and possibly also get
|
||||
* its old attributes)
|
||||
*/
|
||||
int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat,
|
||||
struct mq_attr *omqstat)
|
||||
struct mq_attr *omqstat)
|
||||
{
|
||||
return __syscall_mq_getsetattr(mqdes, mqstat, omqstat);
|
||||
return __syscall_mq_getsetattr(mqdes, mqstat, omqstat);
|
||||
}
|
||||
|
||||
librt_hidden_def(mq_setattr)
|
||||
|
||||
/* Query status and attributes of message queue */
|
||||
int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat)
|
||||
{
|
||||
return mq_setattr(mqdes, NULL, mqstat);
|
||||
return mq_setattr(mqdes, NULL, mqstat);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -12,17 +12,17 @@
|
||||
|
||||
#define __NR___syscall_mq_notify __NR_mq_notify
|
||||
static inline _syscall2(int, __syscall_mq_notify, int, mqdes,
|
||||
const void *, notification);
|
||||
const void *, notification);
|
||||
|
||||
/* Register notification upon message arrival to an empty message queue */
|
||||
int mq_notify(mqd_t mqdes, const struct sigevent *notification)
|
||||
{
|
||||
/* We don't support SIGEV_THREAD notification yet */
|
||||
if (notification != NULL && notification->sigev_notify == SIGEV_THREAD) {
|
||||
__set_errno(ENOSYS);
|
||||
return -1;
|
||||
}
|
||||
return __syscall_mq_notify(mqdes, notification);
|
||||
/* We don't support SIGEV_THREAD notification yet */
|
||||
if (notification != NULL && notification->sigev_notify == SIGEV_THREAD) {
|
||||
__set_errno(ENOSYS);
|
||||
return -1;
|
||||
}
|
||||
return __syscall_mq_notify(mqdes, notification);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -13,7 +13,7 @@
|
||||
|
||||
#define __NR___syscall_mq_open __NR_mq_open
|
||||
static inline _syscall4(int, __syscall_mq_open, const char *, name,
|
||||
int, oflag, __kernel_mode_t, mode, void *, attr);
|
||||
int, oflag, __kernel_mode_t, mode, void *, attr);
|
||||
/*
|
||||
* Establish connection between a process and a message queue and
|
||||
* return message queue descriptor or (mqd_t) -1 on error.
|
||||
@@ -25,28 +25,28 @@ static inline _syscall4(int, __syscall_mq_open, const char *, name,
|
||||
*/
|
||||
mqd_t mq_open(const char *name, int oflag, ...)
|
||||
{
|
||||
mode_t mode;
|
||||
struct mq_attr *attr;
|
||||
mode_t mode;
|
||||
struct mq_attr *attr;
|
||||
|
||||
if (name[0] != '/') {
|
||||
__set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
if (name[0] != '/') {
|
||||
__set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
mode = 0;
|
||||
attr = NULL;
|
||||
mode = 0;
|
||||
attr = NULL;
|
||||
|
||||
if (oflag & O_CREAT) {
|
||||
va_list ap;
|
||||
if (oflag & O_CREAT) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, oflag);
|
||||
mode = va_arg(ap, mode_t);
|
||||
attr = va_arg(ap, struct mq_attr *);
|
||||
va_start(ap, oflag);
|
||||
mode = va_arg(ap, mode_t);
|
||||
attr = va_arg(ap, struct mq_attr *);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
return __syscall_mq_open(name + 1, oflag, mode, attr);
|
||||
return __syscall_mq_open(name + 1, oflag, mode, attr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -8,12 +8,11 @@
|
||||
#include <mqueue.h>
|
||||
|
||||
librt_hidden_proto(mq_timedreceive)
|
||||
|
||||
#ifdef __NR_mq_timedreceive
|
||||
#define __NR___syscall_mq_timedreceive __NR_mq_timedreceive
|
||||
static inline _syscall5(int, __syscall_mq_timedreceive, int, mqdes,
|
||||
char *, msg_ptr, size_t, msg_len, unsigned int *, msg_prio,
|
||||
const void *, abs_timeout);
|
||||
char *, msg_ptr, size_t, msg_len, unsigned int *,
|
||||
msg_prio, const void *, abs_timeout);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -25,17 +24,19 @@ ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
|
||||
const struct timespec *abs_timeout)
|
||||
{
|
||||
#ifdef __NR_mq_timedreceive
|
||||
return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout);
|
||||
return __syscall_mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio,
|
||||
abs_timeout);
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
librt_hidden_def(mq_timedreceive)
|
||||
|
||||
/* Receive the oldest from highest priority messages */
|
||||
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len,
|
||||
unsigned int *msg_prio)
|
||||
unsigned int *msg_prio)
|
||||
{
|
||||
return mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, NULL);
|
||||
}
|
||||
|
@@ -8,12 +8,11 @@
|
||||
#include <mqueue.h>
|
||||
|
||||
librt_hidden_proto(mq_timedsend)
|
||||
|
||||
#ifdef __NR_mq_timedsend
|
||||
#define __NR___syscall_mq_timedsend __NR_mq_timedsend
|
||||
static inline _syscall5(int, __syscall_mq_timedsend, int, mqdes,
|
||||
const char *, msg_ptr, size_t, msg_len, unsigned int, msg_prio,
|
||||
const void *, abs_timeout);
|
||||
const char *, msg_ptr, size_t, msg_len, unsigned int,
|
||||
msg_prio, const void *, abs_timeout);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -21,21 +20,22 @@ static inline _syscall5(int, __syscall_mq_timedsend, int, mqdes,
|
||||
* for sufficient room in the queue until abs_timeout expires.
|
||||
*/
|
||||
int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
|
||||
unsigned int msg_prio,
|
||||
const struct timespec *abs_timeout)
|
||||
unsigned int msg_prio, const struct timespec *abs_timeout)
|
||||
{
|
||||
#ifdef __NR_mq_timedsend
|
||||
return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout);
|
||||
return __syscall_mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio,
|
||||
abs_timeout);
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
librt_hidden_def(mq_timedsend)
|
||||
|
||||
/* Add a message to queue */
|
||||
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len,
|
||||
unsigned int msg_prio)
|
||||
unsigned int msg_prio)
|
||||
{
|
||||
return mq_timedsend(mqdes, msg_ptr, msg_len, msg_prio, NULL);
|
||||
}
|
||||
|
@@ -15,24 +15,25 @@ static inline _syscall1(int, __syscall_mq_unlink, const char *, name);
|
||||
/* Remove message queue */
|
||||
int mq_unlink(const char *name)
|
||||
{
|
||||
int ret;
|
||||
if (name[0] != '/') {
|
||||
__set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
int ret;
|
||||
|
||||
ret = __syscall_mq_unlink(name + 1);
|
||||
if (name[0] != '/') {
|
||||
__set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES. */
|
||||
if (ret < 0) {
|
||||
ret = errno;
|
||||
if (ret == EPERM)
|
||||
ret = EACCES;
|
||||
__set_errno(ret);
|
||||
ret = -1;
|
||||
}
|
||||
ret = __syscall_mq_unlink(name + 1);
|
||||
|
||||
return ret;
|
||||
/* While unlink can return either EPERM or EACCES, mq_unlink should return just EACCES. */
|
||||
if (ret < 0) {
|
||||
ret = errno;
|
||||
if (ret == EPERM)
|
||||
ret = EACCES;
|
||||
__set_errno(ret);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -19,54 +19,54 @@
|
||||
|
||||
#define __NR___syscall_timer_create __NR_timer_create
|
||||
static inline _syscall3(int, __syscall_timer_create, clockid_t, clock_id,
|
||||
struct sigevent *, evp, kernel_timer_t *, ktimerid);
|
||||
struct sigevent *, evp, kernel_timer_t *, ktimerid);
|
||||
|
||||
/* Create a per-process timer */
|
||||
int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
|
||||
int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t * timerid)
|
||||
{
|
||||
int retval;
|
||||
kernel_timer_t ktimerid;
|
||||
struct sigevent local_evp;
|
||||
struct timer *newp;
|
||||
int retval;
|
||||
kernel_timer_t ktimerid;
|
||||
struct sigevent local_evp;
|
||||
struct timer *newp;
|
||||
|
||||
/* Notification via a thread is not supported yet */
|
||||
if (__builtin_expect(evp->sigev_notify == SIGEV_THREAD, 1))
|
||||
return -1;
|
||||
/* Notification via a thread is not supported yet */
|
||||
if (__builtin_expect(evp->sigev_notify == SIGEV_THREAD, 1))
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* We avoid allocating too much memory by basically using
|
||||
* struct timer as a derived class with the first two elements
|
||||
* being in the superclass. We only need these two elements here.
|
||||
*/
|
||||
newp = (struct timer *) malloc(offsetof(struct timer, thrfunc));
|
||||
if (newp == NULL)
|
||||
return -1; /* No memory */
|
||||
|
||||
if (evp == NULL) {
|
||||
/*
|
||||
* The kernel has to pass up the timer ID which is a userlevel object.
|
||||
* Therefore we cannot leave it up to the kernel to determine it.
|
||||
* We avoid allocating too much memory by basically using
|
||||
* struct timer as a derived class with the first two elements
|
||||
* being in the superclass. We only need these two elements here.
|
||||
*/
|
||||
local_evp.sigev_notify = SIGEV_SIGNAL;
|
||||
local_evp.sigev_signo = SIGALRM;
|
||||
local_evp.sigev_value.sival_ptr = newp;
|
||||
newp = (struct timer *)malloc(offsetof(struct timer, thrfunc));
|
||||
if (newp == NULL)
|
||||
return -1; /* No memory */
|
||||
|
||||
evp = &local_evp;
|
||||
}
|
||||
if (evp == NULL) {
|
||||
/*
|
||||
* The kernel has to pass up the timer ID which is a userlevel object.
|
||||
* Therefore we cannot leave it up to the kernel to determine it.
|
||||
*/
|
||||
local_evp.sigev_notify = SIGEV_SIGNAL;
|
||||
local_evp.sigev_signo = SIGALRM;
|
||||
local_evp.sigev_value.sival_ptr = newp;
|
||||
|
||||
retval = __syscall_timer_create(clock_id, evp, &ktimerid);
|
||||
if (retval != -1) {
|
||||
newp->sigev_notify = (evp != NULL ? evp->sigev_notify : SIGEV_SIGNAL);
|
||||
newp->ktimerid = ktimerid;
|
||||
evp = &local_evp;
|
||||
}
|
||||
|
||||
*timerid = (timer_t) newp;
|
||||
} else {
|
||||
/* Cannot allocate the timer, fail */
|
||||
free(newp);
|
||||
retval = -1;
|
||||
}
|
||||
retval = __syscall_timer_create(clock_id, evp, &ktimerid);
|
||||
if (retval != -1) {
|
||||
newp->sigev_notify = (evp != NULL ? evp->sigev_notify : SIGEV_SIGNAL);
|
||||
newp->ktimerid = ktimerid;
|
||||
|
||||
return retval;
|
||||
*timerid = (timer_t) newp;
|
||||
} else {
|
||||
/* Cannot allocate the timer, fail */
|
||||
free(newp);
|
||||
retval = -1;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -17,17 +17,17 @@ static inline _syscall1(int, __syscall_timer_delete, kernel_timer_t, ktimerid);
|
||||
/* Delete a per-process timer */
|
||||
int timer_delete(timer_t timerid)
|
||||
{
|
||||
int res;
|
||||
struct timer *kt = (struct timer *) timerid;
|
||||
int res;
|
||||
struct timer *kt = (struct timer *)timerid;
|
||||
|
||||
/* Delete the kernel timer object */
|
||||
res = __syscall_timer_delete(kt->ktimerid);
|
||||
if (res == 0) {
|
||||
free(kt); /* Free the memory */
|
||||
return 0;
|
||||
}
|
||||
/* Delete the kernel timer object */
|
||||
res = __syscall_timer_delete(kt->ktimerid);
|
||||
if (res == 0) {
|
||||
free(kt); /* Free the memory */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -11,15 +11,16 @@
|
||||
#ifdef __NR_timer_getoverrun
|
||||
|
||||
#define __NR___syscall_timer_getoverrun __NR_timer_getoverrun
|
||||
static inline _syscall1(int, __syscall_timer_getoverrun, kernel_timer_t, ktimerid);
|
||||
static inline _syscall1(int, __syscall_timer_getoverrun, kernel_timer_t,
|
||||
ktimerid);
|
||||
|
||||
/* Get the timer overrun count */
|
||||
int timer_getoverrun(timer_t timerid)
|
||||
{
|
||||
struct timer *kt = (struct timer *) timerid;
|
||||
struct timer *kt = (struct timer *)timerid;
|
||||
|
||||
/* Get the information from the kernel */
|
||||
return __syscall_timer_getoverrun(kt->ktimerid);
|
||||
/* Get the information from the kernel */
|
||||
return __syscall_timer_getoverrun(kt->ktimerid);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -12,15 +12,16 @@
|
||||
#ifdef __NR_timer_gettime
|
||||
|
||||
#define __NR___syscall_timer_gettime __NR_timer_gettime
|
||||
static inline _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid, void *, value);
|
||||
static inline _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid,
|
||||
void *, value);
|
||||
|
||||
/* Get the amount of time left on a timer */
|
||||
int timer_gettime(timer_t timerid, struct itimerspec *value)
|
||||
{
|
||||
struct timer *kt = (struct timer *) timerid;
|
||||
struct timer *kt = (struct timer *)timerid;
|
||||
|
||||
/* Get timeout from the kernel */
|
||||
return __syscall_timer_gettime(kt->ktimerid, value);
|
||||
/* Get timeout from the kernel */
|
||||
return __syscall_timer_gettime(kt->ktimerid, value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -13,16 +13,16 @@
|
||||
|
||||
#define __NR___syscall_timer_settime __NR_timer_settime
|
||||
static inline _syscall4(int, __syscall_timer_settime, kernel_timer_t, ktimerid,
|
||||
int, flags, const void *, value, void *, ovalue);
|
||||
int, flags, const void *, value, void *, ovalue);
|
||||
|
||||
/* Set the expiration time for a timer */
|
||||
int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
|
||||
struct itimerspec *ovalue)
|
||||
struct itimerspec *ovalue)
|
||||
{
|
||||
struct timer *kt = (struct timer *) timerid;
|
||||
struct timer *kt = (struct timer *)timerid;
|
||||
|
||||
/* Set timeout */
|
||||
return __syscall_timer_settime(kt->ktimerid, flags, value, ovalue);
|
||||
/* Set timeout */
|
||||
return __syscall_timer_settime(kt->ktimerid, flags, value, ovalue);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user