Check-in [b25d0baade]
Overview
Comment:Windows fixups
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b25d0baadecd89974ebae7cd26dc3418f9b517d1
User & Date: rkeene on 2014-05-02 06:41:22
Other Links: manifest | tags
Context
2014-05-02
07:08
Experimenting with compiling libtcc1.a with gcc check-in: 8a389f5b8d user: rkeene tags: trunk
06:41
Windows fixups check-in: b25d0baade user: rkeene tags: trunk
06:29
Added more cross-compiling support check-in: ea645d2a50 user: rkeene tags: trunk
Changes

Modified build/tcc-patches/0.9.26/tcc-0.9.26-tclio.diff from [e6c607249f] to [8fe78dd24b].

1
2
3

4
5
6
7
8
9
10
1
2

3
4
5
6
7
8
9
10


-
+







diff -uNr tcc-0.9.26.orig/libtcc.c tcc-0.9.26-1tclio/libtcc.c
--- tcc-0.9.26.orig/libtcc.c	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tclio/libtcc.c	2014-05-01 21:14:22.272599405 -0500
+++ tcc-0.9.26-1tclio/libtcc.c	2014-05-02 01:30:08.967140003 -0500
@@ -669,7 +669,7 @@
     bf->line_num = 1;
     bf->ifndef_macro = 0;
     bf->ifdef_stack_ptr = s1->ifdef_stack_ptr;
-    bf->fd = -1;
+    bf->fd = NULL;
     bf->prev = file;
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
93
94
95
96
97
98
99

100
101
102
103
104
105
106
107







-
+







+    size = Tcl_Read(fd, (char *)&ehdr, sizeof(ehdr));
+    Tcl_Seek(fd, 0, SEEK_SET);
     if (size <= 0) {
         tcc_error_noabort("could not read header");
         goto the_end;
diff -uNr tcc-0.9.26.orig/tcc.h tcc-0.9.26-1tclio/tcc.h
--- tcc-0.9.26.orig/tcc.h	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tclio/tcc.h	2014-05-01 21:14:22.294602204 -0500
+++ tcc-0.9.26-1tclio/tcc.h	2014-05-02 01:30:08.967140003 -0500
@@ -429,7 +429,7 @@
 typedef struct BufferedFile {
     uint8_t *buf_ptr;
     uint8_t *buf_end;
-    int fd;
+    Tcl_Channel fd;
     struct BufferedFile *prev;
152
153
154
155
156
157
158
159

160
161
162
163
164
165
166
152
153
154
155
156
157
158

159
160
161
162
163
164
165
166







-
+







-ST_FUNC int pe_load_file(struct TCCState *s1, const char *filename, int fd);
+ST_FUNC int pe_load_file(struct TCCState *s1, const char *filename, Tcl_Channel fd);
 ST_FUNC int pe_output_file(TCCState * s1, const char *filename);
 ST_FUNC int pe_putimport(TCCState *s1, int dllindex, const char *name, addr_t value);
 ST_FUNC SValue *pe_getimport(SValue *sv, SValue *v2);
diff -uNr tcc-0.9.26.orig/tcccoff.c tcc-0.9.26-1tclio/tcccoff.c
--- tcc-0.9.26.orig/tcccoff.c	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tclio/tcccoff.c	2014-05-01 21:14:22.295602331 -0500
+++ tcc-0.9.26-1tclio/tcccoff.c	2014-05-02 01:30:08.967140003 -0500
@@ -858,10 +858,11 @@
     return 0;
 }
 
-ST_FUNC int tcc_load_coff(TCCState * s1, int fd)
+ST_FUNC int tcc_load_coff(TCCState * s1, Tcl_Channel fd)
 {
184
185
186
187
188
189
190
191

192
193
194
195
196
197
198
184
185
186
187
188
189
190

191
192
193
194
195
196
197
198







-
+







+
+    f = fdopen(native_fd, "rb");
     if (!f) {
 	tcc_error("Unable to open .out file for input");
     }
diff -uNr tcc-0.9.26.orig/tccelf.c tcc-0.9.26-1tclio/tccelf.c
--- tcc-0.9.26.orig/tccelf.c	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tclio/tccelf.c	2014-05-01 21:14:22.301603094 -0500
+++ tcc-0.9.26-1tclio/tccelf.c	2014-05-02 01:30:08.967140003 -0500
@@ -2334,13 +2334,13 @@
     return ret;
 }
 
-static void *load_data(int fd, unsigned long file_offset, unsigned long size)
+static void *load_data(Tcl_Channel fd, unsigned long file_offset, unsigned long size)
 {
319
320
321
322
323
324
325
326

327
328
329
330
331
332
333
319
320
321
322
323
324
325

326
327
328
329
330
331
332
333







-
+







-    read(fd, &ehdr, sizeof(ehdr));
+    Tcl_Read(fd, (char *) &ehdr, sizeof(ehdr));
 
     /* test CPU specific stuff */
     if (ehdr.e_ident[5] != ELFDATA2LSB ||
diff -uNr tcc-0.9.26.orig/tccpe.c tcc-0.9.26-1tclio/tccpe.c
--- tcc-0.9.26.orig/tccpe.c	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tclio/tccpe.c	2014-05-01 21:14:22.302603222 -0500
+++ tcc-0.9.26-1tclio/tccpe.c	2014-05-02 01:30:08.967140003 -0500
@@ -1505,10 +1505,10 @@
 
 /* ------------------------------------------------------------- */
 
-static int read_mem(int fd, unsigned offset, void *buffer, unsigned len)
+static int read_mem(Tcl_Channel fd, unsigned offset, void *buffer, unsigned len)
 {
386
387
388
389
390
391
392
393

394
395
396
397
398
399
400
386
387
388
389
390
391
392

393
394
395
396
397
398
399
400







-
+







-ST_FUNC int pe_load_file(struct TCCState *s1, const char *filename, int fd)
+ST_FUNC int pe_load_file(struct TCCState *s1, const char *filename, Tcl_Channel fd)
 {
     int ret = -1;
     char buf[10];
diff -uNr tcc-0.9.26.orig/tccpp.c tcc-0.9.26-1tclio/tccpp.c
--- tcc-0.9.26.orig/tccpp.c	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tclio/tccpp.c	2014-05-01 22:25:10.373511188 -0500
+++ tcc-0.9.26-1tclio/tccpp.c	2014-05-02 01:30:08.967140003 -0500
@@ -360,13 +360,13 @@
     int len;
     /* only tries to read if really end of buffer */
     if (bf->buf_ptr >= bf->buf_end) {
-        if (bf->fd != -1) {
+        if (bf->fd != NULL) {
 #if defined(PARSE_DEBUG)
412
413
414
415
416
417
418












412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430







+
+
+
+
+
+
+
+
+
+
+
+
             }
 
-            if (tcc_open(s1, buf1) < 0)
+            if (tcc_open(s1, buf1) == NULL)
 include_trynext:
                 continue;
 
diff -uNr tcc-0.9.26.orig/win32/tools/tiny_impdef.c tcc-0.9.26-1tclio/win32/tools/tiny_impdef.c
--- tcc-0.9.26.orig/win32/tools/tiny_impdef.c	2013-02-15 08:24:00.000000000 -0600
+++ tcc-0.9.26-1tclio/win32/tools/tiny_impdef.c	2014-05-02 01:31:28.497140003 -0500
@@ -161,7 +161,7 @@
 /* -------------------------------------------------------------- */
 #endif
 
-char *get_export_names(int fd)
+char *get_export_names(Tcl_Channel fd)
 {
     int l, i, n, n0;
     char *p;

Modified tcltcc.c from [bdb10e54ff] to [373fc5958a].

206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
206
207
208
209
210
211
212



213

214
215
216
217
218
219
220







-
-
-

-







                Tcl_AppendResult(interp, "code already relocated, cannot output to file", NULL);
                return TCL_ERROR;
            }
            if (s->output_type == TCC_OUTPUT_MEMORY) {     
                Tcl_AppendResult(interp, "output_type memory not valid for output to file", NULL);
                return TCL_ERROR;
            }
#ifdef WIN32
            res = tcc_output_pe(s,Tcl_GetString(objv[2]));
#else
            res = tcc_output_file(s,Tcl_GetString(objv[2]));
#endif

            if (res!=0) {
                Tcl_AppendResult(interp, "output to file failed", NULL);
                return TCL_ERROR;
            } else {
                return TCL_OK;
            }