parameters-lib.c revision 3a8a91ca57f66d664b3fbd19882e6d163c7ad496
1#include <string.h> 2#include <stdio.h> 3 4void func_ignore(int a, int b, int c) 5{ 6 printf("%d\n", a + b + c); 7} 8 9void func_intptr(int *i) 10{ 11 printf("%d\n", *i); 12} 13 14void func_intptr_ret(int *i) 15{ 16 *i = 42; 17} 18 19int func_strlen(char* p) 20{ 21 strcpy(p, "Hello world"); 22 return strlen(p); 23} 24 25int func_arg0(char *p) 26{ 27 strcpy(p, "Hello another world!"); 28 return strlen(p); 29} 30 31void func_strfixed(char* p) 32{ 33 strcpy(p, "Hello world"); 34} 35 36void func_string(char* p) 37{ 38 printf("%s\n", p); 39} 40 41void func_ppp(int*** ppp) 42{ 43 printf("%d\n", ***ppp); 44} 45 46void func_stringp(char** sP) 47{ 48 printf("%s\n", *sP); 49} 50 51void func_enum(int x) 52{ 53 printf("enum: %d\n", x); 54} 55 56void func_short(short x1, short x2) 57{ 58 printf("short: %hd %hd\n", x1, x2); 59} 60 61void func_ushort(unsigned short x1, unsigned short x2) 62{ 63 printf("ushort: %hu %hu\n", x1, x2); 64} 65 66float func_float(float f1, float f2) 67{ 68 printf("%f %f\n", f1, f2); 69 return f1; 70} 71 72double func_double(double f1, double f2) 73{ 74 printf("%f %f\n", f1, f2); 75 return f2; 76} 77 78void func_typedef(int x) 79{ 80 printf("typedef'd enum: %d\n", x); 81} 82 83void func_arrayi(int* a, int N) 84{ 85 int i; 86 printf("array[int]: "); 87 for (i = 0; i < N; i++) 88 printf("%d ", a[i]); 89 printf("\n"); 90} 91 92void func_arrayf(float* a, int N) 93{ 94 int i; 95 printf("array[float]: "); 96 for (i = 0; i < N; i++) 97 printf("%f ", a[i]); 98 printf("\n"); 99} 100 101struct test_struct { 102 int simple; 103 int alen; 104 int slen; 105 struct { int a; int b; }* array; 106 struct { int a; int b; } seq[3]; 107 char* str; 108 char* outer_str; 109}; 110 111void func_struct(struct test_struct* x) 112{ 113 char buf[100]; 114 int i; 115 116 printf("struct: "); 117 118 printf("%d, [", x->simple); 119 for (i = 0; i < x->alen; i++) { 120 printf("%d/%d", x->array[i].a, x->array[i].b); 121 if (i < x->alen - 1) 122 printf(" "); 123 } 124 printf("] ["); 125 for (i = 0; i < 3; i++) { 126 printf("%d/%d", x->seq[i].a, x->seq[i].b); 127 if (i < 2) 128 printf(" "); 129 } 130 printf("] "); 131 132 strncpy(buf, x->str, x->slen); 133 buf[x->slen] = '\0'; 134 printf("%s\n", buf); 135} 136 137void func_work (char *x) 138{ 139 *x = 'x'; 140} 141 142void func_call (char *x, char* y, void (*cb) (char *)) 143{ 144 cb (y); 145 *x = (*y)++; 146} 147 148struct S2 { 149 float f; 150 char a; 151 char b; 152}; 153 154struct S3 { 155 char a[6]; 156 float f; 157}; 158 159struct S2 160func_struct_2(int i, struct S3 s3, double d) 161{ 162 return (struct S2){ s3.f, s3.a[1], s3.a[2] }; 163} 164 165struct S4 { 166 long a; 167 long b; 168 long c; 169 long d; 170}; 171 172struct S4 173func_struct_large(struct S4 a, struct S4 b) 174{ 175 return (struct S4){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d }; 176} 177 178struct S5 { 179 char a; 180 char b; 181 long c; 182 long d; 183}; 184 185struct S5 186func_struct_large2(struct S5 a, struct S5 b) 187{ 188 return (struct S5){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d }; 189} 190 191struct S6 { 192 long a; 193 long b; 194 char c; 195 char d; 196}; 197 198struct S6 199func_struct_large3(struct S6 a, struct S6 b) 200{ 201 return (struct S6){ a.a + b.a, a.b + b.b, a.c + b.c, a.d + b.d }; 202} 203 204void 205func_many_args(int a, int b, long c, double d, char e, int f, float g, char h, 206 int i, double j, int k, double l, char m, int n, short o, int p, 207 char q, float r, float s, double t, long u, float v, float w, 208 float x, float y) 209{ 210} 211 212void 213func_lens(int a, long b, short c, long d) 214{ 215} 216 217int 218func_bool(int a, int b) 219{ 220 return !b; 221} 222 223void 224func_hide(int a, int b, int c, int d, int e, int f) 225{ 226} 227 228long * 229func_short_enums(short values[]) 230{ 231 static long retvals[4]; 232 retvals[0] = values[0]; 233 retvals[1] = values[1]; 234 retvals[2] = values[2]; 235 retvals[3] = values[3]; 236 return retvals; 237} 238 239long 240func_negative_enum(short a, unsigned short b, int c, unsigned d, 241 long e, unsigned long f) 242{ 243 return -1; 244} 245 246void 247func_charp_string(char *p) 248{ 249} 250 251struct dbl_eqv1 { double d; }; 252struct dbl_eqv2 { struct dbl_eqv1 d; }; 253struct dbl_eqv3 { struct dbl_eqv2 d; }; 254struct dbl_eqv4 { struct dbl_eqv3 d; }; 255 256struct flt_eqv1 { float d; }; 257struct flt_eqv2 { struct flt_eqv1 d; }; 258struct flt_eqv3 { struct flt_eqv2 d; }; 259struct flt_eqv4 { struct flt_eqv3 d; }; 260 261struct dbl_eqv1 262func_dbl_eqv(struct dbl_eqv1 a, struct dbl_eqv2 b, 263 struct dbl_eqv3 c, struct dbl_eqv4 d) 264{ 265 return (struct dbl_eqv1){ a.d + b.d.d + c.d.d.d + d.d.d.d.d }; 266} 267 268struct flt_eqv1 269func_flt_eqv(struct flt_eqv1 a, struct flt_eqv2 b, 270 struct flt_eqv3 c, struct flt_eqv4 d) 271{ 272 return (struct flt_eqv1){ a.d + b.d.d + c.d.d.d + d.d.d.d.d }; 273} 274 275struct struct_empty {}; 276struct struct_size1 { char a; }; 277struct struct_size2 { short a; }; 278struct struct_size4 { int a; }; 279struct struct_size8 { int a; int b; }; 280 281struct struct_empty 282func_struct_empty(struct struct_empty e) 283{ 284 return e; 285} 286 287struct struct_size1 288func_struct_size1(struct struct_size1 e) 289{ 290 return e; 291} 292 293struct struct_size2 294func_struct_size2(struct struct_size2 e) 295{ 296 return e; 297} 298 299struct struct_size4 300func_struct_size4(struct struct_size4 e) 301{ 302 return e; 303} 304 305struct struct_size8 306func_struct_size8(struct struct_size8 e) 307{ 308 return e; 309} 310 311struct struct_hfa_f2 { float a; struct flt_eqv1 b; }; 312struct struct_hfa_f2 313func_hfa_f2(struct struct_hfa_f2 e) 314{ 315 return e; 316} 317 318struct struct_hfa_f3 { float a; struct struct_hfa_f2 b; }; 319struct struct_hfa_f3 320func_hfa_f3(struct struct_hfa_f3 e) 321{ 322 return e; 323} 324 325struct struct_hfa_f4 { float a; struct struct_hfa_f3 b; }; 326struct struct_hfa_f4 327func_hfa_f4(struct struct_hfa_f4 e) 328{ 329 return e; 330} 331 332struct struct_hfa_f5 { float a; struct struct_hfa_f4 b; }; 333struct struct_hfa_f5 334func_hfa_f5(struct struct_hfa_f5 e) 335{ 336 return e; 337} 338 339struct struct_hfa_f6 { float a; struct struct_hfa_f5 b; }; 340struct struct_hfa_f6 341func_hfa_f6(struct struct_hfa_f6 e) 342{ 343 return e; 344} 345 346struct struct_hfa_f7 { float a; struct struct_hfa_f6 b; }; 347struct struct_hfa_f7 348func_hfa_f7(struct struct_hfa_f7 e) 349{ 350 return e; 351} 352 353struct struct_hfa_f8 { float a; struct struct_hfa_f7 b; }; 354struct struct_hfa_f8 355func_hfa_f8(struct struct_hfa_f8 e) 356{ 357 return e; 358} 359 360struct struct_hfa_f9 { float a; struct struct_hfa_f8 b; }; 361struct struct_hfa_f9 362func_hfa_f9(struct struct_hfa_f9 e) 363{ 364 return e; 365} 366 367struct struct_hfa_f10 { float a; struct struct_hfa_f9 b; }; 368struct struct_hfa_f10 369func_hfa_f10(struct struct_hfa_f10 e) 370{ 371 return e; 372} 373 374struct struct_hfa_f11 { float a; struct struct_hfa_f10 b; }; 375struct struct_hfa_f11 376func_hfa_f11(struct struct_hfa_f11 e) 377{ 378 return e; 379} 380 381struct struct_hfa_f12 { float a; struct struct_hfa_f11 b; }; 382struct struct_hfa_f12 383func_hfa_f12(struct struct_hfa_f12 e) 384{ 385 return e; 386} 387 388 389struct struct_hfa_d2 { double a; struct dbl_eqv1 b; }; 390struct struct_hfa_d2 391func_hfa_d2(struct struct_hfa_d2 e) 392{ 393 return e; 394} 395 396struct struct_hfa_d3 { double a; struct struct_hfa_d2 b; }; 397struct struct_hfa_d3 398func_hfa_d3(struct struct_hfa_d3 e) 399{ 400 return e; 401} 402 403struct struct_hfa_d4 { double a; struct struct_hfa_d3 b; }; 404struct struct_hfa_d4 405func_hfa_d4(struct struct_hfa_d4 e) 406{ 407 return e; 408} 409 410struct struct_hfa_d5 { double a; struct struct_hfa_d4 b; }; 411struct struct_hfa_d5 412func_hfa_d5(struct struct_hfa_d5 e) 413{ 414 return e; 415} 416 417struct struct_hfa_d6 { double a; struct struct_hfa_d5 b; }; 418struct struct_hfa_d6 419func_hfa_d6(struct struct_hfa_d6 e) 420{ 421 return e; 422} 423 424struct struct_hfa_d7 { double a; struct struct_hfa_d6 b; }; 425struct struct_hfa_d7 426func_hfa_d7(struct struct_hfa_d7 e) 427{ 428 return e; 429} 430 431struct struct_hfa_d8 { double a; struct struct_hfa_d7 b; }; 432struct struct_hfa_d8 433func_hfa_d8(struct struct_hfa_d8 e) 434{ 435 return e; 436} 437 438struct struct_hfa_d9 { double a; struct struct_hfa_d8 b; }; 439struct struct_hfa_d9 440func_hfa_d9(struct struct_hfa_d9 e) 441{ 442 return e; 443} 444 445struct struct_hfa_d10 { double a; struct struct_hfa_d9 b; }; 446struct struct_hfa_d10 447func_hfa_d10(struct struct_hfa_d10 e) 448{ 449 return e; 450} 451 452struct struct_hfa_d11 { double a; struct struct_hfa_d10 b; }; 453struct struct_hfa_d11 454func_hfa_d11(struct struct_hfa_d11 e) 455{ 456 return e; 457} 458 459struct struct_hfa_d12 { double a; struct struct_hfa_d11 b; }; 460struct struct_hfa_d12 461func_hfa_d12(struct struct_hfa_d12 e) 462{ 463 return e; 464} 465 466void 467func_printf(char *format, ...) 468{ 469} 470 471void 472func_sprintf(char *str, char *format, ...) 473{ 474} 475