diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | dln.c | 71 | ||||
-rw-r--r-- | io.c | 6 |
3 files changed, 73 insertions, 9 deletions
@@ -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 @@ -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 */ @@ -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; |