summaryrefslogtreecommitdiff
path: root/hw/xquartz/quartzStartup.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xquartz/quartzStartup.c')
-rw-r--r--hw/xquartz/quartzStartup.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index bc16fc3e1..4dc4dd630 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -48,7 +48,8 @@
#include <pthread.h>
-int dix_main(int argc, char **argv, char **envp);
+int
+dix_main(int argc, char **argv, char **envp);
struct arg {
int argc;
@@ -57,63 +58,72 @@ struct arg {
};
_X_NORETURN
-static void server_thread (void *arg) {
+static void
+server_thread(void *arg)
+{
struct arg args = *((struct arg *)arg);
free(arg);
- exit (dix_main(args.argc, args.argv, args.envp));
+ exit(dix_main(args.argc, args.argv, args.envp));
}
-static pthread_t create_thread (void *func, void *arg) {
+static pthread_t
+create_thread(void *func, void *arg)
+{
pthread_attr_t attr;
pthread_t tid;
-
- pthread_attr_init (&attr);
- pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
- pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
- pthread_create (&tid, &attr, func, arg);
- pthread_attr_destroy (&attr);
-
+
+ pthread_attr_init(&attr);
+ pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ pthread_create(&tid, &attr, func, arg);
+ pthread_attr_destroy(&attr);
+
return tid;
}
-void QuartzInitServer(int argc, char **argv, char **envp) {
- struct arg *args = (struct arg*)malloc(sizeof(struct arg));
- if(!args)
+void
+QuartzInitServer(int argc, char **argv, char **envp)
+{
+ struct arg *args = (struct arg *)malloc(sizeof(struct arg));
+ if (!args)
FatalError("Could not allocate memory.\n");
-
+
args->argc = argc;
args->argv = argv;
args->envp = envp;
-
+
if (!create_thread(server_thread, args)) {
FatalError("can't create secondary thread\n");
}
}
-int server_main(int argc, char **argv, char **envp) {
- int i;
- int fd[2];
-
+int
+server_main(int argc, char **argv, char **envp)
+{
+ int i;
+ int fd[2];
+
/* Unset CFProcessPath, so our children don't inherit this kludge we need
* to load our nib. If an xterm gets this set, then it fails to
* 'open hi.txt' properly.
*/
unsetenv("CFProcessPath");
-
+
// Make a pipe to pass events
- assert( pipe(fd) == 0 );
+ assert(pipe(fd) == 0);
darwinEventReadFD = fd[0];
darwinEventWriteFD = fd[1];
fcntl(darwinEventReadFD, F_SETFL, O_NONBLOCK);
-
+
for (i = 1; i < argc; i++) {
// Display version info without starting Mac OS X UI if requested
- if (!strcmp( argv[i], "-showconfig" ) || !strcmp( argv[i], "-version" )) {
+ if (!strcmp(argv[i],
+ "-showconfig") || !strcmp(argv[i], "-version")) {
DarwinPrintBanner();
exit(0);
}
}
-
+
X11ControllerMain(argc, argv, envp);
exit(0);
}