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