xserver: Branch 'master' - 5 commits
Jeremy Huddleston
jeremyhu at kemper.freedesktop.org
Wed May 14 01:16:11 PDT 2008
hw/xquartz/X11Application.m | 21 +++---
hw/xquartz/bundle/Makefile.am | 2
hw/xquartz/darwin.c | 1
hw/xquartz/mach-startup/bundle-main.c | 75 +++++++++++++++++++++--
hw/xquartz/mach-startup/mach_startup_types.h | 4 -
hw/xquartz/mach-startup/stub.c | 85 +++++++++++++++++++++++++--
6 files changed, 165 insertions(+), 23 deletions(-)
New commits:
commit cbb4e80eb7cc8dc2aff5e5268b49cdb7b3c3d5fa
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Wed May 14 01:13:15 2008 -0700
XQuartz: More work on the Mach-IPC startup path
(cherry picked from commit 49cd0b185fd6c99b07357a74734b6a4023faca84)
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index a66afa8..cd64e42 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -73,7 +73,26 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
mach_msg_type_number_t argvCnt,
string_array_t envp,
mach_msg_type_number_t envpCnt) {
- if(server_main(argvCnt - 1, argv, envp) == 0)
+ /* And now back to char ** */
+ char **_argv = alloca((argvCnt + 1) * sizeof(char *));
+ char **_envp = alloca((envpCnt + 1) * sizeof(char *));
+ size_t i;
+
+ if(!_argv || !_envp) {
+ return KERN_FAILURE;
+ }
+
+ for(i=0; i < argvCnt; i++) {
+ _argv[i] = argv[i];
+ }
+ _argv[argvCnt] = NULL;
+
+ for(i=0; i < envpCnt; i++) {
+ _envp[i] = envp[i];
+ }
+ _envp[envpCnt] = NULL;
+
+ if(server_main(argvCnt, _argv, _envp) == 0)
return KERN_SUCCESS;
else
return KERN_FAILURE;
@@ -212,20 +231,38 @@ int main(int argc, char **argv, char **envp) {
#ifdef NEW_LAUNCH_METHOD
kern_return_t kr;
mach_port_t mp;
-
- sleep(2);
+ string_array_t newenvp;
+ string_array_t newargv;
/* We need to count envp */
int envpc;
for(envpc=0; envp[envpc]; envpc++);
+ /* We have fixed-size string lengths due to limitations in IPC,
+ * so we need to copy our argv and envp.
+ */
+ newargv = (string_array_t)alloca(argc * sizeof(string_t));
+ newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
+
+ if(!newargv || !newenvp) {
+ fprintf(stderr, "Memory allocation failure\n");
+ exit(EXIT_FAILURE);
+ }
+
+ for(i=0; i < argc; i++) {
+ strlcpy(newargv[i], argv[i], STRING_T_SIZE);
+ }
+ for(i=0; i < envpc; i++) {
+ strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
+ }
+
kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
if (kr != KERN_SUCCESS) {
fprintf(stderr, "bootstrap_look_up(): %s\n", bootstrap_strerror(kr));
exit(EXIT_FAILURE);
}
- kr = start_x11_server(mp, argv, argc + 1, envp, envpc + 1);
+ kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
if (kr != KERN_SUCCESS) {
fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr));
exit(EXIT_FAILURE);
diff --git a/hw/xquartz/mach-startup/mach_startup_types.h b/hw/xquartz/mach-startup/mach_startup_types.h
index 03939af..97ac147 100644
--- a/hw/xquartz/mach-startup/mach_startup_types.h
+++ b/hw/xquartz/mach-startup/mach_startup_types.h
@@ -2,7 +2,9 @@
#define _MACH_STARTUP_TYPES_H_
#define SERVER_BOOTSTRAP_NAME "org.x.X11"
+#define STRING_T_SIZE 1024
-typedef char ** string_array_t;
+typedef char string_t[STRING_T_SIZE];
+typedef string_t * string_array_t;
#endif
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index ed917cf..fae9720 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -111,9 +111,10 @@ static void set_x11_path() {
int main(int argc, char **argv, char **envp) {
#ifdef NEW_LAUNCH_METHOD_2
int envpc;
- char *newargv[3];
kern_return_t kr;
mach_port_t mp;
+ string_array_t newenvp;
+ string_array_t newargv;
#endif
if(argc == 2 && !strcmp(argv[1], "-version")) {
@@ -137,10 +138,11 @@ int main(int argc, char **argv, char **envp) {
}
if(child == 0) {
- newargv[0] = x11_path;
- newargv[1] = "--listenonly";
- newargv[2] = NULL;
- return execvp(x11_path, newargv);
+ char *_argv[3];
+ _argv[0] = x11_path;
+ _argv[1] = "--listenonly";
+ _argv[2] = NULL;
+ return execvp(x11_path, _argv);
}
/* Try connecting for 10 seconds */
@@ -160,7 +162,25 @@ int main(int argc, char **argv, char **envp) {
/* Count envp */
for(envpc=0; envp[envpc]; envpc++);
- kr = start_x11_server(mp, argv, argc + 1, envp, envpc + 1);
+ /* We have fixed-size string lengths due to limitations in IPC,
+ * so we need to copy our argv and envp.
+ */
+ newargv = (string_array_t)alloca(argc * sizeof(string_t));
+ newenvp = (string_array_t)alloca(envpc * sizeof(string_t));
+
+ if(!newargv || !newenvp) {
+ fprintf(stderr, "Memory allocation failure\n");
+ exit(EXIT_FAILURE);
+ }
+
+ for(i=0; i < argc; i++) {
+ strlcpy(newargv[i], argv[i], STRING_T_SIZE);
+ }
+ for(i=0; i < envpc; i++) {
+ strlcpy(newenvp[i], envp[i], STRING_T_SIZE);
+ }
+
+ kr = start_x11_server(mp, newargv, argc, newenvp, envpc);
if (kr != KERN_SUCCESS) {
fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr));
return EXIT_FAILURE;
commit 3b57c59bb08c9a3211f4ae57d9e2fb569d61bf2f
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Tue May 13 10:40:20 2008 -0700
Xquartz: More work on the new Mach startup
(cherry picked from commit 6237acf75d3310d7d4f262556b677557c2907284)
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index b0ff9df..a66afa8 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -34,9 +34,12 @@
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
+#include <stdbool.h>
#include <CoreFoundation/CoreFoundation.h>
+#include <asl.h>
+
#include <mach/mach.h>
#include <mach/mach_error.h>
#include <servers/bootstrap.h>
@@ -70,7 +73,7 @@ kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
mach_msg_type_number_t argvCnt,
string_array_t envp,
mach_msg_type_number_t envpCnt) {
- if(server_main(argvCnt, argv, envp) == 0)
+ if(server_main(argvCnt - 1, argv, envp) == 0)
return KERN_SUCCESS;
else
return KERN_FAILURE;
@@ -137,7 +140,7 @@ static void startup_trigger_thread(void *arg) {
}
int main(int argc, char **argv, char **envp) {
- BOOL listenOnly = FALSE;
+ Bool listen, listenOnly = FALSE;
int i;
mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
mach_port_t mp;
@@ -151,7 +154,8 @@ int main(int argc, char **argv, char **envp) {
}
/* TODO: This should be unconditional once we figure out fd passing */
- if((argc > 1 && argv[1][0] == ':') || listenOnly) {
+ listen = (argc > 1 && argv[1][0] == ':') || listenOnly;
+ if(listen) {
mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
}
@@ -160,8 +164,10 @@ int main(int argc, char **argv, char **envp) {
*/
if(!listenOnly) {
struct arg *args = (struct arg*)malloc(sizeof(struct arg));
- if(!args)
- FatalError("Could not allocate memory.\n");
+ if(!args) {
+ fprintf(stderr, "Memory allocation error.\n");
+ return EXIT_FAILURE;
+ }
args->argc = argc;
args->argv = argv;
@@ -175,13 +181,13 @@ int main(int argc, char **argv, char **envp) {
* file descriptor. For now, we only listen if we are explicitly
* told to.
*/
- if((argc > 1 && argv[1][0] == ':') || listenOnly) {
+ if(listen) {
/* Main event loop */
kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
if (kr != KERN_SUCCESS) {
asl_log(NULL, NULL, ASL_LEVEL_ERR,
"org.x.X11(mp): %s\n", mach_error_string(kr));
- exit(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
}
@@ -204,11 +210,27 @@ int main(int argc, char **argv, char **envp) {
/* Take care of the case where we're called like a normal DDX */
if(argc > 1 && argv[1][0] == ':') {
#ifdef NEW_LAUNCH_METHOD
+ kern_return_t kr;
+ mach_port_t mp;
+
+ sleep(2);
+
/* We need to count envp */
int envpc;
for(envpc=0; envp[envpc]; envpc++);
- return start_x11_server(argc, argv, envp, envpc);
+ kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "bootstrap_look_up(): %s\n", bootstrap_strerror(kr));
+ exit(EXIT_FAILURE);
+ }
+
+ kr = start_x11_server(mp, argv, argc + 1, envp, envpc + 1);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr));
+ exit(EXIT_FAILURE);
+ }
+ exit(EXIT_SUCCESS);
#else
return server_main(argc, argv, envp);
#endif
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 3be5f65..ed917cf 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -35,10 +35,16 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#define kX11AppBundleId "org.x.X11"
#define kX11AppBundlePath "/Contents/MacOS/X11"
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+#include <servers/bootstrap.h>
+#include "mach_startup.h"
+
static char x11_path[PATH_MAX + 1];
static void set_x11_path() {
@@ -102,17 +108,68 @@ static void set_x11_path() {
#define XSERVER_VERSION "?"
#endif
-int main(int argc, char **argv) {
-
+int main(int argc, char **argv, char **envp) {
+#ifdef NEW_LAUNCH_METHOD_2
+ int envpc;
+ char *newargv[3];
+ kern_return_t kr;
+ mach_port_t mp;
+#endif
+
if(argc == 2 && !strcmp(argv[1], "-version")) {
fprintf(stderr, "X.org Release 7.3\n");
fprintf(stderr, "X.Org X Server %s\n", XSERVER_VERSION);
fprintf(stderr, "Build Date: %s\n", BUILD_DATE);
- return 0;
+ return EXIT_SUCCESS;
}
+
+#ifdef NEW_LAUNCH_METHOD_2
+ kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
+ if(kr != KERN_SUCCESS) {
+ int i;
+ set_x11_path();
+
+ /* This forking is ugly and will be cleaned up later */
+ pid_t child = fork();
+ if(child == -1) {
+ fprintf(stderr, "Could not fork: %s\n", strerror(errno));
+ return EXIT_FAILURE;
+ }
+
+ if(child == 0) {
+ newargv[0] = x11_path;
+ newargv[1] = "--listenonly";
+ newargv[2] = NULL;
+ return execvp(x11_path, newargv);
+ }
+
+ /* Try connecting for 10 seconds */
+ for(i=0; i < 20; i++) {
+ usleep(500);
+ kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
+ if(kr == KERN_SUCCESS)
+ break;
+ }
+
+ if(kr != KERN_SUCCESS) {
+ fprintf(stderr, "bootstrap_look_up(): %s\n", bootstrap_strerror(kr));
+ return EXIT_FAILURE;
+ }
+ }
+
+ /* Count envp */
+ for(envpc=0; envp[envpc]; envpc++);
- set_x11_path();
+ kr = start_x11_server(mp, argv, argc + 1, envp, envpc + 1);
+ if (kr != KERN_SUCCESS) {
+ fprintf(stderr, "start_x11_server: %s\n", mach_error_string(kr));
+ return EXIT_FAILURE;
+ }
+ return EXIT_SUCCESS;
+#else
+ set_x11_path();
argv[0] = x11_path;
return execvp(x11_path, argv);
+#endif
}
commit e435acc84cb9477455ad005cee658630cbd363a2
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Mon May 12 17:57:07 2008 -0700
Added missing to EXTRA_DIST
(cherry picked from commit e39613f4633ed992bc276b70833a703560e528f9)
diff --git a/hw/xquartz/bundle/Makefile.am b/hw/xquartz/bundle/Makefile.am
index a8f45f8..89d04c7 100644
--- a/hw/xquartz/bundle/Makefile.am
+++ b/hw/xquartz/bundle/Makefile.am
@@ -6,6 +6,8 @@ resource_DATA = Xquartz.plist
EXTRA_DIST = \
mk_bundke.sh \
+ Info.plist \
+ PkgInfo \
$(resource_DATA) \
Resources/da.lproj/InfoPlist.strings \
Resources/da.lproj/Localizable.strings \
commit f7d6d20ad64b235700185784d317417a94d1814b
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Mon May 12 13:36:35 2008 -0700
XQuartz: Cleaned up the about box.
(cherry picked from commit 0279a5970694937e949ba533330ea48961c4edba)
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 691725d..9367c9f 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -143,18 +143,21 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
NSMutableDictionary *dict;
NSDictionary *infoDict;
NSString *tem;
-
- dict = [NSMutableDictionary dictionaryWithCapacity:2];
+
+ dict = [NSMutableDictionary dictionaryWithCapacity:3];
infoDict = [[NSBundle mainBundle] infoDictionary];
-
+
[dict setObject: NSLocalizedString (@"The X Window System", @"About panel")
- forKey:@"ApplicationName"];
-
+ forKey:@"ApplicationName"];
+
tem = [infoDict objectForKey:@"CFBundleShortVersionString"];
-
- [dict setObject:[NSString stringWithFormat:@"XQuartz %@ - (xorg-server %s)", tem, XSERVER_VERSION]
- forKey:@"ApplicationVersion"];
-
+
+ [dict setObject:[NSString stringWithFormat:@"XQuartz %@", tem]
+ forKey:@"ApplicationVersion"];
+
+ [dict setObject:[NSString stringWithFormat:@"xorg-server %s", XSERVER_VERSION]
+ forKey:@"Version"];
+
[self orderFrontStandardAboutPanelWithOptions: dict];
}
commit b37e1f1f5ccc5a48df665449b0e31c4d25cc323c
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date: Mon May 12 11:34:06 2008 -0700
Don't need the fink-friendly printf in the DDX anymore.
(cherry picked from commit fe2279440450c795d67ba5a2234b0797d0bfe39c)
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index f20cce1..4f35533 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -153,7 +153,6 @@ DarwinPrintBanner(void)
{
// this should change depending on which specific server we are building
ErrorF("Xquartz starting:\n");
- ErrorF("X.org Release 7.2\n"); // This is here to help fink until they fix their packages.
ErrorF("X.Org X Server %s\nBuild Date: %s\n", XSERVER_VERSION, BUILD_DATE );
}
More information about the xorg-commit
mailing list