]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/Include/Common/UnixInclude.h
2nd wave of r11105 checkin.2nd wave of r11105 checkin.
[mirror_edk2.git] / UnixPkg / Include / Common / UnixInclude.h
CommitLineData
804405e7 1/*++\r
2\r
f9b8ab56 3Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
d0c3acd4 4Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
f9b8ab56 5This program and the accompanying materials\r
804405e7 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13Module Name:\r
14 UnixInclude.h\r
15\r
16Abstract:\r
17 Public include file for the Unix Library\r
18\r
19--*/\r
20\r
21#ifndef __UNIX_INCLUDE_H__\r
22#define __UNIX_INCLUDE_H__\r
d0c3acd4 23\r
24// #include <sys/poll.h>\r
25// #include <dirent.h>\r
26\r
27//\r
28// Name mangle to prevent build errors. I.e conflicts between EFI and OS\r
29//\r
30#define NTOHL _UNIX_EFI_NAME_MANGLE_NTOHL_\r
31#define HTONL _UNIX_EFI_NAME_MANGLE_HTONL_\r
32#define NTOHS _UNIX_EFI_NAME_MANGLE_NTOHS_\r
33#define HTONS _UNIX_EFI_NAME_MANGLE_HTOHS_\r
34#define B0 _UNIX_EFI_NAME_MANGLE_B0_\r
35\r
36\r
37#include <stdio.h>\r
38#include <stdlib.h>\r
39\r
ccd55824 40#include <sys/types.h>\r
41#include <sys/stat.h>\r
d0c3acd4 42#include <sys/termios.h>\r
43#include <sys/time.h>\r
44\r
45#if __CYGWIN__\r
46#include <sys/dirent.h>\r
47#else\r
48#include <sys/dir.h>\r
49#endif\r
50\r
51#include <unistd.h>\r
52#include <poll.h>\r
53#include <fcntl.h>\r
54#include <time.h>\r
55#include <signal.h>\r
56#include <errno.h>\r
57#include <string.h>\r
58#include <stdlib.h>\r
59#include <sys/ioctl.h>\r
60\r
61#include <sys/socket.h>\r
62#include <netdb.h>\r
63#include <netinet/in.h>\r
64#include <net/if.h>\r
65#include <net/if_dl.h>\r
66#include <ifaddrs.h>\r
67#include <net/bpf.h>\r
ccd55824 68\r
69#ifdef __APPLE__\r
70#include <sys/param.h>\r
71#include <sys/mount.h>\r
d0c3acd4 72#define _XOPEN_SOURCE\r
73#ifndef _Bool\r
74 #define _Bool char // for clang debug\r
75#endif\r
ccd55824 76#else\r
d0c3acd4 77#include <termio.h>\r
ccd55824 78#include <sys/vfs.h>\r
79#endif \r
80\r
ccd55824 81#include <utime.h>\r
d0c3acd4 82\r
83#if __APPLE__\r
84//\r
85// EFI packing is not compatible witht he default OS packing for struct stat.\r
86// st_size is 64-bit but starts on a 32-bit offset in the structure. The compiler\r
87// flags used to produce compatible EFI images, break struct stat\r
88//\r
89#ifdef MDE_CPU_IA32\r
90#pragma pack(4)\r
804405e7 91#endif\r
d0c3acd4 92\r
93#if defined(__DARWIN_64_BIT_INO_T)\r
94\r
95\r
96typedef struct {\r
97 UINTN tv_sec; /* seconds */\r
98 UINTN tv_nsec; /* and nanoseconds */\r
99} EFI_timespec;\r
100\r
101\r
102\r
103typedef struct stat_fix { \\r
104 dev_t st_dev; /* [XSI] ID of device containing file */ \r
105 mode_t st_mode; /* [XSI] Mode of file (see below) */ \r
106 nlink_t st_nlink; /* [XSI] Number of hard links */ \r
107 __darwin_ino64_t st_ino; /* [XSI] File serial number */ \r
108 uid_t st_uid; /* [XSI] User ID of the file */ \r
109 gid_t st_gid; /* [XSI] Group ID of the file */ \r
110 dev_t st_rdev; /* [XSI] Device ID */ \r
111\r
112 // clang for X64 ABI follows Windows and a long is 32-bits\r
113 // this breaks system inlcude files so that is why we need\r
114 // to redefine timespec as EFI_timespec \r
115 EFI_timespec st_atimespec;\r
116 EFI_timespec st_mtimespec;\r
117 EFI_timespec st_ctimespec;\r
118 EFI_timespec st_birthtimespec;\r
119\r
120 off_t st_size; /* [XSI] file size, in bytes */ \r
121 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */ \r
122 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */ \r
123 __uint32_t st_flags; /* user defined flags for file */ \r
124 __uint32_t st_gen; /* file generation number */ \r
125 __int32_t st_lspare; /* RESERVED: DO NOT USE! */ \r
126 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */ \r
127} STAT_FIX;\r
128\r
129#else /* !__DARWIN_64_BIT_INO_T */\r
130\r
131typedef struct stat_fix {\r
132 dev_t st_dev; /* [XSI] ID of device containing file */\r
133 ino_t st_ino; /* [XSI] File serial number */\r
134 mode_t st_mode; /* [XSI] Mode of file (see below) */\r
135 nlink_t st_nlink; /* [XSI] Number of hard links */\r
136 uid_t st_uid; /* [XSI] User ID of the file */\r
137 gid_t st_gid; /* [XSI] Group ID of the file */\r
138 dev_t st_rdev; /* [XSI] Device ID */\r
139#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)\r
140 struct timespec st_atimespec; /* time of last access */\r
141 struct timespec st_mtimespec; /* time of last data modification */\r
142 struct timespec st_ctimespec; /* time of last status change */\r
143#else\r
144 time_t st_atime; /* [XSI] Time of last access */\r
145 long st_atimensec; /* nsec of last access */\r
146 time_t st_mtime; /* [XSI] Last data modification time */\r
147 long st_mtimensec; /* last data modification nsec */\r
148 time_t st_ctime; /* [XSI] Time of last status change */\r
149 long st_ctimensec; /* nsec of last status change */\r
150#endif\r
151 off_t st_size; /* [XSI] file size, in bytes */\r
152 blkcnt_t st_blocks; /* [XSI] blocks allocated for file */\r
153 blksize_t st_blksize; /* [XSI] optimal blocksize for I/O */\r
154 __uint32_t st_flags; /* user defined flags for file */\r
155 __uint32_t st_gen; /* file generation number */\r
156 __int32_t st_lspare; /* RESERVED: DO NOT USE! */\r
157 __int64_t st_qspare[2]; /* RESERVED: DO NOT USE! */\r
158} STAT_FIX;\r
159\r
160#endif\r
161\r
162#ifdef MDE_CPU_IA32\r
163#pragma pack(4)\r
164#endif\r
165\r
166#else \r
167\r
168 typedef struct stat STAT_FIX;\r
169\r
170#endif\r
171\r
172//\r
173// Undo name mangling\r
174//\r
175#undef NTOHL\r
176#undef HTONL\r
177#undef NTOHS\r
178#undef HTONS\r
179#undef B0\r
180\r
181\r
182#endif\r
183\r