aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src/ntlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib-src/ntlib.c')
-rw-r--r--lib-src/ntlib.c49
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
3Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. 3Copyright (C) 1994, 2001-2013 Free Software Foundation, Inc.
4 4
5Author: Geoff Voelker (voelker@cs.washington.edu) 5Author: Geoff Voelker (voelker@cs.washington.edu)
6Created: 10-8-94 6Created: 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
40struct 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. */
40void 52unsigned
41sleep (unsigned long seconds) 53sleep (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
128unsigned 141unsigned
142geteuid (void)
143{
144 return getuid ();
145}
146
147unsigned
129getgid (void) 148getgid (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. */
226void
227gettimeofday (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
205int 247int
206fchown (int fd, unsigned uid, unsigned gid) 248fchown (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