diff options
Diffstat (limited to 'lib-src/ntlib.c')
| -rw-r--r-- | lib-src/ntlib.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c index 2cc791fb56a..41b4e3a0cbc 100644 --- a/lib-src/ntlib.c +++ b/lib-src/ntlib.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Utility and Unix shadow routines for GNU Emacs support programs on NT. | 1 | /* Utility and Unix shadow routines for GNU Emacs support programs on NT. |
| 2 | 2 | ||
| 3 | Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. | 3 | Copyright (C) 1994, 2001-2013 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | Author: Geoff Voelker (voelker@cs.washington.edu) | 5 | Author: Geoff Voelker (voelker@cs.washington.edu) |
| 6 | Created: 10-8-94 | 6 | Created: 10-8-94 |
| @@ -29,18 +29,31 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
| 30 | #include <errno.h> | 30 | #include <errno.h> |
| 31 | #include <ctype.h> | 31 | #include <ctype.h> |
| 32 | #include <sys/timeb.h> | ||
| 33 | #include <mbstring.h> | ||
| 32 | 34 | ||
| 33 | #include "ntlib.h" | 35 | #include "ntlib.h" |
| 34 | 36 | ||
| 37 | /* MinGW64 defines _TIMEZONE_DEFINED and defines 'struct timespec' in | ||
| 38 | its system headers. */ | ||
| 39 | #ifndef _TIMEZONE_DEFINED | ||
| 40 | struct timezone | ||
| 41 | { | ||
| 42 | int tz_minuteswest; /* minutes west of Greenwich */ | ||
| 43 | int tz_dsttime; /* type of dst correction */ | ||
| 44 | }; | ||
| 45 | #endif | ||
| 46 | |||
| 35 | #define MAXPATHLEN _MAX_PATH | 47 | #define MAXPATHLEN _MAX_PATH |
| 36 | 48 | ||
| 37 | /* Emulate sleep...we could have done this with a define, but that | 49 | /* Emulate sleep...we could have done this with a define, but that |
| 38 | would necessitate including windows.h in the files that used it. | 50 | would necessitate including windows.h in the files that used it. |
| 39 | This is much easier. */ | 51 | This is much easier. */ |
| 40 | void | 52 | unsigned |
| 41 | sleep (unsigned long seconds) | 53 | sleep (unsigned seconds) |
| 42 | { | 54 | { |
| 43 | Sleep (seconds * 1000); | 55 | Sleep (seconds * 1000); |
| 56 | return 0; | ||
| 44 | } | 57 | } |
| 45 | 58 | ||
| 46 | /* Get the current working directory. */ | 59 | /* Get the current working directory. */ |
| @@ -126,6 +139,12 @@ getuid (void) | |||
| 126 | } | 139 | } |
| 127 | 140 | ||
| 128 | unsigned | 141 | unsigned |
| 142 | geteuid (void) | ||
| 143 | { | ||
| 144 | return getuid (); | ||
| 145 | } | ||
| 146 | |||
| 147 | unsigned | ||
| 129 | getgid (void) | 148 | getgid (void) |
| 130 | { | 149 | { |
| 131 | return 0; | 150 | return 0; |
| @@ -202,6 +221,29 @@ getpass (const char * prompt) | |||
| 202 | return NULL; | 221 | return NULL; |
| 203 | } | 222 | } |
| 204 | 223 | ||
| 224 | /* This is needed because lib/gettime.c calls gettimeofday, which MSVC | ||
| 225 | doesn't have. Copied from w32.c. */ | ||
| 226 | void | ||
| 227 | gettimeofday (struct timeval *tv, struct timezone *tz) | ||
| 228 | { | ||
| 229 | struct _timeb tb; | ||
| 230 | _ftime (&tb); | ||
| 231 | |||
| 232 | tv->tv_sec = tb.time; | ||
| 233 | tv->tv_usec = tb.millitm * 1000L; | ||
| 234 | /* Implementation note: _ftime sometimes doesn't update the dstflag | ||
| 235 | according to the new timezone when the system timezone is | ||
| 236 | changed. We could fix that by using GetSystemTime and | ||
| 237 | GetTimeZoneInformation, but that doesn't seem necessary, since | ||
| 238 | Emacs always calls gettimeofday with the 2nd argument NULL (see | ||
| 239 | current_emacs_time). */ | ||
| 240 | if (tz) | ||
| 241 | { | ||
| 242 | tz->tz_minuteswest = tb.timezone; /* minutes west of Greenwich */ | ||
| 243 | tz->tz_dsttime = tb.dstflag; /* type of dst correction */ | ||
| 244 | } | ||
| 245 | } | ||
| 246 | |||
| 205 | int | 247 | int |
| 206 | fchown (int fd, unsigned uid, unsigned gid) | 248 | fchown (int fd, unsigned uid, unsigned gid) |
| 207 | { | 249 | { |
| @@ -380,4 +422,3 @@ lstat (const char * path, struct stat * buf) | |||
| 380 | { | 422 | { |
| 381 | return stat (path, buf); | 423 | return stat (path, buf); |
| 382 | } | 424 | } |
| 383 | |||