Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
26 pmbaty 1
/* ACC -- Automatic Compiler Configuration
2
 
3
   Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
4
   All Rights Reserved.
5
 
6
   This software is a copyrighted work licensed under the terms of
7
   the GNU General Public License. Please consult the file "ACC_LICENSE"
8
   for details.
9
 
10
   Markus F.X.J. Oberhumer
11
   <markus@oberhumer.com>
12
   http://www.oberhumer.com/
13
 */
14
 
15
 
16
#define __ACCLIB_DOSALLOC_CH_INCLUDED 1
17
#if !defined(ACCLIB_PUBLIC)
18
#  define ACCLIB_PUBLIC(r,f)    r __ACCLIB_FUNCNAME(f)
19
#endif
20
 
21
 
22
#if (ACC_OS_OS216)
23
ACC_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short);
24
ACC_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short);
25
#endif
26
 
27
 
28
/***********************************************************************
29
// dos_alloc
30
************************************************************************/
31
 
32
#if (ACC_OS_DOS16 || ACC_OS_WIN16)
33
#if !defined(ACC_CC_AZTECC)
34
 
35
ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size)
36
{
37
    void __far* p = 0;
38
    union REGS ri, ro;
39
 
40
    if ((long)size <= 0)
41
        return p;
42
    size = (size + 15) >> 4;
43
    if (size > 0xffffu)
44
        return p;
45
    ri.x.ax = 0x4800;
46
    ri.x.bx = (unsigned short) size;
47
    int86(0x21, &ri, &ro);
48
    if ((ro.x.cflag & 1) == 0)  /* if carry flag not set */
49
        p = (void __far*) ACC_MK_FP(ro.x.ax, 0);
50
    return p;
51
}
52
 
53
 
54
ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
55
{
56
    union REGS ri, ro;
57
    struct SREGS rs;
58
 
59
    if (!p)
60
        return 0;
61
    if (ACC_FP_OFF(p) != 0)
62
        return -1;
63
    segread(&rs);
64
    ri.x.ax = 0x4900;
65
    rs.es = ACC_FP_SEG(p);
66
    int86x(0x21, &ri, &ro, &rs);
67
    if (ro.x.cflag & 1)         /* if carry flag set */
68
        return -1;
69
    return 0;
70
}
71
 
72
#endif
73
#endif
74
 
75
 
76
#if (ACC_OS_OS216)
77
 
78
ACCLIB_PUBLIC(void __far*, acc_dos_alloc) (unsigned long size)
79
{
80
    void __far* p = 0;
81
    unsigned short sel = 0;
82
 
83
    if ((long)size <= 0)
84
        return p;
85
    if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0)
86
        p = (void __far*) ACC_MK_FP(sel, 0);
87
    return p;
88
}
89
 
90
ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
91
{
92
    if (!p)
93
        return 0;
94
    if (ACC_FP_OFF(p) != 0)
95
        return -1;
96
    if (DosFreeSeg(ACC_FP_SEG(p)) != 0)
97
        return -1;
98
    return 0;
99
}
100
 
101
#endif
102
 
103
 
104
/*
105
vi:ts=4:et
106
*/