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
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.
17 Public include file for the Unix Library
21 #ifndef __UNIX_INCLUDE_H__
22 #define __UNIX_INCLUDE_H__
24 // #include <sys/poll.h>
25 // #include <dirent.h>
28 // Name mangle to prevent build errors. I.e conflicts between EFI and OS
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_
40 #include <sys/types.h>
42 #include <sys/termios.h>
46 #include <sys/dirent.h>
59 #include <sys/ioctl.h>
61 #include <sys/socket.h>
63 #include <netinet/in.h>
68 #include <net/if_dl.h>
70 #include <sys/param.h>
71 #include <sys/mount.h>
74 #define _Bool char // for clang debug
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
93 #if defined(__DARWIN_64_BIT_INO_T)
97 UINTN tv_sec
; /* seconds */
98 UINTN tv_nsec
; /* and nanoseconds */
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 */
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
;
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! */
129 #else /* !__DARWIN_64_BIT_INO_T */
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 */
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 */
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! */
168 typedef struct stat STAT_FIX
;
173 // Undo name mangling