Minor fixes for gnu90 compatibility
This commit is contained in:
parent
33fa3a4d41
commit
d5e4b258e1
3 changed files with 15 additions and 13 deletions
5
libtcc.c
5
libtcc.c
|
@ -1033,12 +1033,13 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
|
||||||
case AFF_BINTYPE_DYN:
|
case AFF_BINTYPE_DYN:
|
||||||
if (s1->output_type == TCC_OUTPUT_MEMORY) {
|
if (s1->output_type == TCC_OUTPUT_MEMORY) {
|
||||||
#ifdef TCC_IS_NATIVE
|
#ifdef TCC_IS_NATIVE
|
||||||
char* soname = filename;
|
void* dl;
|
||||||
|
const char* soname = filename;
|
||||||
# ifdef TCC_TARGET_MACHO
|
# ifdef TCC_TARGET_MACHO
|
||||||
if (!strcmp(tcc_fileextension(filename), ".tbd"))
|
if (!strcmp(tcc_fileextension(filename), ".tbd"))
|
||||||
soname = macho_tbd_soname(filename);
|
soname = macho_tbd_soname(filename);
|
||||||
# endif
|
# endif
|
||||||
void* dl = dlopen(soname, RTLD_GLOBAL | RTLD_LAZY);
|
dl = dlopen(soname, RTLD_GLOBAL | RTLD_LAZY);
|
||||||
if (dl) {
|
if (dl) {
|
||||||
tcc_add_dllref(s1, soname)->handle = dl;
|
tcc_add_dllref(s1, soname)->handle = dl;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
2
tcc.h
2
tcc.h
|
@ -247,7 +247,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||||
# define ALSO_TRIPLET(s) s
|
# define ALSO_TRIPLET(s) s
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME: do this at runtime instead; check output of `xcode-select -p`. libxcselect provides this stuff
|
/* FIXME: do this at runtime instead; check output of `xcode-select -p`. libxcselect provides this stuff */
|
||||||
#ifndef CONFIG_OSX_SDK1
|
#ifndef CONFIG_OSX_SDK1
|
||||||
# define CONFIG_OSX_SDK1 "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
|
# define CONFIG_OSX_SDK1 "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
|
||||||
# define CONFIG_OSX_SDK2 "/Applications/Xcode.app/Developer/SDKs/MacOSX.sdk"
|
# define CONFIG_OSX_SDK2 "/Applications/Xcode.app/Developer/SDKs/MacOSX.sdk"
|
||||||
|
|
21
tccmacho.c
21
tccmacho.c
|
@ -841,7 +841,8 @@ ST_FUNC int macho_add_dllref(TCCState* s1, int lev, const char* soname)
|
||||||
{
|
{
|
||||||
/* if the dll is already loaded, do not load it */
|
/* if the dll is already loaded, do not load it */
|
||||||
DLLReference *dllref;
|
DLLReference *dllref;
|
||||||
for(int i = 0; i < s1->nb_loaded_dlls; i++) {
|
int i;
|
||||||
|
for(i = 0; i < s1->nb_loaded_dlls; i++) {
|
||||||
dllref = s1->loaded_dlls[i];
|
dllref = s1->loaded_dlls[i];
|
||||||
if (!strcmp(soname, dllref->name)) {
|
if (!strcmp(soname, dllref->name)) {
|
||||||
/* but update level if needed */
|
/* but update level if needed */
|
||||||
|
@ -866,14 +867,14 @@ ST_FUNC int macho_add_dllref(TCCState* s1, int lev, const char* soname)
|
||||||
#define tbd_parse_trample *pos++=0
|
#define tbd_parse_trample *pos++=0
|
||||||
|
|
||||||
ST_FUNC const char* macho_tbd_soname(const char* filename) {
|
ST_FUNC const char* macho_tbd_soname(const char* filename) {
|
||||||
char* soname;
|
char *soname, *data, *pos, *ret;
|
||||||
|
struct stat sb;
|
||||||
int fd = open(filename,O_RDONLY);
|
int fd = open(filename,O_RDONLY);
|
||||||
if (fd<0) return filename;
|
if (fd<0) return filename;
|
||||||
struct stat sb;
|
|
||||||
fstat(fd,&sb);
|
fstat(fd,&sb);
|
||||||
char* data = load_data(fd, 0, sb.st_size+1);
|
data = load_data(fd, 0, sb.st_size+1);
|
||||||
data[sb.st_size]=0;
|
data[sb.st_size]=0;
|
||||||
char* pos = data;
|
pos = data;
|
||||||
|
|
||||||
if (!tbd_parse_movepast("install-name: ")) return filename;
|
if (!tbd_parse_movepast("install-name: ")) return filename;
|
||||||
tbd_parse_skipws;
|
tbd_parse_skipws;
|
||||||
|
@ -881,7 +882,7 @@ ST_FUNC const char* macho_tbd_soname(const char* filename) {
|
||||||
soname = pos;
|
soname = pos;
|
||||||
if (!tbd_parse_movetoany("\n \"'")) return filename;
|
if (!tbd_parse_movetoany("\n \"'")) return filename;
|
||||||
tbd_parse_trample;
|
tbd_parse_trample;
|
||||||
char* ret = tcc_mallocz(strlen(soname)+1);
|
ret = tcc_mallocz(strlen(soname)+1);
|
||||||
strcpy(ret, soname);
|
strcpy(ret, soname);
|
||||||
// soname = strdup(soname);
|
// soname = strdup(soname);
|
||||||
tcc_free(data);
|
tcc_free(data);
|
||||||
|
@ -890,13 +891,13 @@ ST_FUNC const char* macho_tbd_soname(const char* filename) {
|
||||||
|
|
||||||
ST_FUNC int macho_load_tbd(TCCState* s1, int fd, const char* filename, int lev)
|
ST_FUNC int macho_load_tbd(TCCState* s1, int fd, const char* filename, int lev)
|
||||||
{
|
{
|
||||||
char* soname;
|
char *soname, *data, *pos;
|
||||||
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
fstat(fd,&sb);
|
fstat(fd,&sb);
|
||||||
char* data = load_data(fd, 0, sb.st_size+1);
|
data = load_data(fd, 0, sb.st_size+1);
|
||||||
data[sb.st_size]=0;
|
data[sb.st_size]=0;
|
||||||
char* pos = data;
|
pos = data;
|
||||||
|
|
||||||
if (!tbd_parse_movepast("install-name: ")) return -1;
|
if (!tbd_parse_movepast("install-name: ")) return -1;
|
||||||
tbd_parse_skipws;
|
tbd_parse_skipws;
|
||||||
|
@ -908,9 +909,9 @@ ST_FUNC int macho_load_tbd(TCCState* s1, int fd, const char* filename, int lev)
|
||||||
|
|
||||||
while(pos) {
|
while(pos) {
|
||||||
char* sym = NULL;
|
char* sym = NULL;
|
||||||
|
int cont = 1;
|
||||||
if (!tbd_parse_movepast("symbols: ")) break;
|
if (!tbd_parse_movepast("symbols: ")) break;
|
||||||
if (!tbd_parse_movepast("[")) break;
|
if (!tbd_parse_movepast("[")) break;
|
||||||
int cont = 1;
|
|
||||||
while (cont) {
|
while (cont) {
|
||||||
tbd_parse_skipws;
|
tbd_parse_skipws;
|
||||||
tbd_parse_tramplequote;
|
tbd_parse_tramplequote;
|
||||||
|
|
Loading…
Add table
Reference in a new issue