mirror of https://github.com/RT-Thread/rt-thread
[Kernel] header files
1. Remove components.h file; 2. Add libc_* files for standard libc definitions; 3. Add rtdbg.h file for simple debug log; 4. Add single list implementation; 5. Change the 'rt_uint8_t' type of cmd to 'int'.
This commit is contained in:
parent
8bdf993bfc
commit
cd215b2545
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* File : components.h
|
||||
* header for RT-Thread components
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2012-2015, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2012-09-20 Bernard Change the name to components.h
|
||||
* And all components related header files.
|
||||
* 2015-02-06 Bernard Rename the components.h to rtcom.h
|
||||
* 2015-03-22 Bernard Keep the compatibility.
|
||||
*/
|
||||
|
||||
#ifndef COMPONENTS_H__
|
||||
#define COMPONENTS_H__
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <finsh.h>
|
||||
#include <shell.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_LWIP
|
||||
#include <lwip/sys.h>
|
||||
#include <netif/ethernetif.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
#include <dfs_init.h>
|
||||
#include <dfs_fs.h>
|
||||
#ifdef RT_USING_DFS_ELMFAT
|
||||
#include <dfs_elm.h>
|
||||
#endif
|
||||
#if defined(RT_USING_LWIP) && defined(RT_USING_DFS_NFS)
|
||||
#include <dfs_nfs.h>
|
||||
#endif
|
||||
#ifdef RT_USING_DFS_ROMFS
|
||||
#include <dfs_romfs.h>
|
||||
#endif
|
||||
#ifdef RT_USING_DFS_DEVFS
|
||||
#include <devfs.h>
|
||||
#endif
|
||||
#ifdef RT_USING_DFS_UFFS
|
||||
#include <dfs_uffs.h>
|
||||
#endif
|
||||
#ifdef RT_USING_DFS_JFFS2
|
||||
#include <dfs_jffs2.h>
|
||||
#endif
|
||||
#ifdef RT_USING_DFS_YAFFS2
|
||||
#include <dfs_yaffs2.h>
|
||||
#endif
|
||||
#ifdef RT_USING_DFS_RAMFS
|
||||
#include <dfs_ramfs.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_PTHREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
#include <rtm.h>
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef LIBC_DIRENT_H__
|
||||
#define LIBC_DIRENT_H__
|
||||
|
||||
#define DT_UNKNOWN 0x00
|
||||
#define DT_REG 0x01
|
||||
#define DT_DIR 0x02
|
||||
|
||||
#endif
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* File : libc_errno.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2016-11-12 Bernard The first version
|
||||
*/
|
||||
|
||||
#ifndef LIBC_ERRNO_H__
|
||||
#define LIBC_ERRNO_H__
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
#ifdef RT_USING_NEWLIB
|
||||
/* use errno.h file in newlib */
|
||||
#include <errno.h>
|
||||
#else
|
||||
/* define errno self. */
|
||||
#define EPERM 1
|
||||
#define ENOENT 2
|
||||
#define ESRCH 3
|
||||
#define EINTR 4
|
||||
#define EIO 5
|
||||
#define ENXIO 6
|
||||
#define E2BIG 7
|
||||
#define ENOEXEC 8
|
||||
#define EBADF 9
|
||||
#define ECHILD 10
|
||||
#define EAGAIN 11
|
||||
#define ENOMEM 12
|
||||
#define EACCES 13
|
||||
#define EFAULT 14
|
||||
#define ENOTBLK 15
|
||||
#define EBUSY 16
|
||||
#define EEXIST 17
|
||||
#define EXDEV 18
|
||||
#define ENODEV 19
|
||||
#define ENOTDIR 20
|
||||
#define EISDIR 21
|
||||
#define EINVAL 22
|
||||
#define ENFILE 23
|
||||
#define EMFILE 24
|
||||
#define ENOTTY 25
|
||||
#define ETXTBSY 26
|
||||
#define EFBIG 27
|
||||
#define ENOSPC 28
|
||||
#define ESPIPE 29
|
||||
#define EROFS 30
|
||||
#define EMLINK 31
|
||||
#define EPIPE 32
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
#define EDEADLK 35
|
||||
#define ENAMETOOLONG 36
|
||||
#define ENOLCK 37
|
||||
#define ENOSYS 38
|
||||
#define ENOTEMPTY 39
|
||||
#define ELOOP 40
|
||||
#define EWOULDBLOCK EAGAIN
|
||||
#define ENOMSG 42
|
||||
#define EIDRM 43
|
||||
#define ECHRNG 44
|
||||
#define EL2NSYNC 45
|
||||
#define EL3HLT 46
|
||||
#define EL3RST 47
|
||||
#define ELNRNG 48
|
||||
#define EUNATCH 49
|
||||
#define ENOCSI 50
|
||||
#define EL2HLT 51
|
||||
#define EBADE 52
|
||||
#define EBADR 53
|
||||
#define EXFULL 54
|
||||
#define ENOANO 55
|
||||
#define EBADRQC 56
|
||||
#define EBADSLT 57
|
||||
#define EDEADLOCK EDEADLK
|
||||
#define EBFONT 59
|
||||
#define ENOSTR 60
|
||||
#define ENODATA 61
|
||||
#define ETIME 62
|
||||
#define ENOSR 63
|
||||
#define ENONET 64
|
||||
#define ENOPKG 65
|
||||
#define EREMOTE 66
|
||||
#define ENOLINK 67
|
||||
#define EADV 68
|
||||
#define ESRMNT 69
|
||||
#define ECOMM 70
|
||||
#define EPROTO 71
|
||||
#define EMULTIHOP 72
|
||||
#define EDOTDOT 73
|
||||
#define EBADMSG 74
|
||||
#define EOVERFLOW 75
|
||||
#define ENOTUNIQ 76
|
||||
#define EBADFD 77
|
||||
#define EREMCHG 78
|
||||
#define ELIBACC 79
|
||||
#define ELIBBAD 80
|
||||
#define ELIBSCN 81
|
||||
#define ELIBMAX 82
|
||||
#define ELIBEXEC 83
|
||||
#define EILSEQ 84
|
||||
#define ERESTART 85
|
||||
#define ESTRPIPE 86
|
||||
#define EUSERS 87
|
||||
#define ENOTSOCK 88
|
||||
#define EDESTADDRREQ 89
|
||||
#define EMSGSIZE 90
|
||||
#define EPROTOTYPE 91
|
||||
#define ENOPROTOOPT 92
|
||||
#define EPROTONOSUPPORT 93
|
||||
#define ESOCKTNOSUPPORT 94
|
||||
#define EOPNOTSUPP 95
|
||||
#define ENOTSUP EOPNOTSUPP
|
||||
#define EPFNOSUPPORT 96
|
||||
#define EAFNOSUPPORT 97
|
||||
#define EADDRINUSE 98
|
||||
#define EADDRNOTAVAIL 99
|
||||
#define ENETDOWN 100
|
||||
#define ENETUNREACH 101
|
||||
#define ENETRESET 102
|
||||
#define ECONNABORTED 103
|
||||
#define ECONNRESET 104
|
||||
#define ENOBUFS 105
|
||||
#define EISCONN 106
|
||||
#define ENOTCONN 107
|
||||
#define ESHUTDOWN 108
|
||||
#define ETOOMANYREFS 109
|
||||
#define ETIMEDOUT 110
|
||||
#define ECONNREFUSED 111
|
||||
#define EHOSTDOWN 112
|
||||
#define EHOSTUNREACH 113
|
||||
#define EALREADY 114
|
||||
#define EINPROGRESS 115
|
||||
#define ESTALE 116
|
||||
#define EUCLEAN 117
|
||||
#define ENOTNAM 118
|
||||
#define ENAVAIL 119
|
||||
#define EISNAM 120
|
||||
#define EREMOTEIO 121
|
||||
#define EDQUOT 122
|
||||
#define ENOMEDIUM 123
|
||||
#define EMEDIUMTYPE 124
|
||||
#define ECANCELED 125
|
||||
#define ENOKEY 126
|
||||
#define EKEYEXPIRED 127
|
||||
#define EKEYREVOKED 128
|
||||
#define EKEYREJECTED 129
|
||||
#define EOWNERDEAD 130
|
||||
#define ENOTRECOVERABLE 131
|
||||
#define ERFKILL 132
|
||||
#define EHWPOISON 133
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* fcntl.h file in libc
|
||||
*/
|
||||
#ifndef LIBC_FCNTL_H__
|
||||
#define LIBC_FCNTL_H__
|
||||
|
||||
#define O_RDONLY 00
|
||||
#define O_WRONLY 01
|
||||
#define O_RDWR 02
|
||||
|
||||
#define O_CREAT 0100
|
||||
#define O_EXCL 0200
|
||||
#define O_NOCTTY 0400
|
||||
#define O_TRUNC 01000
|
||||
#define O_APPEND 02000
|
||||
#define O_NONBLOCK 04000
|
||||
#define O_DSYNC 010000
|
||||
#define O_SYNC 04010000
|
||||
#define O_RSYNC 04010000
|
||||
#define O_DIRECTORY 0200000
|
||||
#define O_NOFOLLOW 0400000
|
||||
#define O_CLOEXEC 02000000
|
||||
|
||||
#define O_ASYNC 020000
|
||||
#define O_DIRECT 040000
|
||||
#define O_LARGEFILE 0100000
|
||||
#define O_NOATIME 01000000
|
||||
#define O_PATH 010000000
|
||||
#define O_TMPFILE 020200000
|
||||
#define O_NDELAY O_NONBLOCK
|
||||
|
||||
#define O_SEARCH O_PATH
|
||||
#define O_EXEC O_PATH
|
||||
|
||||
#define O_ACCMODE (03|O_SEARCH)
|
||||
|
||||
#define F_DUPFD 0
|
||||
#define F_GETFD 1
|
||||
#define F_SETFD 2
|
||||
#define F_GETFL 3
|
||||
#define F_SETFL 4
|
||||
|
||||
#define F_SETOWN 8
|
||||
#define F_GETOWN 9
|
||||
#define F_SETSIG 10
|
||||
#define F_GETSIG 11
|
||||
|
||||
#define F_GETLK 12
|
||||
#define F_SETLK 13
|
||||
#define F_SETLKW 14
|
||||
|
||||
#define F_SETOWN_EX 15
|
||||
#define F_GETOWN_EX 16
|
||||
|
||||
#define F_GETOWNER_UIDS 17
|
||||
|
||||
#endif
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
* File : libc_ioctl.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-01-21 Bernard the first version
|
||||
*/
|
||||
|
||||
#ifndef LIBC_IOCTL_H__
|
||||
#define LIBC_IOCTL_H__
|
||||
|
||||
#define _IOC(a,b,c,d) ( ((a)<<30) | ((b)<<8) | (c) | ((d)<<16) )
|
||||
#define _IOC_NONE 0U
|
||||
#define _IOC_WRITE 1U
|
||||
#define _IOC_READ 2U
|
||||
|
||||
#define _IO(a,b) _IOC(_IOC_NONE,(a),(b),0)
|
||||
#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),sizeof(c))
|
||||
#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),sizeof(c))
|
||||
#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),sizeof(c))
|
||||
|
||||
#define FIONREAD _IOR('f', 127, int) /* get # bytes to read */
|
||||
#define FIONBIO _IOW('f', 126, int) /* set/clear non-blocking i/o */
|
||||
#define FIONWRITE _IOR('f', 121, int) /* get # bytes outstanding
|
||||
* in send queue. */
|
||||
|
||||
#define TCGETS 0x5401
|
||||
#define TCSETS 0x5402
|
||||
#define TCSETSW 0x5403
|
||||
#define TCSETSF 0x5404
|
||||
#define TCGETA 0x5405
|
||||
#define TCSETA 0x5406
|
||||
#define TCSETAW 0x5407
|
||||
#define TCSETAF 0x5408
|
||||
#define TCSBRK 0x5409
|
||||
#define TCXONC 0x540A
|
||||
#define TCFLSH 0x540B
|
||||
#define TIOCEXCL 0x540C
|
||||
#define TIOCNXCL 0x540D
|
||||
#define TIOCSCTTY 0x540E
|
||||
#define TIOCGPGRP 0x540F
|
||||
#define TIOCSPGRP 0x5410
|
||||
#define TIOCOUTQ 0x5411
|
||||
#define TIOCSTI 0x5412
|
||||
#define TIOCGWINSZ 0x5413
|
||||
#define TIOCSWINSZ 0x5414
|
||||
#define TIOCMGET 0x5415
|
||||
#define TIOCMBIS 0x5416
|
||||
#define TIOCMBIC 0x5417
|
||||
#define TIOCMSET 0x5418
|
||||
#define TIOCGSOFTCAR 0x5419
|
||||
#define TIOCSSOFTCAR 0x541A
|
||||
// #define FIONREAD 0x541B
|
||||
#define TIOCINQ FIONREAD
|
||||
#define TIOCLINUX 0x541C
|
||||
#define TIOCCONS 0x541D
|
||||
#define TIOCGSERIAL 0x541E
|
||||
#define TIOCSSERIAL 0x541F
|
||||
#define TIOCPKT 0x5420
|
||||
// #define FIONBIO 0x5421
|
||||
#define TIOCNOTTY 0x5422
|
||||
#define TIOCSETD 0x5423
|
||||
#define TIOCGETD 0x5424
|
||||
#define TCSBRKP 0x5425
|
||||
#define TIOCSBRK 0x5427
|
||||
#define TIOCCBRK 0x5428
|
||||
#define TIOCGSID 0x5429
|
||||
#define TIOCGRS485 0x542E
|
||||
#define TIOCSRS485 0x542F
|
||||
#define TIOCGPTN 0x80045430
|
||||
#define TIOCSPTLCK 0x40045431
|
||||
#define TIOCGDEV 0x80045432
|
||||
#define TCGETX 0x5432
|
||||
#define TCSETX 0x5433
|
||||
#define TCSETXF 0x5434
|
||||
#define TCSETXW 0x5435
|
||||
#define TIOCSIG 0x40045436
|
||||
#define TIOCVHANGUP 0x5437
|
||||
#define TIOCGPKT 0x80045438
|
||||
#define TIOCGPTLCK 0x80045439
|
||||
#define TIOCGEXCL 0x80045440
|
||||
|
||||
#define FIONCLEX 0x5450
|
||||
#define FIOCLEX 0x5451
|
||||
#define FIOASYNC 0x5452
|
||||
#define TIOCSERCONFIG 0x5453
|
||||
#define TIOCSERGWILD 0x5454
|
||||
#define TIOCSERSWILD 0x5455
|
||||
#define TIOCGLCKTRMIOS 0x5456
|
||||
#define TIOCSLCKTRMIOS 0x5457
|
||||
#define TIOCSERGSTRUCT 0x5458
|
||||
#define TIOCSERGETLSR 0x5459
|
||||
#define TIOCSERGETMULTI 0x545A
|
||||
#define TIOCSERSETMULTI 0x545B
|
||||
|
||||
#define TIOCMIWAIT 0x545C
|
||||
#define TIOCGICOUNT 0x545D
|
||||
#define FIOQSIZE 0x5460
|
||||
|
||||
#define TIOCPKT_DATA 0
|
||||
#define TIOCPKT_FLUSHREAD 1
|
||||
#define TIOCPKT_FLUSHWRITE 2
|
||||
#define TIOCPKT_STOP 4
|
||||
#define TIOCPKT_START 8
|
||||
#define TIOCPKT_NOSTOP 16
|
||||
#define TIOCPKT_DOSTOP 32
|
||||
#define TIOCPKT_IOCTL 64
|
||||
|
||||
#define TIOCSER_TEMT 0x01
|
||||
|
||||
struct winsize {
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
unsigned short ws_xpixel;
|
||||
unsigned short ws_ypixel;
|
||||
};
|
||||
|
||||
#define TIOCM_LE 0x001
|
||||
#define TIOCM_DTR 0x002
|
||||
#define TIOCM_RTS 0x004
|
||||
#define TIOCM_ST 0x008
|
||||
#define TIOCM_SR 0x010
|
||||
#define TIOCM_CTS 0x020
|
||||
#define TIOCM_CAR 0x040
|
||||
#define TIOCM_RNG 0x080
|
||||
#define TIOCM_DSR 0x100
|
||||
#define TIOCM_CD TIOCM_CAR
|
||||
#define TIOCM_RI TIOCM_RNG
|
||||
#define TIOCM_OUT1 0x2000
|
||||
#define TIOCM_OUT2 0x4000
|
||||
#define TIOCM_LOOP 0x8000
|
||||
|
||||
#define N_TTY 0
|
||||
#define N_SLIP 1
|
||||
#define N_MOUSE 2
|
||||
#define N_PPP 3
|
||||
#define N_STRIP 4
|
||||
#define N_AX25 5
|
||||
#define N_X25 6
|
||||
#define N_6PACK 7
|
||||
#define N_MASC 8
|
||||
#define N_R3964 9
|
||||
#define N_PROFIBUS_FDL 10
|
||||
#define N_IRDA 11
|
||||
#define N_SMSBLOCK 12
|
||||
#define N_HDLC 13
|
||||
#define N_SYNC_PPP 14
|
||||
#define N_HCI 15
|
||||
|
||||
#define FIOSETOWN 0x8901
|
||||
#define SIOCSPGRP 0x8902
|
||||
#define FIOGETOWN 0x8903
|
||||
#define SIOCGPGRP 0x8904
|
||||
// #define SIOCATMARK 0x8905
|
||||
#define SIOCGSTAMP 0x8906
|
||||
#define SIOCGSTAMPNS 0x8907
|
||||
|
||||
#define SIOCADDRT 0x890B
|
||||
#define SIOCDELRT 0x890C
|
||||
#define SIOCRTMSG 0x890D
|
||||
|
||||
#define SIOCGIFNAME 0x8910
|
||||
#define SIOCSIFLINK 0x8911
|
||||
#define SIOCGIFCONF 0x8912
|
||||
#define SIOCGIFFLAGS 0x8913
|
||||
#define SIOCSIFFLAGS 0x8914
|
||||
#define SIOCGIFADDR 0x8915
|
||||
#define SIOCSIFADDR 0x8916
|
||||
#define SIOCGIFDSTADDR 0x8917
|
||||
#define SIOCSIFDSTADDR 0x8918
|
||||
#define SIOCGIFBRDADDR 0x8919
|
||||
#define SIOCSIFBRDADDR 0x891a
|
||||
#define SIOCGIFNETMASK 0x891b
|
||||
#define SIOCSIFNETMASK 0x891c
|
||||
#define SIOCGIFMETRIC 0x891d
|
||||
#define SIOCSIFMETRIC 0x891e
|
||||
#define SIOCGIFMEM 0x891f
|
||||
#define SIOCSIFMEM 0x8920
|
||||
#define SIOCGIFMTU 0x8921
|
||||
#define SIOCSIFMTU 0x8922
|
||||
#define SIOCSIFNAME 0x8923
|
||||
#define SIOCSIFHWADDR 0x8924
|
||||
#define SIOCGIFENCAP 0x8925
|
||||
#define SIOCSIFENCAP 0x8926
|
||||
#define SIOCGIFHWADDR 0x8927
|
||||
#define SIOCGIFSLAVE 0x8929
|
||||
#define SIOCSIFSLAVE 0x8930
|
||||
#define SIOCADDMULTI 0x8931
|
||||
#define SIOCDELMULTI 0x8932
|
||||
#define SIOCGIFINDEX 0x8933
|
||||
#define SIOGIFINDEX SIOCGIFINDEX
|
||||
#define SIOCSIFPFLAGS 0x8934
|
||||
#define SIOCGIFPFLAGS 0x8935
|
||||
#define SIOCDIFADDR 0x8936
|
||||
#define SIOCSIFHWBROADCAST 0x8937
|
||||
#define SIOCGIFCOUNT 0x8938
|
||||
|
||||
#define SIOCGIFBR 0x8940
|
||||
#define SIOCSIFBR 0x8941
|
||||
|
||||
#define SIOCGIFTXQLEN 0x8942
|
||||
#define SIOCSIFTXQLEN 0x8943
|
||||
|
||||
#define SIOCDARP 0x8953
|
||||
#define SIOCGARP 0x8954
|
||||
#define SIOCSARP 0x8955
|
||||
|
||||
#define SIOCDRARP 0x8960
|
||||
#define SIOCGRARP 0x8961
|
||||
#define SIOCSRARP 0x8962
|
||||
|
||||
#define SIOCGIFMAP 0x8970
|
||||
#define SIOCSIFMAP 0x8971
|
||||
|
||||
#define SIOCADDDLCI 0x8980
|
||||
#define SIOCDELDLCI 0x8981
|
||||
|
||||
#define SIOCDEVPRIVATE 0x89F0
|
||||
#define SIOCPROTOPRIVATE 0x89E0
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* File : libc_signal.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-09-12 Bernard The first version
|
||||
*/
|
||||
|
||||
#ifndef LIBC_SIGNAL_H__
|
||||
#define LIBC_SIGNAL_H__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
union sigval
|
||||
{
|
||||
int sival_int; /* Integer signal value */
|
||||
void *sival_ptr; /* Pointer signal value */
|
||||
};
|
||||
|
||||
struct siginfo
|
||||
{
|
||||
rt_uint8_t si_signo;
|
||||
rt_uint8_t si_code;
|
||||
rt_int16_t si_errno;
|
||||
|
||||
union sigval si_value;
|
||||
};
|
||||
typedef struct siginfo siginfo_t;
|
||||
|
||||
#define SI_USER 0x01 /* Signal sent by kill(). */
|
||||
#define SI_QUEUE 0x02 /* Signal sent by sigqueue(). */
|
||||
#define SI_TIMER 0x03 /* Signal generated by expiration of a
|
||||
timer set by timer_settime(). */
|
||||
#define SI_ASYNCIO 0x04 /* Signal generated by completion of an
|
||||
asynchronous I/O request. */
|
||||
#define SI_MESGQ 0x05 /* Signal generated by arrival of a
|
||||
message on an empty message queue. */
|
||||
|
||||
#ifdef RT_USING_NEWLIB
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef __CC_ARM
|
||||
#include <signal.h>
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
#define SIGHUP 1
|
||||
// #define SIGINT 2
|
||||
#define SIGQUIT 3
|
||||
// #define SIGILL 4
|
||||
#define SIGTRAP 5
|
||||
// #define SIGABRT 6
|
||||
#define SIGEMT 7
|
||||
// #define SIGFPE 8
|
||||
#define SIGKILL 9
|
||||
#define SIGBUS 10
|
||||
// #define SIGSEGV 11
|
||||
#define SIGSYS 12
|
||||
#define SIGPIPE 13
|
||||
#define SIGALRM 14
|
||||
// #define SIGTERM 15
|
||||
#define SIGURG 16
|
||||
#define SIGSTOP 17
|
||||
#define SIGTSTP 18
|
||||
#define SIGCONT 19
|
||||
#define SIGCHLD 20
|
||||
#define SIGTTIN 21
|
||||
#define SIGTTOU 22
|
||||
#define SIGPOLL 23
|
||||
#define SIGWINCH 24
|
||||
// #define SIGUSR1 25
|
||||
// #define SIGUSR2 26
|
||||
#define SIGRTMIN 27
|
||||
#define SIGRTMAX 31
|
||||
#define NSIG 32
|
||||
|
||||
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
|
||||
#define SIG_BLOCK 1 /* set of signals to block */
|
||||
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
||||
|
||||
typedef void (*_sig_func_ptr)(int);
|
||||
|
||||
struct sigaction
|
||||
{
|
||||
_sig_func_ptr sa_handler;
|
||||
sigset_t sa_mask;
|
||||
int sa_flags;
|
||||
};
|
||||
|
||||
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
|
||||
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
|
||||
#define sigemptyset(what) (*(what) = 0, 0)
|
||||
#define sigfillset(what) (*(what) = ~(0), 0)
|
||||
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
|
||||
|
||||
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
|
||||
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
||||
|
||||
#elif defined(__IAR_SYSTEMS_ICC__)
|
||||
#include <signal.h>
|
||||
typedef unsigned long sigset_t;
|
||||
|
||||
#define SIGHUP 1
|
||||
#define SIGINT 2
|
||||
#define SIGQUIT 3
|
||||
#define SIGILL 4
|
||||
#define SIGTRAP 5
|
||||
// #define SIGABRT 6
|
||||
#define SIGEMT 7
|
||||
#define SIGFPE 8
|
||||
#define SIGKILL 9
|
||||
#define SIGBUS 10
|
||||
#define SIGSEGV 11
|
||||
#define SIGSYS 12
|
||||
#define SIGPIPE 13
|
||||
#define SIGALRM 14
|
||||
#define SIGTERM 15
|
||||
#define SIGURG 16
|
||||
#define SIGSTOP 17
|
||||
#define SIGTSTP 18
|
||||
#define SIGCONT 19
|
||||
#define SIGCHLD 20
|
||||
#define SIGTTIN 21
|
||||
#define SIGTTOU 22
|
||||
#define SIGPOLL 23
|
||||
#define SIGWINCH 24
|
||||
#define SIGUSR1 25
|
||||
#define SIGUSR2 26
|
||||
#define SIGRTMIN 27
|
||||
#define SIGRTMAX 31
|
||||
#define NSIG 32
|
||||
|
||||
#define SIG_SETMASK 0 /* set mask with sigprocmask() */
|
||||
#define SIG_BLOCK 1 /* set of signals to block */
|
||||
#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */
|
||||
|
||||
typedef void (*_sig_func_ptr)(int);
|
||||
|
||||
struct sigaction
|
||||
{
|
||||
_sig_func_ptr sa_handler;
|
||||
sigset_t sa_mask;
|
||||
int sa_flags;
|
||||
};
|
||||
|
||||
#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0)
|
||||
#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0)
|
||||
#define sigemptyset(what) (*(what) = 0, 0)
|
||||
#define sigfillset(what) (*(what) = ~(0), 0)
|
||||
#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0)
|
||||
|
||||
int sigprocmask (int how, const sigset_t *set, sigset_t *oset);
|
||||
int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef LIBC_STAT_H__
|
||||
#define LIBC_STAT_H__
|
||||
|
||||
#define S_IFMT 00170000
|
||||
#define S_IFSOCK 0140000
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFREG 0100000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFIFO 0010000
|
||||
#define S_ISUID 0004000
|
||||
#define S_ISGID 0002000
|
||||
#define S_ISVTX 0001000
|
||||
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
|
||||
#define S_IRWXU 00700
|
||||
#define S_IRUSR 00400
|
||||
#define S_IWUSR 00200
|
||||
#define S_IXUSR 00100
|
||||
|
||||
#define S_IRWXG 00070
|
||||
#define S_IRGRP 00040
|
||||
#define S_IWGRP 00020
|
||||
#define S_IXGRP 00010
|
||||
|
||||
#define S_IRWXO 00007
|
||||
#define S_IROTH 00004
|
||||
#define S_IWOTH 00002
|
||||
#define S_IXOTH 00001
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* File : rtdbg.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2016, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2016-11-12 Bernard The first version
|
||||
*/
|
||||
|
||||
/*
|
||||
* The macro definitions for debug
|
||||
*
|
||||
* These macros are defined in static. If you want to use debug macro, you can
|
||||
* use as following code:
|
||||
*
|
||||
* In your C/C++ file, enable/disable DEBUG_ENABLE macro, and then include this
|
||||
* header file.
|
||||
*
|
||||
* #define DBG_SECTION_NAME "[ MOD]"
|
||||
* #define DEBUG_ENABLE // enable debug macro
|
||||
* #define DEBUG_LEVEL DBG_INFO
|
||||
* #include <rtdbg.h> // must after of DEBUG_ENABLE or some other options
|
||||
*
|
||||
* Then in your C/C++ file, you can use dbg_log macro to print out logs:
|
||||
* dbg_log(DBG_INFO, "this is a log!\n");
|
||||
*
|
||||
* Or if you want to use different color for different kinds log, you can
|
||||
* #define DEBUG_COLOR
|
||||
*/
|
||||
|
||||
#ifndef RT_DBG_H__
|
||||
#define RT_DBG_H__
|
||||
|
||||
#include <rtconfig.h>
|
||||
|
||||
/* DEBUG level */
|
||||
#define DBG_LOG 0
|
||||
#define DBG_INFO 1
|
||||
#define DBG_WARNING 2
|
||||
#define DBG_ERROR 3
|
||||
|
||||
#ifndef DBG_SECTION_NAME
|
||||
#define DBG_SECTION_NAME "[ DBG]"
|
||||
#endif
|
||||
|
||||
#ifdef DBG_ENABLE
|
||||
|
||||
#ifndef DBG_LEVEL
|
||||
#define DBG_LEVEL DBG_WARNING
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The color for terminal (foreground)
|
||||
* BLACK 30
|
||||
* RED 31
|
||||
* GREEN 32
|
||||
* YELLOW 33
|
||||
* BLUE 34
|
||||
* PURPLE 35
|
||||
* CYAN 36
|
||||
* WHITE 37
|
||||
*/
|
||||
#ifdef DBG_COLOR
|
||||
#define _DBG_COLOR(n) rt_kprintf("\033["#n"m")
|
||||
#else
|
||||
#define _DBG_COLOR(n)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* static debug routine
|
||||
*/
|
||||
#define dbg_log(level, fmt, ...) \
|
||||
if ((level) >= DBG_LEVEL) \
|
||||
{ \
|
||||
switch(level) \
|
||||
{ \
|
||||
case DBG_ERROR: _DBG_COLOR(31); break; \
|
||||
case DBG_WARNING: _DBG_COLOR(33); break; \
|
||||
case DBG_INFO: _DBG_COLOR(32); break; \
|
||||
default: break; \
|
||||
} \
|
||||
rt_kprintf(DBG_SECTION_NAME fmt, ##__VA_ARGS__); \
|
||||
_DBG_COLOR(0); \
|
||||
}
|
||||
|
||||
#define dbg_here \
|
||||
if ((DBG_LEVEL) >= DBG_LOG){ \
|
||||
rt_kprintf(DBG_SECTION_NAME " Here %s:%d\n", \
|
||||
__FUNCTION__, __LINE__); \
|
||||
}
|
||||
|
||||
#define dbg_enter \
|
||||
if ((DBG_LEVEL) >= DBG_LOG){ \
|
||||
_DBG_COLOR(32); \
|
||||
rt_kprintf(DBG_SECTION_NAME " Enter %s\n", \
|
||||
__FUNCTION__); \
|
||||
_DBG_COLOR(0); \
|
||||
}
|
||||
|
||||
#define dbg_exit \
|
||||
if ((DBG_LEVEL) >= DBG_LOG){ \
|
||||
_DBG_COLOR(32); \
|
||||
rt_kprintf(DBG_SECTION_NAME " Exit %s:%d\n", \
|
||||
__FUNCTION__); \
|
||||
_DBG_COLOR(0); \
|
||||
}
|
||||
|
||||
#else
|
||||
#define dbg_log(level, fmt, ...)
|
||||
#define dbg_here
|
||||
#define dbg_enter
|
||||
#define dbg_exit
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
* 2012-12-30 Bernard add more control command for graphic.
|
||||
* 2013-01-09 Bernard change version number.
|
||||
* 2015-02-01 Bernard change version number to v2.1.0
|
||||
* 2016-08-31 Bernard change version number to v3.0.0
|
||||
*/
|
||||
|
||||
#ifndef __RT_DEF_H__
|
||||
|
@ -201,6 +202,8 @@ typedef int (*init_fn_t)(void);
|
|||
/* device/component/fs/app init routines will be called in init_thread */
|
||||
/* device initialization */
|
||||
#define INIT_DEVICE_EXPORT(fn) INIT_EXPORT(fn, "2")
|
||||
/* components pre-initialization (pure software initilization) */
|
||||
#define INIT_PREV_EXPORT(fn) INIT_EXPORT(fn, "2")
|
||||
/* components initialization (dfs, lwip, ...) */
|
||||
#define INIT_COMPONENT_EXPORT(fn) INIT_EXPORT(fn, "3")
|
||||
/* file system initialization (dfs-elm, dfs-rom, ...) */
|
||||
|
@ -259,6 +262,8 @@ typedef int (*init_fn_t)(void);
|
|||
#define RT_ENOSYS 6 /**< No system */
|
||||
#define RT_EBUSY 7 /**< Busy */
|
||||
#define RT_EIO 8 /**< IO error */
|
||||
#define RT_EINTR 9 /**< Interrupted system call */
|
||||
#define RT_EINVAL 10 /**< Invalid argument */
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
@ -288,6 +293,9 @@ typedef int (*init_fn_t)(void);
|
|||
*/
|
||||
#define RT_NULL (0)
|
||||
|
||||
/**
|
||||
* Double List structure
|
||||
*/
|
||||
struct rt_list_node
|
||||
{
|
||||
struct rt_list_node *next; /**< point to next node. */
|
||||
|
@ -295,6 +303,15 @@ struct rt_list_node
|
|||
};
|
||||
typedef struct rt_list_node rt_list_t; /**< Type for lists. */
|
||||
|
||||
/**
|
||||
* Single List structure
|
||||
*/
|
||||
struct rt_slist_node
|
||||
{
|
||||
struct rt_slist_node *next; /**< point to next node. */
|
||||
};
|
||||
typedef struct rt_slist_node rt_slist_t; /**< Type for single list. */
|
||||
|
||||
/**
|
||||
* @addtogroup KernelObject
|
||||
*/
|
||||
|
@ -446,6 +463,17 @@ typedef struct rt_timer *rt_timer_t;
|
|||
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup Signal
|
||||
*/
|
||||
#ifdef RT_USING_SIGNALS
|
||||
typedef unsigned long rt_sigset_t;
|
||||
typedef void (*rt_sighandler_t)(int signo);
|
||||
|
||||
#define RT_SIG_MAX 32
|
||||
#endif
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup Thread
|
||||
*/
|
||||
|
@ -466,6 +494,11 @@ typedef struct rt_timer *rt_timer_t;
|
|||
#define RT_THREAD_BLOCK RT_THREAD_SUSPEND /**< Blocked status */
|
||||
#define RT_THREAD_CLOSE 0x04 /**< Closed status */
|
||||
|
||||
#define RT_THREAD_STAT_MASK 0x0f
|
||||
|
||||
#define RT_THREAD_STAT_SIGNAL 0x10
|
||||
#define RT_THREAD_STAT_SIGNAL_READY (RT_THREAD_STAT_SIGNAL | RT_THREAD_READY)
|
||||
|
||||
/**
|
||||
* thread control command definitions
|
||||
*/
|
||||
|
@ -501,7 +534,7 @@ struct rt_thread
|
|||
/* error code */
|
||||
rt_err_t error; /**< error code */
|
||||
|
||||
rt_uint8_t stat; /**< thread stat */
|
||||
rt_uint8_t stat; /**< thread status */
|
||||
|
||||
/* priority */
|
||||
rt_uint8_t current_priority; /**< current priority */
|
||||
|
@ -518,6 +551,15 @@ struct rt_thread
|
|||
rt_uint8_t event_info;
|
||||
#endif
|
||||
|
||||
#if defined(RT_USING_SIGNALS)
|
||||
rt_sigset_t sig_pending; /**< the pending signals */
|
||||
rt_sigset_t sig_mask; /**< the mask bits of signal */
|
||||
|
||||
void *sig_ret; /**< the return stack pointer from signal */
|
||||
rt_sighandler_t *sig_vectors; /**< vectors of signal handler */
|
||||
void *si_list; /**< the signal infor list */
|
||||
#endif
|
||||
|
||||
rt_ubase_t init_tick; /**< thread's initialized tick */
|
||||
rt_ubase_t remaining_tick; /**< remaining tick */
|
||||
|
||||
|
@ -778,11 +820,6 @@ enum rt_device_class_type
|
|||
#define RT_DEVICE_FLAG_SUSPENDED 0x020 /**< device is suspended */
|
||||
#define RT_DEVICE_FLAG_STREAM 0x040 /**< stream mode */
|
||||
|
||||
#define RT_DEVICE_CTRL_CONFIG 0x03 /* configure device */
|
||||
#define RT_DEVICE_CTRL_SET_INT 0x10 /* enable receive irq */
|
||||
#define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable receive irq */
|
||||
#define RT_DEVICE_CTRL_GET_INT 0x12
|
||||
|
||||
#define RT_DEVICE_FLAG_INT_RX 0x100 /**< INT mode on Rx */
|
||||
#define RT_DEVICE_FLAG_DMA_RX 0x200 /**< DMA mode on Rx */
|
||||
#define RT_DEVICE_FLAG_INT_TX 0x400 /**< INT mode on Tx */
|
||||
|
@ -793,12 +830,18 @@ enum rt_device_class_type
|
|||
#define RT_DEVICE_OFLAG_WRONLY 0x002 /**< write only access */
|
||||
#define RT_DEVICE_OFLAG_RDWR 0x003 /**< read and write */
|
||||
#define RT_DEVICE_OFLAG_OPEN 0x008 /**< device is opened */
|
||||
#define RT_DEVICE_OFLAG_MASK 0xf0f /**< mask of open flag */
|
||||
|
||||
/**
|
||||
* general device commands
|
||||
*/
|
||||
#define RT_DEVICE_CTRL_RESUME 0x01 /**< resume device */
|
||||
#define RT_DEVICE_CTRL_SUSPEND 0x02 /**< suspend device */
|
||||
#define RT_DEVICE_CTRL_CONFIG 0x03 /**< configure device */
|
||||
|
||||
#define RT_DEVICE_CTRL_SET_INT 0x10 /**< set interrupt */
|
||||
#define RT_DEVICE_CTRL_CLR_INT 0x11 /**< clear interrupt */
|
||||
#define RT_DEVICE_CTRL_GET_INT 0x12 /**< get interrupt status */
|
||||
|
||||
/**
|
||||
* special device commands
|
||||
|
@ -840,7 +883,12 @@ struct rt_device
|
|||
rt_err_t (*close) (rt_device_t dev);
|
||||
rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
|
||||
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
|
||||
rt_err_t (*control)(rt_device_t dev, rt_uint8_t cmd, void *args);
|
||||
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
|
||||
|
||||
#if defined(RT_USING_DFS) && defined(RT_USING_DFS_DEVFS)
|
||||
const struct dfs_file_ops *fops;
|
||||
rt_list_t wait_queue;
|
||||
#endif
|
||||
|
||||
void *user_data; /**< device private data */
|
||||
};
|
||||
|
@ -991,6 +1039,8 @@ struct rt_module
|
|||
rt_uint16_t nsym; /**< number of symbol in the module */
|
||||
struct rt_module_symtab *symtab; /**< module symbol table */
|
||||
|
||||
rt_uint32_t user_data; /**< arch data in the module */
|
||||
|
||||
/* object in this module, module object is the last basic object type */
|
||||
struct rt_object_information module_object[RT_Object_Class_Unknown];
|
||||
};
|
||||
|
@ -999,8 +1049,24 @@ typedef struct rt_module *rt_module_t;
|
|||
/*@}*/
|
||||
#endif
|
||||
|
||||
/* definitions for libc */
|
||||
#include "rtlibc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* RT-Thread definitions for C++ */
|
||||
namespace rtthread {
|
||||
|
||||
enum TICK_WAIT {
|
||||
WAIT_NONE = 0,
|
||||
WAIT_FOREVER = -1,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* end of __cplusplus */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* File : rtlibc.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2017, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017-01-21 Bernard the first version
|
||||
*/
|
||||
|
||||
#ifndef RTLIBC_H__
|
||||
#define RTLIBC_H__
|
||||
|
||||
/* definitions for libc if toolchain has no these definitions */
|
||||
#include "libc/libc_stat.h"
|
||||
#include "libc/libc_errno.h"
|
||||
|
||||
#include "libc/libc_fcntl.h"
|
||||
#include "libc/libc_ioctl.h"
|
||||
#include "libc/libc_dirent.h"
|
||||
#include "libc/libc_signal.h"
|
||||
|
||||
#if defined(__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)
|
||||
typedef signed long off_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -134,6 +134,73 @@ rt_inline int rt_list_isempty(const rt_list_t *l)
|
|||
*/
|
||||
#define rt_list_first_entry(ptr, type, member) \
|
||||
rt_list_entry((ptr)->next, type, member)
|
||||
|
||||
#define RT_SLIST_OBJECT_INIT(object) { RT_NULL }
|
||||
|
||||
/**
|
||||
* @brief initialize a single list
|
||||
*
|
||||
* @param l the single list to be initialized
|
||||
*/
|
||||
rt_inline void rt_slist_init(rt_slist_t *l)
|
||||
{
|
||||
l->next = RT_NULL;
|
||||
}
|
||||
|
||||
rt_inline void rt_slist_append(rt_slist_t *l, rt_slist_t *n)
|
||||
{
|
||||
struct rt_slist_node *node;
|
||||
|
||||
node = l;
|
||||
while (node->next) node = node->next;
|
||||
|
||||
/* append the node to the tail */
|
||||
node->next = n;
|
||||
n->next = RT_NULL;
|
||||
}
|
||||
|
||||
rt_inline void rt_slist_insert(rt_slist_t *l, rt_slist_t *n)
|
||||
{
|
||||
n->next = l->next;
|
||||
l->next = n;
|
||||
}
|
||||
|
||||
rt_inline rt_slist_t *rt_slist_remove(rt_slist_t *l, rt_slist_t *n)
|
||||
{
|
||||
/* remove slist head */
|
||||
struct rt_slist_node *node = l;
|
||||
while (node->next && node->next != n) node = node->next;
|
||||
|
||||
/* remove node */
|
||||
if (node->next != (rt_slist_t *)0) node->next = node->next->next;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief get the struct for this single list node
|
||||
* @param node the entry point
|
||||
* @param type the type of structure
|
||||
* @param member the name of list in structure
|
||||
*/
|
||||
#define rt_slist_entry(node, type, member) \
|
||||
((type *)((char*)(node)-(unsigned long)(&((type *)0)->member)))
|
||||
|
||||
/**
|
||||
* rt_slist_for_each_entry - iterate over single list of given type
|
||||
* @node: the type * to use as a loop cursor.
|
||||
* @list: the head for your single list.
|
||||
*/
|
||||
#define rt_slist_foreach(node, list) \
|
||||
for ((node) = (list)->next; (node) != RT_NULL; (node) = (node)->next)
|
||||
|
||||
/**
|
||||
* rt_container_of - return the member address of ptr, if the type of ptr is the
|
||||
* struct type.
|
||||
*/
|
||||
#define rt_container_of(ptr, type, member) \
|
||||
((type *)((char *)(ptr) - (unsigned long)(&((type *)0)->member)))
|
||||
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -87,7 +87,7 @@ void rt_system_tick_init(void);
|
|||
rt_tick_t rt_tick_get(void);
|
||||
void rt_tick_set(rt_tick_t tick);
|
||||
void rt_tick_increase(void);
|
||||
rt_tick_t rt_tick_from_millisecond(rt_uint32_t ms);
|
||||
int rt_tick_from_millisecond(rt_int32_t ms);
|
||||
|
||||
void rt_system_timer_init(void);
|
||||
void rt_system_timer_thread_init(void);
|
||||
|
@ -107,7 +107,7 @@ rt_timer_t rt_timer_create(const char *name,
|
|||
rt_err_t rt_timer_delete(rt_timer_t timer);
|
||||
rt_err_t rt_timer_start(rt_timer_t timer);
|
||||
rt_err_t rt_timer_stop(rt_timer_t timer);
|
||||
rt_err_t rt_timer_control(rt_timer_t timer, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg);
|
||||
|
||||
rt_tick_t rt_timer_next_timeout_tick(void);
|
||||
void rt_timer_check(void);
|
||||
|
@ -149,11 +149,17 @@ rt_err_t rt_thread_delete(rt_thread_t thread);
|
|||
|
||||
rt_err_t rt_thread_yield(void);
|
||||
rt_err_t rt_thread_delay(rt_tick_t tick);
|
||||
rt_err_t rt_thread_control(rt_thread_t thread, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_thread_control(rt_thread_t thread, int cmd, void *arg);
|
||||
rt_err_t rt_thread_suspend(rt_thread_t thread);
|
||||
rt_err_t rt_thread_resume(rt_thread_t thread);
|
||||
void rt_thread_timeout(void *parameter);
|
||||
|
||||
#ifdef RT_USING_SIGNALS
|
||||
void rt_thread_alloc_sig(rt_thread_t tid);
|
||||
void rt_thread_free_sig(rt_thread_t tid);
|
||||
int rt_thread_kill(rt_thread_t tid, int sig);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_HOOK
|
||||
void rt_thread_suspend_sethook(void (*hook)(rt_thread_t thread));
|
||||
void rt_thread_resume_sethook (void (*hook)(rt_thread_t thread));
|
||||
|
@ -190,6 +196,19 @@ void rt_scheduler_sethook(void (*hook)(rt_thread_t from, rt_thread_t to));
|
|||
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup Signals
|
||||
* @{
|
||||
*/
|
||||
#ifdef RT_USING_SIGNALS
|
||||
void rt_signal_mask(int signo);
|
||||
void rt_signal_unmask(int signo);
|
||||
rt_sighandler_t rt_signal_install(int signo, rt_sighandler_t handler);
|
||||
|
||||
int rt_system_signal_init(void);
|
||||
#endif
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* @addtogroup MM
|
||||
*/
|
||||
|
@ -290,7 +309,7 @@ rt_err_t rt_sem_delete(rt_sem_t sem);
|
|||
rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time);
|
||||
rt_err_t rt_sem_trytake(rt_sem_t sem);
|
||||
rt_err_t rt_sem_release(rt_sem_t sem);
|
||||
rt_err_t rt_sem_control(rt_sem_t sem, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_sem_control(rt_sem_t sem, int cmd, void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MUTEX
|
||||
|
@ -304,7 +323,7 @@ rt_err_t rt_mutex_delete(rt_mutex_t mutex);
|
|||
|
||||
rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time);
|
||||
rt_err_t rt_mutex_release(rt_mutex_t mutex);
|
||||
rt_err_t rt_mutex_control(rt_mutex_t mutex, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_mutex_control(rt_mutex_t mutex, int cmd, void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_EVENT
|
||||
|
@ -322,7 +341,7 @@ rt_err_t rt_event_recv(rt_event_t event,
|
|||
rt_uint8_t opt,
|
||||
rt_int32_t timeout,
|
||||
rt_uint32_t *recved);
|
||||
rt_err_t rt_event_control(rt_event_t event, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MAILBOX
|
||||
|
@ -343,7 +362,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
|
|||
rt_uint32_t value,
|
||||
rt_int32_t timeout);
|
||||
rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t *value, rt_int32_t timeout);
|
||||
rt_err_t rt_mb_control(rt_mailbox_t mb, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_MESSAGEQUEUE
|
||||
|
@ -369,7 +388,7 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
|
|||
void *buffer,
|
||||
rt_size_t size,
|
||||
rt_int32_t timeout);
|
||||
rt_err_t rt_mq_control(rt_mq_t mq, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg);
|
||||
#endif
|
||||
|
||||
/**@}*/
|
||||
|
@ -410,7 +429,7 @@ rt_size_t rt_device_write(rt_device_t dev,
|
|||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
rt_size_t size);
|
||||
rt_err_t rt_device_control(rt_device_t dev, rt_uint8_t cmd, void *arg);
|
||||
rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg);
|
||||
|
||||
/**@}*/
|
||||
#endif
|
||||
|
@ -513,6 +532,8 @@ int *_rt_errno(void);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
int __rt_ffs(int value);
|
||||
|
||||
void *rt_memset(void *src, int c, rt_ubase_t n);
|
||||
void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
|
||||
|
||||
|
|
Loading…
Reference in New Issue