[libc] Add more system header file for armlibc and dlib.

This commit is contained in:
Bernard Xiong 2015-05-04 20:35:28 +08:00
parent 10d3afde03
commit 0af011101d
11 changed files with 342 additions and 0 deletions

View File

@ -0,0 +1 @@
Because Keil MDK leaks some system header file, we put them in here.

View File

@ -0,0 +1,77 @@
#ifndef SYS_ERRNO_H__
#define SYS_ERRNO_H__
#ifdef RT_USING_DFS
#include <dfs_def.h>
/* using device error codes */
#define ENOENT DFS_STATUS_ENOENT
#define EIO DFS_STATUS_EIO
#define ENXIO DFS_STATUS_ENXIO
#define EBADF DFS_STATUS_EBADF
#define EAGAIN DFS_STATUS_EAGAIN
#define ENOMEM DFS_STATUS_ENOMEM
#define EBUSY DFS_STATUS_EBUSY
#define EEXIST DFS_STATUS_EEXIST
#define EXDEV DFS_STATUS_EXDEV
#define ENODEV DFS_STATUS_ENODEV
#define ENOTDIR DFS_STATUS_ENOTDIR
#define EISDIR DFS_STATUS_EISDIR
#define EINVAL DFS_STATUS_EINVAL
#define ENOSPC DFS_STATUS_ENOSPC
#define EROFS DFS_STATUS_EROFS
#define ENOSYS DFS_STATUS_ENOSYS
#define ENOTEMPTY DFS_STATUS_ENOTEMPTY
#else
/* error codes */
#define ENOENT 2 /* No such file or directory */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define EBADF 9 /* Bad file number */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* no memory */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENOSPC 28 /* No space left on device */
#define EROFS 30 /* Read-only file system */
#define ENOSYS 38 /* Function not implemented */
#define ENOTEMPTY 39 /* Directory not empty */
#endif
#define EPERM 1 /* Not super-user */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EFAULT 14 /* Bad address */
#define ENFILE 23 /* Too many open files in system */
#define ERANGE 34 /* Math result not representable */
#define EDEADLK 45 /* Deadlock condition */
#define EBADMSG 77 /* Trying to read unreadable message */
#define EMSGSIZE 90 /* Message too long */
#define ENOPROTOOPT 92 /* Protocol not available */
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
#define EADDRINUSE 98 /* Address already in use */
#define ENETDOWN 100 /* Network is down */
#define ENETUNREACH 101 /* Network is unreachable */
#define ECONNABORTED 103 /* Software caused connection abort */
#define ECONNRESET 104 /* Connection reset by peer */
#define ENOBUFS 105 /* No buffer space available */
#define ENOTCONN 107 /* Transport endpoint is not connected */
#define EINPROGRESS 115 /* Operation now in progress */
#define ETIMEDOUT 116 /* Connection timed out */
#define EHOSTUNREACH 113 /* No route to host */
#define EALREADY 114 /* Operation already in progress */
#define ENOTSUP 134 /* Not supported */
#define ENSRNOTFOUND 163 /* Domain name not found */
#define EWOULDBLOCK EAGAIN /* Operation would block */
#endif

View File

@ -0,0 +1,45 @@
#ifndef _SYS_TIME_H_
#define _SYS_TIME_H_
#include <time.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
/*
* Structure returned by gettimeofday(2) system call,
* and used in other calls.
*/
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif /* _TIMEVAL_DEFINED */
#ifndef _TIMESPEC_DEFINED
#define _TIMESPEC_DEFINED
/*
* Structure defined by POSIX.1b to be like a timeval.
*/
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
#endif /* _TIMESPEC_DEFINED */
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval *tp, void *ignore);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_TIME_H_ */

View File

@ -0,0 +1,12 @@
#ifndef __TYPES_H__
#define __TYPES_H__
#include <stdint.h>
#include <rtthread.h>
typedef rt_int32_t clockid_t;
typedef rt_int32_t key_t; /* Used for interprocess communication. */
typedef rt_int32_t pid_t; /* Used for process IDs and process group IDs. */
typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */
#endif

View File

@ -0,0 +1,34 @@
#ifndef _SYS_UNISTD_H
#define _SYS_UNISTD_H
#ifdef RT_USING_DFS
#include <dfs_posix.h>
#else
#define _FREAD 0x0001 /* read enabled */
#define _FWRITE 0x0002 /* write enabled */
#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
#define _FMARK 0x0010 /* internal; mark during gc() */
#define _FDEFER 0x0020 /* internal; defer for next gc pass */
#define _FASYNC 0x0040 /* signal pgrp when data ready */
#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
#define _FCREAT 0x0200 /* open with file create */
#define _FTRUNC 0x0400 /* open with truncation */
#define _FEXCL 0x0800 /* error on open if file exists */
#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
#define _FSYNC 0x2000 /* do all writes synchronously */
#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */
#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
#define O_RDONLY 0 /* +1 == FREAD */
#define O_WRONLY 1 /* +1 == FWRITE */
#define O_RDWR 2 /* +1 == FREAD|FWRITE */
#define O_APPEND _FAPPEND
#define O_CREAT _FCREAT
#define O_TRUNC _FTRUNC
#define O_EXCL _FEXCL
#define O_SYNC _FSYNC
#endif
#endif /* _SYS_UNISTD_H */

View File

