Qore Programming Language
0.8.11
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
include
qore
macros-i386.h
1
/* -*- mode: c++; indent-tabs-mode: nil -*- */
2
/*
3
Qore Programming Language
4
5
Copyright 2003 - 2013 David Nichols
6
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Lesser General Public
9
License as published by the Free Software Foundation; either
10
version 2.1 of the License, or (at your option) any later version.
11
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Lesser General Public License for more details.
16
17
You should have received a copy of the GNU Lesser General Public
18
License along with this library; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
#ifndef _QORE_MACHINE_MACROS_H
23
#define _QORE_MACHINE_MACROS_H
24
25
#define STACK_DIRECTION_DOWN 1
26
27
#ifdef __GNUC__
28
#define HAVE_ATOMIC_MACROS
29
30
// returns 1 when counter reaches zero, 0 if not
31
static
inline
int
atomic_dec(
volatile
int
*a) {
32
unsigned
char
rc;
33
34
__asm(
35
"lock; decl %0; sete %1"
36
:
"=m"
(*a),
"=qm"
(rc)
37
:
"m"
(*a) :
"memory"
38
);
39
return
rc != 0;
40
}
41
42
static
inline
void
atomic_inc(
volatile
int
*a) {
43
__asm(
44
"lock; incl %0"
45
:
"=m"
(*a)
46
);
47
}
48
49
#define HAVE_CHECK_STACK_POS
50
51
static
inline
size_t
get_stack_pos() {
52
size_t
addr;
53
__asm(
"movl %%esp, %0"
:
"=g"
(addr) );
54
return
addr;
55
}
56
57
#endif // __GNUC__
58
59
#ifdef __SUNPRO_CC
60
#define HAVE_ATOMIC_MACROS
61
62
// these routines are implemented in assembler
63
extern
"C"
int
atomic_dec(
volatile
int
*a);
64
extern
"C"
void
atomic_inc(
volatile
int
*a);
65
66
#define HAVE_CHECK_STACK_POS
67
extern
"C"
size_t
get_stack_pos();
68
#endif // #ifdef __SUNPRO_CC
69
70
#endif // #ifndef _QORE_MACHINE_MACROS_H
71