Skip to content

Commit

Permalink
Add __attribute__((constructor)) to macos builds for _init
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrewh committed Dec 27, 2024
1 parent b403254 commit c5a1cef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/unix/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ static init_fn_t
#else
/* If we're a normal shared object, then we override _init.
*/
int
IF_MACOS(__attribute__((constructor))) int
_init(int argc, char **argv, char **envp)
{
# ifdef ANDROID
Expand Down Expand Up @@ -1143,6 +1143,7 @@ get_application_name_helper(bool ignore_cache, bool full_path)
#else
/* OSX kernel puts full app exec path above envp */
char *c, **env = our_environ;
ASSERT(our_environ != NULL && "our_environ is not set in get_application_name_helper");
do {
env++;
} while (*env != NULL);
Expand Down
2 changes: 1 addition & 1 deletion core/unix/preload.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ take_over(const char *pname)
return true;
}

__attribute__((constructor)) int
IF_MACOS(__attribute__((constructor))) int
#if INIT_BEFORE_LIBC
_init(int argc, char *arg0, ...)
{
Expand Down

0 comments on commit c5a1cef

Please sign in to comment.