/
platform_interface.h
157 lines (121 loc) · 3.28 KB
/
platform_interface.h
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Copyright (C) 2003-2010, Parrot Foundation.
*/
#ifndef PARROT_PLATFORM_INTERFACE_H_GUARD
#define PARROT_PLATFORM_INTERFACE_H_GUARD
/*
** platform_interface.h
*/
#include "parrot/config.h"
#include "parrot/interpreter.h"
/*
** I/O:
*/
/*
** Math:
*/
extern int Parrot_signbit(double x);
#if NUMVAL_SIZE == 12
int Parrot_signbit_l(long double x);
#endif
/*
** Memory:
*/
void *Parrot_memalign(size_t align, size_t size);
void *Parrot_memalign_if_possible(size_t align, size_t size);
void Parrot_free_memalign(void *);
#if !defined(PARROT_HAS_SOME_MEMALIGN)
# define Parrot_memalign_if_possible(a, s) malloc(s)
#else
# define Parrot_memalign_if_possible(a, s) Parrot_memalign((a), (s))
#endif
#ifdef PARROT_HAS_EXEC_PROTECT
void *mem_alloc_executable(size_t);
void mem_free_executable(void *, size_t);
void *mem_realloc_executable(void *, size_t, size_t);
#else
# define mem_alloc_executable mem_internal_allocate
# define mem_free_executable(a, b) mem_internal_free(a)
# define mem_realloc_executable(a, b, c) mem_internal_realloc((a), (c))
#endif
/*
** Process ID
*/
UINTVAL Parrot_getpid(void);
/*
** Time
*/
void Parrot_sleep(unsigned int seconds);
void Parrot_usleep(unsigned int microseconds);
INTVAL Parrot_intval_time(void);
FLOATVAL Parrot_floatval_time(void);
PARROT_EXPORT
struct tm * Parrot_gmtime_r(const time_t *, struct tm *);
PARROT_EXPORT
struct tm * Parrot_localtime_r(const time_t *, struct tm *);
PARROT_EXPORT
char* Parrot_asctime_r(const struct tm*, char *);
/*
* Env
*/
void Parrot_setenv(PARROT_INTERP, STRING *name, STRING *value);
void Parrot_unsetenv(PARROT_INTERP, STRING *name);
char * Parrot_getenv(PARROT_INTERP, STRING *name);
/*
** Dynamic Loading:
*/
/*
* The second argument to Parrot_dlopen below provides portable access to
* non-default behavior of dynamic linkers.
*
* All flags will be ignored on platforms for which they are inapplicable.
*/
/* &gen_from_enum(dlopenflags.pasm) */
typedef enum Parrot_dlopen_enum {
/*
* Activates RTLD_GLOBAL on *NIX systems, making symbols from the newly
* loaded library visible to other libraries; this is usually needed if
* it will load libraries itself.
*/
Parrot_dlopen_global_FLAG = 0x01
} Parrot_dlopen_flags;
/* &end_gen */
void *Parrot_dlopen(const char *filename, Parrot_dlopen_flags flags);
const char *Parrot_dlerror(void);
void *Parrot_dlsym(void *handle, const char *symbol);
int Parrot_dlclose(void *handle);
/*
* signal handling
*/
#ifndef PARROT_HAS_HEADER_SIGNAL
# define Parrot_set_sighandler(s, h)
#endif
/*
* system timer
*/
#ifdef PARROT_HAS_SOME_SYS_TIMER
void * new_sys_timer_ms(void);
void start_sys_timer_ms(void *handle, int ms);
void stop_sys_timer_ms(void *handle);
int get_sys_timer_ms(void *handle);
#else
# define new_sys_timer_ms() NULL
# define start_sys_timer_ms(h, m)
# define stop_sys_timer_ms(h)
# define get_sys_timer_ms(h) 0
#endif
/*
* high-resolution timer support
*/
UHUGEINTVAL Parrot_hires_get_time(void);
UINTVAL Parrot_hires_get_tick_duration(void);
struct parrot_string_t;
INTVAL Parrot_Run_OS_Command(Interp*, struct parrot_string_t *);
INTVAL Parrot_Run_OS_Command_Argv(Interp*, struct PMC *);
#endif /* PARROT_PLATFORM_INTERFACE_H_GUARD */
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4:
*/