summaryrefslogtreecommitdiff
path: root/gcc/ada/adaint.c
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-21 13:42:24 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2003-10-21 13:42:24 +0000
commit9dfe12ae5b94d03c997ea2903022a5d2d5c5f266 (patch)
treebdfc70477b60f1220cb05dd233a4570dd9c6bb5c /gcc/ada/adaint.c
parent1c662558a1113238a624245a45382d3df90ccf13 (diff)
downloadgcc-9dfe12ae5b94d03c997ea2903022a5d2d5c5f266.tar.gz
2003-10-21 Arnaud Charlet <charlet@act-europe.fr>
* 3psoccon.ads, 3veacodu.adb, 3vexpect.adb, 3vsoccon.ads, 3vsocthi.adb, 3vsocthi.ads, 3vtrasym.adb, 3zsoccon.ads, 3zsocthi.adb, 3zsocthi.ads, 50system.ads, 51system.ads, 55system.ads, 56osinte.adb, 56osinte.ads, 56taprop.adb, 56taspri.ads, 56tpopsp.adb, 57system.ads, 58system.ads, 59system.ads, 5aml-tgt.adb, 5bml-tgt.adb, 5csystem.ads, 5dsystem.ads, 5fosinte.adb, 5gml-tgt.adb, 5hml-tgt.adb, 5isystem.ads, 5lparame.adb, 5msystem.ads, 5psystem.ads, 5sml-tgt.adb, 5sosprim.adb, 5stpopsp.adb, 5tsystem.ads, 5usystem.ads, 5vml-tgt.adb, 5vsymbol.adb, 5vtraent.adb, 5vtraent.ads, 5wml-tgt.adb, 5xparame.ads, 5xsystem.ads, 5xvxwork.ads, 5yparame.ads, 5ytiitho.adb, 5zinit.adb, 5zml-tgt.adb, 5zparame.ads, 5ztaspri.ads, 5ztfsetr.adb, 5zthrini.adb, 5ztiitho.adb, 5ztpopsp.adb, 7stfsetr.adb, 7straces.adb, 7strafor.adb, 7strafor.ads, 7stratas.adb, a-excach.adb, a-exexda.adb, a-exexpr.adb, a-exextr.adb, a-exstat.adb, a-strsup.adb, a-strsup.ads, a-stwisu.adb, a-stwisu.ads, bld.adb, bld.ads, bld-io.adb, bld-io.ads, clean.adb, clean.ads, ctrl_c.c, erroutc.adb, erroutc.ads, errutil.adb, errutil.ads, err_vars.ads, final.c, g-arrspl.adb, g-arrspl.ads, g-boubuf.adb, g-boubuf.ads, g-boumai.ads, g-bubsor.adb, g-bubsor.ads, g-comver.adb, g-comver.ads, g-ctrl_c.ads, g-dynhta.adb, g-dynhta.ads, g-eacodu.adb, g-excact.adb, g-excact.ads, g-heasor.adb, g-heasor.ads, g-memdum.adb, g-memdum.ads, gnatclean.adb, gnatsym.adb, g-pehage.adb, g-pehage.ads, g-perhas.ads, gpr2make.adb, gpr2make.ads, gprcmd.adb, gprep.adb, gprep.ads, g-semaph.adb, g-semaph.ads, g-string.adb, g-string.ads, g-strspl.ads, g-wistsp.ads, i-vthrea.adb, i-vthrea.ads, i-vxwoio.adb, i-vxwoio.ads, Makefile.generic, Makefile.prolog, Makefile.rtl, prep.adb, prep.ads, prepcomp.adb, prepcomp.ads, prj-err.adb, prj-err.ads, s-boarop.ads, s-carsi8.adb, s-carsi8.ads, s-carun8.adb, s-carun8.ads, s-casi16.adb, s-casi16.ads, s-casi32.adb, s-casi32.ads, s-casi64.adb, s-casi64.ads, s-casuti.adb, s-casuti.ads, s-caun16.adb, s-caun16.ads, s-caun32.adb, s-caun32.ads, s-caun64.adb, s-caun64.ads, scng.adb, scng.ads, s-exnint.adb, s-exnllf.adb, s-exnlli.adb, s-expint.adb, s-explli.adb, s-geveop.adb, s-geveop.ads, s-hibaen.ads, s-htable.adb, s-htable.ads, sinput-c.adb, sinput-c.ads, s-memcop.ads, socket.c, s-purexc.ads, s-scaval.adb, s-stopoo.adb, s-strcom.adb, s-strcom.ads, s-strxdr.adb, s-rident.ads, s-thread.adb, s-thread.ads, s-tpae65.adb, s-tpae65.ads, s-tporft.adb, s-traent.adb, s-traent.ads, styleg.adb, styleg.ads, styleg-c.adb, styleg-c.ads, s-veboop.adb, s-veboop.ads, s-vector.ads, symbols.adb, symbols.ads, tb-alvms.c, tb-alvxw.c, tempdir.adb, tempdir.ads, vms_conv.ads, vms_conv.adb, vms_data.ads, vxaddr2line.adb: Files added. Merge with ACT tree. * 4dintnam.ads, 4mintnam.ads, 4uintnam.ads, 52system.ads, 5dosinte.ads, 5etpopse.adb, 5mosinte.ads, 5qosinte.adb, 5qosinte.ads, 5qstache.adb, 5qtaprop.adb, 5qtaspri.ads, 5stpopse.adb, 5uintman.adb, 5uosinte.ads, adafinal.c, g-enblsp.adb, io-aux.c, scn-nlit.adb, scn-slit.adb, s-exnflt.ads, s-exngen.adb, s-exngen.ads, s-exnlfl.ads, s-exnlin.ads, s-exnsfl.ads, s-exnsin.ads, s-exnssi.ads, s-expflt.ads, s-expgen.adb, s-expgen.ads, s-explfl.ads, s-explin.ads, s-expllf.ads, s-expsfl.ads, s-expsin.ads, s-expssi.ads, style.adb: Files removed. Merge with ACT tree. * 1ic.ads, 31soccon.ads, 31soliop.ads, 3asoccon.ads, 3bsoccon.ads, 3gsoccon.ads, 3hsoccon.ads, 3ssoccon.ads, 3ssoliop.ads, 3wsoccon.ads, 3wsocthi.adb, 3wsocthi.ads, 3wsoliop.ads, 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads, 4gintnam.ads, 4hexcpol.adb, 4hintnam.ads, 4lintnam.ads, 4nintnam.ads, 4ointnam.ads, 4onumaux.ads, 4pintnam.ads, 4sintnam.ads, 4vcaldel.adb, 4vcalend.adb, 4vintnam.ads, 4wexcpol.adb, 4wintnam.ads, 4zintnam.ads, 51osinte.adb, 51osinte.ads, 52osinte.adb, 52osinte.ads, 53osinte.ads, 54osinte.ads, 5aosinte.adb, 5aosinte.ads, 5asystem.ads, 5ataprop.adb, 5atasinf.ads, 5ataspri.ads, 5atpopsp.adb, 5avxwork.ads, 5bosinte.adb, 5bosinte.ads, 5bsystem.ads, 5cosinte.ads, 5esystem.ads, 5fintman.adb, 5fosinte.ads, 5fsystem.ads, 5ftaprop.adb, 5ftasinf.ads, 5ginterr.adb, 5gintman.adb, 5gmastop.adb, 5gosinte.ads, 5gproinf.ads, 5gsystem.ads, 5gtaprop.adb, 5gtasinf.ads, 5gtpgetc.adb, 5hosinte.adb, 5hosinte.ads, 5hsystem.ads, 5htaprop.adb, 5htaspri.ads, 5htraceb.adb, 5iosinte.adb, 5itaprop.adb, 5itaspri.ads, 5ksystem.ads, 5kvxwork.ads, 5lintman.adb, 5lml-tgt.adb, 5losinte.ads, 5lsystem.ads, 5mvxwork.ads, 5ninmaop.adb, 5nintman.adb, 5nosinte.ads, 5ntaprop.adb, 5ntaspri.ads, 5ointerr.adb, 5omastop.adb, 5oosinte.adb, 5oosinte.ads, 5oosprim.adb, 5oparame.adb, 5osystem.ads, 5otaprop.adb, 5otaspri.ads, 5posinte.ads, 5posprim.adb, 5pvxwork.ads, 5sintman.adb, 5sosinte.adb, 5sosinte.ads, 5ssystem.ads, 5staprop.adb, 5stasinf.ads, 5staspri.ads, 5svxwork.ads, 5tosinte.ads, 5vasthan.adb, 5vinmaop.adb, 5vinterr.adb, 5vintman.adb, 5vintman.ads, 5vmastop.adb, 5vosinte.adb, 5vosinte.ads, 5vosprim.adb, 5vsystem.ads, 5vtaprop.adb, 5vtaspri.ads, 5vtpopde.adb, 5vtpopde.ads, 5wgloloc.adb, 5wintman.adb, 5wmemory.adb, 5wosprim.adb, 5wsystem.ads, 5wtaprop.adb, 5wtaspri.ads, 5ysystem.ads, 5zinterr.adb, 5zintman.adb, 5zosinte.adb, 5zosinte.ads, 5zosprim.adb, 5zsystem.ads, 5ztaprop.adb, 6vcpp.adb, 6vcstrea.adb, 6vinterf.ads, 7sinmaop.adb, 7sintman.adb, 7sosinte.adb, 7sosprim.adb, 7staprop.adb, 7staspri.ads, 7stpopsp.adb, 7straceb.adb, 9drpc.adb, a-caldel.adb, a-caldel.ads, a-charac.ads, a-colien.ads, a-comlin.adb, adaint.c, adaint.h, ada-tree.def, a-diocst.adb, a-diocst.ads, a-direio.adb, a-except.adb, a-except.ads, a-excpol.adb, a-exctra.adb, a-exctra.ads, a-filico.adb, a-interr.adb, a-intsig.adb, a-intsig.ads, ali.adb, ali.ads, ali-util.adb, ali-util.ads, a-ngcefu.adb, a-ngcoty.adb, a-ngelfu.adb, a-nudira.adb, a-nudira.ads, a-nuflra.adb, a-nuflra.ads, a-reatim.adb, a-reatim.ads, a-retide.ads, a-sequio.adb, a-siocst.adb, a-siocst.ads, a-ssicst.adb, a-ssicst.ads, a-strbou.adb, a-strbou.ads, a-strfix.adb, a-strmap.adb, a-strsea.ads, a-strunb.adb, a-strunb.ads, a-ststio.adb, a-stunau.adb, a-stunau.ads, a-stwibo.adb, a-stwibo.ads, a-stwifi.adb, a-stwima.adb, a-stwiun.adb, a-stwiun.ads, a-tags.adb, a-tags.ads, a-tasatt.adb, a-taside.adb, a-teioed.adb, a-textio.adb, a-textio.ads, a-tienau.adb, a-tifiio.adb, a-tiflau.adb, a-tiflio.adb, a-tigeau.adb, a-tigeau.ads, a-tiinau.adb, a-timoau.adb, a-tiocst.adb, a-tiocst.ads, atree.adb, atree.ads, a-witeio.adb, a-witeio.ads, a-wtcstr.adb, a-wtcstr.ads, a-wtdeio.adb, a-wtedit.adb, a-wtenau.adb, a-wtflau.adb, a-wtinau.adb, a-wtmoau.adb, bcheck.adb, binde.adb, bindgen.adb, bindusg.adb, checks.adb, checks.ads, cio.c, comperr.adb, comperr.ads, csets.adb, cstand.adb, cstreams.c, debug_a.adb, debug_a.ads, debug.adb, decl.c, einfo.adb, einfo.ads, errout.adb, errout.ads, eval_fat.adb, eval_fat.ads, exp_aggr.adb, expander.adb, expander.ads, exp_attr.adb, exp_ch11.adb, exp_ch13.adb, exp_ch2.adb, exp_ch3.adb, exp_ch3.ads, exp_ch4.adb, exp_ch5.adb, exp_ch6.adb, exp_ch7.adb, exp_ch7.ads, exp_ch8.adb, exp_ch9.adb, exp_code.adb, exp_dbug.adb, exp_dbug.ads, exp_disp.adb, exp_dist.adb, expect.c, exp_fixd.adb, exp_imgv.adb, exp_intr.adb, exp_pakd.adb, exp_prag.adb, exp_strm.adb, exp_strm.ads, exp_tss.adb, exp_tss.ads, exp_util.adb, exp_util.ads, exp_vfpt.adb, fe.h, fmap.adb, fmap.ads, fname.adb, fname.ads, fname-uf.adb, fname-uf.ads, freeze.adb, freeze.ads, frontend.adb, g-awk.adb, g-awk.ads, g-busora.adb, g-busora.ads, g-busorg.adb, g-busorg.ads, g-casuti.adb, g-casuti.ads, g-catiio.adb, g-catiio.ads, g-cgi.adb, g-cgi.ads, g-cgicoo.adb, g-cgicoo.ads, g-cgideb.adb, g-cgideb.ads, g-comlin.adb, g-comlin.ads, g-crc32.adb, g-crc32.ads, g-debpoo.adb, g-debpoo.ads, g-debuti.adb, g-debuti.ads, g-diopit.adb, g-diopit.ads, g-dirope.adb, g-dirope.ads, g-dyntab.adb, g-dyntab.ads, g-except.ads, g-exctra.adb, g-exctra.ads, g-expect.adb, g-expect.ads, g-hesora.adb, g-hesora.ads, g-hesorg.adb, g-hesorg.ads, g-htable.adb, g-htable.ads, gigi.h, g-io.adb, g-io.ads, g-io_aux.adb, g-io_aux.ads, g-locfil.adb, g-locfil.ads, g-md5.adb, g-md5.ads, gmem.c, gnat1drv.adb, gnatbind.adb, gnatchop.adb, gnatcmd.adb, gnatfind.adb, gnatkr.adb, gnatlbr.adb, gnatlink.adb, gnatls.adb, gnatmake.adb, gnatmem.adb, gnatname.adb, gnatprep.adb, gnatprep.ads, gnatpsta.adb, gnatxref.adb, g-os_lib.adb, g-os_lib.ads, g-regexp.adb, g-regexp.ads, g-regist.adb, g-regist.ads, g-regpat.adb, g-regpat.ads, g-soccon.ads, g-socket.adb, g-socket.ads, g-socthi.adb, g-socthi.ads, g-soliop.ads, g-souinf.ads, g-speche.adb, g-speche.ads, g-spipat.adb, g-spipat.ads, g-spitbo.adb, g-spitbo.ads, g-sptabo.ads, g-sptain.ads, g-sptavs.ads, g-table.adb, g-table.ads, g-tasloc.adb, g-tasloc.ads, g-thread.adb, g-thread.ads, g-traceb.adb, g-traceb.ads, g-trasym.adb, g-trasym.ads, hostparm.ads, i-c.ads, i-cobol.adb, i-cpp.adb, i-cstrea.ads, i-cstrin.adb, i-cstrin.ads, impunit.adb, init.c, inline.adb, interfac.ads, i-pacdec.ads, itypes.adb, itypes.ads, i-vxwork.ads, lang.opt, lang-specs.h, layout.adb, lib.adb, lib.ads, lib-list.adb, lib-load.adb, lib-load.ads, lib-sort.adb, lib-util.adb, lib-writ.adb, lib-writ.ads, lib-xref.adb, lib-xref.ads, link.c, live.adb, make.adb, make.ads, Makefile.adalib, Makefile.in, Make-lang.in, makeusg.adb, mdll.adb, mdll-fil.adb, mdll-fil.ads, mdll-utl.adb, mdll-utl.ads, memroot.adb, memroot.ads, memtrack.adb, misc.c, mkdir.c, mlib.adb, mlib.ads, mlib-fil.adb, mlib-fil.ads, mlib-prj.adb, mlib-prj.ads, mlib-tgt.adb, mlib-tgt.ads, mlib-utl.adb, mlib-utl.ads, namet.adb, namet.ads, namet.h, nlists.ads, nlists.h, nmake.adt, opt.adb, opt.ads, osint.adb, osint.ads, osint-b.adb, osint-c.adb, par.adb, par-ch10.adb, par-ch11.adb, par-ch2.adb, par-ch3.adb, par-ch4.adb, par-ch5.adb, par-ch6.adb, par-ch9.adb, par-endh.adb, par-labl.adb, par-load.adb, par-prag.adb, par-sync.adb, par-tchk.adb, par-util.adb, prj.adb, prj.ads, prj-attr.adb, prj-attr.ads, prj-com.adb, prj-com.ads, prj-dect.adb, prj-dect.ads, prj-env.adb, prj-env.ads, prj-ext.adb, prj-ext.ads, prj-makr.adb, prj-makr.ads, prj-nmsc.adb, prj-nmsc.ads, prj-pars.adb, prj-pars.ads, prj-part.adb, prj-part.ads, prj-pp.adb, prj-pp.ads, prj-proc.adb, prj-proc.ads, prj-strt.adb, prj-strt.ads, prj-tree.adb, prj-tree.ads, prj-util.adb, prj-util.ads, raise.c, raise.h, repinfo.adb, repinfo.h, restrict.adb, restrict.ads, rident.ads, rtsfind.adb, rtsfind.ads, s-addima.ads, s-arit64.adb, s-assert.adb, s-assert.ads, s-atacco.adb, s-atacco.ads, s-auxdec.adb, s-auxdec.ads, s-bitops.adb, scans.ads, scn.adb, scn.ads, s-crc32.adb, s-crc32.ads, s-direio.adb, sem.adb, sem.ads, sem_aggr.adb, sem_attr.adb, sem_attr.ads, sem_case.adb, sem_case.ads, sem_cat.adb, sem_cat.ads, sem_ch10.adb, sem_ch11.adb, sem_ch12.adb, sem_ch12.ads, sem_ch13.adb, sem_ch13.ads, sem_ch3.adb, sem_ch3.ads, sem_ch4.adb, sem_ch5.adb, sem_ch5.ads, sem_ch6.adb, sem_ch6.ads, sem_ch7.adb, sem_ch7.ads, sem_ch8.adb, sem_ch8.ads, sem_ch9.adb, sem_disp.adb, sem_disp.ads, sem_dist.adb, sem_elab.adb, sem_eval.adb, sem_eval.ads, sem_intr.adb, sem_maps.adb, sem_mech.adb, sem_prag.adb, sem_prag.ads, sem_res.adb, sem_res.ads, sem_type.adb, sem_type.ads, sem_util.adb, sem_util.ads, sem_warn.adb, s-errrep.adb, s-errrep.ads, s-exctab.adb, s-exctab.ads, s-exnint.ads, s-exnllf.ads, s-exnlli.ads, s-expint.ads, s-explli.ads, s-expuns.ads, s-fatflt.ads, s-fatgen.adb, s-fatgen.ads, s-fatlfl.ads, s-fatllf.ads, s-fatsfl.ads, s-fileio.adb, s-fileio.ads, s-finimp.adb, s-finimp.ads, s-finroo.adb, s-finroo.ads, sfn_scan.adb, s-gloloc.adb, s-gloloc.ads, s-imgdec.adb, s-imgenu.adb, s-imgrea.adb, s-imgwch.adb, sinfo.adb, sinfo.ads, s-inmaop.ads, sinput.adb, sinput.ads, sinput-d.adb, sinput-l.adb, sinput-l.ads, sinput-p.adb, sinput-p.ads, s-interr.adb, s-interr.ads, s-intman.ads, s-maccod.ads, s-mastop.adb, s-mastop.ads, s-memory.adb, s-memory.ads, snames.adb, snames.ads, snames.h, s-osprim.ads, s-parame.ads, s-parint.ads, s-pooloc.adb, s-pooloc.ads, s-poosiz.adb, sprint.adb, s-proinf.ads, s-scaval.ads, s-secsta.adb, s-secsta.ads, s-sequio.adb, s-shasto.adb, s-shasto.ads, s-soflin.ads, s-stache.adb, s-stache.ads, s-stalib.adb, s-stalib.ads, s-stoele.ads, s-stopoo.ads, s-stratt.adb, s-stratt.ads, s-strops.adb, s-strops.ads, s-taasde.adb, s-taasde.ads, s-tadeca.adb, s-tadeca.ads, s-tadert.adb, s-tadert.ads, s-taenca.adb, s-taenca.ads, s-taprob.adb, s-taprob.ads, s-taprop.ads, s-tarest.adb, s-tarest.ads, s-tasdeb.adb, s-tasdeb.ads, s-tasinf.adb, s-tasinf.ads, s-tasini.adb, s-tasini.ads, s-taskin.adb, s-taskin.ads, s-tasque.adb, s-tasque.ads, s-tasren.adb, s-tasren.ads, s-tasres.ads, s-tassta.adb, s-tassta.ads, s-tasuti.adb, s-tasuti.ads, s-tataat.adb, s-tataat.ads, s-tpinop.adb, s-tpinop.ads, s-tpoben.adb, s-tpoben.ads, s-tpobop.adb, s-tpobop.ads, s-tposen.adb, s-tposen.ads, s-traceb.adb, s-traceb.ads, stringt.adb, stringt.ads, stringt.h, style.ads, stylesw.adb, stylesw.ads, s-unstyp.ads, s-vaflop.ads, s-valrea.adb, s-valuti.adb, s-vercon.adb, s-vmexta.adb, s-wchcnv.ads, s-wchcon.ads, s-widcha.adb, switch.adb, switch.ads, switch-b.adb, switch-c.adb, switch-m.adb, s-wwdcha.adb, s-wwdwch.adb, sysdep.c, system.ads, table.adb, table.ads, targparm.adb, targparm.ads, targtyps.c, tbuild.adb, tbuild.ads, tracebak.c, trans.c, tree_io.adb, treepr.adb, treeprs.adt, ttypes.ads, types.ads, types.h, uintp.adb, uintp.ads, uintp.h, uname.adb, urealp.adb, urealp.ads, urealp.h, usage.adb, utils2.c, utils.c, validsw.adb, validsw.ads, widechar.adb, xeinfo.adb, xnmake.adb, xref_lib.adb, xref_lib.ads, xr_tabls.adb, xr_tabls.ads, xtreeprs.adb, xsnames.adb, einfo.h, sinfo.h, treeprs.ads, nmake.ads, nmake.adb, gnatvsn.ads: Merge with ACT tree. * gnatvsn.adb: Rewritten in a simpler and more efficient way. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72751 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/adaint.c')
-rw-r--r--gcc/ada/adaint.c648
1 files changed, 411 insertions, 237 deletions
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 864e9dc1141..44fd3357868 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -4,7 +4,6 @@
* *
* A D A I N T *
* *
- * *
* C Implementation File *
* *
* Copyright (C) 1992-2003, Free Software Foundation, Inc. *
@@ -54,6 +53,7 @@
#ifdef IN_RTS
#include "tconfig.h"
#include "tsystem.h"
+
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
@@ -65,7 +65,23 @@
#include "config.h"
#include "system.h"
#endif
+
+#ifdef __MINGW32__
+#include "mingw32.h"
+#include <sys/utime.h>
+#else
+#ifndef VMS
+#include <utime.h>
+#endif
+#endif
+
+#ifdef __MINGW32__
+#if OLD_MINGW
#include <sys/wait.h>
+#endif
+#else
+#include <sys/wait.h>
+#endif
#if defined (__EMX__) || defined (MSDOS) || defined (_WIN32)
#elif defined (VMS)
@@ -98,7 +114,7 @@ struct dsc$descriptor_fib
/* I/O Status Block. */
struct IOSB
-{
+{
unsigned short status, count;
unsigned long devdep;
};
@@ -213,34 +229,56 @@ const int __gnat_vmsp = 1;
const int __gnat_vmsp = 0;
#endif
-/* This variable is used to export the maximum length of a path name to
- Ada code. */
-
#ifdef __EMX__
-int __gnat_max_path_len = _MAX_PATH;
+#define GNAT_MAX_PATH_LEN MAX_PATH
#elif defined (VMS)
-int __gnat_max_path_len = 4096; /* PATH_MAX */
+#define GNAT_MAX_PATH_LEN 256 /* PATH_MAX */
#elif defined (__vxworks) || defined (__OPENNT)
-int __gnat_max_path_len = PATH_MAX;
+#define GNAT_MAX_PATH_LEN PATH_MAX
+
+#else
+
+#if defined (__MINGW32__)
+#include "mingw32.h"
+
+#if OLD_MINGW
+#include <sys/param.h>
+#endif
#else
#include <sys/param.h>
-int __gnat_max_path_len = MAXPATHLEN;
+#endif
+
+#define GNAT_MAX_PATH_LEN MAXPATHLEN
#endif
+/* The __gnat_max_path_len variable is used to export the maximum
+ length of a path name to Ada code. max_path_len is also provided
+ for compatibility with older GNAT versions, please do not use
+ it. */
+
+int __gnat_max_path_len = GNAT_MAX_PATH_LEN;
+int max_path_len = GNAT_MAX_PATH_LEN;
+
/* The following macro HAVE_READDIR_R should be defined if the
system provides the routine readdir_r. */
#undef HAVE_READDIR_R
void
-__gnat_to_gm_time (p_time, p_year, p_month, p_day, p_hours, p_mins, p_secs)
- int *p_time, *p_year, *p_month, *p_day, *p_hours, *p_mins, *p_secs;
+__gnat_to_gm_time
+ (OS_Time *p_time,
+ int *p_year,
+ int *p_month,
+ int *p_day,
+ int *p_hours,
+ int *p_mins,
+ int *p_secs)
{
struct tm *res;
- time_t time = *p_time;
+ time_t time = (time_t) *p_time;
#ifdef _WIN32
/* On Windows systems, the time is sometimes rounded up to the nearest
@@ -249,7 +287,11 @@ __gnat_to_gm_time (p_time, p_year, p_month, p_day, p_hours, p_mins, p_secs)
time++;
#endif
+#ifdef VMS
+ res = localtime (&time);
+#else
res = gmtime (&time);
+#endif
if (res)
{
@@ -269,11 +311,8 @@ __gnat_to_gm_time (p_time, p_year, p_month, p_day, p_hours, p_mins, p_secs)
of characters of its content in BUF. Otherwise, return -1. For Windows,
OS/2 and vxworks, always return -1. */
-int
-__gnat_readlink (path, buf, bufsiz)
- char *path;
- char *buf;
- size_t bufsiz;
+int
+__gnat_readlink (char *path, char *buf, size_t bufsiz)
{
#if defined (MSDOS) || defined (_WIN32) || defined (__EMX__)
return -1;
@@ -291,9 +330,7 @@ __gnat_readlink (path, buf, bufsiz)
Interix and VMS, always return -1. */
int
-__gnat_symlink (oldpath, newpath)
- char *oldpath;
- char *newpath;
+__gnat_symlink (char *oldpath, char *newpath)
{
#if defined (MSDOS) || defined (_WIN32) || defined (__EMX__)
return -1;
@@ -313,9 +350,7 @@ __gnat_symlink (oldpath, newpath)
/* Version that does not use link. */
int
-__gnat_try_lock (dir, file)
- char *dir;
- char *file;
+__gnat_try_lock (char *dir, char *file)
{
char full_path[256];
int fd;
@@ -335,9 +370,7 @@ __gnat_try_lock (dir, file)
line problem ??? */
int
-__gnat_try_lock (dir, file)
- char *dir;
- char *file;
+__gnat_try_lock (char *dir, char *file)
{
char full_path[256];
int fd;
@@ -354,11 +387,10 @@ __gnat_try_lock (dir, file)
#else
/* Version using link(), more secure over NFS. */
+/* See TN 6913-016 for discussion ??? */
int
-__gnat_try_lock (dir, file)
- char *dir;
- char *file;
+__gnat_try_lock (char *dir, char *file)
{
char full_path[256];
char temp_file[256];
@@ -428,9 +460,7 @@ __gnat_get_default_identifier_character_set ()
/* Return the current working directory. */
void
-__gnat_get_current_dir (dir, length)
- char *dir;
- int *length;
+__gnat_get_current_dir (char *dir, int *length)
{
#ifdef VMS
/* Force Unix style, which is what GNAT uses internally. */
@@ -441,17 +471,18 @@ __gnat_get_current_dir (dir, length)
*length = strlen (dir);
- dir[*length] = DIR_SEPARATOR;
- ++*length;
+ if (dir [*length - 1] != DIR_SEPARATOR)
+ {
+ dir [*length] = DIR_SEPARATOR;
+ ++(*length);
+ }
dir[*length] = '\0';
}
/* Return the suffix for object files. */
void
-__gnat_get_object_suffix_ptr (len, value)
- int *len;
- const char **value;
+__gnat_get_object_suffix_ptr (int *len, const char **value)
{
*value = HOST_OBJECT_SUFFIX;
@@ -466,9 +497,7 @@ __gnat_get_object_suffix_ptr (len, value)
/* Return the suffix for executable files. */
void
-__gnat_get_executable_suffix_ptr (len, value)
- int *len;
- const char **value;
+__gnat_get_executable_suffix_ptr (int *len, const char **value)
{
*value = HOST_EXECUTABLE_SUFFIX;
if (!*value)
@@ -483,9 +512,7 @@ __gnat_get_executable_suffix_ptr (len, value)
executable extension. */
void
-__gnat_get_debuggable_suffix_ptr (len, value)
- int *len;
- const char **value;
+__gnat_get_debuggable_suffix_ptr (int *len, const char **value)
{
#ifndef MSDOS
*value = HOST_EXECUTABLE_SUFFIX;
@@ -503,9 +530,7 @@ __gnat_get_debuggable_suffix_ptr (len, value)
}
int
-__gnat_open_read (path, fmode)
- char *path;
- int fmode;
+__gnat_open_read (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
@@ -526,16 +551,23 @@ __gnat_open_read (path, fmode)
return fd < 0 ? -1 : fd;
}
-#if defined (__EMX__)
+#if defined (__EMX__) || defined (__MINGW32__)
#define PERM (S_IREAD | S_IWRITE)
+#elif defined (VMS)
+/* Excerpt from DECC C RTL Reference Manual:
+ To create files with OpenVMS RMS default protections using the UNIX
+ system-call functions umask, mkdir, creat, and open, call mkdir, creat,
+ and open with a file-protection mode argument of 0777 in a program
+ that never specifically calls umask. These default protections include
+ correctly establishing protections based on ACLs, previous versions of
+ files, and so on. */
+#define PERM 0777
#else
#define PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#endif
int
-__gnat_open_rw (path, fmode)
- char *path;
- int fmode;
+__gnat_open_rw (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
@@ -554,9 +586,7 @@ __gnat_open_rw (path, fmode)
}
int
-__gnat_open_create (path, fmode)
- char *path;
- int fmode;
+__gnat_open_create (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
@@ -575,9 +605,7 @@ __gnat_open_create (path, fmode)
}
int
-__gnat_open_append (path, fmode)
- char *path;
- int fmode;
+__gnat_open_append (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
@@ -598,9 +626,7 @@ __gnat_open_append (path, fmode)
/* Open a new file. Return error (-1) if the file already exists. */
int
-__gnat_open_new (path, fmode)
- char *path;
- int fmode;
+__gnat_open_new (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
@@ -623,9 +649,7 @@ __gnat_open_new (path, fmode)
processes, however they really slow down output. Used in gnatchop. */
int
-__gnat_open_new_temp (path, fmode)
- char *path;
- int fmode;
+__gnat_open_new_temp (char *path, int fmode)
{
int fd;
int o_fmode = O_BINARY;
@@ -658,8 +682,7 @@ __gnat_open_new_temp (path, fmode)
/* Return the number of bytes in the specified file. */
long
-__gnat_file_length (fd)
- int fd;
+__gnat_file_length (int fd)
{
int ret;
struct stat statbuf;
@@ -675,8 +698,7 @@ __gnat_file_length (fd)
TMP_FILENAME. */
void
-__gnat_tmp_name (tmp_filename)
- char *tmp_filename;
+__gnat_tmp_name (char *tmp_filename)
{
#ifdef __MINGW32__
{
@@ -689,10 +711,16 @@ __gnat_tmp_name (tmp_filename)
pname = (char *) tempnam ("c:\\temp", "gnat-");
+ /* if pname is NULL, the file was not created properly, the disk is full
+ or there is no more free temporary files */
+
+ if (pname == NULL)
+ *tmp_filename = '\0';
+
/* If pname start with a back slash and not path information it means that
the filename is valid for the current working directory. */
- if (pname[0] == '\\')
+ else if (pname[0] == '\\')
{
strcpy (tmp_filename, ".\\");
strcat (tmp_filename, pname+1);
@@ -704,12 +732,15 @@ __gnat_tmp_name (tmp_filename)
}
#elif defined (linux)
+#define MAX_SAFE_PATH 1000
char *tmpdir = getenv ("TMPDIR");
- if (tmpdir == NULL)
+ /* If tmpdir is longer than MAX_SAFE_PATH, revert to default value to avoid
+ a buffer overflow. */
+ if (tmpdir == NULL || strlen (tmpdir) > MAX_SAFE_PATH)
strcpy (tmp_filename, "/tmp/gnat-XXXXXX");
else
- sprintf (tmp_filename, "%.200s/gnat-XXXXXX", tmpdir);
+ sprintf (tmp_filename, "%s/gnat-XXXXXX", tmpdir);
close (mkstemp(tmp_filename));
#else
@@ -721,9 +752,7 @@ __gnat_tmp_name (tmp_filename)
in the buffer. */
char *
-__gnat_readdir (dirp, buffer)
- DIR *dirp;
- char* buffer;
+__gnat_readdir (DIR *dirp, char *buffer)
{
/* If possible, try to use the thread-safe version. */
#ifdef HAVE_READDIR_R
@@ -766,8 +795,7 @@ __gnat_readdir_is_thread_safe ()
stat structure. */
static time_t
-win32_filetime (h)
- HANDLE h;
+win32_filetime (HANDLE h)
{
BOOL res;
FILETIME t_create;
@@ -784,7 +812,7 @@ win32_filetime (h)
res = GetFileTime (h, &t_create, &t_access, &t_write);
- timestamp = (((long long) t_write.dwHighDateTime << 32)
+ timestamp = (((long long) t_write.dwHighDateTime << 32)
+ t_write.dwLowDateTime);
timestamp = timestamp / 10000000 - offset;
@@ -796,8 +824,7 @@ win32_filetime (h)
/* Return a GNAT time stamp given a file name. */
time_t
-__gnat_file_time_name (name)
- char *name;
+__gnat_file_time_name (char *name)
{
struct stat statbuf;
@@ -828,8 +855,7 @@ __gnat_file_time_name (name)
/* Return a GNAT time stamp given a file descriptor. */
time_t
-__gnat_file_time_fd (fd)
- int fd;
+__gnat_file_time_fd (int fd)
{
/* The following workaround code is due to the fact that under EMX and
DJGPP fstat attempts to convert time values to GMT rather than keep the
@@ -920,9 +946,7 @@ __gnat_file_time_fd (fd)
/* Set the file time stamp. */
void
-__gnat_set_file_time_name (name, time_stamp)
- char *name;
- time_t time_stamp;
+__gnat_set_file_time_name (char *name, time_t time_stamp)
{
#if defined (__EMX__) || defined (MSDOS) || defined (_WIN32) \
|| defined (__vxworks)
@@ -1051,18 +1075,14 @@ __gnat_set_file_time_name (name, time_stamp)
{
time_t t;
- struct tm *ts;
-
- ts = localtime (&time_stamp);
/* Set creation time to requested time. */
- unix_time_to_vms (time_stamp + ts->tm_gmtoff, newtime);
+ unix_time_to_vms (time_stamp, newtime);
t = time ((time_t) 0);
- ts = localtime (&t);
/* Set revision time to now in local time. */
- unix_time_to_vms (t + ts->tm_gmtoff, revtime);
+ unix_time_to_vms (t, revtime);
}
/* Reopen the file, modify the times and then close. */
@@ -1105,10 +1125,7 @@ __gnat_set_file_time_name (name, time_stamp)
}
void
-__gnat_get_env_value_ptr (name, len, value)
- char *name;
- int *len;
- char **value;
+__gnat_get_env_value_ptr (char *name, int *len, char **value)
{
*value = getenv (name);
if (!*value)
@@ -1123,7 +1140,7 @@ __gnat_get_env_value_ptr (name, len, value)
#ifdef VMS
-static char *to_host_path_spec PARAMS ((char *));
+static char *to_host_path_spec (char *);
struct descriptor_s
{
@@ -1141,9 +1158,7 @@ typedef struct _ile3
#endif
void
-__gnat_set_env_value (name, value)
- char *name;
- char *value;
+__gnat_set_env_value (char *name, char *value)
{
#ifdef MSDOS
@@ -1151,18 +1166,25 @@ __gnat_set_env_value (name, value)
struct descriptor_s name_desc;
/* Put in JOB table for now, so that the project stuff at least works. */
struct descriptor_s table_desc = {7, 0, "LNM$JOB"};
- char *host_pathspec = to_host_path_spec (value);
+ char *host_pathspec = value;
char *copy_pathspec;
int num_dirs_in_pathspec = 1;
char *ptr;
-
- if (*host_pathspec == 0)
- return;
+ long status;
name_desc.len = strlen (name);
name_desc.mbz = 0;
name_desc.adr = name;
+ if (*host_pathspec == 0)
+ /* deassign */
+ {
+ status = LIB$DELETE_LOGICAL (&name_desc, &table_desc);
+ /* no need to check status; if the logical name is not
+ defined, that's fine. */
+ return;
+ }
+
ptr = host_pathspec;
while (*ptr++)
if (*ptr == ',')
@@ -1280,9 +1302,7 @@ __gnat_get_libraries_from_registry ()
}
int
-__gnat_stat (name, statbuf)
- char *name;
- struct stat *statbuf;
+__gnat_stat (char *name, struct stat *statbuf)
{
#ifdef _WIN32
/* Under Windows the directory name for the stat function must not be
@@ -1311,17 +1331,15 @@ __gnat_stat (name, statbuf)
}
int
-__gnat_file_exists (name)
- char *name;
+__gnat_file_exists (char *name)
{
struct stat statbuf;
return !__gnat_stat (name, &statbuf);
}
-int
-__gnat_is_absolute_path (name)
- char *name;
+int
+__gnat_is_absolute_path (char *name)
{
return (*name == '/' || *name == DIR_SEPARATOR
#if defined (__EMX__) || defined (MSDOS) || defined (WINNT)
@@ -1331,8 +1349,7 @@ __gnat_is_absolute_path (name)
}
int
-__gnat_is_regular_file (name)
- char *name;
+__gnat_is_regular_file (char *name)
{
int ret;
struct stat statbuf;
@@ -1342,8 +1359,7 @@ __gnat_is_regular_file (name)
}
int
-__gnat_is_directory (name)
- char *name;
+__gnat_is_directory (char *name)
{
int ret;
struct stat statbuf;
@@ -1353,8 +1369,19 @@ __gnat_is_directory (name)
}
int
-__gnat_is_writable_file (name)
- char *name;
+__gnat_is_readable_file (char *name)
+{
+ int ret;
+ int mode;
+ struct stat statbuf;
+
+ ret = __gnat_stat (name, &statbuf);
+ mode = statbuf.st_mode & S_IRUSR;
+ return (!ret && mode);
+}
+
+int
+__gnat_is_writable_file (char *name)
{
int ret;
int mode;
@@ -1365,6 +1392,52 @@ __gnat_is_writable_file (name)
return (!ret && mode);
}
+void
+__gnat_set_writable (char *name)
+{
+#ifndef __vxworks
+ struct stat statbuf;
+
+ if (stat (name, &statbuf) == 0)
+ {
+ statbuf.st_mode = statbuf.st_mode | S_IWUSR;
+ chmod (name, statbuf.st_mode);
+ }
+#endif
+}
+
+void
+__gnat_set_readonly (char *name)
+{
+#ifndef __vxworks
+ struct stat statbuf;
+
+ if (stat (name, &statbuf) == 0)
+ {
+ statbuf.st_mode = statbuf.st_mode & 07577;
+ chmod (name, statbuf.st_mode);
+ }
+#endif
+}
+
+int
+__gnat_is_symbolic_link (char *name)
+{
+#if defined (__vxworks)
+ return 0;
+
+#elif defined (_AIX) || defined (unix)
+ int ret;
+ struct stat statbuf;
+
+ ret = lstat (name, &statbuf);
+ return (!ret && S_ISLNK (statbuf.st_mode));
+
+#else
+ return 0;
+#endif
+}
+
#ifdef VMS
/* Defined in VMS header files. */
#define fork() (decc$$alloc_vfork_blocks() >= 0 ? \
@@ -1379,8 +1452,7 @@ __gnat_is_writable_file (name)
#endif
int
-__gnat_portable_spawn (args)
- char *args[];
+__gnat_portable_spawn (char *args[])
{
int status = 0;
int finished;
@@ -1468,8 +1540,7 @@ static Process_List *PLIST = NULL;
static int plist_length = 0;
static void
-add_handle (h)
- HANDLE h;
+add_handle (HANDLE h)
{
Process_List *pl;
@@ -1487,8 +1558,7 @@ add_handle (h)
plist_leave();
}
-void remove_handle (h)
- HANDLE h;
+void remove_handle (HANDLE h)
{
Process_List *pl, *prev;
@@ -1521,9 +1591,7 @@ void remove_handle (h)
}
static int
-win32_no_block_spawn (command, args)
- char *command;
- char *args[];
+win32_no_block_spawn (char *command, char *args[])
{
BOOL result;
STARTUPINFO SI;
@@ -1586,8 +1654,7 @@ win32_no_block_spawn (command, args)
}
static int
-win32_wait (status)
- int *status;
+win32_wait (int *status)
{
DWORD exitcode;
HANDLE *hl;
@@ -1634,8 +1701,7 @@ win32_wait (status)
#endif
int
-__gnat_portable_no_block_spawn (args)
- char *args[];
+__gnat_portable_no_block_spawn (char *args[])
{
int pid = 0;
@@ -1669,7 +1735,7 @@ __gnat_portable_no_block_spawn (args)
if (execv (args[0], args) != 0)
#if defined (VMS)
return -1; /* execv is in parent context on VMS. */
-#else
+#else
_exit (1);
#endif
}
@@ -1680,8 +1746,7 @@ __gnat_portable_no_block_spawn (args)
}
int
-__gnat_portable_wait (process_status)
- int *process_status;
+__gnat_portable_wait (int *process_status)
{
int status = 0;
int pid = 0;
@@ -1707,8 +1772,7 @@ __gnat_portable_wait (process_status)
}
int
-__gnat_waitpid (pid)
- int pid;
+__gnat_waitpid (int pid)
{
int status = 0;
@@ -1725,8 +1789,7 @@ __gnat_waitpid (pid)
}
void
-__gnat_os_exit (status)
- int status;
+__gnat_os_exit (int status)
{
#ifdef VMS
/* Exit without changing 0 to 1. */
@@ -1739,26 +1802,29 @@ __gnat_os_exit (status)
/* Locate a regular file, give a Path value. */
char *
-__gnat_locate_regular_file (file_name, path_val)
- char *file_name;
- char *path_val;
+__gnat_locate_regular_file (char *file_name, char *path_val)
{
char *ptr;
+ int absolute = __gnat_is_absolute_path (file_name);
/* Handle absolute pathnames. */
+ if (absolute)
+ {
+ if (__gnat_is_regular_file (file_name))
+ return xstrdup (file_name);
+
+ return 0;
+ }
+
+ /* If file_name include directory separator(s), try it first as
+ a path name relative to the current directory */
for (ptr = file_name; *ptr && *ptr != '/' && *ptr != DIR_SEPARATOR; ptr++)
;
- if (*ptr != 0
-#if defined (__EMX__) || defined (MSDOS) || defined (WINNT)
- || isalpha (file_name[0]) && file_name[1] == ':'
-#endif
- )
+ if (*ptr != 0)
{
if (__gnat_is_regular_file (file_name))
return xstrdup (file_name);
-
- return 0;
}
if (path_val == 0)
@@ -1798,9 +1864,7 @@ __gnat_locate_regular_file (file_name, path_val)
instead. */
char *
-__gnat_locate_exec (exec_name, path_val)
- char *exec_name;
- char *path_val;
+__gnat_locate_exec (char *exec_name, char *path_val)
{
if (!strstr (exec_name, HOST_EXECUTABLE_SUFFIX))
{
@@ -1818,17 +1882,31 @@ __gnat_locate_exec (exec_name, path_val)
/* Locate an executable using the Systems default PATH. */
char *
-__gnat_locate_exec_on_path (exec_name)
- char *exec_name;
+__gnat_locate_exec_on_path (char *exec_name)
{
+ char *apath_val;
#ifdef VMS
char *path_val = "/VAXC$PATH";
#else
char *path_val = getenv ("PATH");
#endif
- char *apath_val = alloca (strlen (path_val) + 1);
+#ifdef _WIN32
+ /* In Win32 systems we expand the PATH as for XP environment
+ variables are not automatically expanded. */
+ int len = strlen (path_val) * 3;
+ char *expanded_path_val = alloca (len + 1);
+
+ DWORD res = ExpandEnvironmentStrings (path_val, expanded_path_val, len);
+
+ if (res != 0)
+ {
+ path_val = expanded_path_val;
+ }
+#endif
+ apath_val = alloca (strlen (path_val) + 1);
strcpy (apath_val, path_val);
+
return __gnat_locate_exec (exec_name, apath_val);
}
@@ -1837,32 +1915,33 @@ __gnat_locate_exec_on_path (exec_name)
/* These functions are used to translate to and from VMS and Unix syntax
file, directory and path specifications. */
+#define MAXPATH 256
#define MAXNAMES 256
#define NEW_CANONICAL_FILELIST_INCREMENT 64
-static char new_canonical_dirspec[255];
-static char new_canonical_filespec[255];
-static char new_canonical_pathspec[MAXNAMES*255];
+static char new_canonical_dirspec [MAXPATH];
+static char new_canonical_filespec [MAXPATH];
+static char new_canonical_pathspec [MAXNAMES*MAXPATH];
static unsigned new_canonical_filelist_index;
static unsigned new_canonical_filelist_in_use;
static unsigned new_canonical_filelist_allocated;
static char **new_canonical_filelist;
-static char new_host_pathspec[MAXNAMES*255];
-static char new_host_dirspec[255];
-static char new_host_filespec[255];
+static char new_host_pathspec [MAXNAMES*MAXPATH];
+static char new_host_dirspec [MAXPATH];
+static char new_host_filespec [MAXPATH];
/* Routine is called repeatedly by decc$from_vms via
- __gnat_to_canonical_file_list_init until it returns 0 or the expansion runs
- out. */
+ __gnat_to_canonical_file_list_init until it returns 0 or the expansion
+ runs out. */
static int
-wildcard_translate_unix (name)
- char *name;
+wildcard_translate_unix (char *name)
{
char *ver;
- char buff[256];
+ char buff [MAXPATH];
- strcpy (buff, name);
+ strncpy (buff, name, MAXPATH);
+ buff [MAXPATH - 1] = (char) 0;
ver = strrchr (buff, '.');
/* Chop off the version. */
@@ -1888,19 +1967,19 @@ wildcard_translate_unix (name)
one at a time (_next). If onlydirs set, only expand directory files. */
int
-__gnat_to_canonical_file_list_init (filespec, onlydirs)
- char *filespec;
- int onlydirs;
+__gnat_to_canonical_file_list_init (char *filespec, int onlydirs)
{
int len;
- char buff[256];
+ char buff [MAXPATH];
len = strlen (filespec);
- strcpy (buff, filespec);
+ strncpy (buff, filespec, MAXPATH);
+
+ /* Only look for directories */
+ if (onlydirs && !strstr (&buff [len-5], "*.dir"))
+ strncat (buff, "*.dir", MAXPATH);
- /* Only look for directories. */
- if (onlydirs && !strstr (&buff[len - 5], "*.dir"))
- strcat (buff, "*.dir");
+ buff [MAXPATH - 1] = (char) 0;
decc$from_vms (buff, wildcard_translate_unix, 1);
@@ -1953,9 +2032,7 @@ __gnat_to_canonical_file_list_free ()
slashes, in case it's a logical name. */
char *
-__gnat_to_canonical_dir_spec (dirspec, prefixflag)
- char *dirspec;
- int prefixflag;
+__gnat_to_canonical_dir_spec (char *dirspec, int prefixflag)
{
int len;
@@ -1965,16 +2042,28 @@ __gnat_to_canonical_dir_spec (dirspec, prefixflag)
char *dirspec1;
if (strchr (dirspec, ']') || strchr (dirspec, ':'))
- strcpy (new_canonical_dirspec, (char *) decc$translate_vms (dirspec));
+ {
+ strncpy (new_canonical_dirspec,
+ (char *) decc$translate_vms (dirspec),
+ MAXPATH);
+ }
else if (!strchr (dirspec, '/') && (dirspec1 = getenv (dirspec)) != 0)
- strcpy (new_canonical_dirspec, (char *) decc$translate_vms (dirspec1));
+ {
+ strncpy (new_canonical_dirspec,
+ (char *) decc$translate_vms (dirspec1),
+ MAXPATH);
+ }
else
- strcpy (new_canonical_dirspec, dirspec);
+ {
+ strncpy (new_canonical_dirspec, dirspec, MAXPATH);
+ }
}
len = strlen (new_canonical_dirspec);
- if (prefixflag && new_canonical_dirspec[len - 1] != '/')
- strcat (new_canonical_dirspec, "/");
+ if (prefixflag && new_canonical_dirspec [len-1] != '/')
+ strncat (new_canonical_dirspec, "/", MAXPATH);
+
+ new_canonical_dirspec [MAXPATH - 1] = (char) 0;
return new_canonical_dirspec;
@@ -1984,14 +2073,22 @@ __gnat_to_canonical_dir_spec (dirspec, prefixflag)
If no indicators of VMS syntax found, return input string. */
char *
-__gnat_to_canonical_file_spec (filespec)
- char *filespec;
+__gnat_to_canonical_file_spec (char *filespec)
{
- strcpy (new_canonical_filespec, "");
+ strncpy (new_canonical_filespec, "", MAXPATH);
+
if (strchr (filespec, ']') || strchr (filespec, ':'))
- strcpy (new_canonical_filespec, (char *) decc$translate_vms (filespec));
+ {
+ strncpy (new_canonical_filespec,
+ (char *) decc$translate_vms (filespec),
+ MAXPATH);
+ }
else
- strcpy (new_canonical_filespec, filespec);
+ {
+ strncpy (new_canonical_filespec, filespec, MAXPATH);
+ }
+
+ new_canonical_filespec [MAXPATH - 1] = (char) 0;
return new_canonical_filespec;
}
@@ -2000,10 +2097,9 @@ __gnat_to_canonical_file_spec (filespec)
If no indicators of VMS syntax found, return input string. */
char *
-__gnat_to_canonical_path_spec (pathspec)
- char *pathspec;
+__gnat_to_canonical_path_spec (char *pathspec)
{
- char *curr, *next, buff[256];
+ char *curr, *next, buff [MAXPATH];
if (pathspec == 0)
return pathspec;
@@ -2035,37 +2131,38 @@ __gnat_to_canonical_path_spec (pathspec)
char *next_dir;
next_dir = __gnat_to_canonical_file_list_next ();
- strcat (new_canonical_pathspec, next_dir);
+ strncat (new_canonical_pathspec, next_dir, MAXPATH);
/* Don't append the separator after the last expansion. */
if (i+1 < dirs)
- strcat (new_canonical_pathspec, ":");
+ strncat (new_canonical_pathspec, ":", MAXPATH);
}
__gnat_to_canonical_file_list_free ();
}
else
- strcat (new_canonical_pathspec,
- __gnat_to_canonical_dir_spec (buff, 0));
+ strncat (new_canonical_pathspec,
+ __gnat_to_canonical_dir_spec (buff, 0), MAXPATH);
if (*next == 0)
break;
- strcat (new_canonical_pathspec, ":");
+ strncat (new_canonical_pathspec, ":", MAXPATH);
curr = next + 1;
}
+ new_canonical_pathspec [MAXPATH - 1] = (char) 0;
+
return new_canonical_pathspec;
}
-static char filename_buff[256];
+static char filename_buff [MAXPATH];
static int
-translate_unix (name, type)
- char *name;
- int type;
+translate_unix (char *name, int type)
{
- strcpy (filename_buff, name);
+ strncpy (filename_buff, name, MAXPATH);
+ filename_buff [MAXPATH - 1] = (char) 0;
return 0;
}
@@ -2073,10 +2170,9 @@ translate_unix (name, type)
directories. */
static char *
-to_host_path_spec (pathspec)
- char *pathspec;
+to_host_path_spec (char *pathspec)
{
- char *curr, *next, buff[256];
+ char *curr, *next, buff [MAXPATH];
if (pathspec == 0)
return pathspec;
@@ -2097,13 +2193,15 @@ to_host_path_spec (pathspec)
strncpy (buff, curr, next - curr);
buff[next - curr] = 0;
- strcat (new_host_pathspec, __gnat_to_host_dir_spec (buff, 0));
+ strncat (new_host_pathspec, __gnat_to_host_dir_spec (buff, 0), MAXPATH);
if (*next == 0)
break;
- strcat (new_host_pathspec, ",");
+ strncat (new_host_pathspec, ",", MAXPATH);
curr = next + 1;
}
+ new_host_pathspec [MAXPATH - 1] = (char) 0;
+
return new_host_pathspec;
}
@@ -2113,13 +2211,12 @@ to_host_path_spec (pathspec)
string. */
char *
-__gnat_to_host_dir_spec (dirspec, prefixflag)
- char *dirspec;
- int prefixflag ATTRIBUTE_UNUSED;
+__gnat_to_host_dir_spec (char *dirspec, int prefixflag ATTRIBUTE_UNUSED)
{
int len = strlen (dirspec);
- strcpy (new_host_dirspec, dirspec);
+ strncpy (new_host_dirspec, dirspec, MAXPATH);
+ new_host_dirspec [MAXPATH - 1] = (char) 0;
if (strchr (new_host_dirspec, ']') || strchr (new_host_dirspec, ':'))
return new_host_dirspec;
@@ -2131,28 +2228,31 @@ __gnat_to_host_dir_spec (dirspec, prefixflag)
}
decc$to_vms (new_host_dirspec, translate_unix, 1, 2);
- strcpy (new_host_dirspec, filename_buff);
+ strncpy (new_host_dirspec, filename_buff, MAXPATH);
+ new_host_dirspec [MAXPATH - 1] = (char) 0;
return new_host_dirspec;
-
}
/* Translate a Unix syntax file specification into VMS syntax.
If indicators of VMS syntax found, return input string. */
char *
-__gnat_to_host_file_spec (filespec)
- char *filespec;
+__gnat_to_host_file_spec (char *filespec)
{
- strcpy (new_host_filespec, "");
+ strncpy (new_host_filespec, "", MAXPATH);
if (strchr (filespec, ']') || strchr (filespec, ':'))
- strcpy (new_host_filespec, filespec);
+ {
+ strncpy (new_host_filespec, filespec, MAXPATH);
+ }
else
{
decc$to_vms (filespec, translate_unix, 1, 1);
- strcpy (new_host_filespec, filename_buff);
+ strncpy (new_host_filespec, filename_buff, MAXPATH);
}
+ new_host_filespec [MAXPATH - 1] = (char) 0;
+
return new_host_filespec;
}
@@ -2162,14 +2262,13 @@ __gnat_adjust_os_resource_limits ()
SYS$ADJWSL (131072, 0);
}
-#else
+#else /* VMS */
/* Dummy functions for Osint import for non-VMS systems. */
int
-__gnat_to_canonical_file_list_init (dirspec, onlydirs)
- char *dirspec ATTRIBUTE_UNUSED;
- int onlydirs ATTRIBUTE_UNUSED;
+__gnat_to_canonical_file_list_init
+ (char *dirspec ATTRIBUTE_UNUSED, int onlydirs ATTRIBUTE_UNUSED)
{
return 0;
}
@@ -2186,38 +2285,31 @@ __gnat_to_canonical_file_list_free ()
}
char *
-__gnat_to_canonical_dir_spec (dirspec, prefixflag)
- char *dirspec;
- int prefixflag ATTRIBUTE_UNUSED;
+__gnat_to_canonical_dir_spec (char *dirspec, int prefixflag ATTRIBUTE_UNUSED)
{
return dirspec;
}
char *
-__gnat_to_canonical_file_spec (filespec)
- char *filespec;
+__gnat_to_canonical_file_spec (char *filespec)
{
return filespec;
}
char *
-__gnat_to_canonical_path_spec (pathspec)
- char *pathspec;
+__gnat_to_canonical_path_spec (char *pathspec)
{
return pathspec;
}
char *
-__gnat_to_host_dir_spec (dirspec, prefixflag)
- char *dirspec;
- int prefixflag ATTRIBUTE_UNUSED;
+__gnat_to_host_dir_spec (char *dirspec, int prefixflag ATTRIBUTE_UNUSED)
{
return dirspec;
}
char *
-__gnat_to_host_file_spec (filespec)
- char *filespec;
+__gnat_to_host_file_spec (char *filespec)
{
return filespec;
}
@@ -2238,7 +2330,8 @@ void __dummy () {}
#endif
#if defined (__mips_vxworks)
-int _flush_cache()
+int
+_flush_cache()
{
CACHE_USER_FLUSH (0, ENTIRE_CACHE);
}
@@ -2246,21 +2339,21 @@ int _flush_cache()
#if defined (CROSS_COMPILE) \
|| (! (defined (sparc) && defined (sun) && defined (__SVR4)) \
- && ! defined (linux) \
+ && ! (defined (linux) && defined (i386)) \
&& ! defined (hpux) \
+ && ! defined (_AIX) \
&& ! (defined (__alpha__) && defined (__osf__)) \
&& ! defined (__MINGW32__))
/* Dummy function to satisfy g-trasym.o. Currently Solaris sparc, HP/UX,
- GNU/Linux, Tru64 & Windows provide a non-dummy version of this procedure in
- libaddr2line.a. */
+ GNU/Linux x86, Tru64 & Windows provide a non-dummy version of this
+ procedure in libaddr2line.a. */
void
-convert_addresses (addrs, n_addr, buf, len)
- char *addrs[] ATTRIBUTE_UNUSED;
- int n_addr ATTRIBUTE_UNUSED;
- void *buf ATTRIBUTE_UNUSED;
- int *len;
+convert_addresses (void *addrs ATTRIBUTE_UNUSED,
+ int n_addr ATTRIBUTE_UNUSED,
+ void *buf ATTRIBUTE_UNUSED,
+ int *len ATTRIBUTE_UNUSED)
{
*len = 0;
}
@@ -2271,3 +2364,84 @@ int __gnat_argument_needs_quote = 1;
#else
int __gnat_argument_needs_quote = 0;
#endif
+
+/* This option is used to enable/disable object files handling from the
+ binder file by the GNAT Project module. For example, this is disabled on
+ Windows as it is already done by the mdll module. */
+#if defined (_WIN32)
+int __gnat_prj_add_obj_files = 0;
+#else
+int __gnat_prj_add_obj_files = 1;
+#endif
+
+/* char used as prefix/suffix for environment variables */
+#if defined (_WIN32)
+char __gnat_environment_char = '%';
+#else
+char __gnat_environment_char = '$';
+#endif
+
+/* This functions copy the file attributes from a source file to a
+ destination file.
+
+ mode = 0 : In this mode copy only the file time stamps (last access and
+ last modification time stamps).
+
+ mode = 1 : In this mode, time stamps and read/write/execute attributes are
+ copied.
+
+ Returns 0 if operation was successful and -1 in case of error. */
+
+int
+__gnat_copy_attribs (char *from, char *to, int mode)
+{
+#if defined (VMS) || defined (__vxworks)
+ return -1;
+#else
+ struct stat fbuf;
+ struct utimbuf tbuf;
+
+ if (stat (from, &fbuf) == -1)
+ {
+ return -1;
+ }
+
+ tbuf.actime = fbuf.st_atime;
+ tbuf.modtime = fbuf.st_mtime;
+
+ if (utime (to, &tbuf) == -1)
+ {
+ return -1;
+ }
+
+ if (mode == 1)
+ {
+ if (chmod (to, fbuf.st_mode) == -1)
+ {
+ return -1;
+ }
+ }
+
+ return 0;
+#endif
+}
+
+/* This function is installed in libgcc.a. */
+extern void __gnat_install_locks (void (*) (void), void (*) (void));
+
+/* This function offers a hook for libgnarl to set the
+ locking subprograms for libgcc_eh. */
+
+void
+__gnatlib_install_locks (lock, unlock)
+ void (*lock) (void) ATTRIBUTE_UNUSED;
+ void (*unlock) (void) ATTRIBUTE_UNUSED;
+{
+#ifdef IN_RTS
+ __gnat_install_locks (lock, unlock);
+ /* There is a bootstrap path issue if adaint is build with this
+ symbol unresolved for the stage1 compiler. Since the compiler
+ does not use tasking, we simply make __gnatlib_install_locks
+ a no-op in this case. */
+#endif
+}