@ -9,6 +9,10 @@ CPPPATH = [cwd]
CPPDEFINES = ['RT_USING_DLIBC']
if rtconfig.PLATFORM == 'iar':
if GetDepend('RT_USING_DFS'):
CPPDEFINES = CPPDEFINES + ['_DLIB_FILE_DESCRIPTOR', '_DLIB_THREAD_SUPPORT']
group = DefineGroup('dlib', src, depend = ['RT_USING_LIBC'],
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)

View File

@ -0,0 +1 @@
Because IAR leaks some system header file, we put them in here.

View File

@ -0,0 +1,77 @@
#ifndef SYS_ERRNO_H__
#define SYS_ERRNO_H__
#ifdef RT_USING_DFS
#include <dfs_def.h>
/* using device error codes */
#define ENOENT DFS_STATUS_ENOENT
#define EIO DFS_STATUS_EIO
#define ENXIO DFS_STATUS_ENXIO
#define EBADF DFS_STATUS_EBADF
#define EAGAIN DFS_STATUS_EAGAIN
#define ENOMEM DFS_STATUS_ENOMEM
#define EBUSY DFS_STATUS_EBUSY
#define EEXIST DFS_STATUS_EEXIST
#define EXDEV DFS_STATUS_EXDEV
#define ENODEV DFS_STATUS_ENODEV
#define ENOTDIR DFS_STATUS_ENOTDIR
#define EISDIR DFS_STATUS_EISDIR
#define EINVAL DFS_STATUS_EINVAL
#define ENOSPC DFS_STATUS_ENOSPC
#define EROFS DFS_STATUS_EROFS
#define ENOSYS DFS_STATUS_ENOSYS
#define ENOTEMPTY DFS_STATUS_ENOTEMPTY
#else
/* error codes */
#define ENOENT 2 /* No such file or directory */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define EBADF 9 /* Bad file number */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* no memory */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENOSPC 28 /* No space left on device */
#define EROFS 30 /* Read-only file system */
#define ENOSYS 38 /* Function not implemented */
#define ENOTEMPTY 39 /* Directory not empty */
#endif
#define EPERM 1 /* Not super-user */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EFAULT 14 /* Bad address */
#define ENFILE 23 /* Too many open files in system */
#define ERANGE 34 /* Math result not representable */
#define EDEADLK 45 /* Deadlock condition */
#define EBADMSG 77 /* Trying to read unreadable message */
#define EMSGSIZE 90 /* Message too long */
#define ENOPROTOOPT 92 /* Protocol not available */
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
#define EADDRINUSE 98 /* Address already in use */
#define ENETDOWN 100 /* Network is down */
#define ENETUNREACH 101 /* Network is unreachable */
#define ECONNABORTED 103 /* Software caused connection abort */
#define ECONNRESET 104 /* Connection reset by peer */
#define ENOBUFS 105 /* No buffer space available */
#define ENOTCONN 107 /* Transport endpoint is not connected */
#define EINPROGRESS 115 /* Operation now in progress */
#define ETIMEDOUT 116 /* Connection timed out */
#define EHOSTUNREACH 113 /* No route to host */
#define EALREADY 114 /* Operation already in progress */
#define ENOTSUP 134 /* Not supported */
#define ENSRNOTFOUND 163 /* Domain name not found */
#define EWOULDBLOCK EAGAIN /* Operation would block */
#endif

View File

@ -0,0 +1,45 @@
#ifndef _SYS_TIME_H_
#define _SYS_TIME_H_
#include <time.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
/*
* Structure returned by gettimeofday(2) system call,
* and used in other calls.
*/
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif /* _TIMEVAL_DEFINED */
#ifndef _TIMESPEC_DEFINED
#define _TIMESPEC_DEFINED
/*
* Structure defined by POSIX.1b to be like a timeval.
*/
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
#endif /* _TIMESPEC_DEFINED */
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int gettimeofday(struct timeval *tp, void *ignore);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_TIME_H_ */

View File

@ -0,0 +1,12 @@
#ifndef __TYPES_H__
#define __TYPES_H__
#include <stdint.h>
#include <rtthread.h>
typedef rt_int32_t clockid_t;
typedef rt_int32_t key_t; /* Used for interprocess communication. */
typedef rt_int32_t pid_t; /* Used for process IDs and process group IDs. */
typedef signed long ssize_t; /* Used for a count of bytes or an error indication. */
#endif

View File

@ -0,0 +1,34 @@
#ifndef _SYS_UNISTD_H
#define _SYS_UNISTD_H
#ifdef RT_USING_DFS
#include <dfs_posix.h>
#else
#define _FREAD 0x0001 /* read enabled */
#define _FWRITE 0x0002 /* write enabled */
#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
#define _FMARK 0x0010 /* internal; mark during gc() */
#define _FDEFER 0x0020 /* internal; defer for next gc pass */
#define _FASYNC 0x0040 /* signal pgrp when data ready */
#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
#define _FCREAT 0x0200 /* open with file create */
#define _FTRUNC 0x0400 /* open with truncation */
#define _FEXCL 0x0800 /* error on open if file exists */
#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
#define _FSYNC 0x2000 /* do all writes synchronously */
#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */
#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
#define O_RDONLY 0 /* +1 == FREAD */
#define O_WRONLY 1 /* +1 == FWRITE */
#define O_RDWR 2 /* +1 == FREAD|FWRITE */
#define O_APPEND _FAPPEND
#define O_CREAT _FCREAT
#define O_TRUNC _FTRUNC
#define O_EXCL _FEXCL
#define O_SYNC _FSYNC
#endif
#endif /* _SYS_UNISTD_H */