4 * things that are not available in header files
8 #define hstrerror strerror
10 #define S_IFLNK 0120000 /* Symbolic link */
11 #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
20 #define WIFEXITED(x) ((unsigned)(x) < 259) /* STILL_ACTIVE */
21 #define WEXITSTATUS(x) ((x) & 0xff)
22 #define WIFSIGNALED(x) ((unsigned)(x) > 259)
33 #define FD_CLOEXEC 0x1
42 int fd; /* file descriptor */
43 short events; /* requested events */
44 short revents; /* returned events */
49 typedef void (__cdecl *sig_handler_t)(int);
51 sig_handler_t sa_handler;
54 #define sigemptyset(x) (void)0
58 struct timeval it_value, it_interval;
62 #define st_blocks st_size/512 /* will be cleaned up later */
68 static inline int readlink(const char *path, char *buf, size_t bufsiz)
69 { errno = ENOSYS; return -1; }
70 static inline int symlink(const char *oldpath, const char *newpath)
71 { errno = ENOSYS; return -1; }
72 static inline int link(const char *oldpath, const char *newpath)
73 { errno = ENOSYS; return -1; }
74 static inline int fchmod(int fildes, mode_t mode)
75 { errno = ENOSYS; return -1; }
76 static inline int fork(void)
77 { errno = ENOSYS; return -1; }
78 static inline unsigned int alarm(unsigned int seconds)
80 static inline int fsync(int fd)
82 static inline int getppid(void)
84 static inline void sync(void)
86 static inline int getuid()
88 static inline struct passwd *getpwnam(const char *name)
90 static inline int fcntl(int fd, int cmd, long arg)
92 if (cmd == F_GETFD || cmd == F_SETFD)
102 static inline int mingw_mkdir(const char *path, int mode)
106 #define mkdir mingw_mkdir
108 static inline int mingw_unlink(const char *pathname)
110 /* read-only files cannot be removed */
111 chmod(pathname, 0666);
112 return unlink(pathname);
114 #define unlink mingw_unlink
116 static inline int waitpid(pid_t pid, unsigned *status, unsigned options)
119 return _cwait(status, pid, 0);
125 * implementations of missing functions
128 int pipe(int filedes[2]);
129 unsigned int sleep (unsigned int seconds);
130 int mkstemp(char *template);
131 int gettimeofday(struct timeval *tv, void *tz);
132 int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
133 struct tm *gmtime_r(const time_t *timep, struct tm *result);
134 struct tm *localtime_r(const time_t *timep, struct tm *result);
135 int getpagesize(void); /* defined in MinGW's libgcc.a */
136 struct passwd *getpwuid(int uid);
137 int setitimer(int type, struct itimerval *in, struct itimerval *out);
138 int sigaction(int sig, struct sigaction *in, struct sigaction *out);
141 * replacements of existing functions
144 int mingw_open (const char *filename, int oflags, ...);
145 #define open mingw_open
147 char *mingw_getcwd(char *pointer, int len);
148 #define getcwd mingw_getcwd
150 struct hostent *mingw_gethostbyname(const char *host);
151 #define gethostbyname mingw_gethostbyname
153 int mingw_socket(int domain, int type, int protocol);
154 #define socket mingw_socket
156 int mingw_connect(int sockfd, struct sockaddr *sa, size_t sz);
157 #define connect mingw_connect
159 int mingw_rename(const char*, const char*);
160 #define rename mingw_rename
162 /* Use mingw_lstat() instead of lstat()/stat() and
163 * mingw_fstat() instead of fstat() on Windows.
165 int mingw_lstat(const char *file_name, struct stat *buf);
166 int mingw_fstat(int fd, struct stat *buf);
167 #define fstat mingw_fstat
168 #define lstat mingw_lstat
169 #define stat(x,y) mingw_lstat(x,y)
171 pid_t mingw_spawnvpe(const char *cmd, const char **argv, char **env);
172 void mingw_execvp(const char *cmd, char *const *argv);
173 #define execvp mingw_execvp
175 sig_handler_t mingw_signal(int sig, sig_handler_t handler);
176 #define signal mingw_signal
179 * git specific compatibility
182 #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':')
183 #define is_dir_sep(c) ((c) == '/' || (c) == '\\')
185 #define PRIuMAX "I64u"
191 char **copy_environ(void);
192 void free_environ(char **env);
193 char **env_setenv(char **env, const char *name);