]>
git.saurik.com Git - apple/dyld.git/blob - src/glue.c
1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
3 * Copyright (c) 2004-2005 Apple Computer, Inc. All rights reserved.
5 * @APPLE_LICENSE_HEADER_START@
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
22 * @APPLE_LICENSE_HEADER_END@
33 // Stub functions needed for dyld to link with libc.a instead of libSystem.dylib
36 static char* dyld_progname
= "dyld";
39 // libc has calls to _dyld_lookup_and_bind to find args and environment. Since
40 // dyld links with a staic copy of libc, those calls need to find dyld's args and env
41 // not the host process. We implement a special _dyld_lookup_and_bind() that
42 // just knows how to bind the few symbols needed by dyld.
44 void _dyld_lookup_and_bind(const char* symbolName
, void** address
, void* module)
46 if ( strcmp(symbolName
, "_environ") == 0 ) {
47 // dummy up empty environment list
48 static char *p
= NULL
;
49 static char **pp
= &p
;
53 else if ( strcmp(symbolName
, "___progname") == 0 ) {
54 *address
= &dyld_progname
;
58 fprintf(stderr
, "dyld: internal error: unknown symbol '%s'\n", symbolName
);
62 int NSIsSymbolNameDefined(const char* symbolName
)
64 if ( strcmp(symbolName
, "___progname") == 0 ) {
67 fprintf(stderr
, "dyld: internal error: unknown symbol '%s'\n", symbolName
);
73 * To avoid linking in libm. These variables are defined as they are used in
74 * pthread_init() to put in place a fast sqrt().
76 size_t hw_sqrt_len
= 0;
90 * More stubs to avoid linking in libm. This works as along as we don't use
94 __fpclassifyd(double x
)
100 __fpclassify(long double x
)
106 char* __hdtoa(double d
, const char *xdigs
, int ndigits
, int *decpt
, int *sign
, char **rve
)
111 char* __hldtoa(/*long*/ double e
, const char *xdigs
, int ndigits
, int *decpt
, int *sign
, char **rve
)
116 int __fegetfltrounds(void)
118 return 1; /* FE_NEAREST */
122 * We have our own localtime() to avoid needing the notify API which is used
123 * by the code in libc.a for localtime() but is in libnotify.
125 struct tm
* localtime(const time_t* t
)
127 return (struct tm
*)NULL
;
131 * On ppc64, the C++ runtime references strftime & wcsftime, but they
132 * never actually get called, and they try to use all the localtime()
133 * machinery, so stub them out.
136 size_t strftime(char * __restrict p1
, size_t p2
, const char * __restrict p3
,
137 const struct tm
* __restrict p4
)
141 size_t wcsftime(wchar_t * __restrict p1
, size_t p2
,
142 const wchar_t * __restrict p3
,
143 const struct tm
* __restrict p4
)
148 int __strtopdd (const char* p1
, char** p2
, double* p3
)
153 char* __ldtoa(long double *ld
, int mode
, int ndigits
, int *decpt
, int *sign
, char **rve
)