📄 funcargs.c
字号:
#elsecall6g (uc, us, ui, ul)unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{ uc = uc; call6h (us, ui, ul);}#ifdef PROTOTYPESvoid call6f (double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsecall6f (d, uc, us, ui, ul)double d;unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{ d = d; call6g (uc, us, ui, ul);}#ifdef PROTOTYPESvoid call6e (float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsecall6e (f, d, uc, us, ui, ul)float f; double d;unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{ f = f; call6f (d, uc, us, ui, ul);}#ifdef PROTOTYPESvoid call6d (long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsecall6d (l, f, d, uc, us, ui, ul)long l; float f; double d;unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{ l = l; call6e (f, d, uc, us, ui, ul);}#ifdef PROTOTYPESvoid call6c (int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsecall6c (i, l, f, d, uc, us, ui, ul)int i; long l; float f; double d;unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{ i = i; call6d (l, f, d, uc, us, ui, ul);}#ifdef PROTOTYPESvoid call6b (short s, int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsecall6b (s, i, l, f, d, uc, us, ui, ul)short s; int i; long l; float f; double d;unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{ s = s; call6c (i, l, f, d, uc, us, ui, ul);}#ifdef PROTOTYPESvoid call6a (char c, short s, int i, long l, float f, double d, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsecall6a (c, s, i, l, f, d, uc, us, ui, ul)char c; short s; int i; long l; float f; double d;unsigned char uc; unsigned short us; unsigned int ui; unsigned long ul;#endif{ c = c; call6b (s, i, l, f, d, uc, us, ui, ul);}/* Test shuffling of args, round robin */#ifdef PROTOTYPESvoid call7k (char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui)#elsecall7k (c, i, s, l, f, uc, d, us, ul, ui)char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui;#endif{ c = 'a'; i = 7; s = 8; l = 7; f = 0.3; uc = 44; d = 0.44; us = 77; ul = 43; ui = 33;}#ifdef PROTOTYPESvoid call7j (unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul)#elsecall7j (ui, c, i, s, l, f, uc, d, us, ul)unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul;#endif{ call7k (c, i, s, l, f, uc, d, us, ul, ui);}#ifdef PROTOTYPESvoid call7i (unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us)#elsecall7i (ul, ui, c, i, s, l, f, uc, d, us)unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us;#endif{ call7j (ui, c, i, s, l, f, uc, d, us, ul);}#ifdef PROTOTYPESvoid call7h (unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc, double d)#elsecall7h (us, ul, ui, c, i, s, l, f, uc, d)unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc; double d;#endif{ call7i (ul, ui, c, i, s, l, f, uc, d, us);}#ifdef PROTOTYPESvoid call7g (double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f, unsigned char uc)#elsecall7g (d, us, ul, ui, c, i, s, l, f, uc)double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f; unsigned char uc;#endif{ call7h (us, ul, ui, c, i, s, l, f, uc, d);}#ifdef PROTOTYPESvoid call7f (unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l, float f)#elsecall7f (uc, d, us, ul, ui, c, i, s, l, f)unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l; float f;#endif{ call7g (d, us, ul, ui, c, i, s, l, f, uc);}#ifdef PROTOTYPESvoid call7e (float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s, long l)#elsecall7e (f, uc, d, us, ul, ui, c, i, s, l)float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s; long l;#endif{ call7f (uc, d, us, ul, ui, c, i, s, l, f);}#ifdef PROTOTYPESvoid call7d (long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i, short s)#elsecall7d (l, f, uc, d, us, ul, ui, c, i, s)long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i; short s;#endif{ call7e (f, uc, d, us, ul, ui, c, i, s, l);}#ifdef PROTOTYPESvoid call7c (short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c, int i)#elsecall7c (s, l, f, uc, d, us, ul, ui, c, i)short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c; int i;#endif{ call7d (l, f, uc, d, us, ul, ui, c, i, s);}#ifdef PROTOTYPESvoid call7b (int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui, char c)#elsecall7b (i, s, l, f, uc, d, us, ul, ui, c)int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui; char c;#endif{ call7c (s, l, f, uc, d, us, ul, ui, c, i);}#ifdef PROTOTYPESvoid call7a (char c, int i, short s, long l, float f, unsigned char uc, double d, unsigned short us, unsigned long ul, unsigned int ui)#elsecall7a (c, i, s, l, f, uc, d, us, ul, ui)char c; int i; short s; long l; float f; unsigned char uc; double d; unsigned short us; unsigned long ul; unsigned int ui;#endif{ call7b (i, s, l, f, uc, d, us, ul, ui, c);}/* Test printing of structures passed as arguments to recursive functions. */typedef struct s{ short s; int i; long l;} SVAL; void hitbottom (){}#ifdef PROTOTYPESvoid recurse (SVAL a, int depth)#elsevoid recurse (a, depth)SVAL a;int depth;#endif{ a.s = a.i = a.l = --depth; if (depth == 0) hitbottom (); else recurse (a, depth);}void test_struct_args (){ SVAL s; s.s = 5; s.i = 5; s.l = 5; recurse (s, 5);}/* On various machines (pa, 29k, and rs/6000, at least), a function which calls alloca may do things differently with respect to frames. So give it a try. */#ifdef PROTOTYPESvoid localvars_after_alloca (char c, short s, int i, long l)#elsevoidlocalvars_after_alloca (c, s, i, l) char c; short s; int i; long l;#endif{#ifdef HAVE_STACK_ALLOCA /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't test what we are looking for, so if we don't have an alloca which allocates on the stack, just don't bother to call alloca at all. */ char *z = alloca (s + 50);#endif c = 'a'; s = 5; i = 6; l = 7;}#ifdef PROTOTYPESvoid call_after_alloca_subr (char c, short s, int i, long l, unsigned char uc, unsigned short us, unsigned int ui, unsigned long ul)#elsevoidcall_after_alloca_subr (c, s, i, l, uc, us, ui, ul)char c; int i; short s; long l; unsigned char uc; unsigned short us; unsigned long ul; unsigned int ui;#endif{ c = 'a'; i = 7; s = 8; l = 7; uc = 44; us = 77; ul = 43; ui = 33;}#ifdef PROTOTYPESvoid call_after_alloca (char c, short s, int i, long l)#elsevoidcall_after_alloca (c, s, i, l) char c; short s; int i; long l;#endif{#ifdef HAVE_STACK_ALLOCA /* No need to use the alloca.c alloca-on-top-of-malloc; it doesn't test what we are looking for, so if we don't have an alloca which allocates on the stack, just don't bother to call alloca at all. */ char *z = alloca (s + 50);#endif call_after_alloca_subr (c, s, i, l, 'b', 11, 12, (unsigned long)13);}/* The point behind this test is the PA will call this indirectly through dyncall. Unlike the indirect calls to call0a, this test will require a trampoline between dyncall and this function on the call path, then another trampoline on between this function and main on the return path. */#ifdef PROTOTYPESdouble call_with_trampolines (double d1)#elsedoublecall_with_trampolines (d1)double d1;#endif{ return d1;} /* End of call_with_trampolines, this comment is needed by funcargs.exp *//* Dummy functions which the testsuite can use to run to, etc. */voidmarker_indirect_call () {}voidmarker_call_with_trampolines () {}int main (){ void (*pointer_to_call0a) (char, short, int, long) = (void (*)(char, short, int, long))call0a; double (*pointer_to_call_with_trampolines) (double) = call_with_trampolines;#ifdef usestubs set_debug_traps(); breakpoint();#endif /* Test calling with basic integer types */ call0a (c, s, i, l); call0b (s, i, l, c); call0c (i, l, c, s); call0d (l, c, s, i); call0e (c, l, c, i, c, s, c, c); /* Test calling with unsigned integer types */ call1a (uc, us, ui, ul); call1b (us, ui, ul, uc); call1c (ui, ul, uc, us); call1d (ul, uc, us, ui); call1e (uc, ul, uc, ui, uc, us, uc, uc); /* Test calling with integral types mixed with floating point types */ call2a (c, f, s, d, i, f, l, d); call2b (f, s, d, i, f, l, d, c); call2c (s, d, i, f, l, d, c, f); call2d (d, i, f, l, d, c, f, s); call2e (i, f, l, d, c, f, s, d); call2f (f, l, d, c, f, s, d, i); call2g (l, d, c, f, s, d, i, f); call2h (d, c, f, s, d, i, f, l); call2i (c, f, c, c, d, c, c, c, f, s, c, d); /* Test dereferencing pointers to various integral and floating types */ call3a (cp, sp, ip, lp); call3b (ucp, usp, uip, ulp); call3c (fp, dp); /* Test dereferencing pointers to structs and unions */ call4a (stp); un.u1 = 1; call4b (unp); /* Test calling with structures and unions. */ call5a (st); un.u1 = 2; call5b (un); /* Test shuffling of args */ call6a (c, s, i, l, f, d, uc, us, ui, ul); call7a (c, i, s, l, f, uc, d, us, ul, ui); /* Test passing structures recursively. */ test_struct_args (); localvars_after_alloca (c, s, i, l); call_after_alloca (c, s, i, l); /* This is for localvars_in_indirect_call. */ marker_indirect_call (); /* The comment on the following two lines is used by funcargs.exp, don't change it. */ (*pointer_to_call0a) (c, s, i, l); /* First step into call0a. */ (*pointer_to_call0a) (c, s, i, l); /* Second step into call0a. */ marker_call_with_trampolines (); (*pointer_to_call_with_trampolines) (d); /* Test multiple trampolines. */ return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -