~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/default/scimem.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright INRIA */
 
2
#include <string.h>
 
3
 
 
4
#ifdef __STDC__
 
5
#include <stdlib.h>
 
6
#else
 
7
#include <malloc.h>
 
8
#endif
 
9
 
 
10
#include "../machine.h"
 
11
 
 
12
#if defined(netbsd)
 
13
#include <ieeefp.h>
 
14
#endif
 
15
 
 
16
#if defined(freebsd)
 
17
#include <floatingpoint.h>
 
18
#endif
 
19
 
 
20
#if defined(netbsd) || defined(freebsd)
 
21
void C2F(nofpex)()
 
22
{
 
23
  fpsetmask(0);   /* Don't dump core on FPE return Inf or NaN */
 
24
}
 
25
#else
 
26
void C2F(nofpex)()
 
27
{
 
28
  return;
 
29
}
 
30
#endif
 
31
 
 
32
char *the_p=NULL;
 
33
char *the_ps=NULL;
 
34
char *the_gp=NULL;
 
35
char *the_gps=NULL;
 
36
 
 
37
/* static  char *the_p,*the_ps;*/
 
38
 
 
39
extern struct {
 
40
  double stk_1[2];
 
41
} C2F(stack);
 
42
 
 
43
integer C2F(scimem)(n,ptr)
 
44
     integer *n, *ptr;
 
45
{
 
46
  char *p1;
 
47
  if (*n > 0){
 
48
    /* add 1 for alignment problems */
 
49
    p1 = (char *) malloc((unsigned)sizeof(double) * (*n + 1));
 
50
    if (p1 != NULL) {
 
51
      the_ps = the_p;
 
52
      the_p = p1;
 
53
      /* add 1 for alignment problems */
 
54
      *ptr = ((int) (the_p - (char *)C2F(stack).stk_1))/sizeof(double) + 1;
 
55
    }
 
56
    else 
 
57
      {
 
58
        if (the_p == NULL) {
 
59
          sciprint("No space to allocate Scilab stack\r\n");
 
60
          exit(1); 
 
61
        }
 
62
        *ptr=0;
 
63
      }
 
64
  }
 
65
  return(0);
 
66
}
 
67
integer C2F(scigmem)(n,ptr)
 
68
     integer *n, *ptr;
 
69
{
 
70
  char *p1;
 
71
  if (*n > 0){
 
72
    /* add 1 for alignment problems */
 
73
    p1 = (char *) malloc((unsigned)sizeof(double) * (*n + 1));
 
74
    if (p1 != NULL) {
 
75
      the_gps = the_gp;
 
76
      the_gp = p1;
 
77
      /* add 1 for alignment problems */
 
78
      *ptr = ((int) (the_gp - (char *)C2F(stack).stk_1))/sizeof(double) + 1;
 
79
    }
 
80
    else 
 
81
      {
 
82
        if (the_gp == NULL) {
 
83
          sciprint("No space to allocate Scilab stack\r\n");
 
84
          exit(1); 
 
85
        }
 
86
        *ptr=0;
 
87
      }
 
88
  }
 
89
  return(0);
 
90
}
 
91
void C2F(freegmem)()
 
92
{
 
93
  if (the_gps != NULL) free(the_gps);
 
94
}
 
95
 
 
96
void C2F(freemem)()
 
97
{
 
98
  if (the_ps != NULL) free(the_ps);
 
99
}
 
100