Skip to content

Commit 3953937

Browse files
committed
add support for MacOS.
issue #11
1 parent 91c6770 commit 3953937

File tree

3 files changed

+48
-26
lines changed

3 files changed

+48
-26
lines changed

aco.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,11 @@ extern void aco_runtime_test(void);
138138

139139
extern void aco_thread_init(aco_cofuncp_t last_word_co_fp);
140140

141-
// TODO: plan to use regparm(0) (fastcall) in Sys V ABI intel386
142-
// to accelerate acosw and copystack(-8bytes), and PR is welcome :)
143-
extern void* acosw(aco_t* from_co, aco_t* to_co); // asm
141+
extern void* acosw(aco_t* from_co, aco_t* to_co) asm("acosw"); // asm
144142

145-
extern void aco_save_fpucw_mxcsr(void* p); // asm
143+
extern void aco_save_fpucw_mxcsr(void* p) asm("aco_save_fpucw_mxcsr"); // asm
146144

147-
extern void aco_funcp_protector_asm(void); // asm
145+
extern void aco_funcp_protector_asm(void) asm("aco_funcp_protector_asm"); // asm
148146

149147
extern void aco_funcp_protector(void);
150148

acosw.S

+42-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
.text
22
.globl acosw
3+
#if defined(__APPLE__)
4+
#else
35
.type acosw, @function
6+
#endif
47
.intel_syntax noprefix
58
acosw:
69
/*
@@ -120,7 +123,10 @@ acosw:
120123
#endif
121124

122125
.globl aco_save_fpucw_mxcsr
126+
#if defined(__APPLE__)
127+
#else
123128
.type aco_save_fpucw_mxcsr, @function
129+
#endif
124130
.intel_syntax noprefix
125131
aco_save_fpucw_mxcsr:
126132
#ifdef __i386__
@@ -136,33 +142,51 @@ aco_save_fpucw_mxcsr:
136142
#error "platform not support"
137143
#endif
138144

145+
#if defined(__APPLE__)
146+
.globl _abort
147+
.globl _aco_funcp_protector
148+
#else
139149
.globl abort
140150
.globl aco_funcp_protector
151+
#endif
141152

142153
.globl aco_funcp_protector_asm
154+
#if defined(__APPLE__)
155+
#else
143156
.type aco_funcp_protector_asm, @function
157+
#endif
144158
.intel_syntax noprefix
145159
aco_funcp_protector_asm:
146160
#ifdef __i386__
147-
and esp,0xfffffff0
148-
#if defined(__pic__) || defined(__PIC__)
149-
call aco_funcp_protector@PLT
150-
call abort@PLT
151-
#else
152-
call aco_funcp_protector
153-
call abort
154-
#endif
155-
ret
161+
and esp,0xfffffff0
162+
#if defined(__APPLE__)
163+
call _aco_funcp_protector
164+
call _abort
165+
#else
166+
#if defined(__pic__) || defined(__PIC__)
167+
call aco_funcp_protector@PLT
168+
call abort@PLT
169+
#else
170+
call aco_funcp_protector
171+
call abort
172+
#endif
173+
#endif
174+
ret
156175
#elif __x86_64__
157-
and rsp,0xfffffffffffffff0
158-
#if defined(__pic__) || defined(__PIC__)
159-
call aco_funcp_protector@PLT
160-
call abort@PLT
161-
#else
162-
call aco_funcp_protector
163-
call abort
164-
#endif
165-
ret
176+
and rsp,0xfffffffffffffff0
177+
#if defined(__APPLE__)
178+
call _aco_funcp_protector
179+
call _abort
180+
#else
181+
#if defined(__pic__) || defined(__PIC__)
182+
call aco_funcp_protector@PLT
183+
call abort@PLT
184+
#else
185+
call aco_funcp_protector
186+
call abort
187+
#endif
188+
#endif
189+
ret
166190
#else
167191
#error "platform not support"
168192
#endif

test.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
ulimit -c unlimited
17+
#ulimit -c unlimited
1818

1919
gl_trap_str=""
2020

@@ -107,8 +107,8 @@ function test_f(){
107107
declare errc
108108
declare test_ct
109109
declare infile
110-
test_ct=`file * | grep -P "ELF.*executable" | grep -Po '^[^:]+' | wc -l`
111-
file * | grep -P "ELF.*executable" | grep -Po '^[^:]+' | while read infile
110+
test_ct=`file * | grep -P "\bexecutable\b" | grep -Po '^[^:]+' | wc -l`
111+
file * | grep -P "\bexecutable\b" | grep -Po '^[^:]+' | while read infile
112112
do
113113
test_f_is_exclude_app "$infile"
114114
if [ "0" -eq "$?" ]

0 commit comments

Comments
 (0)