mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Disable use of a fake main function by default on Darwin/Mac OS X.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4529ebcb0d
commit
dc6aaa64aa
4 changed files with 2936 additions and 16869 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2011-03-17 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
* Source/NSProcessInfo.m (_gnu_process_args): Use C runtime system
|
||||
functions to access command line arguments and the environment
|
||||
under Darwin/Mac OS X.
|
||||
|
||||
* configure.ac: Add special case to disable fake-main by default
|
||||
on Darwin/OS X.
|
||||
|
||||
* configure: Regenerated.
|
||||
|
||||
2011-03-17 15:02 David Chisnall <theraven@gna.org>
|
||||
|
||||
* libs/base/trunk/Source/NSObject.m: Correctly call C++
|
||||
|
|
|
@ -101,6 +101,10 @@
|
|||
#undef id
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && !GS_FAKE_MAIN
|
||||
#include <crt_externs.h>
|
||||
#endif
|
||||
|
||||
#import "GNUstepBase/GSConfig.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
|
@ -448,7 +452,7 @@ _gnu_process_args(int argc, char *argv[], char *env[])
|
|||
IF_NO_GC(RELEASE(arp));
|
||||
}
|
||||
|
||||
#if !GS_FAKE_MAIN && ((defined(HAVE_PROCFS) || defined(HAVE_KVM_ENV) || defined(HAVE_PROCFS_PSINFO)) && (defined(HAVE_LOAD_METHOD)))
|
||||
#if !GS_FAKE_MAIN && ((defined(HAVE_PROCFS) || defined(HAVE_KVM_ENV) || defined(HAVE_PROCFS_PSINFO) || defined(__APPLE__)) && (defined(HAVE_LOAD_METHOD)))
|
||||
/*
|
||||
* We have to save program arguments and environment before main () is
|
||||
* executed, because main () could modify their values before we get a
|
||||
|
@ -623,6 +627,45 @@ static char **_gnu_noobjc_env = NULL;
|
|||
}
|
||||
_gnu_noobjc_argv[i] = NULL;
|
||||
|
||||
return;
|
||||
#elif defined(__APPLE__)
|
||||
/*
|
||||
* Darwin/Mac OS X provides indirect access to command line arguments and
|
||||
* the environment with functions defined in the C runtime system.
|
||||
*/
|
||||
int i, n;
|
||||
int argc = *_NSGetArgc();
|
||||
char **argv = *_NSGetArgv();
|
||||
char **environ = *_NSGetEnviron();
|
||||
|
||||
/* copy environment */
|
||||
n = 0;
|
||||
while (environ[n] != NULL)
|
||||
n++;
|
||||
_gnu_noobjc_env = (char **)malloc(sizeof(char *) * (n + 1));
|
||||
if (_gnu_noobjc_env == NULL)
|
||||
goto malloc_error;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
_gnu_noobjc_env[i] = (char *)strdup(environ[i]);
|
||||
if (_gnu_noobjc_env[i] == NULL)
|
||||
goto malloc_error;
|
||||
}
|
||||
_gnu_noobjc_env[i] = NULL;
|
||||
|
||||
/* copy arguments */
|
||||
_gnu_noobjc_argc = argc;
|
||||
_gnu_noobjc_argv = (char **)malloc(sizeof(char *) * (argc + 1));
|
||||
if (_gnu_noobjc_argv == NULL)
|
||||
goto malloc_error;
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
_gnu_noobjc_argv[i] = (char *)strdup(argv[i]);
|
||||
if (_gnu_noobjc_argv[i] == NULL)
|
||||
goto malloc_error;
|
||||
}
|
||||
_gnu_noobjc_argv[i] = NULL;
|
||||
|
||||
return;
|
||||
#else /* !HAVE_KVM_ENV (i.e. HAVE_PROCFS). */
|
||||
/*
|
||||
|
|
|
@ -2250,8 +2250,12 @@ elif test "$enable_pass_arguments" = "no"; then
|
|||
AC_MSG_WARN([Using libkvm which is known to be buggy on some systems consider configuring with --enable-fake-main instead.])
|
||||
fi
|
||||
else
|
||||
GS_FAKE_MAIN=1
|
||||
enable_fake_main=yes
|
||||
case "$target_os" in
|
||||
darwin* ) ;;
|
||||
* )
|
||||
GS_FAKE_MAIN=1
|
||||
enable_fake_main=yes
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
case "$target_os" in
|
||||
|
|
Loading…
Reference in a new issue