machdep.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. *
  4. * This product is part of the Amsterdam Compiler Kit.
  5. *
  6. * Permission to use, sell, duplicate or disclose this software must be
  7. * obtained in writing. Requests for such permissions may be sent to
  8. *
  9. * Dr. Andrew S. Tanenbaum
  10. * Wiskundig Seminarium
  11. * Vrije Universiteit
  12. * Postbox 7161
  13. * 1007 MC Amsterdam
  14. * The Netherlands
  15. *
  16. */
  17. /*
  18. * L L G E N
  19. *
  20. * An Extended LL(1) Parser Generator
  21. *
  22. * Author : Ceriel J.H. Jacobs
  23. */
  24. /*
  25. * machdep.c
  26. * Machine dependant things
  27. */
  28. # include "../../../h/em_path.h"
  29. # include "types.h"
  30. # ifndef NORCSID
  31. static string rcsid5 = "$Header$";
  32. # endif
  33. /* In this file the following routines are defined: */
  34. extern UNLINK();
  35. extern RENAME();
  36. extern string libpath();
  37. UNLINK(x) string x; {
  38. /* Must remove the file "x" */
  39. unlink(x); /* systemcall to remove file */
  40. }
  41. RENAME(x,y) string x,y; {
  42. /* Must move the file "x" to the file "y" */
  43. unlink(y);
  44. if(link(x,y)!=0)fatal(1,"Cannot link to %s",y);
  45. unlink(x);
  46. }
  47. string
  48. libpath(s) string s; {
  49. /* Must deliver a full pathname to the library file "s" */
  50. register string p;
  51. register length;
  52. p_mem alloc();
  53. string strcpy(), strcat();
  54. static string subdir = "/lib/LLgen/";
  55. length = strlen(EM_DIR) + strlen(subdir) + strlen(s) + 1;
  56. p = (string) alloc((unsigned) length);
  57. strcpy(p,EM_DIR);
  58. strcat(p,subdir);
  59. strcat(p,s);
  60. return p;
  61. }