Check-in [7256978106]
Overview
Comment:Updated to fail to open files and set path to library
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 72569781067f4247d4b3f676a34d2e477d1ff56c
User & Date: rkeene on 2014-05-02 03:32:24
Other Links: manifest | tags
Context
2014-05-02
03:43
Updated library paths check-in: 8c5cb4e725 user: rkeene tags: trunk
03:32
Updated to fail to open files and set path to library check-in: 7256978106 user: rkeene tags: trunk
03:10
Updated to create additional install directories check-in: ae8cc5e6e3 user: rkeene tags: trunk
Changes

Modified build/tcc-patches/0.9.26/tcc-0.9.26-tclio.diff from [81bcf0a4f9] to [e6c607249f].

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 20:13:50.626814210 -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;


|







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
@@ -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
+    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 19:55:39.093986611 -0500
@@ -429,7 +429,7 @@
 typedef struct BufferedFile {
     uint8_t *buf_ptr;
     uint8_t *buf_end;
-    int fd;
+    Tcl_Channel fd;
     struct BufferedFile *prev;







|







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
@@ -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
-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 20:02:37.695836363 -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)
 {







|







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
@@ -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
+
+    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 20:14:26.278515126 -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)
 {







|







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
@@ -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
-    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 20:09:11.572909155 -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)
 {







|







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
@@ -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
401
402
403
404
405
406
407
408
409









-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 20:12:26.967021662 -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)
             len = 8;
 #else
             len = IO_BUF_SIZE;
 #endif
-            len = read(bf->fd, bf->buffer, len);
+            len = Tcl_Read(bf->fd, bf->buffer, len);
             if (len < 0)
                 len = 0;
         } else {
















|
















>
>
>
>
>
>
>
>
>
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
-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
@@ -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)
             len = 8;
 #else
             len = IO_BUF_SIZE;
 #endif
-            len = read(bf->fd, bf->buffer, len);
+            len = Tcl_Read(bf->fd, bf->buffer, len);
             if (len < 0)
                 len = 0;
         } else {
@@ -1484,7 +1484,7 @@
                 goto include_done;
             }
 
-            if (tcc_open(s1, buf1) < 0)
+            if (tcc_open(s1, buf1) == NULL)
 include_trynext:
                 continue;
 

Modified tcltcc.c from [056e832bbd] to [cebccc8dc1].

256
257
258
259
260
261
262


263
264
265
266
267
268
269
		}
	}

	s = tcc_new();
	if (s == NULL) {
		return(TCL_ERROR);
	}



	tcc_set_error_func(s, interp, (void *)&TccErrorFunc);

	ts = (void *) ckalloc(sizeof(*ts));
	ts->s = s;
    	ts->relocated = 0;








>
>







256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
		}
	}

	s = tcc_new();
	if (s == NULL) {
		return(TCL_ERROR);
	}

	s->tcc_lib_path = Tcl_GetString(objv[1]);

	tcc_set_error_func(s, interp, (void *)&TccErrorFunc);

	ts = (void *) ckalloc(sizeof(*ts));
	ts->s = s;
    	ts->relocated = 0;