File: sysdep.h

package info (click to toggle)
yorick 1.4-14
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,948 kB
  • ctags: 6,609
  • sloc: ansic: 63,898; yacc: 889; makefile: 605; sh: 65; lisp: 60; fortran: 19
file content (133 lines) | stat: -rw-r--r-- 5,320 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
    SYSDEP.H
    Declare operating system-dependent functions required by Yorick,
    and define operating system-dependent macros.

    $Id: sysdep.h,v 1.1 1993/08/27 18:32:09 munro Exp $
 */
/*    Copyright (c) 1994.  The Regents of the University of California.
                    All rights reserved.  */

#ifndef SYSDEP_H
#define SYSDEP_H
/*--------------------------------------------------------------------------*/

/* If the header file setjmp.h cannot be found, you must find the
   correct definition of the data type jmp_buf, which is normally
   an array capable of holding enough state information to make the
   longjmp.  Put the declaration here.  */
/* #define JMP_BUF_DECLARATION typedef int jmp_buf[???]; */

/* If the system math library does not have hypotenuse c= hypot(a,b),
   define the following and nonc.c will create a reasonable facsimile:  */
/* #define NO_HYPOT */

/* The following characters delimit directories in a pathname, or
   pathnames in a list of pathnames.  */
#define DIR_SEP '/'
#define DIR_SEP_S "/"
#define PATH_SEP ":"

#ifdef DOS_FILENAMES
#undef DIR_SEP
#define DIR_SEP '\\'
#undef DIR_SEP_S
#define DIR_SEP_S "\\"
#endif

#ifdef MAC_FILENAMES
#undef DIR_SEP
#define DIR_SEP ':'
#undef DIR_SEP_S
#define DIR_SEP_S ":"
#define PATH_SEP ";"
#define getenv GetStringResource
#endif

/* The following is used as the pathname separator delimiter in calls
   to strtok to separate a list of directory names.  */
#define PATH_SEP_DELIMIT PATH_SEP " \t"

/* BUFFERING
   Since Yorick has its own caching scheme which involves potentially
   variable buffer sizes (controlled by IOStream->blockSize), my first
   thought was to use the ANSI setbuf function to "unbuffered" I/O.
   This might seem like a good idea, but it turns out that both on UNIX
   and MacIntosh (and probably DOS), "unbuffered" means to read the
   stream one byte at a time, NOT to use the space passed to fread/fwrite
   as the buffer, as I originally assumed.
   On UNIX, the only solution is to use the raw read/write functions,
   which simply use the space passed to them as the buffer.  On the
   MacIntosh under Think C, read/write are implemented as wrappers for
   fread/fwrite, so you may as well define NO_UNIX_READ there; I don't
   know what sort of performance hit you will take for not setting the
   buffer size.  The code using this is in binio.c (search for BUFFERING,
   READ_BYTES, and WRITE_BYTES).  FLUSH_BYTES is in cache.c  */
#undef READ_BYTES
#undef WRITE_BYTES
#undef FLUSH_BYTES
#undef SEEK_BYTES
#undef TELL_BYTES

#ifndef NO_UNIX_READ
#define READ_BYTES(file, buffer, n) read(fileno(file), buffer, n)
#define WRITE_BYTES(file, buffer, n) write(fileno(file), buffer, n)
#define FLUSH_BYTES(file)
#define SEEK_BYTES(file, off, w) (lseek(fileno(file), off, w)==-1L)
#define TELL_BYTES(file) lseek(fileno(file), 0L, SEEK_CUR)
#else
/* Could also define READ_BYTES to some other non-UNIX alternative.  */
#define READ_BYTES(file, buffer, n) fread(buffer, sizeof(char), n, file)
#define WRITE_BYTES(file, buffer, n) fwrite(buffer, sizeof(char), n, file)
#define FLUSH_BYTES(file) fflush(file)
#define SEEK_BYTES(file, off, w) fseek(file, off, w)
#define TELL_BYTES(file) ftell(file)
#endif

/* To use getrusage() and gettimeofday() instead of times(), try this: */
/* #define BSD_TIMER */
/* If neither works, a crude timer can be built using only ANSI standard
   library routines with the following:  */
/* #define CLOCK_FUNCTION clock
   #define TICKS_PER_SEC CLOCKS_PER_SEC    */
/* On a MacIntosh, the following works better:  */
/* #include <pascal.h>
   #include <Events.h>
   #define CLOCK_FUNCTION TickCount
   #define TICKS_PER_SEC 60           */
/* You may be able to do better by modifying Ytimer in sysdep.c.  */

/* If the getpwnam function is not defined in <pwd.h>, set this */
/* #define NO_GETPWNAM */

/* If the readlink routine does not exist, set this */
/* #define NO_SOFT_LINKS */

/* sysdep.c defines the following functions:
      int YGetLaunchDir(char *argv0)
         - tracks down the directory in which Yorick's executable resides.
	   Include files necessary for startup are in subdirectories of
	   this directory.
      int YstdinNB(int noWait)
         - If you are running without Gist, this routine is necessary;
	   with Gist, it is never called.  YstdinNB(0) pauses until
	   input arrives on stdin, then returns 0.  YstdinNB(1) returns
	   immediately (NB is for "non-blocking") no matter what; its value
	   is 0 if and only if input is present on stdin, so that fgets
	   will not block.
      void Ytimer(double *cpu, double *sys, double *wall)
         - returns elapsed cpu, system, and wall clock times in seconds
	   (from an arbitrary origin -- used for timing differences only)
      char *Ytimestamp(void)
         - returns result of ANSI ctime, with trailing "\n" stripped
      void SetSignals(int flags)
         - sets up signal handling for keyboard interrupt (^C), floating
	   point interrupts, segmentation and illegal address violations,
	   and alignment errors
      YSetCWD, YGetHome, YPATHstrtok, YExpandName, YNameTail, YNameHead,
      YNameToHead, YIsAbsolute, YIsDotRelative are described in yio.h,
      as is Ygetenv
 */

/*--------------------------------------------------------------------------*/
#endif