Skip to content

Commit fc094e9

Browse files
committed
[rtlibc] remove libc_signal.h and libc_fdset.h
1 parent 73bd7a7 commit fc094e9

File tree

15 files changed

+139
-141
lines changed

15 files changed

+139
-141
lines changed

components/dfs/include/dfs_select.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef DFS_SELECT_H__
1111
#define DFS_SELECT_H__
1212

13-
#include <libc/libc_fdset.h>
13+
#include <sys/select.h>
1414

1515
#ifdef __cplusplus
1616
extern "C" {

components/libc/aio/posix_aio.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,8 @@
99
*/
1010

1111
#include <stdint.h>
12-
#include <stdio.h>
13-
1412
#include <rthw.h>
15-
#include <rtdevice.h>
16-
#include <rtthread.h>
17-
1813
#include <dfs_posix.h>
19-
2014
#include "posix_aio.h"
2115

2216
struct rt_workqueue* aio_queue = NULL;

components/libc/aio/posix_aio.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
#ifndef POSIX_AIO_H__
1212
#define POSIX_AIO_H__
1313

14+
#include <stdio.h>
15+
#include <sys/signal.h>
16+
#include <rtdevice.h>
17+
1418
struct aiocb
1519
{
1620
int aio_fildes; /* File descriptor. */

components/libc/compilers/common/none-gcc/sys/errno.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Date Author Notes
88
* 2021-05-22 Meco Man The first version.
99
*/
10-
#ifndef _SYS_ERRNO_H
11-
#define _SYS_ERRNO_H
10+
#ifndef __SYS_ERRNO_H__
11+
#define __SYS_ERRNO_H__
1212

1313
#if defined(__ARMCC_VERSION)
1414
/*

components/libc/compilers/common/none-gcc/sys/stat.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@
66
* Change Logs:
77
* Date Author Notes
88
*/
9+
10+
#ifndef __SYS_STAT_H__
11+
#define __SYS_STAT_H__
12+
13+
#endif

components/libc/compilers/common/none-gcc/sys/types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* 2020-09-05 Meco Man fix bugs
99
* 2020-12-16 Meco Man add useconds_t
1010
*/
11-
#ifndef __TYPES_H__
12-
#define __TYPES_H__
11+
#ifndef __SYS_TYPES_H__
12+
#define __SYS_TYPES_H__
1313

1414
#include <stdint.h>
1515

components/libc/compilers/common/none-gcc/sys/unistd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Date Author Notes
88
* 2020-12-16 Meco Man add usleep
99
*/
10-
#ifndef _SYS_UNISTD_H
11-
#define _SYS_UNISTD_H
10+
#ifndef __SYS_UNISTD_H__
11+
#define __SYS_UNISTD_H__
1212

1313
#include <rtconfig.h>
1414
#include "types.h"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-07-21 Meco Man The first version
9+
*/
10+
11+
#ifndef __SYS_SELECT_H__
12+
#define __SYS_SELECT_H__
13+
14+
#include <rtconfig.h>
15+
#include <sys/types.h>
16+
17+
#ifndef FD_SETSIZE
18+
#define FD_SETSIZE 32
19+
#endif
20+
21+
#ifdef SAL_USING_POSIX
22+
#ifdef FD_SETSIZE
23+
#undef FD_SETSIZE
24+
#endif
25+
#define FD_SETSIZE DFS_FD_MAX
26+
#endif /* SAL_USING_POSIX */
27+
28+
#define NBBY 8 /* number of bits in a byte */
29+
30+
typedef long fd_mask;
31+
32+
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
33+
#ifndef howmany
34+
#define howmany(x,y) (((x)+((y)-1))/(y))
35+
#endif
36+
37+
#ifndef _SYS_TYPES_FD_SET /* MIPS */
38+
typedef struct _types_fd_set {
39+
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
40+
} _types_fd_set;
41+
#define fd_set _types_fd_set
42+
43+
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
44+
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
45+
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
46+
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
47+
#endif /* _SYS_TYPES_FD_SET */
48+
49+
#endif /* __SYS_SELECT_H__ */

include/libc/libc_signal.h renamed to components/libc/compilers/common/sys/signal.h

Lines changed: 70 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,27 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2017-09-12 Bernard The first version
9+
* 2021-07-21 Meco Man move to libc/common
910
*/
1011

11-
#ifndef LIBC_SIGNAL_H__
12-
#define LIBC_SIGNAL_H__
12+
#ifndef __SYS_SIGNAL_H__
13+
#define __SYS_SIGNAL_H__
1314

1415
#ifdef __cplusplus
1516
extern "C" {
1617
#endif
1718

1819
#include <stdint.h>
19-
#ifdef HAVE_CCONFIG_H
20-
#include <cconfig.h>
21-
#endif
2220

23-
#ifndef HAVE_SIGVAL
2421
/* Signal Generation and Delivery, P1003.1b-1993, p. 63
2522
NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and
2623
sigev_notify_attributes to the sigevent structure. */
27-
2824
union sigval
2925
{
3026
int sival_int; /* Integer signal value */
3127
void *sival_ptr; /* Pointer signal value */
3228
};
33-
#endif
3429

35-
#ifndef HAVE_SIGEVENT
3630
struct sigevent
3731
{
3832
int sigev_notify; /* Notification type */
@@ -42,9 +36,7 @@ struct sigevent
4236
/* Notification function */
4337
void *sigev_notify_attributes; /* Notification Attributes, really pthread_attr_t */
4438
};
45-
#endif
4639

47-
#ifndef HAVE_SIGINFO
4840
struct siginfo
4941
{
5042
uint16_t si_signo;
@@ -53,26 +45,37 @@ struct siginfo
5345
union sigval si_value;
5446
};
5547
typedef struct siginfo siginfo_t;
56-
#endif
5748

5849
#define SI_USER 0x01 /* Signal sent by kill(). */
5950
#define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
60-
#define SI_TIMER 0x03 /* Signal generated by expiration of a
61-
timer set by timer_settime(). */
62-
#define SI_ASYNCIO 0x04 /* Signal generated by completion of an
63-
asynchronous I/O request. */
64-
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
65-
message on an empty message queue. */
66-
67-
#if !defined(RT_USING_NEWLIB)
51+
#define SI_TIMER 0x03 /* Signal generated by expiration of a timer set by timer_settime(). */
52+
#define SI_ASYNCIO 0x04 /* Signal generated by completion of an asynchronous I/O request. */
53+
#define SI_MESGQ 0x05 /* Signal generated by arrival of a message on an empty message queue. */
54+
6855
typedef void (*_sig_func_ptr)(int);
6956
typedef unsigned long sigset_t;
70-
#endif
7157

72-
#include <signal.h>
58+
struct sigaction
59+
{
60+
_sig_func_ptr sa_handler;
61+
sigset_t sa_mask;
62+
int sa_flags;
63+
};
7364

74-
#ifdef __ARMCC_VERSION
65+
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
66+
#define SIG_BLOCK 1 /* set of signals to block */
67+
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
7568

69+
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
70+
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
71+
#define sigemptyset(what) (*(what) = 0, 0)
72+
#define sigfillset(what) (*(what) = ~(0), 0)
73+
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
74+
75+
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
76+
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
77+
78+
#ifdef __ARMCC_VERSION
7679
#define SIGHUP 1
7780
/* #define SIGINT 2 */
7881
#define SIGQUIT 3
@@ -103,28 +106,9 @@ typedef unsigned long sigset_t;
103106
#define SIGRTMAX 31
104107
#define NSIG 32
105108

106-
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
107-
#define SIG_BLOCK 1 /* set of signals to block */
108-
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
109-
110-
struct sigaction
111-
{
112-
_sig_func_ptr sa_handler;
113-
sigset_t sa_mask;
114-
int sa_flags;
115-
};
116-
117-
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
118-
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
119-
#define sigemptyset(what) (*(what) = 0, 0)
120-
#define sigfillset(what) (*(what) = ~(0), 0)
121-
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
122-
123-
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
124-
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
109+
#include <signal.h>
125110

126111
#elif defined(__IAR_SYSTEMS_ICC__)
127-
128112
#define SIGHUP 1
129113
#define SIGINT 2
130114
#define SIGQUIT 3
@@ -155,25 +139,51 @@ int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact)
155139
#define SIGRTMAX 31
156140
#define NSIG 32
157141

158-
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
159-
#define SIG_BLOCK 1 /* set of signals to block */
160-
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
161-
162-
struct sigaction
163-
{
164-
_sig_func_ptr sa_handler;
165-
sigset_t sa_mask;
166-
int sa_flags;
167-
};
142+
#include <signal.h>
168143

169-
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
170-
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
171-
#define sigemptyset(what) (*(what) = 0, 0)
172-
#define sigfillset(what) (*(what) = ~(0), 0)
173-
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
144+
#elif defined(__GNUC__)
145+
#define SIGHUP 1 /* hangup */
146+
#define SIGINT 2 /* interrupt */
147+
#define SIGQUIT 3 /* quit */
148+
#define SIGILL 4 /* illegal instruction (not reset when caught) */
149+
#define SIGTRAP 5 /* trace trap (not reset when caught) */
150+
#define SIGIOT 6 /* IOT instruction */
151+
#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */
152+
#define SIGEMT 7 /* EMT instruction */
153+
#define SIGFPE 8 /* floating point exception */
154+
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
155+
#define SIGBUS 10 /* bus error */
156+
#define SIGSEGV 11 /* segmentation violation */
157+
#define SIGSYS 12 /* bad argument to system call */
158+
#define SIGPIPE 13 /* write on a pipe with no one to read it */
159+
#define SIGALRM 14 /* alarm clock */
160+
#define SIGTERM 15 /* software termination signal from kill */
161+
#define SIGURG 16 /* urgent condition on IO channel */
162+
#define SIGSTOP 17 /* sendable stop signal not from tty */
163+
#define SIGTSTP 18 /* stop signal from tty */
164+
#define SIGCONT 19 /* continue a stopped process */
165+
#define SIGCHLD 20 /* to parent on child stop or exit */
166+
#define SIGCLD 20 /* System V name for SIGCHLD */
167+
#define SIGTTIN 21 /* to readers pgrp upon background tty read */
168+
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
169+
#define SIGIO 23 /* input/output possible signal */
170+
#define SIGPOLL SIGIO /* System V name for SIGIO */
171+
#define SIGXCPU 24 /* exceeded CPU time limit */
172+
#define SIGXFSZ 25 /* exceeded file size limit */
173+
#define SIGVTALRM 26 /* virtual time alarm */
174+
#define SIGPROF 27 /* profiling time alarm */
175+
#define SIGWINCH 28 /* window changed */
176+
#define SIGLOST 29 /* resource lost (eg, record-lock lost) */
177+
#define SIGUSR1 30 /* user defined signal 1 */
178+
#define SIGUSR2 31 /* user defined signal 2 */
179+
#define NSIG 32 /* signal 0 implied */
180+
181+
#ifndef _SIGNAL_H_
182+
/* Some applications take advantage of the fact that <sys/signal.h>
183+
* and <signal.h> are equivalent in glibc. Allow for that here. */
184+
#include <signal.h>
185+
#endif
174186

175-
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
176-
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
177187
#endif
178188

179189
#ifdef __cplusplus

components/libc/pthreads/mqueue.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <string.h>
11+
#include <sys/signal.h>
1112
#include "mqueue.h"
1213
#include "pthread_internal.h"
1314

0 commit comments

Comments
 (0)