| OLD | NEW |
| 1 /* Copyright (c) 2005-2011, Google Inc. | 1 /* Copyright (c) 2005-2011, Google Inc. |
| 2 * All rights reserved. | 2 * All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 } \ | 1417 } \ |
| 1418 return (type) (res); \ | 1418 return (type) (res); \ |
| 1419 } while (0) | 1419 } while (0) |
| 1420 #elif defined(__mips__) | 1420 #elif defined(__mips__) |
| 1421 /* On MIPS, failing system calls return -1, and set errno in a | 1421 /* On MIPS, failing system calls return -1, and set errno in a |
| 1422 * separate CPU register. | 1422 * separate CPU register. |
| 1423 */ | 1423 */ |
| 1424 #define LSS_RETURN(type, res, err) \ | 1424 #define LSS_RETURN(type, res, err) \ |
| 1425 do { \ | 1425 do { \ |
| 1426 if (err) { \ | 1426 if (err) { \ |
| 1427 LSS_ERRNO = (res); \ | 1427 unsigned long __errnovalue = (res); \ |
| 1428 LSS_ERRNO = __errnovalue; \ |
| 1428 res = -1; \ | 1429 res = -1; \ |
| 1429 } \ | 1430 } \ |
| 1430 return (type) (res); \ | 1431 return (type) (res); \ |
| 1431 } while (0) | 1432 } while (0) |
| 1432 #elif defined(__PPC__) | 1433 #elif defined(__PPC__) |
| 1433 /* On PPC, failing system calls return -1, and set errno in a | 1434 /* On PPC, failing system calls return -1, and set errno in a |
| 1434 * separate CPU register. See linux/unistd.h. | 1435 * separate CPU register. See linux/unistd.h. |
| 1435 */ | 1436 */ |
| 1436 #define LSS_RETURN(type, res, err) \ | 1437 #define LSS_RETURN(type, res, err) \ |
| 1437 do { \ | 1438 do { \ |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2206 LSS_RETURN(int, __res); | 2207 LSS_RETURN(int, __res); |
| 2207 } | 2208 } |
| 2208 #elif defined(__mips__) | 2209 #elif defined(__mips__) |
| 2209 #undef LSS_REG | 2210 #undef LSS_REG |
| 2210 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ | 2211 #define LSS_REG(r,a) register unsigned long __r##r __asm__("$"#r) = \ |
| 2211 (unsigned long)(a) | 2212 (unsigned long)(a) |
| 2212 #undef LSS_BODY | 2213 #undef LSS_BODY |
| 2213 #define LSS_BODY(type,name,r7,...) \ | 2214 #define LSS_BODY(type,name,r7,...) \ |
| 2214 register unsigned long __v0 __asm__("$2") = __NR_##name; \ | 2215 register unsigned long __v0 __asm__("$2") = __NR_##name; \ |
| 2215 __asm__ __volatile__ ("syscall\n" \ | 2216 __asm__ __volatile__ ("syscall\n" \ |
| 2216 : "=&r"(__v0), r7 (__r7) \ | 2217 : "+r"(__v0), r7 (__r7) \ |
| 2217 : "0"(__v0), ##__VA_ARGS__ \ | 2218 : "0"(__v0), ##__VA_ARGS__ \ |
| 2218 : "$8", "$9", "$10", "$11", "$12", \ | 2219 : "$8", "$9", "$10", "$11", "$12", \ |
| 2219 "$13", "$14", "$15", "$24", "memory"); \ | 2220 "$13", "$14", "$15", "$24", "$25", \ |
| 2221 "memory"); \ |
| 2220 LSS_RETURN(type, __v0, __r7) | 2222 LSS_RETURN(type, __v0, __r7) |
| 2221 #undef _syscall0 | 2223 #undef _syscall0 |
| 2222 #define _syscall0(type, name) \ | 2224 #define _syscall0(type, name) \ |
| 2223 type LSS_NAME(name)() { \ | 2225 type LSS_NAME(name)() { \ |
| 2224 register unsigned long __r7 __asm__("$7"); \ | 2226 register unsigned long __r7 __asm__("$7"); \ |
| 2225 LSS_BODY(type, name, "=r"); \ | 2227 LSS_BODY(type, name, "=r"); \ |
| 2226 } | 2228 } |
| 2227 #undef _syscall1 | 2229 #undef _syscall1 |
| 2228 #define _syscall1(type, name, type1, arg1) \ | 2230 #define _syscall1(type, name, type1, arg1) \ |
| 2229 type LSS_NAME(name)(type1 arg1) { \ | 2231 type LSS_NAME(name)(type1 arg1) { \ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2255 #if _MIPS_SIM == _MIPS_SIM_ABI32 | 2257 #if _MIPS_SIM == _MIPS_SIM_ABI32 |
| 2256 /* The old 32bit MIPS system call API passes the fifth and sixth argument | 2258 /* The old 32bit MIPS system call API passes the fifth and sixth argument |
| 2257 * on the stack, whereas the new APIs use registers "r8" and "r9". | 2259 * on the stack, whereas the new APIs use registers "r8" and "r9". |
| 2258 */ | 2260 */ |
| 2259 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 2261 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 2260 type5,arg5) \ | 2262 type5,arg5) \ |
| 2261 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 2263 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 2262 type5 arg5) { \ | 2264 type5 arg5) { \ |
| 2263 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ | 2265 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ |
| 2264 LSS_REG(7, arg4); \ | 2266 LSS_REG(7, arg4); \ |
| 2265 register unsigned long __v0 __asm__("$2"); \ | 2267 register unsigned long __v0 __asm__("$2") = __NR_##name; \ |
| 2266 __asm__ __volatile__ (".set noreorder\n" \ | 2268 __asm__ __volatile__ (".set noreorder\n" \ |
| 2267 "lw $2, %6\n" \ | |
| 2268 "subu $29, 32\n" \ | 2269 "subu $29, 32\n" \ |
| 2269 "sw $2, 16($29)\n" \ | 2270 "sw %5, 16($29)\n" \ |
| 2270 "li $2, %2\n" \ | |
| 2271 "syscall\n" \ | 2271 "syscall\n" \ |
| 2272 "addiu $29, 32\n" \ | 2272 "addiu $29, 32\n" \ |
| 2273 ".set reorder\n" \ | 2273 ".set reorder\n" \ |
| 2274 : "=&r"(__v0), "+r" (__r7) \ | 2274 : "+r"(__v0), "+r" (__r7) \ |
| 2275 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ | 2275 : "r"(__r4), "r"(__r5), \ |
| 2276 "r"(__r6), "m" ((unsigned long)arg5) \ | 2276 "r"(__r6), "r" ((unsigned long)arg5) \ |
| 2277 : "$8", "$9", "$10", "$11", "$12", \ | 2277 : "$8", "$9", "$10", "$11", "$12", \ |
| 2278 "$13", "$14", "$15", "$24", "memory"); \ | 2278 "$13", "$14", "$15", "$24", "$25", \ |
| 2279 "memory"); \ |
| 2279 LSS_RETURN(type, __v0, __r7); \ | 2280 LSS_RETURN(type, __v0, __r7); \ |
| 2280 } | 2281 } |
| 2281 #else | 2282 #else |
| 2282 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 2283 #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 2283 type5,arg5) \ | 2284 type5,arg5) \ |
| 2284 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 2285 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 2285 type5 arg5) { \ | 2286 type5 arg5) { \ |
| 2286 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ | 2287 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ |
| 2287 LSS_REG(7, arg4); LSS_REG(8, arg5); \ | 2288 LSS_REG(7, arg4); LSS_REG(8, arg5); \ |
| 2288 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ | 2289 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ |
| 2289 "r"(__r8)); \ | 2290 "r"(__r8)); \ |
| 2290 } | 2291 } |
| 2291 #endif | 2292 #endif |
| 2292 #undef _syscall6 | 2293 #undef _syscall6 |
| 2293 #if _MIPS_SIM == _MIPS_SIM_ABI32 | 2294 #if _MIPS_SIM == _MIPS_SIM_ABI32 |
| 2294 /* The old 32bit MIPS system call API passes the fifth and sixth argument | 2295 /* The old 32bit MIPS system call API passes the fifth and sixth argument |
| 2295 * on the stack, whereas the new APIs use registers "r8" and "r9". | 2296 * on the stack, whereas the new APIs use registers "r8" and "r9". |
| 2296 */ | 2297 */ |
| 2297 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 2298 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 2298 type5,arg5,type6,arg6) \ | 2299 type5,arg5,type6,arg6) \ |
| 2299 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 2300 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 2300 type5 arg5, type6 arg6) { \ | 2301 type5 arg5, type6 arg6) { \ |
| 2301 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ | 2302 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ |
| 2302 LSS_REG(7, arg4); \ | 2303 LSS_REG(7, arg4); \ |
| 2303 register unsigned long __v0 __asm__("$2"); \ | 2304 register unsigned long __v0 __asm__("$2") = __NR_##name; \ |
| 2304 __asm__ __volatile__ (".set noreorder\n" \ | 2305 __asm__ __volatile__ (".set noreorder\n" \ |
| 2305 "lw $2, %6\n" \ | |
| 2306 "lw $8, %7\n" \ | |
| 2307 "subu $29, 32\n" \ | 2306 "subu $29, 32\n" \ |
| 2308 "sw $2, 16($29)\n" \ | 2307 "sw %5, 16($29)\n" \ |
| 2309 "sw $8, 20($29)\n" \ | 2308 "sw %6, 20($29)\n" \ |
| 2310 "li $2, %2\n" \ | |
| 2311 "syscall\n" \ | 2309 "syscall\n" \ |
| 2312 "addiu $29, 32\n" \ | 2310 "addiu $29, 32\n" \ |
| 2313 ".set reorder\n" \ | 2311 ".set reorder\n" \ |
| 2314 : "=&r"(__v0), "+r" (__r7) \ | 2312 : "+r"(__v0), "+r" (__r7) \ |
| 2315 : "i" (__NR_##name), "r"(__r4), "r"(__r5), \ | 2313 : "r"(__r4), "r"(__r5), \ |
| 2316 "r"(__r6), "r" ((unsigned long)arg5), \ | 2314 "r"(__r6), "r" ((unsigned long)arg5), \ |
| 2317 "r" ((unsigned long)arg6) \ | 2315 "r" ((unsigned long)arg6) \ |
| 2318 : "$8", "$9", "$10", "$11", "$12", \ | 2316 : "$8", "$9", "$10", "$11", "$12", \ |
| 2319 "$13", "$14", "$15", "$24", "memory"); \ | 2317 "$13", "$14", "$15", "$24", "$25", \ |
| 2318 "memory"); \ |
| 2320 LSS_RETURN(type, __v0, __r7); \ | 2319 LSS_RETURN(type, __v0, __r7); \ |
| 2321 } | 2320 } |
| 2322 #else | 2321 #else |
| 2323 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ | 2322 #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \ |
| 2324 type5,arg5,type6,arg6) \ | 2323 type5,arg5,type6,arg6) \ |
| 2325 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ | 2324 type LSS_NAME(name)(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \ |
| 2326 type5 arg5,type6 arg6) { \ | 2325 type5 arg5,type6 arg6) { \ |
| 2327 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ | 2326 LSS_REG(4, arg1); LSS_REG(5, arg2); LSS_REG(6, arg3); \ |
| 2328 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ | 2327 LSS_REG(7, arg4); LSS_REG(8, arg5); LSS_REG(9, arg6); \ |
| 2329 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ | 2328 LSS_BODY(type, name, "+r", "r"(__r4), "r"(__r5), "r"(__r6), \ |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2409 "syscall\n" | 2408 "syscall\n" |
| 2410 | 2409 |
| 2411 "1:\n" | 2410 "1:\n" |
| 2412 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 | 2411 #if _MIPS_SIM == _MIPS_SIM_ABI32 && _MIPS_SZPTR == 32 |
| 2413 "addu $29, 24\n" | 2412 "addu $29, 24\n" |
| 2414 #elif _MIPS_SIM == _MIPS_SIM_NABI32 | 2413 #elif _MIPS_SIM == _MIPS_SIM_NABI32 |
| 2415 "add $29, 16\n" | 2414 "add $29, 16\n" |
| 2416 #else | 2415 #else |
| 2417 "daddu $29,16\n" | 2416 "daddu $29,16\n" |
| 2418 #endif | 2417 #endif |
| 2419 : "=&r" (__v0), "=r" (__r7) | 2418 : "=&r" (__v0), "+r" (__r7) |
| 2420 : "i"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), | 2419 : "i"(-EINVAL), "i"(__NR_clone), "i"(__NR_exit), |
| 2421 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), | 2420 "r"(fn), "r"(__stack), "r"(__flags), "r"(arg), |
| 2422 "r"(__ptid), "r"(__r7), "r"(__ctid) | 2421 "r"(__ptid), "r"(__r7), "r"(__ctid) |
| 2423 : "$9", "$10", "$11", "$12", "$13", "$14", "$15", | 2422 : "$9", "$10", "$11", "$12", "$13", "$14", "$15", |
| 2424 "$24", "memory"); | 2423 "$24", "$25", "memory"); |
| 2425 } | 2424 } |
| 2426 LSS_RETURN(int, __v0, __r7); | 2425 LSS_RETURN(int, __v0, __r7); |
| 2427 } | 2426 } |
| 2428 #elif defined (__PPC__) | 2427 #elif defined (__PPC__) |
| 2429 #undef LSS_LOADARGS_0 | 2428 #undef LSS_LOADARGS_0 |
| 2430 #define LSS_LOADARGS_0(name, dummy...) \ | 2429 #define LSS_LOADARGS_0(name, dummy...) \ |
| 2431 __sc_0 = __NR_##name | 2430 __sc_0 = __NR_##name |
| 2432 #undef LSS_LOADARGS_1 | 2431 #undef LSS_LOADARGS_1 |
| 2433 #define LSS_LOADARGS_1(name, arg1) \ | 2432 #define LSS_LOADARGS_1(name, arg1) \ |
| 2434 LSS_LOADARGS_0(name); \ | 2433 LSS_LOADARGS_0(name); \ |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3332 #endif | 3331 #endif |
| 3333 #if defined(__mips__) | 3332 #if defined(__mips__) |
| 3334 /* sys_pipe() on MIPS has non-standard calling conventions, as it returns | 3333 /* sys_pipe() on MIPS has non-standard calling conventions, as it returns |
| 3335 * both file handles through CPU registers. | 3334 * both file handles through CPU registers. |
| 3336 */ | 3335 */ |
| 3337 LSS_INLINE int LSS_NAME(pipe)(int *p) { | 3336 LSS_INLINE int LSS_NAME(pipe)(int *p) { |
| 3338 register unsigned long __v0 __asm__("$2") = __NR_pipe; | 3337 register unsigned long __v0 __asm__("$2") = __NR_pipe; |
| 3339 register unsigned long __v1 __asm__("$3"); | 3338 register unsigned long __v1 __asm__("$3"); |
| 3340 register unsigned long __r7 __asm__("$7"); | 3339 register unsigned long __r7 __asm__("$7"); |
| 3341 __asm__ __volatile__ ("syscall\n" | 3340 __asm__ __volatile__ ("syscall\n" |
| 3342 : "=&r"(__v0), "=&r"(__v1), "+r" (__r7) | 3341 : "+r"(__v0), "=r"(__v1), "=r" (__r7) |
| 3343 : "0"(__v0) | 3342 : "0"(__v0) |
| 3344 : "$8", "$9", "$10", "$11", "$12", | 3343 : "$8", "$9", "$10", "$11", "$12", |
| 3345 "$13", "$14", "$15", "$24", "memory"); | 3344 "$13", "$14", "$15", "$24", "$25", "memory"); |
| 3346 if (__r7) { | 3345 if (__r7) { |
| 3347 LSS_ERRNO = __v0; | 3346 unsigned long __errnovalue = __v0; |
| 3347 LSS_ERRNO = __errnovalue; |
| 3348 return -1; | 3348 return -1; |
| 3349 } else { | 3349 } else { |
| 3350 p[0] = __v0; | 3350 p[0] = __v0; |
| 3351 p[1] = __v1; | 3351 p[1] = __v1; |
| 3352 return 0; | 3352 return 0; |
| 3353 } | 3353 } |
| 3354 } | 3354 } |
| 3355 #else | 3355 #else |
| 3356 LSS_INLINE _syscall1(int, pipe, int *, p) | 3356 LSS_INLINE _syscall1(int, pipe, int *, p) |
| 3357 #endif | 3357 #endif |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3513 } | 3513 } |
| 3514 #endif | 3514 #endif |
| 3515 #endif | 3515 #endif |
| 3516 | 3516 |
| 3517 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) | 3517 #if defined(__cplusplus) && !defined(SYS_CPLUSPLUS) |
| 3518 } | 3518 } |
| 3519 #endif | 3519 #endif |
| 3520 | 3520 |
| 3521 #endif | 3521 #endif |
| 3522 #endif | 3522 #endif |
| OLD | NEW |