History

Minor fixes for gnu90 compatibility

Sushant Pandurangi committed 5 years ago

Commit d5e4b251 parent 33fa3a43 files · +15 −13Browse files

Unified · Split

3 files
  1. libtcc.c +3 −2
  2. tcc.h +1 −1
  3. tccmacho.c +11 −10
libtcc.c+3−2
@@ -1033,12 +1033,13 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 1032 unmodified lines
1033 case AFF_BINTYPE_DYN:1033 case AFF_BINTYPE_DYN:
1034 if (s1->output_type == TCC_OUTPUT_MEMORY) {1034 if (s1->output_type == TCC_OUTPUT_MEMORY) {
1035#ifdef TCC_IS_NATIVE1035#ifdef TCC_IS_NATIVE
1036 char* soname = filename;1036 void* dl;
1037 const char* soname = filename;
1037# ifdef TCC_TARGET_MACHO1038# ifdef TCC_TARGET_MACHO
1038 if (!strcmp(tcc_fileextension(filename), ".tbd"))1039 if (!strcmp(tcc_fileextension(filename), ".tbd"))
1039 soname = macho_tbd_soname(filename);1040 soname = macho_tbd_soname(filename);
1040# endif1041# endif
1041 void* dl = dlopen(soname, RTLD_GLOBAL | RTLD_LAZY);1042 dl = dlopen(soname, RTLD_GLOBAL | RTLD_LAZY);
1042 if (dl) {1043 if (dl) {
1043 tcc_add_dllref(s1, soname)->handle = dl;1044 tcc_add_dllref(s1, soname)->handle = dl;
1044 ret = 0;1045 ret = 0;
tcc.h+1−1
@@ -247,7 +247,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 246 unmodified lines
247# define ALSO_TRIPLET(s) s247# define ALSO_TRIPLET(s) s
248#endif248#endif
249 249
250// FIXME: do this at runtime instead; check output of `xcode-select -p`. libxcselect provides this stuff250/* FIXME: do this at runtime instead; check output of `xcode-select -p`. libxcselect provides this stuff */
251#ifndef CONFIG_OSX_SDK1251#ifndef CONFIG_OSX_SDK1
252# define CONFIG_OSX_SDK1 "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"252# define CONFIG_OSX_SDK1 "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
253# define CONFIG_OSX_SDK2 "/Applications/Xcode.app/Developer/SDKs/MacOSX.sdk"253# define CONFIG_OSX_SDK2 "/Applications/Xcode.app/Developer/SDKs/MacOSX.sdk"
tccmacho.c+11−10
@@ -841,7 +841,8 @@ ST_FUNC int macho_add_dllref(TCCState* s1, int lev, const char* soname) · 840 unmodified lines
841{841{
842 /* if the dll is already loaded, do not load it */842 /* if the dll is already loaded, do not load it */
843 DLLReference *dllref;843 DLLReference *dllref;
844 for(int i = 0; i < s1->nb_loaded_dlls; i++) {844 int i;
845 for(i = 0; i < s1->nb_loaded_dlls; i++) {
845 dllref = s1->loaded_dlls[i];846 dllref = s1->loaded_dlls[i];
846 if (!strcmp(soname, dllref->name)) {847 if (!strcmp(soname, dllref->name)) {
847 /* but update level if needed */848 /* but update level if needed */
@@ -866,14 +867,14 @@ ST_FUNC int macho_add_dllref(TCCState* s1, int lev, const char* soname) · 18 unmodified lines
866#define tbd_parse_trample *pos++=0867#define tbd_parse_trample *pos++=0
867 868
868ST_FUNC const char* macho_tbd_soname(const char* filename) {869ST_FUNC const char* macho_tbd_soname(const char* filename) {
869 char* soname;870 char *soname, *data, *pos, *ret;
871 struct stat sb;
870 int fd = open(filename,O_RDONLY);872 int fd = open(filename,O_RDONLY);
871 if (fd<0) return filename;873 if (fd<0) return filename;
872 struct stat sb;
873 fstat(fd,&sb);874 fstat(fd,&sb);
874 char* data = load_data(fd, 0, sb.st_size+1);875 data = load_data(fd, 0, sb.st_size+1);
875 data[sb.st_size]=0;876 data[sb.st_size]=0;
876 char* pos = data;877 pos = data;
877 878
878 if (!tbd_parse_movepast("install-name: ")) return filename;879 if (!tbd_parse_movepast("install-name: ")) return filename;
879 tbd_parse_skipws;880 tbd_parse_skipws;
@@ -881,7 +882,7 @@ ST_FUNC const char* macho_tbd_soname(const char* filename) { · 1 unmodified line
881 soname = pos;882 soname = pos;
882 if (!tbd_parse_movetoany("\n \"'")) return filename;883 if (!tbd_parse_movetoany("\n \"'")) return filename;
883 tbd_parse_trample;884 tbd_parse_trample;
884 char* ret = tcc_mallocz(strlen(soname)+1);885 ret = tcc_mallocz(strlen(soname)+1);
885 strcpy(ret, soname);886 strcpy(ret, soname);
886 // soname = strdup(soname);887 // soname = strdup(soname);
887 tcc_free(data);888 tcc_free(data);
@@ -890,13 +891,13 @@ ST_FUNC const char* macho_tbd_soname(const char* filename) { · 2 unmodified lines
890 891
891ST_FUNC int macho_load_tbd(TCCState* s1, int fd, const char* filename, int lev)892ST_FUNC int macho_load_tbd(TCCState* s1, int fd, const char* filename, int lev)
892{893{
893 char* soname;894 char *soname, *data, *pos;
894 895
895 struct stat sb;896 struct stat sb;
896 fstat(fd,&sb);897 fstat(fd,&sb);
897 char* data = load_data(fd, 0, sb.st_size+1);898 data = load_data(fd, 0, sb.st_size+1);
898 data[sb.st_size]=0;899 data[sb.st_size]=0;
899 char* pos = data;900 pos = data;
900 901
901 if (!tbd_parse_movepast("install-name: ")) return -1;902 if (!tbd_parse_movepast("install-name: ")) return -1;
902 tbd_parse_skipws;903 tbd_parse_skipws;
@@ -908,9 +909,9 @@ ST_FUNC int macho_load_tbd(TCCState* s1, int fd, const char* filename, int lev) · 5 unmodified lines
908 909
909 while(pos) {910 while(pos) {
910 char* sym = NULL;911 char* sym = NULL;
912 int cont = 1;
911 if (!tbd_parse_movepast("symbols: ")) break;913 if (!tbd_parse_movepast("symbols: ")) break;
912 if (!tbd_parse_movepast("[")) break;914 if (!tbd_parse_movepast("[")) break;
913 int cont = 1;
914 while (cont) {915 while (cont) {
915 tbd_parse_skipws;916 tbd_parse_skipws;
916 tbd_parse_tramplequote;917 tbd_parse_tramplequote;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t