aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2013-07-31 14:50:09 +0000
committerChristopher Faylor <me@cgf.cx>2013-07-31 14:50:09 +0000
commitb3e59d6710c1a9e0b8a6b703b3a660482050aa87 (patch)
treed53fd3c2169ec1011a893650cb2c508f431ebd22 /winsup
parentcc7407f0b20d2d8d81158012e0df637520e3440b (diff)
downloadnewlib-github/callout.zip
newlib-github/callout.tar.gz
newlib-github/callout.tar.bz2
* environ.cc (known): Add preload keyword.github/calloutcallout
* external.cc: Include new callout.h header. (cygwin_internal): Initial implementation of CW_CALLOUT and CW_CYGHEAP_MALLOC. (dll_preload): Handle CYGWIN=preload:foo.dll. (dummy_callout): Default NULL callout function. * globals.cc: Include new callout.h header. (callout): Declare/define. * uname.cc (uname): Initial implementation of callout handling. * winsup.h (dll_preload): Declare. * include/cygwin/version.h: Bump API minor number to 269. * include/sys/cygwin.h: Define CW_CALLOUT, CW_CYGHEAP_MALLOC.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog15
-rw-r--r--winsup/cygwin/environ.cc1
-rw-r--r--winsup/cygwin/external.cc22
-rw-r--r--winsup/cygwin/globals.cc6
-rw-r--r--winsup/cygwin/include/cygwin/callout.h30
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/include/sys/cygwin.h6
-rw-r--r--winsup/cygwin/uname.cc8
-rw-r--r--winsup/cygwin/winsup.h1
9 files changed, 90 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 273861a..72d0acb 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,20 @@
2013-07-31 Christopher Faylor <me.cygwin2013@cgf.cx>
+ * environ.cc (known): Add preload keyword.
+ * external.cc: Include new callout.h header.
+ (cygwin_internal): Initial implementation of CW_CALLOUT and
+ CW_CYGHEAP_MALLOC.
+ (dll_preload): Handle CYGWIN=preload:foo.dll.
+ (dummy_callout): Default NULL callout function.
+ * globals.cc: Include new callout.h header.
+ (callout): Declare/define.
+ * uname.cc (uname): Initial implementation of callout handling.
+ * winsup.h (dll_preload): Declare.
+ * include/cygwin/version.h: Bump API minor number to 269.
+ * include/sys/cygwin.h: Define CW_CALLOUT, CW_CYGHEAP_MALLOC.
+
+2013-07-31 Christopher Faylor <me.cygwin2013@cgf.cx>
+
* cygheap.cc (cmalloc): Use size_t for size field.
(cmalloc_abort): Ditto.
(crealloc): Ditto.
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 54b7242..e98af97 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -130,6 +130,7 @@ static struct parse_thing
{"error_start", {func: error_start_init}, isfunc, NULL, {{0}, {0}}},
{"export", {&export_settings}, setbool, NULL, {{false}, {true}}},
{"glob", {func: glob_init}, isfunc, NULL, {{0}, {s: "normal"}}},
+ {"preload", {func: dll_preload}, isfunc, NULL, {{0}, {0}}},
{"pipe_byte", {&pipe_byte}, setbool, NULL, {{false}, {true}}},
{"proc_retry", {func: set_proc_retry}, isfunc, NULL, {{0}, {5}}},
{"reset_com", {&reset_com}, setbool, NULL, {{false}, {true}}},
diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc
index 4dc87bf..bbb4c65 100644
--- a/winsup/cygwin/external.cc
+++ b/winsup/cygwin/external.cc
@@ -30,6 +30,7 @@ details. */
#include <stdlib.h>
#include <wchar.h>
#include <iptypes.h>
+#include <cygwin/callout.h>
child_info *get_cygwin_startup_info ();
static void exit_process (UINT, bool) __attribute__((noreturn));
@@ -553,9 +554,30 @@ cygwin_internal (cygwin_getinfo_types t, ...)
}
break;
+ case CW_CALLOUT:
+ callout = va_arg (arg, cw_callout_function_t);
+ break;
+
+ case CW_CYGHEAP_MALLOC:
+ res = (uintptr_t) cmalloc (HEAP_USER, va_arg (arg, size_t));
+ break;
+
default:
set_errno (ENOSYS);
}
va_end (arg);
return res;
}
+
+extern "C" void
+dll_preload (const char *dll)
+{
+ if (!LoadLibrary (dll))
+ api_fatal ("couldn't load CYGWIN=preload DLL: %s, %E", dll);
+}
+
+extern "C" cw_callout_return_t
+dummy_callout (cw_callout_t, ...)
+{
+ return CO_R_KEEP_GOING;
+}
diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc
index a39d5c9..65be6aa 100644
--- a/winsup/cygwin/globals.cc
+++ b/winsup/cygwin/globals.cc
@@ -17,6 +17,7 @@ details. */
#include "thread.h"
#include <malloc.h>
#include <cygwin/version.h>
+#include <cygwin/callout.h>
HANDLE NO_COPY hMainThread;
HANDLE NO_COPY hProcToken;
@@ -75,6 +76,11 @@ bool reset_com;
bool wincmdln;
winsym_t allow_winsymlinks = WSYM_sysfile;
+extern "C" {
+cw_callout_return_t dummy_callout (cw_callout_t, ...);
+cw_callout_function_t callout = dummy_callout;
+};
+
bool NO_COPY in_forkee;
/* Taken from BSD libc:
diff --git a/winsup/cygwin/include/cygwin/callout.h b/winsup/cygwin/include/cygwin/callout.h
new file mode 100644
index 0000000..4f50675
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/callout.h
@@ -0,0 +1,30 @@
+/* callout.h -- Definitions used by Cygwin callout mechanism
+
+ Copyright 2013 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#pragma once
+
+extern "C" {
+enum cw_callout_t
+{
+ CO_ENV,
+ CO_SPAWN,
+ CO_SYMLINK,
+ CO_UNAME
+};
+
+enum cw_callout_return_t
+{
+ CO_R_ERROR,
+ CO_R_KEEP_GOING,
+ CO_R_SHORT_CIRCUIT
+};
+
+typedef cw_callout_return_t (*cw_callout_function_t) (cw_callout_t, ...);
+};
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index fb66c4a..b1e90ba 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -438,12 +438,13 @@ details. */
arc4random_stir, arc4random_uniform.
267: Export rawmemchr.
268: Export GetCommandLineA, GetCommandLineW
+ 269: Implement Cygwin callout functionality v1
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 268
+#define CYGWIN_VERSION_API_MINOR 269
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h
index 354d0eb..14b556d 100644
--- a/winsup/cygwin/include/sys/cygwin.h
+++ b/winsup/cygwin/include/sys/cygwin.h
@@ -143,7 +143,9 @@ typedef enum
CW_CVT_ENV_TO_WINENV,
CW_ALLOC_DRIVE_MAP,
CW_MAP_DRIVE_MAP,
- CW_FREE_DRIVE_MAP
+ CW_FREE_DRIVE_MAP,
+ CW_CALLOUT,
+ CW_CYGHEAP_MALLOC
} cygwin_getinfo_types;
#define CW_LOCK_PINFO CW_LOCK_PINFO
@@ -194,6 +196,8 @@ typedef enum
#define CW_ALLOC_DRIVE_MAP CW_ALLOC_DRIVE_MAP
#define CW_MAP_DRIVE_MAP CW_MAP_DRIVE_MAP
#define CW_FREE_DRIVE_MAP CW_FREE_DRIVE_MAP
+#define CW_CALLOUT CW_CALLOUT
+#define CW_CYGHEAP_MALLOC CW_CYGHEAP_MALLOC
/* Token type for CW_SET_EXTERNAL_TOKEN */
enum
diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc
index c571850..6e4fe04 100644
--- a/winsup/cygwin/uname.cc
+++ b/winsup/cygwin/uname.cc
@@ -15,6 +15,7 @@ details. */
#include <sys/utsname.h>
#include "cygwin_version.h"
#include "cygtls.h"
+#include <cygwin/callout.h>
/* uname: POSIX 4.4.1.1 */
extern "C" int
@@ -91,5 +92,12 @@ uname (struct utsname *name)
break;
}
+ switch (callout (CO_UNAME, name))
+ {
+ case CO_R_KEEP_GOING:
+ break;
+ default:
+ return -1;
+ }
return 0;
}
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index eb7a423..4ca0e9d 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -198,6 +198,7 @@ void __stdcall close_all_files (bool = false);
extern "C" void error_start_init (const char*);
extern "C" int try_to_debug (bool waitloop = 1);
+extern "C" void dll_preload (const char*);
void ld_preload ();
const char *find_first_notloaded_dll (class path_conv &);