From d0b3651906aa943423e430a61437a42f7dd39422 Mon Sep 17 00:00:00 2001 From: H_Konishi Date: Tue, 11 Jun 2002 01:27:48 +0000 Subject: [PATCH] new platform [bccwin32] merged. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 16 ++ bcc32/Makefile.sub | 542 ++++++++++++++++++++++++++++++++++++++++ bcc32/README.bcc32 | 123 +++++++++ bcc32/configure.bat | 11 + bcc32/mkexports.rb | 26 ++ bcc32/setup.mak | 50 ++++ error.c | 3 + ext/Win32API/Win32API.c | 34 +++ ext/digest/defs.h | 2 + ext/dl/depend | 8 +- ext/dl/dl.c | 2 +- ext/dl/extconf.rb | 15 ++ ext/dl/sym.c | 2 +- ext/extmk.rb.in | 123 ++++++--- ext/pty/extconf.rb | 2 +- ext/socket/extconf.rb | 4 + ext/tcltklib/extconf.rb | 8 +- file.c | 22 +- hash.c | 12 + instruby.rb | 2 +- io.c | 3 + lib/ftools.rb | 2 +- lib/mkmf.rb | 91 +++++-- win32/dir.h | 7 + win32/resource.rb | 2 + win32/win32.c | 71 +++++- win32/win32.h | 79 ++++-- 27 files changed, 1174 insertions(+), 88 deletions(-) create mode 100644 bcc32/Makefile.sub create mode 100644 bcc32/README.bcc32 create mode 100644 bcc32/configure.bat create mode 100644 bcc32/mkexports.rb create mode 100644 bcc32/setup.mak diff --git a/ChangeLog b/ChangeLog index 8565268514..c01d4ed26e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Tue Jun 11 10:18:23 2002 KONISHI Hiromasa + + * new platform [bccwin32] merged. + - create new folder bcc32 + - modify any files for bccwin32 + error.c, file.c, hash.c, io.c, instruby.rb, + ext/extmk.rb.in, + lib/mkmf.rb, lib/ftools.rb, + ext/digest/defs.h, + ext/dl/depend, ext/dl/dl.c, ext/dl/sym.c, ext/dl/extconf.rb, + ext/socket/extconf.rb, + ext/pty/extconf.rb, + ext/tcltklib/extconf.rb + ext/Win32API/Win32API.c, + win32/dir.h, win32/win32.c, win32/win32.h, win32/resource.rb + Mon Jun 10 19:02:19 2002 Nobuyoshi Nakada * numeric.c (fix_lshift): negative shift count means right shift. diff --git a/bcc32/Makefile.sub b/bcc32/Makefile.sub new file mode 100644 index 0000000000..9ef83105cc --- /dev/null +++ b/bcc32/Makefile.sub @@ -0,0 +1,542 @@ +SHELL = $(COMSPEC) + +#### Start of system configuration section. #### + +## variables may be overridden by $(compile_dir)/Makefile +!ifndef srcdir +srcdir = .. +!endif +!ifndef RUBY_INSTALL_NAME +RUBY_INSTALL_NAME = ruby +!endif +!ifndef RUBYW_INSTALL_NAME +RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME:ruby=rubyw) +!elif "$(RUBYW_INSTALL_NAME)" == "$(RUBY_INSTALL_NAME)" +RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME:ruby=rubyw) +!endif +!if "$(RUBYW_INSTALL_NAME)" == "$(RUBY_INSTALL_NAME)" +RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME)w +!endif +!ifndef RUBY_SO_NAME +RUBY_SO_NAME = rubybcc +!endif +!ifndef icondirs +!ifdef ICONDIRS +icondirs=$(ICONDIRS) +!endif +!endif +!ifdef icondirs +icondirs=$(icondirs:\=/) +iconinc=-I$(icondirs: = -I) +!endif +############### + +VPATH = $(srcdir):$(srcdir)/missing +.SUFFIXES: .y + +!ifndef CC +CC = bcc32 +!endif +!ifndef RC +RC = brc32 +!endif +!ifndef YACC +YACC = byacc +!endif +PURIFY = +AUTOCONF = autoconf + +!if !defined(PROCESSOR_ARCHITECTURE) || "$(PROCESSOR_ARCHITECTURE)" == "x86" +!ifndef PROCESSOR_LEVEL +PROCESSOR_LEVEL = 5 +!endif +PROCESSOR_FLAG = -$(PROCESSOR_LEVEL) +CPU = i$(PROCESSOR_LEVEL)86 +ARCH = i$(PROCESSOR_LEVEL)86 +!else +CPU = $(PROCESSOR_ARCHITECTURE) +ARCH = $(PROCESSOR_ARCHITECTURE) +!endif +!ifndef DEBUGFLAGS +DEBUGFLAGS = +!endif +!ifndef OPTFLAGS +OPTFLAGS = -O +!endif +OS = bccwin32 + +!ifndef prefix +prefix = /usr +!endif +!ifndef DESTDIR +DESTDIR = $(prefix) +!endif +!ifndef CFLAGS +CFLAGS = -DNT=1 $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG) -w-aus -w-par -w-pro +!endif +!ifndef CPPFLAGS +CPPFLAGS = -I. -I$(srcdir) -I$(srcdir)missing -DLIBRUBY_SO=\"$(LIBRUBY_SO)\" +!endif +!ifndef LDFLAGS +LDFLAGS = $(CFLAGS) +!endif +!ifndef XLDFLAGS +XLDFLAGS = +!endif +!ifndef RFLAGS +RFLAGS = -r +!endif +!ifndef EXTLIBS +EXTLIBS = # cw32.lib +!endif +LIBS = $(EXTLIBS) +MISSING = acosh.obj crypt.obj win32.obj + +!ifndef STACK +STACK = 0x2000000 +!endif + +LDSHARED = $(CC) -lS:$(STACK) +LINK = $(LDSHARED) -WC +LINK_W = $(LDSHARED) -W +LINK_SO = $(LDSHARED) -WD + +DLDFLAGS = +SOLIBS = + +EXEEXT = .exe +PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT) +WPROGRAM=$(RUBYW_INSTALL_NAME)$(EXEEXT) +RUBYDEF = $(RUBY_SO_NAME).def +MINIRUBY=miniruby$(EXEEXT) + +ORGLIBPATH = $(LIB) + +#### End of system configuration section. #### + +LIBRUBY_A = lib$(RUBY_INSTALL_NAME).lib +LIBRUBY_SO = $(RUBY_SO_NAME).dll +LIBRUBY = $(RUBY_SO_NAME).lib +LIBRUBYARG = $(LIBRUBY) + +EXTOBJS = dmyext.obj + +MAINOBJ = main.obj +WINMAINOBJ = winmain.obj + +OBJS = array.obj \ + bignum.obj \ + class.obj \ + compar.obj \ + dir.obj \ + dln.obj \ + enum.obj \ + error.obj \ + eval.obj \ + file.obj \ + gc.obj \ + hash.obj \ + inits.obj \ + io.obj \ + marshal.obj \ + math.obj \ + numeric.obj \ + object.obj \ + pack.obj \ + parse.obj \ + prec.obj \ + process.obj \ + random.obj \ + range.obj \ + re.obj \ + regex.obj \ + ruby.obj \ + signal.obj \ + sprintf.obj \ + st.obj \ + string.obj \ + struct.obj \ + time.obj \ + util.obj \ + variable.obj \ + version.obj \ + $(MISSING) + +all: miniruby$(EXEEXT) rbconfig.rb ext/extmk.rb \ + $(LIBRUBY) $(MISCLIBS) + @.\miniruby$(EXEEXT) -Cext extmk.rb + +ruby: $(PROGRAM) +rubyw: $(WPROGRAM) +lib: $(LIBRUBY) +dll: $(LIBRUBY_SO) + +config: config.h config.status + +config.h: Makefile $(srcdir)bcc32/Makefile.sub + @echo Creating config.h + type > $@ &&| +\#define HAVE_PROTOTYPES 1 +\#define HAVE_STDARG_PROTOTYPES 1 +/* \#define HAVE_ATTR_NORETURN 1 */ +\#define NORETURN(x) x +\#define TOKEN_PASTE(x,y) x\#\#y +\#define inline __inline +/* \#define HAVE_DIRENT_H 1 */ +/* \#define HAVE_UNISTD_H 1 */ +\#define HAVE_STDLIB_H 1 +\#define HAVE_LIMITS_H 1 +/* \#define HAVE_SYS_FILE_H 1 */ +\#define HAVE_FCNTL_H 1 +/* \#define HAVE_PWD_H 1 */ +/* \#define HAVE_SYS_TIME_H 1 */ +/* \#define HAVE_SYS_TIMES_H 1 */ +/* \#define HAVE_SYS_PARAM_H 1 */ +/* \#define HAVE_SYS_WAIT_H 1 */ +\#define HAVE_STRING_H 1 +/* \#define HAVE_UTIME_H 1 */ +\#define HAVE_MEMORY_H 1 +/* \#define HAVE_ST_BLKSIZE 1 */ +\#define HAVE_ST_RDEV 1 +/* \#define GETGROUPS_T gid_t */ +\#define GETGROUPS_T int +\#define RETSIGTYPE void +\#define HAVE_ALLOCA 1 +\#define vfork fork +\#define HAVE_FMOD 1 +/* \#define HAVE_RANDOM 1 */ +\#define HAVE_WAITPID 1 +\#define HAVE_GETCWD 1 +/* \#define HAVE_TRUNCATE 1 */ +\#define HAVE_CHSIZE 1 +\#define HAVE_TIMES 1 +/* \#define HAVE_UTIMES 1 */ +/* \#define HAVE_FCNTL 1 */ +/* \#define HAVE_SETITIMER 1 */ +\#define HAVE_GETGROUPS 1 +/* \#define HAVE_SIGPROCMASK 1 */ +\#define HAVE_GETLOGIN 1 +\#define HAVE_TELLDIR 1 +\#define HAVE_SEEKDIR 1 +\#define HAVE_COSH 1 +\#define HAVE_SINH 1 +\#define HAVE_TANH 1 + +\#define RSHIFT(x,y) ((x)>>y) +\#define FILE_COUNT level +\#define FILE_READPTR curp +\#define DEFAULT_KCODE KCODE_NONE +\#define DLEXT ".so" +\#define DLEXT2 ".dll" +\#define RUBY_LIB "/lib/ruby/1.7" +\#define RUBY_SITE_LIB "/lib/ruby/site_ruby" +\#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/1.7" +\#define RUBY_PLATFORM "$(ARCH)-$(OS)" +\#define RUBY_ARCHLIB "/lib/ruby/1.7/$(ARCH)-$(OS)" +\#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/1.7/$(ARCH)-$(OS)" + +\#define SIZEOF_INT 4 +\#define SIZEOF_SHORT 2 +\#define SIZEOF_LONG 4 +\#define SIZEOF___INT64 8 +\#define SIZEOF_VOIDP 4 +\#define SIZEOF_FLOAT 4 +\#define SIZEOF_DOUBLE 8 + +\#define HAVE_DECL_SYS_NERR 1 +\#define HAVE_ISINF 1 +\#define HAVE_ISNAN 1 +\#define HAVE_MEMMOVE 1 +\#define HAVE_MKDIR 1 +\#define HAVE_STRCASECMP 1 +\#define HAVE_STRNCASECMP 1 +\#define HAVE_STRCHR 1 +\#define HAVE_STRERROR 1 +\#define HAVE_STRFTIME 1 +\#define HAVE_STRSTR 1 +\#define HAVE_STRTOD 1 +\#define HAVE_STRTOUL 1 +| + +config.status: Makefile $(srcdir)bcc32/Makefile.sub $(MINIRUBY) + @echo Creating config.status + @$(MINIRUBY) -pe "~/@CFLAGS@/||$$_.sub!(/'$(CFLAGS)'/, '$$(CFLAGS)')" > $@ &&| +# Generated automatically by Makefile.sub. +s,@SHELL@,$$(COMSPEC),;t t +s,@CFLAGS@,$(CFLAGS),;t t +s,@CPPFLAGS@,$(CPPFLAGS),;t t +s,@CXXFLAGS@,$(CXXFLAGS),;t t +s,@FFLAGS@,$(FFLAGS),;t t +s,@LDFLAGS@,$(LDFLAGS),;t t +s,@LIBS@,,;t t +s,@exec_prefix@,$${prefix},;t t +s,@prefix@,,;t t +s,@program_transform_name@,s,,,,;t t +s,@bindir@,$${exec_prefix}/bin,;t t +s,@sbindir@,$${exec_prefix}/sbin,;t t +s,@libexecdir@,$${exec_prefix}/libexec,;t t +s,@datadir@,$${prefix}/share,;t t +s,@sysconfdir@,$${prefix}/etc,;t t +s,@sharedstatedir@,/etc,;t t +s,@localstatedir@,/var,;t t +s,@libdir@,$${exec_prefix}/lib,;t t +s,@includedir@,$${prefix}/include,;t t +s,@oldincludedir@,/usr/include,;t t +s,@infodir@,$${prefix}/info,;t t +s,@mandir@,$${prefix}/man,;t t +s,@build@,$(CPU)-pc-$(OS),;t t +s,@build_alias@,$(CPU)-$(OS),;t t +s,@build_cpu@,$(CPU),;t t +s,@build_vendor@,pc,;t t +s,@build_os@,$(OS),;t t +s,@host@,$(CPU)-pc-$(OS),;t t +s,@host_alias@,$(CPU)-$(OS),;t t +s,@host_cpu@,$(CPU),;t t +s,@host_vendor@,pc,;t t +s,@host_os@,$(OS),;t t +s,@target@,$(ARCH)-pc-$(OS),;t t +s,@target_alias@,$(ARCH)-$(OS),;t t +s,@target_cpu@,$(ARCH),;t t +s,@target_vendor@,pc,;t t +s,@target_os@,$(OS),;t t +s,@CC@,$(CC),;t t +s,@CPP@,cpp32,;t t +s,@YACC@,$(YACC),;t t +s,@RANLIB@,rem,;t t +s,@AR@,tlib -nologo,;t t +s,@LN_S@,$(LN_S),;t t +s,@SET_MAKE@,$(SET_MAKE),;t t +s,@LIBOBJS@, acosh.obj crypt.obj win32.obj,;t t +s,@ALLOCA@,$(ALLOCA),;t t +s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t +s,@EXEEXT@,.exe,;t t +s,@OBJEXT@,obj,;t t +s,@XLDFLAGS@,$(XLDFLAGS),;t t +s,@DLDFLAGS@,$$(CFLAGS),;t t +s,@STATIC@,$(STATIC),;t t +s,@CCDLFLAGS@,-DIMPORT,;t t +s,@LDSHARED@,ilink32 -S:$(STACK) -Tpd,;t t +s,@DLEXT@,so,;t t +s,@DLEXT2@,dll,;t t +s,@STRIP@,$(STRIP),;t t +s,@EXTSTATIC@,$(EXTSTATIC),;t t +s,@setup@,Setup,;t t +s,@LIBRUBY_LDSHARED@,$(LIBRUBY_LDSHARED),;t t +s,@LIBRUBY_DLDFLAGS@,$(LIBRUBY_DLDFLAGS),;t t +s,@RUBY_INSTALL_NAME@,$(RUBY_INSTALL_NAME),;t t +s,@RUBY_SO_NAME@,$(RUBY_SO_NAME),;t t +s,@LIBRUBY_A@,lib$$(RUBY_INSTALL_NAME).lib,;t t +s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t +s,@LIBRUBY_ALIASES@,$(LIBRUBY_ALIASES),;t t +s,@LIBRUBY@,$$(RUBY_SO_NAME).lib,;t t +s,@LIBRUBYARG@,$$(RUBY_SO_NAME).lib,;t t +s,@SOLIBS@,$(SOLIBS),;t t +s,@DLDLIBS@,$(DLDLIBS),;t t +s,@ENABLE_SHARED@,yes,;t t +s,@arch@,$(ARCH)-$(OS),;t t +s,@sitedir@,$${prefix}/lib/ruby/site_ruby,;t t +s,@configure_args@,--enable-shared $(configure_args),;t t +s,@configure_input@,$$configure_input,;t t +s,@srcdir@,$(srcdir),;t t +s,@top_srcdir@,$(srcdir),;t t +| + +ext/extmk.rb: $(srcdir)ext/extmk.rb.in config.status + @echo Creating ext/extmk.rb + @.\miniruby$(EXEEXT) $(srcdir)ext/configsub.rb \ + -srcdir=$(srcdir) \ + -install_name=$(RUBY_INSTALL_NAME) \ + -so_name=$(RUBY_SO_NAME) \ + -output=$@ $(srcdir)ext/extmk.rb.in + +miniruby$(EXEEXT): $(OBJS) $(MAINOBJ) $(EXTOBJS) + @echo $(EXTOBJS) + @echo $(LIBS) + $(LINK) -e$@ $(MAINOBJ) $(EXTOBJS) $(OBJS) $(LIBS) + +$(PROGRAM): $(MAINOBJ) $(LIBRUBY_SO) $(*:.exe=.res) + $(LINK) -e$@ $(MAINOBJ) $(LIBRUBYARG) + +$(WPROGRAM): $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_SO) $(*:.exe=.res) + $(LINK_W) -e$@ $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBYARG) + +$(LIBRUBY_A): $(OBJS) dmyext.obj + @-if exist $@ del $@ + tlib $@ /a @&&| +$(OBJS) dmyext.obj +| + +$(LIBRUBY): $(LIBRUBY_SO) + implib $@ $(LIBRUBY_SO) + +$(LIBRUBY_SO): $(LIBRUBY_A) $(EXTOBJS) $(RUBYDEF) $(*:.dll=.res) + $(LINK_SO) -e$@ $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $(LIBS) + +$(RUBYDEF): $(LIBRUBY_A) miniruby$(EXEEXT) + .\miniruby$(EXEEXT) $(srcdir)bcc32/mkexports.rb -output=$@ $(LIBRUBY_A) + +install: rbconfig.rb + .\miniruby$(EXEEXT) $(srcdir)instruby.rb $(DESTDIR) + +clean: clean-ext clean-local + +clean-local: + @if exist $(LIBRUBY_A) del $(LIBRUBY_A) + @if exist $(MAINOBJ) del $(MAINOBJ) + @if exist rbconfig.rb del rbconfig.rb + @if exist ext\extinit.c del ext\extinit.c + @if exist ext\extinit.obj del ext\extinit.obj + @if exist ext\vc*.pdb del ext\vc*.pdb + @if exist *.obj del *.obj + @if exist *.res del *.res + @if exist *.tds del *.tds + +clean-ext: + @-.\miniruby$(EXEEXT) -Cext extmk.rb clean + +distclean: distclean-ext distclean-local + +distclean-local: clean-local + @if exist Makefile del Makefile + @if exist ext\extmk.rb del ext\extmk.rb + @if exist config.h del config.h + @if exist ext\config.cache del ext\config.cache + @if exist config.cache del config.cache + @if exist config.log del config.log + @if exist config.status del config.status + @if exist *~ del *~ + @if exist *.bak del *.bak + @if exist *.stackdump del *.stackdump + @if exist *.core del *.core + @if exist gmon.out del gmon.out + @if exist y.tab.c del y.tab.c + @if exist y.output del y.output + @if exist *.map del *.map + @if exist *.pdb del *.pdb + @if exist *.ilk del *.ilk + @if exist *.exp del *.exp + @if exist $(RUBYDEF) del $(RUBYDEF) + @if exist pub.def del pub.def + @if exist $(RUBY_INSTALL_NAME).rc del $(RUBY_INSTALL_NAME).rc + @if exist $(RUBYW_INSTALL_NAME).rc del $(RUBYW_INSTALL_NAME).rc + @if exist $(LIBRUBY_SO).rc del $(LIBRUBY_SO).rc + @if exist $(PROGRAM) del $(PROGRAM) + @if exist $(WPROGRAM) del $(WPROGRAM) + @if exist $(LIBRUBY_SO) del $(LIBRUBY_SO) + @if exist $(LIBRUBY) del $(LIBRUBY) + @if exist ext\nul if not exist ext\* rmdir ext + @if exist miniruby$(EXEEXT) del miniruby$(EXEEXT) + +distclean-ext: + @-.\miniruby$(EXEEXT) -Cext extmk.rb distclean + +realclean: distclean + @if exist parse.c del parse.c + @if exist lex.c del lex.c + +test: miniruby$(EXEEXT) + @.\miniruby$(EXEEXT) $(srcdir)rubytest.rb + +rbconfig.rb: miniruby$(EXEEXT) config.status + @.\miniruby$(EXEEXT) $(srcdir)mkconfig.rb -srcdir=$(srcdir) \ + -install_name=$(RUBY_INSTALL_NAME) \ + -so_name=$(RUBY_SO_NAME) rbconfig.rb + +$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(LIBRUBY_SO).rc: rbconfig.rb + @.\miniruby$(EXEEXT) $(srcdir)win32/resource.rb \ + -ruby_name=$(RUBY_INSTALL_NAME) \ + -rubyw_name=$(RUBYW_INSTALL_NAME) \ + -so_name=$(LIBRUBY_SO) \ + . $(icondirs) $(srcdir)/win32 + +#config.status: $(srcdir)configure +# $(SHELL) .config.status --recheck + +.path.c = .;$(srcdir);$(srcdir)win32;$(srcdir)missing +.path.h = .;$(srcdir);$(srcdir)win32;$(srcdir)missing +.path.y = $(srcdir) + +.c.obj: + $(CC) $(CFLAGS) -I. $(CPPFLAGS) -c $(<:/=\) + +.rc.res: + $(RC) -I. -I$( $(@F) + @del y.tab.c + +parse.c: parse.y + +acosh.obj: acosh.c win32.h +alloca.obj: alloca.c win32.h +crypt.obj: crypt.c win32.h +dup2.obj: dup2.c win32.h +finite.obj: finite.c win32.h +flock.obj: flock.c win32.h +isinf.obj: isinf.c win32.h +isnan.obj: isnan.c win32.h +memcmp.obj: memcmp.c win32.h +memmove.obj: memmove.c win32.h +mkdir.obj: mkdir.c win32.h +vsnprintf.obj: vsnprintf.c win32.h +strcasecmp.obj: strcasecmp.c win32.h +strncasecmp.obj: strncasecmp.c win32.h +strchr.obj: strchr.c win32.h +strdup.obj: strdup.c win32.h +strerror.obj: strerror.c win32.h +strftime.obj: strftime.c win32.h +strstr.obj: strstr.c win32.h +strtod.obj: strtod.c win32.h +strtol.obj: strtol.c win32.h +strtoul.obj: strtoul.c win32.h +nt.obj: nt.c win32.h +x68.obj: x68.c win32.h +os2.obj: os2.c win32.h +dl_os2.obj: dl_os2.c win32.h + +# when I use -I., there is confliction at "OpenFile" +# so, set . into environment varible "include" +win32.obj: win32.c win32.h + +### +parse.obj: parse.c ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c win32.h +### +array.obj: array.c ruby.h config.h defines.h intern.h win32.h +bignum.obj: bignum.c ruby.h config.h defines.h intern.h win32.h +class.obj: class.c ruby.h config.h defines.h intern.h node.h st.h win32.h +compar.obj: compar.c ruby.h config.h defines.h intern.h win32.h +dir.obj: dir.c ruby.h config.h defines.h intern.h win32.h +dln.obj: dln.c config.h defines.h dln.h win32.h +dmyext.obj: dmyext.c win32.h +enum.obj: enum.c ruby.h config.h defines.h intern.h win32.h +error.obj: error.c ruby.h config.h defines.h intern.h env.h win32.h +eval.obj: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h win32.h +file.obj: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h win32.h +gc.obj: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h win32.h +hash.obj: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.h win32.h +inits.obj: inits.c ruby.h config.h defines.h intern.h win32.h +io.obj: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h env.h win32.h +main.obj: main.c ruby.h config.h defines.h intern.h win32.h +marshal.obj: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h win32.h +prec.obj: prec.c ruby.h config.h defines.h intern.h win32.h +math.obj: math.c ruby.h config.h defines.h intern.h win32.h +numeric.obj: numeric.c ruby.h config.h defines.h intern.h win32.h +object.obj: object.c ruby.h config.h defines.h intern.h st.h win32.h +pack.obj: pack.c ruby.h config.h defines.h intern.h win32.h +process.obj: process.c ruby.h config.h defines.h intern.h rubysig.h st.h win32.h +random.obj: random.c ruby.h config.h defines.h intern.h win32.h +range.obj: range.c ruby.h config.h defines.h intern.h win32.h +re.obj: re.c ruby.h config.h defines.h intern.h re.h regex.h win32.h +regex.obj: regex.c config.h regex.h util.h win32.h +ruby.obj: ruby.c ruby.h config.h defines.h intern.h dln.h util.h win32.h +signal.obj: signal.c ruby.h config.h defines.h intern.h rubysig.h win32.h +sprintf.obj: sprintf.c ruby.h config.h defines.h intern.h win32.h +st.obj: st.c config.h st.h win32.h +string.obj: string.c ruby.h config.h defines.h intern.h re.h regex.h win32.h +struct.obj: struct.c ruby.h config.h defines.h intern.h win32.h +time.obj: time.c ruby.h config.h defines.h intern.h win32.h +util.obj: util.c ruby.h config.h defines.h intern.h util.h win32.h +variable.obj: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h win32.h +version.obj: version.c ruby.h config.h defines.h intern.h version.h win32.h diff --git a/bcc32/README.bcc32 b/bcc32/README.bcc32 new file mode 100644 index 0000000000..fe55046013 --- /dev/null +++ b/bcc32/README.bcc32 @@ -0,0 +1,123 @@ +=begin + += How to build ruby using Borland C++ + +== Requirement + +(1) Borland C++ 5.0 or later. + +(2) If you want to run `((%make clean%))' or `((%make distclean%))' + properly, you must install UNIX compatible `((%rm%))' command on + your ((|PATH|)). + +(3) Please set environment variable (({INCLUDE})), (({LIB})), (({PATH})) + to run required commands properly from the command line. + + Note: building ruby requires following commands. + * make + * bcc + * tlib + * ilink + +== How to compile and install + +(1) Execute bcc32\configure.bat on your build directory. + ex. c:\ruby-1.6.7>bcc32\configure.bat + +(2) Change ((|RUBY_INSTALL_NAME|)) and ((|RUBY_SO_NAME|)) in (({Makefile})) + if you want to change the name of the executable files. + And add ((|RUBYW_INSTALL_NAME|)) to change the name of the + executable without console window if also you want. + +(3) Run `((%make%))' + +(4) Run `((%make test%))' + +(5) Run `((%make DESTDIR= install%))' + + This command will create following directories and install files onto them. + * \bin + * \lib + * \lib\ruby + * \lib\ruby\. + * \lib\ruby\.\ + * \lib\ruby\site_ruby + * \lib\ruby\site_ruby\. + * \lib\ruby\site_ruby\.\ + * \man\man1 + If Ruby's version is `x.y.z', the ((||)) is `x' and the ((||)) is `y'. + The ((||)) is usually `(({i586-bccwin32}))'. + +== Icons + +Any icon files(*.ico) in the build directory, directories specified with +((|icondirs|)) make variable and (({win32})) directory under the ruby +source directory will be included in DLL or executable files, according +to their base names. + $(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe + $(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe + the others --> $(RUBY_SO_NAME).dll + +Although no icons are distributed with the ruby source or in the official +site, you can use anything you like. For example, followings are written +in Japanese, but you can download at least. + +* (()) or + (()) +* (()) or + (()) + +== Build examples + +* Build on the ruby source directory. + + ex.) + ruby source directory: C:\ruby + build directory: C:\ruby + install directory: C:\usr\local + + C: + cd \ruby + bcc32\configure + make + make test + make DESTDIR=/usr/local install + +* Build on the relative directory from the ruby source directory. + + ex.) + ruby source directory: C:\ruby + build directory: C:\ruby\bccwin32 + install directory: C:\usr\local + + C: + cd \ruby + mkdir bccwin32 + cd bccwin32 + ..\bcc32\configure + make + make test + make DESTDIR=/usr/local install + +* Build on the different drive. + + ex.) + ruby source directory: C:\src\ruby + build directory: D:\build\ruby + install directory: C:\usr\local + + D: + cd D:\build\ruby + C:\src\ruby\bcc32\configure + make + make test + make DESTDIR=C:/usr/local install + +== Bugs + +You can ((*NOT*)) use a path name contains any white space characters as +the ruby source directory, this restriction comes from the behavior of +(({!INCLUDE})) directives of (({MAKE})). +((- you may call it a bug. -)) + +=end diff --git a/bcc32/configure.bat b/bcc32/configure.bat new file mode 100644 index 0000000000..b9067c6688 --- /dev/null +++ b/bcc32/configure.bat @@ -0,0 +1,11 @@ +@echo off +::: Don't set environment variable in batch file other than autoexec.bat +::: to avoid "Out of environment space" problem on Windows 95/98. +::: set TMPMAKE=~tmp~.mak + +echo> ~tmp~.mak #### +echo>> ~tmp~.mak conf = %0 +echo>> ~tmp~.mak $(conf:\=/): +echo>> ~tmp~.mak @del ~tmp~.mak +echo>> ~tmp~.mak make -Dbcc32dir="$(@D)" -f$(@D)/setup.mak %1 +make -f ~tmp~.mak diff --git a/bcc32/mkexports.rb b/bcc32/mkexports.rb new file mode 100644 index 0000000000..46edf190ee --- /dev/null +++ b/bcc32/mkexports.rb @@ -0,0 +1,26 @@ +#!./miniruby -s + +SYM = {} +objs = ARGV.collect {|s| s.tr('/', '\\')} +system("tdump -oiPUBDEF -oiPUBD32 #{objs.join(' ')} > pub.def") + +IO.foreach('pub.def'){|l| + next unless /(PUBDEF|PUBD32)/ =~ l + /'(.*?)'/ =~ l + SYM[$1] = true +} + +exports = [] +if $name + exports << "Name " + $name +elsif $library + exports << "Library " + $library +end +exports << "Description " + $description.dump if $description +exports << "EXPORTS" << SYM.keys.sort + +if $output + open($output, 'w') {|f| f.puts exports.join("\n")} +else + puts exports.join("\n") +end diff --git a/bcc32/setup.mak b/bcc32/setup.mak new file mode 100644 index 0000000000..38c98133fb --- /dev/null +++ b/bcc32/setup.mak @@ -0,0 +1,50 @@ +# -*- makefile -*- + +!if "$(bcc32dir)" == "bcc32/" +srcdir = ./ +!elseif "$(bcc32dir)" == "../bcc32/" +srcdir = ../ +!else +srcdir = $(bcc32dir)../ +!endif + +OS = bccwin32 + +all: ext makefile + @echo type `make' to make ruby for bccwin32. + +makefile: make_s make_e + +make_s: + @if exist makefile @del makefile + @echo ### makefile for ruby $(OS) ###> makefile + @echo srcdir = $(srcdir:\=/)>> makefile + @echo RUBY_INSTALL_NAME = ruby>> makefile + @echo RUBY_SO_NAME = $(OS)_$$(RUBY_INSTALL_NAME)17>> makefile + +make_e: + @echo !INCLUDE $$(srcdir)bcc32/makefile.sub>> makefile + +ext: + @if not exist $@\* mkdir $@ + +pl3: + @echo PROCESSOR_LEVEL = 3 >> makefile + +pl4: + @echo PROCESSOR_LEVEL = 4 >> makefile + +pl5: + @echo PROCESSOR_LEVEL = 5 >> makefile + +pl6: + @echo PROCESSOR_LEVEL = 6 >> makefile + +3: ext make_s pl3 make_e + +4: ext make_s pl4 make_e + +5: ext make_s pl5 make_e + +6: ext make_s pl6 make_e + diff --git a/error.c b/error.c index 8d95e4a395..26c16328df 100644 --- a/error.c +++ b/error.c @@ -732,6 +732,9 @@ rb_sys_fail(mesg) rb_bug("rb_sys_fail() - errno == 0"); } +#ifdef __BORLANDC__ + if (errno == EPIPE) return; // (*moriq*) +#endif err = strerror(errno); if (mesg) { volatile VALUE tmp = rb_str_inspect(rb_str_new2(mesg)); diff --git a/ext/Win32API/Win32API.c b/ext/Win32API/Win32API.c index 65b6a558c1..b9f16e2519 100644 --- a/ext/Win32API/Win32API.c +++ b/ext/Win32API/Win32API.c @@ -148,6 +148,15 @@ Win32API_initialize(self, dllname, proc, import, export) return Qnil; } +#ifdef __BORLANDC__ +int c_m( FARPROC api, long* p ) +{ + long pp[16]; + memcpy( pp, p, 16*sizeof(long) ); + return api(); +} +#endif + static VALUE Win32API_Call(argc, argv, obj) int argc; @@ -175,6 +184,10 @@ Win32API_Call(argc, argv, obj) int nimport, timport, texport, i; int items; int ret; +#ifdef __BORLANDC__ + long* ptr; + long p[16]; +#endif items = rb_scan_args(argc, argv, "0*", &args); @@ -192,6 +205,9 @@ Win32API_Call(argc, argv, obj) nimport, items); if (0 < nimport) { +#ifdef __BORLANDC__ + ptr = p + ( nimport - 1 ); +#endif for (i = nimport - 1; 0 <= i; i--) { VALUE str; import_type = rb_ary_entry(obj_import, i); @@ -215,6 +231,9 @@ Win32API_Call(argc, argv, obj) #else #error #endif +#elif defined(__BORLANDC__) + *ptr = lParam; + --ptr; #elif defined __GNUC__ asm volatile ("pushl %0" :: "g" (lParam)); #else @@ -247,6 +266,9 @@ Win32API_Call(argc, argv, obj) #else #error #endif +#elif defined(__BORLANDC__) + *ptr = (long)pParam; + --ptr; #elif defined __GNUC__ asm volatile ("pushl %0" :: "g" (pParam)); #else @@ -275,16 +297,28 @@ Win32API_Call(argc, argv, obj) #else switch (texport) { case _T_NUMBER: +#if defined(__BORLANDC__) + Return = INT2NUM((long)c_m(ApiFunction, p)); +#else ApiFunctionNumber = (ApiNumber *) ApiFunction; Return = INT2NUM(ApiFunctionNumber()); +#endif break; case _T_POINTER: +#if defined(__BORLANDC__) + Return = rb_str_new2((char *)c_m(ApiFunction, p)); +#else ApiFunctionPointer = (ApiPointer *) ApiFunction; Return = rb_str_new2((char *)ApiFunctionPointer()); +#endif break; case _T_INTEGER: +#if defined(__BORLANDC__) + Return = INT2NUM((int)c_m(ApiFunction, p)); +#else ApiFunctionInteger = (ApiInteger *) ApiFunction; Return = INT2NUM(ApiFunctionInteger()); +#endif break; case _T_VOID: default: diff --git a/ext/digest/defs.h b/ext/digest/defs.h index df7df377b9..8e44cf6fa2 100644 --- a/ext/digest/defs.h +++ b/ext/digest/defs.h @@ -27,6 +27,8 @@ typedef unsigned long long uint64_t; # elif defined(_MSC_VER) typedef unsigned _int64 uint64_t; +# elif defined(__BORLANDC__) + typedef unsigned __int64 uint64_t; # else # define NO_UINT64_T # endif diff --git a/ext/dl/depend b/ext/dl/depend index 552c67d0f5..313fac43a7 100644 --- a/ext/dl/depend +++ b/ext/dl/depend @@ -6,19 +6,19 @@ LDSHARED_TEST = $(LDSHARED) $(LDFLAGS) test/test.o -o test/libtest.so $(LOCAL_LI libtest.so: test/libtest.so test/libtest.so: test/test.o test/libtest.def - $(RUBY) -rftools -e 'ARGV.each{|d|File.mkpath(File.dirname(d))}' $@ + $(RUBY) -rftools -e 'ARGV.each do|d|File.mkpath(File.dirname(d))end' $@ $(LDSHARED_TEST:dl.def=test/libtest.def) test/test.o: $(srcdir)/test/test.c @$(RUBY) -rftools -e 'File.mkpath(*ARGV)' test $(CC) $(CFLAGS) $(CPPFLAGS) -c $(srcdir)/test/test.c -o $@ -test:: dl.so libtest.so .force +test:: dl.so libtest.so force $(RUBY) -I. -I$(srcdir)/lib $(srcdir)/test/test.rb -.force: +force: -.PHONY: .force test +.PHONY: force test allclean: distclean @rm -f $(CLEANFILES) $(DISTCLEANFILES) diff --git a/ext/dl/dl.c b/ext/dl/dl.c index 935ae33e32..dd4f4423b5 100644 --- a/ext/dl/dl.c +++ b/ext/dl/dl.c @@ -626,7 +626,7 @@ rb_dl_callback(int argc, VALUE argv[], VALUE self) rb_assoc_new(INT2NUM(rettype),INT2NUM(entry)), rb_assoc_new(type,proc)); sprintf(fname, "rb_dl_callback_func_%d_%d", rettype, entry); - return rb_dlsym_new(rb_dl_callback_table[rettype][entry], fname, STR2CSTR(type)); + return rb_dlsym_new((void (*)())rb_dl_callback_table[rettype][entry], fname, STR2CSTR(type)); } static VALUE diff --git a/ext/dl/extconf.rb b/ext/dl/extconf.rb index 7b7c48f1a2..46b3c6c87d 100644 --- a/ext/dl/extconf.rb +++ b/ext/dl/extconf.rb @@ -176,6 +176,21 @@ $INSTALLFILES = [ ["dl.h", "$(archdir)$(target_prefix)", ""], ] +if /bccwin32/ =~ RUBY_PLATFORM + srcdir = $top_srcdir + "/ext/dl/" + if !FileTest.exist?( srcdir+"dl.def.org" ) + File.copy( srcdir+"dl.def", srcdir+"dl.def.org" ) + open( srcdir+"dl.def.org" ){ |f| + open( "dl.def", "w" ) { |g| + g.print f.gets + while line = f.gets + g.print "_", line + end + } + } + end +end + create_makefile('dl') rescue SystemExit # do nothing diff --git a/ext/dl/sym.c b/ext/dl/sym.c index bc51ebe102..3326d6743f 100644 --- a/ext/dl/sym.c +++ b/ext/dl/sym.c @@ -140,7 +140,7 @@ rb_dlsym_s_new(int argc, VALUE argv[], VALUE self) sname = NIL_P(name) ? NULL : StringValuePtr(name); stype = NIL_P(type) ? NULL : StringValuePtr(type); - val = rb_dlsym_new(saddr, sname, stype); + val = rb_dlsym_new((void (*)())saddr, sname, stype); if( val != Qnil ){ rb_obj_call_init(val, argc, argv); diff --git a/ext/extmk.rb.in b/ext/extmk.rb.in index 55dee24780..34c30638fc 100644 --- a/ext/extmk.rb.in +++ b/ext/extmk.rb.in @@ -28,7 +28,7 @@ $extlist = [] $libdir = "@libdir@" $top_srcdir = "@top_srcdir@" -if $top_srcdir !~ "^/" +if $top_srcdir !~ ("^" + File::SEPARATOR) # get absolute path $top_srcdir = File.expand_path($top_srcdir) end @@ -72,6 +72,8 @@ if RUBY_PLATFORM == "m68k-human" end if /mswin32/ =~ RUBY_PLATFORM OUTFLAG = '-Fe' +elsif /bccwin32/ =~ RUBY_PLATFORM + OUTFLAG = '-o' else OUTFLAG = '-o ' end @@ -101,7 +103,7 @@ def try_link0(src, opt="") cfile.print src cfile.close ldflags = $LDFLAGS - if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty? + if /mswin32|bccwin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty? ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';') else ldflags = ldflags.dup @@ -110,7 +112,7 @@ def try_link0(src, opt="") begin xsystem(Config::expand(format(LINK, $CFLAGS, $CPPFLAGS, ldflags, opt, $LOCAL_LIBS))) ensure - ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM + ENV['LIB'] = ORIG_LIBPATH if /mswin32|bccwin32/ =~ RUBY_PLATFORM end end @@ -119,6 +121,9 @@ def try_link(src, opt="") try_link0(src, opt) ensure rm_f "conftest*" + if /bccwin32/ =~ RUBY_PLATFORM + rm_f "c0x32*" + end end end @@ -162,7 +167,7 @@ end def install_rb(mfile, srcdir = nil) libdir = "lib" - libdir = srcdir + "/" + libdir if srcdir + libdir = File.join(srcdir, libdir) if srcdir path = [] dir = [] if File.directory? libdir @@ -186,7 +191,7 @@ def install_rb(mfile, srcdir = nil) end def append_library(libs, lib) - if /mswin32/ =~ RUBY_PLATFORM + if /mswin32|bccwin32/ =~ RUBY_PLATFORM lib + ".lib " + libs else "-l" + lib + " " + libs @@ -196,7 +201,7 @@ end def have_library(lib, func="main") if func && func != "" libs = append_library($libs, lib) - if /mswin32|mingw/ =~ RUBY_PLATFORM + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM return true if lib == 'm' r = try_link(<<"SRC", libs) #include @@ -249,7 +254,7 @@ end def have_func(func, header=nil) libs = $libs src = - if /mswin32|mingw/ =~ RUBY_PLATFORM + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM r = <<"SRC" #include #include @@ -293,7 +298,7 @@ def arg_config(config, default=nil) unless defined? $configure_args $configure_args = {} args = "@configure_args@" - if /mswin32|mingw/ =~ RUBY_PLATFORM and ENV["CONFIGURE_ARGS"] + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM and ENV["CONFIGURE_ARGS"] args << " " << ENV["CONFIGURE_ARGS"] end for arg in Shellwords::shellwords(args) @@ -386,9 +391,16 @@ def create_makefile(target) end end defflag = target + ".def" + elsif RUBY_PLATFORM =~ /bccwin32/ + deffile = target + '.def' + if not File.exist? target + '.def' + open(deffile, 'wb') do |f| + f.print "EXPORTS\n", "_Init_", target, "\n" + end + end end - if RUBY_PLATFORM =~ /mswin32/ + if RUBY_PLATFORM =~ /mswin32|bccwin32/ libpath = $LIBPATH.join(';') else $LIBPATH.each {|d| $DLDFLAGS << " -L" << d} @@ -397,7 +409,7 @@ def create_makefile(target) end end - $srcdir = $top_srcdir + "/ext/" + $mdir + $srcdir = File.join($top_srcdir,"ext",$mdir) mfile = open("Makefile", "w") mfile.binmode if /mingw/ =~ RUBY_PLATFORM mfile.printf "\ @@ -415,8 +427,15 @@ CC = @CC@ CFLAGS = %s #{CFLAGS} #$CFLAGS CPPFLAGS = -I$(topdir) -I$(hdrdir) %s #$CPPFLAGS -DLDFLAGS = #$DLDFLAGS #$LDFLAGS -LDSHARED = @LDSHARED@ #{defflag} +#{ +if /bccwin32/ =~ RUBY_PLATFORM + "DLDFLAGS = #$LDFLAGS -L" + '"$(topdir:/=\\)"' + "\n" + + "LDSHARED = @LDSHARED@\n" +else + "DLDFLAGS = #$DLDFLAGS #$LDFLAGS\n" + + "LDSHARED = @LDSHARED@ #{defflag}\n" +end +} ", if $static then "" else "@CCDLFLAGS@" end, $defs.join(" ") mfile.puts "LIBPATH = #{libpath}" if libpath @@ -440,9 +459,13 @@ target_prefix = #{target_prefix} " mfile.printf "LOCAL_LIBS = %s %s\n", $LOCAL_LIBS, $local_flags - mfile.printf "LIBS = %s\n", $libs + if /bccwin32/ =~ RUBY_PLATFORM + mfile.printf "LIBS = $(topdir:/=\\)\\%s\n", $libs + else + mfile.printf "LIBS = %s\n", $libs + end mfile.printf "OBJS = " - if !$objs then + if !$objs or (/bccwin32/ =~ RUBY_PLATFORM) then $objs = [] for f in Dir["#{$top_srcdir}/ext/#{$mdir}/*.{#{SRC_EXT.join(%q{,})}}"] f = File.basename(f) @@ -457,9 +480,13 @@ target_prefix = #{target_prefix} mfile.printf $objs.join(" ") mfile.printf "\n" - ruby_interpreter = "$(topdir)/miniruby@EXEEXT@" - if /nmake/i =~ $make - ruby_interpreter = '$(topdir:/=\)\miniruby@EXEEXT@' + if /bccwin32/ =~ RUBY_PLATFORM + ruby_interpreter = '$(topdir:/=\)/miniruby@EXEEXT@' + else + ruby_interpreter = "$(topdir)/miniruby@EXEEXT@" + if /nmake/i =~ $make + ruby_interpreter = '$(topdir:/=\)\miniruby@EXEEXT@' + end end if defined? CROSS_COMPILING ruby_interpreter = "@MINIRUBY@" @@ -476,8 +503,16 @@ EXEEXT = @EXEEXT@ all: $(DLLIB) -clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB) - @$(RM) *.ilk *.exp *.pdb *.bak $(CLEANFILES) +clean: + @$(RM) *.#{$OBJEXT} *.so *.sl *.#{$LIBEXT} $(DLLIB) +#{ +if /bccwin32/ =~ RUBY_PLATFORM + " @$(RM) *.def *.ilc *.ild *.ilf *.ils *.map *.tds *.bak $(CLEANFILES)\n" + + " @if exist $(target).def.org ren $(target).def.org $(target).def" +else + " @$(RM) *.ilk *.exp *.pdb *.bak $(CLEANFILES)" +end +} distclean: clean @$(RM) Makefile extconf.h conftest.* @@ -501,7 +536,11 @@ EOS mfile.printf "\n" unless /mswin32/ =~ RUBY_PLATFORM - src = '$<' + if /bccwin32/=~ RUBY_PLATFORM + src = '$(<:\\=/)' + else + src = '$<' + end copt = cxxopt = '' else if /nmake/i =~ $make @@ -513,6 +552,18 @@ EOS cxxopt = '-Tp' end unless /nmake/i =~ $make + if /bccwin32/ =~ RUBY_PLATFORM + mfile.print " +{$(srcdir)}.cc{}.@OBJEXT@: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} +{$(srcdir)}.cpp{}.@OBJEXT@: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} +{$(srcdir)}.cxx{}.@OBJEXT@: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} +{$(srcdir)}.c{}.@OBJEXT@: + $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} +" + end mfile.puts " .cc.@OBJEXT@: $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} @@ -561,14 +612,18 @@ $(DLLIB): $(OBJS) end elsif "@DLEXT@" != $OBJEXT mfile.print "$(DLLIB): $(OBJS)\n" - if /mswin32/ =~ RUBY_PLATFORM - if /nmake/i =~ $make - mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n" - else - mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n" + if /bccwin32/ =~ RUBY_PLATFORM + mfile.print "\t$(LDSHARED) $(DLDFLAGS) C0D32.OBJ $(OBJS), $@,, CW32.LIB IMPORT32.LIB WS2_32.LIB $(LIBS), #{deffile}\n" + else + if /mswin32/ =~ RUBY_PLATFORM + if /nmake/i =~ $make + mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n" + else + mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n" + end end + mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" end - mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" elsif RUBY_PLATFORM == "m68k-human" mfile.printf "\ $(DLLIB): $(OBJS) @@ -586,7 +641,11 @@ $(DLLIB): $(OBJS) mfile.printf "###\n" while line = dfile.gets() line.gsub!(/\.o\b/, ".#{$OBJEXT}") - line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if /nmake/i =~ $make + if /bccwin32/ =~ RUBY_PLATFORM + line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') + else + line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if /nmake/i =~ $make + end mfile.printf "%s", line.gsub('\$\(hdrdir\)/config.h', '$(topdir)/config.h') end dfile.close @@ -613,6 +672,8 @@ def extmake(target) if /mswin32/ =~ RUBY_PLATFORM $LIBEXT = "lib" $local_flags = "-link /INCREMENTAL:no /EXPORT:Init_$(TARGET)" + elsif /bccwin32/ =~ RUBY_PLATFORM + $LIBEXT = "lib" end $LOCAL_LIBS = "" # to be assigned in extconf.rb $CFLAGS = "" @@ -651,7 +712,11 @@ def extmake(target) $extlist.push [$static, File.basename($target)] end if $install - system "#{$make} install DESTDIR=#{$destdir}" + if /bccwin32/ =~ RUBY_PLATFORM + system "#{$make} -DDESTDIR=#{$destdir} install" + else + system "#{$make} install DESTDIR=#{$destdir}" + end elsif $clean system "#{$make} #{$clean}" else @@ -691,7 +756,7 @@ for setup in ["@setup@", "#{$top_srcdir}/ext/@setup@"] next end target = line.split[0] - target = target.downcase if /mswin32/ =~ RUBY_PLATFORM + target = target.downcase if /mswin32|bccwin32/ =~ RUBY_PLATFORM $static_ext[target] = true end f.close diff --git a/ext/pty/extconf.rb b/ext/pty/extconf.rb index ec35879a33..5e126fe0cf 100644 --- a/ext/pty/extconf.rb +++ b/ext/pty/extconf.rb @@ -1,6 +1,6 @@ require 'mkmf' -if /mswin32|mingw/ !~ RUBY_PLATFORM +if /mswin32|mingw|bccwin32/ !~ RUBY_PLATFORM have_header("sys/stropts.h") have_func("setresuid") have_header("libutil.h") diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 29f9b5d189..e178533bdc 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -39,6 +39,10 @@ SRC end case RUBY_PLATFORM +when /bccwin32/ + test_func = "WSACleanup" + have_library("ws2_32", "WSACleanup") + have_func("closesocket") when /mswin32|mingw/ test_func = "WSACleanup" have_library("wsock32", "WSACleanup") diff --git a/ext/tcltklib/extconf.rb b/ext/tcltklib/extconf.rb index fd98b1e7da..d58c8045a0 100644 --- a/ext/tcltklib/extconf.rb +++ b/ext/tcltklib/extconf.rb @@ -2,7 +2,7 @@ require 'mkmf' -if RUBY_PLATFORM !~ /mswin32|mingw|cygwin/ +if RUBY_PLATFORM !~ /mswin32|mingw|cygwin|bccwin32/ have_library("nsl", "t_open") have_library("socket", "socket") have_library("dl", "dlopen") @@ -22,7 +22,7 @@ def find_tcl(tcllib, stubs) func = stubs ? "Tcl_InitStubs" : "Tcl_FindExecutable" if tcllib find_library(tcllib, func, *paths) - elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin/ + elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin|bccwin32/ find_library("tcl", func, *paths) or find_library("tcl84", func, *paths) or find_library("tcl83", func, *paths) or @@ -44,7 +44,7 @@ def find_tk(tklib, stubs) func = stubs ? "Tk_InitStubs" : "Tk_Init" if tklib find_library(tklib, func, *paths) - elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin/ + elsif RUBY_PLATFORM =~ /mswin32|mingw|cygwin|bccwin32/ find_library("tk", func, *paths) or find_library("tk84", func, *paths) or find_library("tk83", func, *paths) or @@ -62,7 +62,7 @@ def find_tk(tklib, stubs) end if have_header("tcl.h") && have_header("tk.h") && - (/mswin32|mingw|cygwin/ =~ RUBY_PLATFORM || find_library("X11", "XOpenDisplay", + (/mswin32|mingw|cygwin|bccwin32/ =~ RUBY_PLATFORM || find_library("X11", "XOpenDisplay", "/usr/X11/lib", "/usr/X11R6/lib", "/usr/openwin/lib")) && find_tcl(tcllib, stubs) && find_tk(tklib, stubs) diff --git a/file.c b/file.c index 718a38075e..33b9cc985b 100644 --- a/file.c +++ b/file.c @@ -179,7 +179,11 @@ static VALUE rb_stat_mode(self) VALUE self; { - return UINT2NUM(get_stat(self)->st_mode); +#ifdef __BORLANDC__ + return UINT2NUM((unsigned short)(get_stat(self)->st_mode)); +#else + return UINT2NUM(get_stat(self)->st_mode); +#endif } static VALUE @@ -544,6 +548,14 @@ test_l(obj, fname) #ifndef S_ISLNK # ifdef _S_ISLNK # define S_ISLNK(m) _S_ISLNK(m) +# elif defined __BORLANDC__ +# ifdef _S_IFLNK +# define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == _S_IFLNK) +# else +# ifdef S_IFLNK +# define S_ISLNK(m) (((unsigned short)(m) & S_IFMT) == S_IFLNK) +# endif +# endif # else # ifdef _S_IFLNK # define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK) @@ -573,6 +585,14 @@ test_S(obj, fname) #ifndef S_ISSOCK # ifdef _S_ISSOCK # define S_ISSOCK(m) _S_ISSOCK(m) +# elif defined __BORLANDC__ +# ifdef _S_IFSOCK +# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == _S_IFSOCK) +# else +# ifdef S_IFSOCK +# define S_ISSOCK(m) (((unsigned short)(m) & S_IFMT) == S_IFSOCK) +# endif +# endif # else # ifdef _S_IFSOCK # define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK) diff --git a/hash.c b/hash.c index f6d19acdcd..43fbd284f2 100644 --- a/hash.c +++ b/hash.c @@ -949,7 +949,11 @@ env_delete(obj, name) VALUE value = rb_tainted_str_new2(val); ruby_setenv(nam, 0); +#ifdef __BORLANDC__ + if (strcmpi(nam, "PATH") == 0 && !OBJ_TAINTED(name)) { +#else if (strcmp(nam, "PATH") == 0 && !OBJ_TAINTED(name)) { +#endif path_tainted = 0; } return value; @@ -979,7 +983,11 @@ rb_f_getenv(obj, name) } env = getenv(nam); if (env) { +#ifdef __BORLANDC__ + if (strcmpi(nam, "PATH") == 0 && !rb_env_path_tainted()) +#else if (strcmp(nam, "PATH") == 0 && !rb_env_path_tainted()) +#endif return rb_str_new2(env); return rb_tainted_str_new2(env); } @@ -1013,7 +1021,11 @@ env_fetch(argc, argv) } return if_none; } +#ifdef __BORLANDC__ + if (strcmpi(nam, "PATH") == 0 && !rb_env_path_tainted()) +#else if (strcmp(nam, "PATH") == 0 && !rb_env_path_tainted()) +#endif return rb_str_new2(env); return rb_tainted_str_new2(env); } diff --git a/instruby.rb b/instruby.rb index 7818455dec..a18e7f39a7 100644 --- a/instruby.rb +++ b/instruby.rb @@ -88,7 +88,7 @@ end for f in Dir["*.h"] File.install f, archlibdir, 0644, true end -if RUBY_PLATFORM =~ /mswin32|mingw/ +if RUBY_PLATFORM =~ /mswin32|mingw|bccwin32/ File.makedirs archlibdir + "/win32", true File.install "win32/win32.h", archlibdir + "/win32", 0644, true end diff --git a/io.c b/io.c index 6f14290a05..41a5ac91da 100644 --- a/io.c +++ b/io.c @@ -586,6 +586,9 @@ io_fread(ptr, len, f) case EAGAIN: #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN case EWOULDBLOCK: +#endif +#ifdef __BORLANDC__ + case EPIPE: #endif return len - n; } diff --git a/lib/ftools.rb b/lib/ftools.rb index 4047a595eb..6bf23fe7e5 100644 --- a/lib/ftools.rb +++ b/lib/ftools.rb @@ -63,7 +63,7 @@ class << File to = catname(from, to) $stderr.print from, " -> ", to, "\n" if verbose - if RUBY_PLATFORM =~ /djgpp|cygwin|mswin32/ and FileTest.file? to + if RUBY_PLATFORM =~ /djgpp|cygwin|mswin32|bccwin32/ and FileTest.file? to unlink to end fstat = stat(from) diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 3491662028..a8485d3942 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -65,7 +65,7 @@ else exit 1 end $topdir = $hdrdir -# $hdrdir.gsub!('/', '\\') if RUBY_PLATFORM =~ /mswin32/ +# $hdrdir.gsub!('/', '\\') if RUBY_PLATFORM =~ /mswin32|bccwin32/ CFLAGS = CONFIG["CFLAGS"] if RUBY_PLATFORM == "m68k-human" @@ -78,6 +78,8 @@ $log = open('mkmf.log', 'w') if /mswin32/ =~ RUBY_PLATFORM OUTFLAG = '-Fe' +elsif /bccwin32/ =~ RUBY_PLATFORM + OUTFLAG = '-o' else OUTFLAG = '-o ' end @@ -117,7 +119,7 @@ def try_link0(src, opt="") cfile.print src cfile.close ldflags = $LDFLAGS - if /mswin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty? + if /mswin32|bccwin32/ =~ RUBY_PLATFORM and !$LIBPATH.empty? ENV['LIB'] = ($LIBPATH + [ORIG_LIBPATH]).compact.join(';') else $LDFLAGS = ldflags.dup @@ -127,7 +129,7 @@ def try_link0(src, opt="") xsystem(Config.expand(format(LINK, $CFLAGS, $CPPFLAGS, $LDFLAGS, opt, $LOCAL_LIBS))) ensure $LDFLAGS = ldflags - ENV['LIB'] = ORIG_LIBPATH if /mswin32/ =~ RUBY_PLATFORM + ENV['LIB'] = ORIG_LIBPATH if /mswin32|bccwin32/ =~ RUBY_PLATFORM end end @@ -136,6 +138,9 @@ def try_link(src, opt="") try_link0(src, opt) ensure rm_f "conftest*" + if /bccwin32/ =~ RUBY_PLATFORM + rm_f "c0x32*" + end end end @@ -219,7 +224,7 @@ def install_rb(mfile, dest, srcdir = nil) end def append_library(libs, lib) - if /mswin32/ =~ RUBY_PLATFORM + if /mswin32|bccwin32/ =~ RUBY_PLATFORM lib + ".lib " + libs else "-l" + lib + " " + libs @@ -232,7 +237,7 @@ def have_library(lib, func="main") if func && func != "" libs = append_library($libs, lib) - if /mswin32|mingw/ =~ RUBY_PLATFORM + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM if lib == 'm' print "yes\n" return true @@ -298,7 +303,7 @@ def have_func(func, header=nil) libs = $libs src = - if /mswin32|mingw/ =~ RUBY_PLATFORM + if /mswin32|bccwin32|mingw/ =~ RUBY_PLATFORM r = <<"SRC" #include #include @@ -404,6 +409,10 @@ def with_destdir(dir) /^\$[\(\{]/ =~ dir ? dir : "$(DESTDIR)"+dir end +def winsep(s) + s.tr('/', '\\') +end + def create_makefile(target, srcprefix = nil) save_libs = $libs.dup save_libpath = $LIBPATH.dup @@ -432,7 +441,14 @@ def create_makefile(target, srcprefix = nil) srcprefix ||= '$(srcdir)' Config::expand(srcdir = srcprefix.dup) defflag = '' - if RUBY_PLATFORM =~ /cygwin|mingw/ + if RUBY_PLATFORM =~ /bccwin32/ + deffile = target + '.def' + if not File.exist? deffile + open(deffile, 'wb') do |f| + f.print "EXPORTS\n", "_Init_", target, "\n" + end + end + elsif RUBY_PLATFORM =~ /cygwin|mingw/ deffile = target + '.def' if not File.exist? deffile if File.exist? File.join srcdir, deffile @@ -446,7 +462,7 @@ def create_makefile(target, srcprefix = nil) defflag = deffile end - if RUBY_PLATFORM =~ /mswin32/ + if RUBY_PLATFORM =~ /mswin32|bccwin32/ libpath = $LIBPATH.join(';') else $LIBPATH.each {|d| $DLDFLAGS << " -L" << d} @@ -487,8 +503,15 @@ CC = #{CONFIG["CC"]} CFLAGS = #{CONFIG["CCDLFLAGS"]} #{CFLAGS} #{$CFLAGS} CPPFLAGS = -I. -I$(hdrdir) -I$(srcdir) #{$defs.join(" ")} #{CONFIG["CPPFLAGS"]} #{$CPPFLAGS} CXXFLAGS = $(CFLAGS) -DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS} -LDSHARED = #{CONFIG["LDSHARED"]} #{defflag} +#{ +if /bccwin32/ =~ RUBY_PLATFORM + "DLDFLAGS = #$LDFLAGS -L" + '"$(topdir:/=\\)"' + "\n" + + "LDSHARED = #{CONFIG[\"LDSHARED\"]}\n" +else + "DLDFLAGS = #{$DLDFLAGS} #{$LDFLAGS}\n" + + "LDSHARED = #{CONFIG[\"LDSHARED\"]} #{defflag}\n" +end +} LIBPATH = #{libpath} RUBY_INSTALL_NAME = #{CONFIG["RUBY_INSTALL_NAME"]} @@ -529,9 +552,17 @@ EXEEXT = #{CONFIG["EXEEXT"]} all: $(DLLIB) -clean:; @$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB) - @$(RM) $(TARGET).lib $(TARGET).exp $(TARGET).ilk *.pdb $(CLEANFILES) - +clean: + @$(RM) *.#{$OBJEXT} *.so *.sl *.a $(DLLIB) +#{ +if /bccwin32/ =~ RUBY_PLATFORM + " @$(RM) $(TARGET).lib $(TARGET).def $(TARGET).ilc $(TARGET).ild $(TARGET).ilf $(TARGET).ils $(TARGET).tds $(TARGET).map $(CLEANFILES)\n"+ + " @if exist $(target).def.org ren $(target).def.org $(target).def" +else + " @$(RM) $(TARGET).lib $(TARGET).exp $(TARGET).ilk *.pdb $(CLEANFILES)" +end +} + distclean: clean @$(RM) Makefile extconf.h conftest.* mkmf.log @$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) @@ -560,7 +591,11 @@ EOMF install_files(mfile, $INSTALLFILES, SITEINSTALL_DIRS, srcprefix) unless /mswin32/ =~ RUBY_PLATFORM - src = '$<' + if /bccwin32/ =~ RUBY_PLAT_FORM + src = '$(<:\\=/)' + else + src = '$<' + end copt = cxxopt = '' else if /nmake/i =~ $make @@ -572,6 +607,18 @@ EOMF cxxopt = '-Tp' end unless /nmake/i =~ $make + if /bccwin32/ =~ RUBY_PLATFORM + mfile.print " +{$(srcdir)}.cc{}.@OBJEXT@: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} +{$(srcdir)}.cpp{}.@OBJEXT@: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} +{$(srcdir)}.cxx{}.@OBJEXT@: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} +{$(srcdir)}.c{}.@OBJEXT@: + $(CC) $(CFLAGS) $(CPPFLAGS) -c #{copt}#{src} +" + end mfile.puts " .cc.#{$OBJEXT}: $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c #{cxxopt}#{src} @@ -607,14 +654,18 @@ EOMF if CONFIG["DLEXT"] != $OBJEXT mfile.print "$(DLLIB): $(OBJS)\n" - if /mswin32/ =~ RUBY_PLATFORM - if /nmake/i =~ $make - mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n" - else - mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n" + if /bccwin32/ =~ RUBY_PLATFORM + mfile.print "\t$(LDSHARED) $(DLDFLAGS) C0D32.OBJ $(OBJS), $@,, CW32.LIB IMPORT32.LIB WS2_32.LIB $(LIBS), #{deffile}\n" + else + if /mswin32|bccwin32/ =~ RUBY_PLATFORM + if /nmake/i =~ $make + mfile.print "\tset LIB=$(LIBPATH:/=\\);$(LIB)\n" + else + mfile.print "\tenv LIB='$(subst /,\\\\,$(LIBPATH));$(LIB)' \\\n" + end end + mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" end - mfile.print "\t$(LDSHARED) $(DLDFLAGS) #{OUTFLAG}$(DLLIB) $(OBJS) $(LIBS) $(LOCAL_LIBS)\n" elsif not File.exist?(target + ".c") and not File.exist?(target + ".cc") mfile.print "$(DLLIB): $(OBJS)\n" case RUBY_PLATFORM diff --git a/win32/dir.h b/win32/dir.h index 8665fb2d3b..3dd670bef0 100644 --- a/win32/dir.h +++ b/win32/dir.h @@ -1,3 +1,10 @@ +#ifdef __BORLANDC__ +# ifndef WIN32_DIR_H_ +# define WIN32_DIR_H_ +# include +# endif +#endif + struct direct { long d_namlen; diff --git a/win32/resource.rb b/win32/resource.rb index 7eca372df1..d29691ebf8 100644 --- a/win32/resource.rb +++ b/win32/resource.rb @@ -55,7 +55,9 @@ end f.binmode if /mingw/ =~ RUBY_PLATFORM f.print < +#endif #{icons} VS_VERSION_INFO VERSIONINFO diff --git a/win32/win32.c b/win32/win32.c index cd8bcae491..81ce8b6ba0 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -45,6 +45,11 @@ # undef WIN95 #endif +#ifdef __BORLANDC__ +# define _filbuf _fgetc +# define _flsbuf fputc +#endif + #if HAVE_WSAWAITFORMULTIPLEEVENTS # define USE_INTERRUPT_WINSOCK #endif @@ -1115,7 +1120,11 @@ rb_w32_opendir(const char *filename) // if ((rb_w32_stat (filename, &sbuf) < 0 || +#ifdef __BORLANDC__ + (unsigned short)(sbuf.st_mode) & _S_IFDIR == 0) && +#else sbuf.st_mode & _S_IFDIR == 0) && +#endif (!ISALPHA(filename[0]) || filename[1] != ':' || filename[2] != '\0' || ((1 << (filename[0] & 0x5f) - 'A') & GetLogicalDrives()) == 0)) { return NULL; @@ -1320,6 +1329,9 @@ EXTERN_C void __cdecl _unlock(int); #ifdef MSVCRT_THREADS # define MTHREAD_ONLY(x) x # define STHREAD_ONLY(x) +#elif defined(__BORLANDC__) +# define MTHREAD_ONLY(x) +# define STHREAD_ONLY(x) #else # define MTHREAD_ONLY(x) # define STHREAD_ONLY(x) x @@ -1339,15 +1351,16 @@ typedef struct { #define _CRTIMP __declspec(dllimport) #endif +#ifndef __BORLANDC__ EXTERN_C _CRTIMP ioinfo * __pioinfo[]; #define IOINFO_L2E 5 #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E) #define _pioinfo(i) (__pioinfo[i >> IOINFO_L2E] + (i & (IOINFO_ARRAY_ELTS - 1))) - #define _osfhnd(i) (_pioinfo(i)->osfhnd) #define _osfile(i) (_pioinfo(i)->osfile) #define _pipech(i) (_pioinfo(i)->pipech) +#endif #define FOPEN 0x01 /* file handle open */ #define FNOINHERIT 0x10 /* file handle opened O_NOINHERIT */ @@ -1375,6 +1388,29 @@ rb_w32_open_osfhandle(long osfhandle, int flags) if (flags & O_NOINHERIT) fileflags |= FNOINHERIT; +#ifdef __BORLANDC__ + { + /* attempt to allocate a C Runtime file handle */ + HANDLE hF = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL); + fh = _open_osfhandle((long)hF, 0); + CloseHandle(hF); + if (fh == -1) { + errno = EMFILE; /* too many open files */ + _doserrno = 0L; /* not an OS error */ + } + else { + + MTHREAD_ONLY(EnterCriticalSection(&(_pioinfo(fh)->lock))); + /* the file is open. now, set the info in _osfhnd array */ + //_set_osfhnd(fh, osfhandle); + + fileflags |= FOPEN; /* mark as open */ + + //_osfile(fh) = fileflags; /* set osfile entry */ + MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fh)->lock)); + } + } +#else RUBY_CRITICAL({ /* attempt to allocate a C Runtime file handle */ HANDLE hF = CreateFile("NUL", 0, 0, NULL, OPEN_ALWAYS, 0, NULL); @@ -1396,7 +1432,7 @@ rb_w32_open_osfhandle(long osfhandle, int flags) MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fh)->lock)); } }); - +#endif return fh; /* return handle */ } @@ -1538,7 +1574,11 @@ setgid(int gid) int /* ioctl(int i, unsigned int u, char *data) */ -ioctl(int i, unsigned int u, long data) +#ifdef __BORLANDC__ + ioctl(int i, int u, ...) +#else + ioctl(int i, unsigned int u, long data) +#endif { return -1; } @@ -1713,10 +1753,18 @@ StartSockets () atexit((void (*)(void)) WSACleanup); +#ifndef SO_SYNCHRONOUS_NONALERT +#define SO_SYNCHRONOUS_NONALERT 0x20 +#endif + iSockOpt = SO_SYNCHRONOUS_NONALERT; /* * Enable the use of sockets as filehandles */ +#ifndef SO_OPENTYPE +#define SO_OPENTYPE 0x7008 +#endif + setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&iSockOpt, sizeof(iSockOpt)); @@ -1955,7 +2003,11 @@ rb_w32_socket (int af, int type, int protocol) errno = WSAGetLastError(); //fprintf(stderr, "socket fail (%d)", WSAGetLastError()); } +#ifdef __BORLANDC__ + return _open_osfhandle(s, O_RDWR|O_BINARY); +#else return rb_w32_open_osfhandle(s, O_RDWR|O_BINARY); +#endif } #undef gethostbyaddr @@ -2211,7 +2263,12 @@ rb_w32_getcwd(buffer, size) int length; char *bp; +#ifdef __BORLANDC__ +#undef getcwd + if (getcwd(buffer, size) == NULL) { +#else if (_getcwd(buffer, size) == NULL) { +#endif return NULL; } length = strlen(buffer); @@ -2671,8 +2728,8 @@ static void catch_interrupt(void) int rb_w32_getc(FILE* stream) { int c, trap_immediate = rb_trap_immediate; - if (--stream->_cnt >= 0) { - c = (unsigned char)*stream->_ptr++; + if (--stream->FILE_COUNT >= 0) { + c = (unsigned char)*stream->FILE_READPTR++; rb_trap_immediate = trap_immediate; } else { @@ -2687,8 +2744,8 @@ int rb_w32_getc(FILE* stream) int rb_w32_putc(int c, FILE* stream) { int trap_immediate = rb_trap_immediate; - if (--stream->_cnt >= 0) { - c = (unsigned char)(*stream->_ptr++ = (char)c); + if (--stream->FILE_COUNT >= 0) { + c = (unsigned char)(*stream->FILE_READPTR++ = (char)c); rb_trap_immediate = trap_immediate; } else { diff --git a/win32/win32.h b/win32/win32.h index b2be02047b..c33405110d 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -89,28 +89,16 @@ extern "C++" { #define fgetchar(_stream) getchar() #define fputchar(_c, _stream) putchar(_c) +#ifndef __BORLANDC__ + #define access _access #define chmod _chmod #define chsize _chsize -#define close _close -#define creat _creat #define dup _dup #define dup2 _dup2 -#define eof _eof -#define filelength _filelength #define isatty _isatty -#define locking _locking -#define lseek _lseek -#define mktemp _mktemp #define open _open -#define perror _perror -#define read _read #define setmode _setmode -#define sopen _sopen -#define tell _tell -#define umask _umask -#define unlink _unlink -#define write _write #define execl _execl #define execle _execle #define execlp _execlp @@ -119,8 +107,7 @@ extern "C++" { #define execve _execve #define execvp _execvp #define execvpe _execvpe -#define getpid _getpid -#define sleep(x) rb_w32_sleep((x)*1000) +#define lseek _lseek #define spawnl _spawnl #define spawnle _spawnle #define spawnlp _spawnlp @@ -132,13 +119,34 @@ extern "C++" { #if _MSC_VER < 800 #define fileno _fileno #endif +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#else +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define _open _sopen +#endif + +#define close _close +#define creat _creat +#define eof _eof +#define filelength _filelength +#define locking _locking +#define mktemp _mktemp +#define perror _perror +#define read _read +#define sopen _sopen +#define tell _tell +#define umask _umask +#define unlink _unlink +#define write _write +#define getpid _getpid +#define sleep(x) rb_w32_sleep((x)*1000) #define utime _utime #define vsnprintf _vsnprintf #define snprintf _snprintf #define popen _popen #define pclose _pclose -#define strcasecmp _stricmp -#define strncasecmp _strnicmp #undef stat #define stat(path,st) rb_w32_stat(path,st) /* these are defined in nt.c */ @@ -196,9 +204,44 @@ extern int gettimeofday(struct timeval *, struct timezone *); extern pid_t waitpid (pid_t, int *, int); extern int do_spawn(char *); extern int kill(int, int); +#ifndef __BORLANDC__ extern int isinf(double); extern int isnan(double); +#else +#include +#ifndef isinf +#define isinf !_finite +#endif +#ifndef isnan +#define isnan _isnan +#endif +#ifdef S_ISDIR +#undef S_ISDIR +#endif + +#ifdef S_ISFIFO +#undef S_ISFIFO +#endif + +#ifdef S_ISBLK +#undef S_ISBLK +#endif + +#ifdef S_ISCHR +#undef S_ISCHR +#endif + +#ifdef S_ISREG +#undef S_ISREG +#endif + +#define S_ISDIR(m) (((unsigned short)(m) & S_IFMT) == S_IFDIR) +#define S_ISFIFO(m) (((unsigned short)(m) & S_IFMT) == S_IFIFO) +#define S_ISBLK(m) (((unsigned short)(m) & S_IFMT) == S_IFBLK) +#define S_ISCHR(m) (((unsigned short)(m) & S_IFMT) == S_IFCHR) +#define S_ISREG(m) (((unsigned short)(m) & S_IFMT) == S_IFREG) +#endif // // define this so we can do inplace editing