summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakiyoshi <akiyoshi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-19 02:09:51 +0000
committerakiyoshi <akiyoshi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-19 02:09:51 +0000
commita23bc676658106e96a00bd294e64ce53249b1392 (patch)
tree0c3749224d162e2e3fa0c95efed18e04ab1f92c8
parentc2d20d7f8cf99d58678c007731c51a3ffa7324fa (diff)
Update for VMS ports.
* dln.c (dln_load): Modify to call lib$find_image_symbol for VMS. * io.c (rb_io_fwrite): Use fputc() for VMS non-stream file. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--dln.c71
-rw-r--r--io.c6
3 files changed, 73 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index ab6370ee45..e3ca223a37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 20 11:00:00 2004 Akiyoshi, Masamichi <masamichi.akiyoshi@hp.com>
+
+ * dln.c (dln_load): Modify to call lib$find_image_symbol for VMS.
+ * io.c (rb_io_fwrite): Use fputc() for VMS non-stream file.
+
Thu Aug 19 06:07:45 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/token.c: re2c no longer compiled with bit vectors. caused
diff --git a/dln.c b/dln.c
index 87a8fa6f91..8f0b2a0409 100644
--- a/dln.c
+++ b/dln.c
@@ -1261,6 +1261,19 @@ aix_loaderror(const char *pathname)
}
#endif
+#if defined(__VMS)
+#include <starlet.h>
+#include <rms.h>
+#include <stsdef.h>
+#include <unixlib.h>
+#include <descrip.h>
+#include <lib$routines.h>
+
+static char *vms_filespec;
+static int vms_fileact(char *filespec, int type);
+static long vms_fisexh(long *sigarr, long *mecarr);
+#endif
+
void*
dln_load(file)
const char *file;
@@ -1561,9 +1574,16 @@ dln_load(file)
#if defined(__VMS)
#define DLN_DEFINED
{
- void *handle, (*init_fct)();
+ long status;
+ void (*init_fct)();
char *fname, *p1, *p2;
+ $DESCRIPTOR(fname_d, "");
+ $DESCRIPTOR(image_d, "");
+ $DESCRIPTOR(buf_d, "");
+
+ decc$to_vms(file, vms_fileact, 0, 0);
+
fname = (char *)__alloca(strlen(file)+1);
strcpy(fname,file);
if (p1 = strrchr(fname,'/'))
@@ -1571,19 +1591,35 @@ dln_load(file)
if (p2 = strrchr(fname,'.'))
*p2 = '\0';
- if ((handle = (void*)dlopen(fname, 0)) == NULL) {
+ fname_d.dsc$w_length = strlen(fname);
+ fname_d.dsc$a_pointer = fname;
+ image_d.dsc$w_length = strlen(vms_filespec);
+ image_d.dsc$a_pointer = vms_filespec;
+ buf_d.dsc$w_length = strlen(buf);
+ buf_d.dsc$a_pointer = buf;
+
+ lib$establish(vms_fisexh);
+
+ status = lib$find_image_symbol (
+ &fname_d,
+ &buf_d,
+ &init_fct,
+ &image_d);
+
+ lib$establish(0);
+
+ if (status == RMS$_FNF) {
error = dln_strerror();
goto failed;
- }
-
- if ((init_fct = (void (*)())dlsym(handle, buf)) == NULL) {
+ } else if (!$VMS_STATUS_SUCCESS(status)) {
error = DLN_ERROR();
- dlclose(handle);
goto failed;
}
+
/* Call the init code */
(*init_fct)();
- return handle;
+
+ return 1;
}
#endif /* __VMS */
@@ -1824,3 +1860,24 @@ dln_find_1(fname, path, exe_flag)
/* otherwise try the next component in the search path */
}
}
+
+#if defined(__VMS)
+
+/* action routine for decc$to_vms */
+static int vms_fileact(char *filespec, int type)
+{
+ if (vms_filespec)
+ free(vms_filespec);
+ vms_filespec = malloc(strlen(filespec)+1);
+ strcpy(vms_filespec, filespec);
+ return 1;
+}
+
+/* exception handler for LIB$FIND_IMAGE_SYMBOL */
+static long vms_fisexh(long *sigarr, long *mecarr)
+{
+ sys$unwind(1, 0);
+ return 1;
+}
+
+#endif /* __VMS */
diff --git a/io.c b/io.c
index 1556a86f73..09fbde48f9 100644
--- a/io.c
+++ b/io.c
@@ -135,7 +135,9 @@ static VALUE lineno = INT2FIX(0);
#elif defined(__BEOS__)
# define READ_DATA_PENDING(fp) (fp->_state._eof == 0)
#elif defined(__VMS)
-# define READ_DATA_PENDING(fp) (((unsigned int)((*(fp))->_flag) & _IOEOF) == 0)
+# define READ_DATA_PENDING_COUNT(fp) ((unsigned int)(*(fp))->_cnt)
+# define READ_DATA_PENDING(fp) (((unsigned int)(*(fp))->_cnt) > 0)
+# define READ_DATA_BUFFERED(fp) 0
#else
/* requires systems own version of the ReadDataPending() */
extern int ReadDataPending();
@@ -385,7 +387,7 @@ rb_io_fwrite(ptr, len, f)
long n, r;
if ((n = len) <= 0) return n;
-#ifdef __human68k__
+#if defined(__human68k__) || defined(__vms)
do {
if (fputc(*ptr++, f) == EOF) {
if (ferror(f)) return -1L;