From 9f5c69c96d122c16fc0a6c131bc3b40605576a86 Mon Sep 17 00:00:00 2001 From: Tijl Coosemans Date: Fri, 24 Aug 2007 15:46:36 +0200 Subject: [PATCH] loader: Introduce FreeBSD loader. --- .gitignore | 2 ++ configure | 5 ++++ configure.ac | 3 +++ loader/Makefile.in | 9 +++++++ loader/freebsd.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 loader/freebsd.c diff --git a/.gitignore b/.gitignore index be3dbc071c..95e06ac158 100644 --- a/.gitignore +++ b/.gitignore @@ -764,6 +764,8 @@ libs/wpp/ppl.yy.c libs/wpp/ppy.tab.c libs/wpp/ppy.tab.h loader/wine +loader/wine-freebsd +loader/wine-freebsd-installed loader/wine-glibc loader/wine-glibc-installed loader/wine-kthread diff --git a/configure b/configure index ac5c0929d0..a94ced776a 100755 --- a/configure +++ b/configure @@ -15622,6 +15622,11 @@ MAIN_BINARY="wine-pthread" MAIN_BINARY="wine-glibc" EXTRA_BINARIES="wine-kthread wine-pthread wine-preloader" + ;; + freebsd*) + MAIN_BINARY="wine-freebsd" + + EXTRA_BINARIES="wine-pthread" ;; esac ;; diff --git a/configure.ac b/configure.ac index 64be416106..16a6370fcf 100644 --- a/configure.ac +++ b/configure.ac @@ -1224,6 +1224,9 @@ case $host_cpu in linux* | k*bsd*-gnu) AC_SUBST(MAIN_BINARY,"wine-glibc") AC_SUBST(EXTRA_BINARIES,"wine-kthread wine-pthread wine-preloader") ;; + freebsd*) + AC_SUBST(MAIN_BINARY,"wine-freebsd") + AC_SUBST(EXTRA_BINARIES,"wine-pthread") ;; esac ;; esac diff --git a/loader/Makefile.in b/loader/Makefile.in index f94e08f9c9..ef60a56e10 100644 --- a/loader/Makefile.in +++ b/loader/Makefile.in @@ -5,6 +5,7 @@ VPATH = @srcdir@ MODULE = wine C_SRCS = \ + freebsd.c \ glibc.c \ kthread.c \ main.c \ @@ -20,6 +21,8 @@ WINE_BINARIES = $(MAIN_BINARY) $(EXTRA_BINARIES) PROGRAMS = \ wine \ + wine-freebsd \ + wine-freebsd-installed \ wine-glibc \ wine-glibc-installed \ wine-kthread \ @@ -40,6 +43,12 @@ all: $(WINE_BINARIES) $(WINE_BINARIES:%=%-installed) $(MODULE) $(MANPAGES) LIBPTHREAD = @LIBPTHREAD@ LDEXECFLAGS = @LDEXECFLAGS@ +wine-freebsd: freebsd.o Makefile.in + $(CC) -o $@ freebsd.o $(LIBWINE) $(LIBPORT) $(LIBPTHREAD) $(EXTRALIBS) $(LDFLAGS) $(LDRPATH_LOCAL) + +wine-freebsd-installed: freebsd.o Makefile.in + $(CC) -o $@ freebsd.o $(LIBWINE) $(LIBPORT) $(LIBPTHREAD) $(EXTRALIBS) $(LDFLAGS) $(LDRPATH_INSTALL) + wine-glibc: glibc.o Makefile.in $(CC) -o $@ glibc.o $(LIBWINE) $(LIBPORT) $(LIBPTHREAD) $(EXTRALIBS) $(LDFLAGS) $(LDRPATH_LOCAL) diff --git a/loader/freebsd.c b/loader/freebsd.c new file mode 100644 index 0000000000..0d0eb5767c --- /dev/null +++ b/loader/freebsd.c @@ -0,0 +1,61 @@ +/* + * FreeBSD loader + * + * Copyright 2007 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" +#include "wine/port.h" + +#include +#include +#include +#ifdef HAVE_SYS_RESOURCE_H +# include +#endif + +#include "wine/library.h" + +/* build a new full path from the specified path and name */ +static const char *build_new_path( const char *path, const char *name ) +{ + const char *p; + char *ret; + + if (!(p = strrchr( path, '/' ))) return name; + p++; + ret = malloc( (p - path) + strlen(name) + 1 ); + memcpy( ret, path, p - path ); + strcpy( ret + (p - path), name ); + return ret; +} + +/********************************************************************** + * main + */ +int main( int argc, char *argv[] ) +{ + const char *new_argv0 = build_new_path( argv[0], "wine-pthread" ); + struct rlimit rl; + rl.rlim_cur = 0x02000000; + rl.rlim_max = 0x02000000; + setrlimit( RLIMIT_DATA, &rl ); + wine_init_argv0_path( new_argv0 ); + wine_exec_wine_binary( NULL, argv, NULL ); + fprintf( stderr, "wine: could not exec %s\n", new_argv0 ); + exit(1); +}