GNU PROLOG with UTF8 support
machine.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------*
2  * GNU Prolog *
3  * *
4  * Part : Prolog engine *
5  * File : machine.h *
6  * Descr.: machine dependent features - Header file *
7  * Author: Daniel Diaz *
8  * *
9  * Copyright (C) 1999-2015 Daniel Diaz *
10  * *
11  * This file is part of GNU Prolog *
12  * *
13  * GNU Prolog is free software: you can redistribute it and/or *
14  * modify it under the terms of either: *
15  * *
16  * - the GNU Lesser General Public License as published by the Free *
17  * Software Foundation; either version 3 of the License, or (at your *
18  * option) any later version. *
19  * *
20  * or *
21  * *
22  * - the GNU General Public License as published by the Free *
23  * Software Foundation; either version 2 of the License, or (at your *
24  * option) any later version. *
25  * *
26  * or both in parallel, as here. *
27  * *
28  * GNU Prolog is distributed in the hope that it will be useful, *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
31  * General Public License for more details. *
32  * *
33  * You should have received copies of the GNU General Public License and *
34  * the GNU Lesser General Public License along with this program. If *
35  * not, see http://www.gnu.org/licenses/. *
36  *-------------------------------------------------------------------------*/
37 
38 
39 #ifndef _MACHINE_H
40 #define _MACHINE_H
41 
42 #include "bool.h"
43 
44 
45 /*---------------------------------*
46  * Constants *
47  *---------------------------------*/
48 
49 /*---------------------------------*
50  * Type Definitions *
51  *---------------------------------*/
52 
53 /*---------------------------------*
54  * Global Variables *
55  *---------------------------------*/
56 
57 /*---------------------------------*
58  * Function Prototypes *
59  *---------------------------------*/
60 
61 void Pl_Init_Machine(void);
62 
63 char *Pl_M_Sys_Err_String(int ret_val);
64 
66 
68 
70 
71 void Pl_M_Randomize(void);
72 
73 void Pl_M_Set_Seed(int n);
74 
75 int Pl_M_Get_Seed(void);
76 
77 int Pl_M_Random_Integer(int n);
78 
79 double Pl_M_Random_Float(double n);
80 
81 
82 
83 char *Pl_M_Host_Name_From_Name(char *host_name);
84 
85 char *Pl_M_Host_Name_From_Adr(char *host_address);
86 
87 char *Pl_M_Get_Working_Dir(void);
88 
89 Bool Pl_M_Set_Working_Dir(char *path);
90 
91 char *Pl_M_Absolute_Path_Name(char *src);
92 
94 
95 char *Pl_M_Decompose_File_Name(char *path, Bool del_trail_slashes,
96  char **base, char **suffix);
97 
98 #if defined(_WIN32) && !defined(__CYGWIN__)
99 
100 int getpagesize(void);
101 
102 #endif
103 
104 void M_Check_Magic_Words(void); /* not compiled if not needed */
105 
106 
107 
108 
109 /*---------------------------------*
110  * Register Definitions *
111  *---------------------------------*/
112 
113 #if defined(M_sparc)
114 
115 # define M_USED_REGS {"g6", "g7", 0}
116 
117 #elif defined(M_mips)
118 
119 #define M_USED_REGS {"$16", "$17", "$18", "$19", "$20", \
120  "$21", "$22", "$23", 0}
121 
122 #elif defined(M_alpha)
123 
124 # define M_USED_REGS {"$9", "$10", "$11", "$12", "$13", "$14", 0}
125 
126 /* on M_ix86_darwin : %ebx is used by gcc for pic base */
127 #elif defined(M_ix86) && !defined(_MSC_VER) && !defined(M_ix86_darwin)
128 
129 #ifdef NO_USE_EBP
130 # define M_USED_REGS {"ebx", 0}
131 #else
132 # define M_USED_REGS {"ebx", "ebp", 0}
133 #endif
134 
135 #elif defined(M_powerpc)
136 
137 # define M_USED_REGS {"15", "20", 0}
138 
139 /* on M_x86_64_darwin Lion r12-r15 do not work (why ?) */
140 #elif defined(M_x86_64) && !defined(_MSC_VER) && !defined(M_x86_64_darwin)
141 
142 # define M_USED_REGS {"r12", "r13", "r14", "r15", 0}
143 
144 #else
145 
146 # define M_USED_REGS {0}
147 
148 #endif
149 
150 
151 
152 #if defined(M_ix86) // && !defined(_WIN32) // && !defined(NO_USE_REGS)
153 #define NO_MACHINE_REG_FOR_REG_BANK
154 #endif
155 
156 /* In any case M_x86_64_darwin needs a reg for pl_reg_bank (default is r12)
157  * else Ma2Asm produces code ending with the following error:
158  * '32-bit absolute addressing is not supported for x86-64'
159  */
160 #if defined(NO_USE_REGS) && !defined(NO_MACHINE_REG_FOR_REG_BANK) && \
161  defined(M_x86_64) && !defined(M_x86_64_darwin)
162 #define NO_MACHINE_REG_FOR_REG_BANK
163 #endif
164 
165 
166 
167 
168 /*---------------------------------*
169  * Stacks Management *
170  *---------------------------------*/
171 
172 #if WORD_SIZE == 32
173 
174 # define M_MMAP_HIGH_ADR1 0x0ffffff0
175 # define M_MMAP_HIGH_ADR2 0x3ffffff0
176 # define M_MMAP_HIGH_ADR3 0x7ffffff0
177 
178 #elif defined(M_alpha_osf) || defined(M_alpha_linux)
179 
180 # define M_MMAP_HIGH_ADR1 0x3f800000000ULL
181 
182 #elif defined(M_x86_64_linux) || defined(M_x86_64_solaris)
183 
184 # define M_MMAP_HIGH_ADR1 0x4000000000ULL
185 
186 #endif
187 
188 #if defined(M_sunos) || defined(M_solaris)
189 # define MMAP_NEEDS_FIXED
190 #endif
191 
192 
193 
194 /*---------------------------------*
195  * Malloc Management *
196  *---------------------------------*/
197 
198 #if defined(__OpenBSD__) || defined(M_bsd)
199 #define USE_DL_MALLOC
200 #endif
201 
202 
203 #endif
PlLong Pl_M_User_Time(void)
Definition: machine.c:245
Bool Pl_M_Is_Absolute_File_Name(char *path)
Definition: machine.c:774
void Pl_Init_Machine(void)
Definition: machine.c:168
char * Pl_M_Host_Name_From_Name(char *host_name)
Definition: machine.c:452
int getpagesize(void)
Definition: WIN32_SIGSEGV.c:8
char * Pl_M_Absolute_Path_Name(char *src)
Definition: machine.c:595
char * Pl_M_Decompose_File_Name(char *path, Bool del_trail_slashes, char **base, char **suffix)
Definition: machine.c:830
intptr_t PlLong
Definition: gprolog.h:88
double Pl_M_Random_Float(double n)
Definition: machine.c:438
static PlLong ret_val
Definition: ctrl_c.c:71
int Pl_M_Random_Integer(int n)
Definition: machine.c:424
void Pl_M_Randomize(void)
Definition: machine.c:368
PlLong Pl_M_Real_Time(void)
Definition: machine.c:329
char * Pl_M_Host_Name_From_Adr(char *host_address)
Definition: machine.c:500
void M_Check_Magic_Words(void)
void Pl_M_Set_Seed(int n)
Definition: machine.c:396
char * Pl_M_Get_Working_Dir(void)
Definition: machine.c:577
PlLong Pl_M_System_Time(void)
Definition: machine.c:287
int Pl_M_Get_Seed(void)
Definition: machine.c:410
int Bool
Definition: bool.h:65
char * Pl_M_Sys_Err_String(int ret_val)
Definition: machine.c:191
Bool Pl_M_Set_Working_Dir(char *path)
Definition: machine.c:562