/* Written 2002 by Andi Kleen */ #include #include #include #include #include #include #include /* Make --3gb the default for buggy Java */ #define STUPID_DEFAULT 1 #ifdef STUPID_DEFAULT #define DFL_PER PER_LINUX32_3GB #else #define DFL_PER PER_LINUX32 #endif #define ADDR_LIMIT_3GB 0x8000000 #define PER_LINUX32_3GB (0x0008 | ADDR_LIMIT_3GB) int main(int ac, char **av) { int pers = DFL_PER; char *progname; progname = basename(av[0]); if (!strcmp(progname, "linux64")) { pers= PER_LINUX; /* ignore --3gb or --4gb for linux64 */ if (av[1] && (!strcmp(av[1], "--3gb") || !strcmp(av[1], "--4gb"))) av++; } else if (!strcmp(progname,"linux32")) { pers = DFL_PER; if (av[1] && !strcmp(av[1], "--3gb")) { pers = PER_LINUX32_3GB; av++; } if (av[1] && !strcmp(av[1], "--4gb")) { pers = PER_LINUX32; av++; } } if (!av[1]) { if (pers == PER_LINUX) { /* 64 bit, no options */ fprintf(stderr, "usage: %s program args ...\n", progname); } else { fprintf(stderr, "usage: %s [--3gb] [--4gb] program args ...\n", progname); #if DFL_PER == PER_LINUX32_3GB fprintf(stderr, "Default is --3gb to limit the address space of the 32bit children to 3GB\n"); #endif } exit(1); } if (personality(pers) < 0) { fprintf(stderr, "Cannot set %x personality: %s\n", pers, strerror(errno)); exit(1); } execvp(av[1],av+1); fprintf(stderr, "Cannot execute %s: %s\n", av[1], strerror(errno)); exit(1); }