#include <tlhelp32.h>
#include <psapi.h>
#include <w32api.h>
-#if !defined(__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
+#if !defined (__MINGW32__) || __W32API_MAJOR_VERSION < 3 || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION < 15)
/* This either is not in psapi.h or guarded by higher value of
_WIN32_WINNT than what we use. w32api supplied with MinGW 3.15
defines it in psapi.h */
typedef HRESULT (WINAPI * ShGetFolderPath_fn)
(IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
+Lisp_Object QCloaded_from;
+
void globals_of_w32 (void);
static DWORD get_rid (PSID);
return 0;
}
+int
+pthread_sigmask (int how, const sigset_t *set, sigset_t *oset)
+{
+ if (sigprocmask (how, set, oset) == -1)
+ return EINVAL;
+ return 0;
+}
+
int
setpgrp (int pid, int gid)
{
char locale_name[32];
struct stat ignored;
char default_home[MAX_PATH];
+ int appdata = 0;
static const struct env_entry
{
/* If we can't get the appdata dir, revert to old behavior. */
if (profile_result == S_OK)
- env_vars[0].def_value = default_home;
+ {
+ env_vars[0].def_value = default_home;
+ appdata = 1;
+ }
}
}
lpval = env_vars[i].def_value;
dwType = REG_EXPAND_SZ;
dont_free = 1;
+ if (!strcmp (env_vars[i].name, "HOME") && !appdata)
+ {
+ Lisp_Object warning[2];
+ warning[0] = intern ("initialization");
+ warning[1] = build_string ("Setting HOME to C:\\ by default is deprecated");
+ Vdelayed_warnings_list = Fcons (Flist (2, warning),
+ Vdelayed_warnings_list);
+ }
}
if (lpval)
return localtime (t);
}
+
+\f
+/* Delayed loading of libraries. */
+
+Lisp_Object Vlibrary_cache;
+
+/* The argument LIBRARIES is an alist that associates a symbol
+ LIBRARY_ID, identifying an external DLL library known to Emacs, to
+ a list of filenames under which the library is usually found. In
+ most cases, the argument passed as LIBRARIES is the variable
+ `dynamic-library-alist', which is initialized to a list of common
+ library names. If the function loads the library successfully, it
+ returns the handle of the DLL, and records the filename in the
+ property :loaded-from of LIBRARY_ID; it returns NULL if the library
+ could not be found, or when it was already loaded (because the
+ handle is not recorded anywhere, and so is lost after use). It
+ would be trivial to save the handle too in :loaded-from, but
+ currently there's no use case for it. */
+HMODULE
+w32_delayed_load (Lisp_Object libraries, Lisp_Object library_id)
+{
+ HMODULE library_dll = NULL;
+
+ CHECK_SYMBOL (library_id);
+
+ if (CONSP (libraries) && NILP (Fassq (library_id, Vlibrary_cache)))
+ {
+ Lisp_Object found = Qnil;
+ Lisp_Object dlls = Fassq (library_id, libraries);
+
+ if (CONSP (dlls))
+ for (dlls = XCDR (dlls); CONSP (dlls); dlls = XCDR (dlls))
+ {
+ CHECK_STRING_CAR (dlls);
+ if (library_dll = LoadLibrary (SDATA (XCAR (dlls))))
+ {
+ found = XCAR (dlls);
+ break;
+ }
+ }
+
+ Fput (library_id, QCloaded_from, found);
+ }
+
+ return library_dll;
+}
+
+\f
static void
check_windows_init_file (void)
{
get_process_times_fn = (GetProcessTimes_Proc)
GetProcAddress (kernel32, "GetProcessTimes");
+ DEFSYM (QCloaded_from, ":loaded-from");
+
+ Vlibrary_cache = Qnil;
+ staticpro (&Vlibrary_cache);
+
g_b_init_is_windows_9x = 0;
g_b_init_open_process_token = 0;
g_b_init_get_token_information = 0;
for (;;)
{
- n = sys_read(fd, (char*)buf, sz);
+ n = sys_read (fd, (char*)buf, sz);
if (n >= 0)
return n;
if (err == EWOULDBLOCK)
{
/* Set a small timeout. */
- EMACS_SET_SECS_USECS(timeout, 1, 0);
+ EMACS_SET_SECS_USECS (timeout, 1, 0);
FD_ZERO (&fdset);
FD_SET ((int)fd, &fdset);
err = errno; /* Other errors are just passed on. */
}
- gnutls_transport_set_errno (process->gnutls_state, err);
+ emacs_gnutls_transport_set_errno (process->gnutls_state, err);
return -1;
}
{
struct Lisp_Process *process = (struct Lisp_Process *)p;
int fd = process->outfd;
- ssize_t n = sys_write(fd, buf, sz);
+ ssize_t n = sys_write (fd, buf, sz);
/* 0 or more bytes written means everything went fine. */
if (n >= 0)
/* Negative bytes written means we got an error in errno.
Translate the WSAEWOULDBLOCK alias EWOULDBLOCK to EAGAIN. */
- gnutls_transport_set_errno (process->gnutls_state,
- errno == EWOULDBLOCK ? EAGAIN : errno);
+ emacs_gnutls_transport_set_errno (process->gnutls_state,
+ errno == EWOULDBLOCK ? EAGAIN : errno);
return -1;
}