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
This commit is contained in:
akiyoshi 2004-08-19 02:09:51 +00:00
parent c2d20d7f8c
commit a23bc67665
3 changed files with 74 additions and 10 deletions

View file

@ -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> 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 * ext/syck/token.c: re2c no longer compiled with bit vectors. caused

73
dln.c
View file

@ -1261,6 +1261,19 @@ aix_loaderror(const char *pathname)
} }
#endif #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* void*
dln_load(file) dln_load(file)
const char *file; const char *file;
@ -1561,9 +1574,16 @@ dln_load(file)
#if defined(__VMS) #if defined(__VMS)
#define DLN_DEFINED #define DLN_DEFINED
{ {
void *handle, (*init_fct)(); long status;
void (*init_fct)();
char *fname, *p1, *p2; 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); fname = (char *)__alloca(strlen(file)+1);
strcpy(fname,file); strcpy(fname,file);
if (p1 = strrchr(fname,'/')) if (p1 = strrchr(fname,'/'))
@ -1571,19 +1591,35 @@ dln_load(file)
if (p2 = strrchr(fname,'.')) if (p2 = strrchr(fname,'.'))
*p2 = '\0'; *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(); error = dln_strerror();
goto failed; goto failed;
} else if (!$VMS_STATUS_SUCCESS(status)) {
error = DLN_ERROR();
goto failed;
} }
if ((init_fct = (void (*)())dlsym(handle, buf)) == NULL) {
error = DLN_ERROR();
dlclose(handle);
goto failed;
}
/* Call the init code */ /* Call the init code */
(*init_fct)(); (*init_fct)();
return handle;
return 1;
} }
#endif /* __VMS */ #endif /* __VMS */
@ -1824,3 +1860,24 @@ dln_find_1(fname, path, exe_flag)
/* otherwise try the next component in the search path */ /* 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 */

6
io.c
View file

@ -135,7 +135,9 @@ static VALUE lineno = INT2FIX(0);
#elif defined(__BEOS__) #elif defined(__BEOS__)
# define READ_DATA_PENDING(fp) (fp->_state._eof == 0) # define READ_DATA_PENDING(fp) (fp->_state._eof == 0)
#elif defined(__VMS) #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 #else
/* requires systems own version of the ReadDataPending() */ /* requires systems own version of the ReadDataPending() */
extern int ReadDataPending(); extern int ReadDataPending();
@ -385,7 +387,7 @@ rb_io_fwrite(ptr, len, f)
long n, r; long n, r;
if ((n = len) <= 0) return n; if ((n = len) <= 0) return n;
#ifdef __human68k__ #if defined(__human68k__) || defined(__vms)
do { do {
if (fputc(*ptr++, f) == EOF) { if (fputc(*ptr++, f) == EOF) {
if (ferror(f)) return -1L; if (ferror(f)) return -1L;