missing-ansi.c 1.44 KB
Newer Older
Per Cederqvist's avatar
Per Cederqvist committed
1
2
3
4
5
6
/*
 * Some missing functions that are needed.
 *
 * Written by ceder.
 */

Per Cederqvist's avatar
Per Cederqvist committed
7
8
9
static char *rcsid = "$Id: missing-ansi.c,v 0.3 1991/08/28 02:21:17 ceder Exp $";


Per Cederqvist's avatar
Per Cederqvist committed
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
#include <string.h>
#include <time.h>

#if defined(__sequent__) && !defined(DEBUG_MALLOC)

void *
memcpy (void * s1, const void * s2, size_t n)
{
    extern bcopy(const char *b1, char *b2, unsigned int length);

    /* bcopy takes the parameters the other way round. */
    
    bcopy(s2, s1, n);
    return s1;			/* Since ANSI says so */
}

#endif

#if defined(__sequent__) || defined(__sun__)

extern double
difftime(time_t t1, time_t t2)
{
    return (double) t1 - (double) t2;
}

#endif

#ifdef __sequent__

/*
 * This version in NOT 100 % ANSI-conformant, but it is enough to run LysKOM
 * (I hope) /ceder
 */

extern time_t
mktime (const struct tm  * temeptr )
{
    int nyears;
    int nleaps;
    int ndays;

    nyears = temeptr->tm_year - 70;
    nleaps = (nyears+2) / 4;

    ndays = 365 * nyears + nleaps + temeptr->tm_yday;
    
    return (time_t) ( temeptr->tm_sec
		     + 60 * ( temeptr->tm_min
			     + 60 * ( temeptr->tm_hour 
				     + 24 * ndays )));
}

#endif


66
#if defined(__sequent__) || defined(__sun__)
Per Cederqvist's avatar
Per Cederqvist committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <errno.h>
#include <stdio.h>

extern char *sys_errlist[];
extern int sys_nerr;

const char *strerror(int eno)
{
  static char buf[200];

  
  if (eno < 0 || eno >= sys_nerr)
  {
    sprintf(buf, "error #%d", eno);
    return buf;
  }
  else
    return sys_errlist[eno];
}
#endif