pe_var.h (128229) | pe_var.h (132973) |
---|---|
1/* 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/sys/compat/ndis/pe_var.h 128229 2004-04-14 07:48:03Z wpaul $ | 32 * $FreeBSD: head/sys/compat/ndis/pe_var.h 132973 2004-08-01 20:04:31Z wpaul $ |
33 */ 34 35#ifndef _PE_VAR_H_ 36#define _PE_VAR_H_ 37 38/* 39 * Image Format 40 */ --- 372 unchanged lines hidden (view full) --- 413 * that the callback functions provided in the function table must 414 * be declared using __attribute__((__stdcall__)), otherwise the 415 * Windows code will likely screw up the %esp register and cause 416 * us to jump to an invalid address when it returns. 417 */ 418 419#ifdef __amd64__ 420#define __stdcall | 33 */ 34 35#ifndef _PE_VAR_H_ 36#define _PE_VAR_H_ 37 38/* 39 * Image Format 40 */ --- 372 unchanged lines hidden (view full) --- 413 * that the callback functions provided in the function table must 414 * be declared using __attribute__((__stdcall__)), otherwise the 415 * Windows code will likely screw up the %esp register and cause 416 * us to jump to an invalid address when it returns. 417 */ 418 419#ifdef __amd64__ 420#define __stdcall |
421#define __regcall 422#define __fastcall 423#define REGARGS1(decl1) decl1 424#define REGARGS2(decl1, decl2) decl1, decl2 425#define REGCALL1(arg1) arg1 426#define REGCALL2(arg1, arg2) arg1, arg2 |
|
421#else 422#define __stdcall __attribute__((__stdcall__)) | 427#else 428#define __stdcall __attribute__((__stdcall__)) |
429#define __regcall __attribute__((__regparm__(3))) 430#define __fastcall __stdcall __regcall 431#define REGARGS1(decl1) int dummy1, int dummy2, decl1 432#define REGARGS2(decl1, decl2) int dummy1, decl2, decl1 433#define REGCALL1(arg1) 0, 0, arg1 434#define REGCALL2(arg1, arg2) 0, arg2, arg1 |
|
423#endif 424 425 426/* 427 * This mess allows us to call a _fastcall style routine with our 428 * version of gcc, which lacks __attribute__((__fastcall__)). Only 429 * has meaning on x86; everywhere else, it's a no-op. 430 */ 431 432#ifdef __i386__ | 435#endif 436 437 438/* 439 * This mess allows us to call a _fastcall style routine with our 440 * version of gcc, which lacks __attribute__((__fastcall__)). Only 441 * has meaning on x86; everywhere else, it's a no-op. 442 */ 443 444#ifdef __i386__ |
433typedef __stdcall int (*fcall)(void); 434typedef __stdcall int (*fcall2)(int); | 445typedef __fastcall int (*fcall1)(REGARGS1(uint32_t)); 446typedef __fastcall int (*fcall2)(REGARGS2(uint32_t, uint32_t)); 447typedef __fastcall int (*fcall3)(REGARGS2(uint32_t, uint32_t), uint32_t); 448 |
435static __inline uint32_t | 449static __inline uint32_t |
436fastcall1(fcall f, uint32_t a) | 450fastcall1(fcall1 f, uint32_t a) |
437{ | 451{ |
438 __asm__ __volatile__ ("movl %0,%%ecx" : : "r" (a)); 439 return(f()); | 452 return(f(REGCALL1(a))); |
440} 441 442static __inline uint32_t | 453} 454 455static __inline uint32_t |
443fastcall2(fcall f, uint32_t a, uint32_t b) | 456fastcall2(fcall2 f, uint32_t a, uint32_t b) |
444{ | 457{ |
445 __asm__ __volatile__ ("movl %0,%%ecx" : : "r" (a)); 446 __asm__ __volatile__ ("movl %0,%%edx" : : "r" (b)); 447 return(f()); | 458 return(f(REGCALL2(a, b))); |
448} 449 450static __inline uint32_t | 459} 460 461static __inline uint32_t |
451fastcall3(fcall2 f, uint32_t a, uint32_t b, uint32_t c) | 462fastcall3(fcall3 f, uint32_t a, uint32_t b, uint32_t c) |
452{ | 463{ |
453 __asm__ __volatile__ ("movl %0,%%ecx" : : "r" (a)); 454 __asm__ __volatile__ ("movl %0,%%edx" : : "r" (b)); 455 return(f(c)); | 464 return(f(REGCALL2(a, b), c)); |
456} 457 458#define FASTCALL1(f, a) \ | 465} 466 467#define FASTCALL1(f, a) \ |
459 fastcall1((fcall)(f), (uint32_t)(a)) | 468 fastcall1((fcall1)(f), (uint32_t)(a)) |
460#define FASTCALL2(f, a, b) \ | 469#define FASTCALL2(f, a, b) \ |
461 fastcall2((fcall)(f), (uint32_t)(a), (uint32_t)(b)) | 470 fastcall2((fcall2)(f), (uint32_t)(a), (uint32_t)(b)) |
462#define FASTCALL3(f, a, b, c) \ | 471#define FASTCALL3(f, a, b, c) \ |
463 fastcall3((fcall2)(f), (uint32_t)(a), (uint32_t)(b), (uint32_t)(c)) | 472 fastcall3((fcall3)(f), (uint32_t)(a), (uint32_t)(b), (uint32_t)(c)) |
464#else 465#define FASTCALL1(f, a) (f)((a)) 466#define FASTCALL2(f, a, b) (f)((a), (b)) 467#define FASTCALL3(f, a, b, c) (f)((a), (b), (c)) 468#endif /* __i386__ */ 469 470__BEGIN_DECLS 471extern int pe_get_dos_header(vm_offset_t, image_dos_header *); --- 17 unchanged lines hidden --- | 473#else 474#define FASTCALL1(f, a) (f)((a)) 475#define FASTCALL2(f, a, b) (f)((a), (b)) 476#define FASTCALL3(f, a, b, c) (f)((a), (b), (c)) 477#endif /* __i386__ */ 478 479__BEGIN_DECLS 480extern int pe_get_dos_header(vm_offset_t, image_dos_header *); --- 17 unchanged lines hidden --- |