main.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. unsigned
  8. fib2(unsigned n)
  9. {
  10. if (n < 2) {
  11. return 1;
  12. }
  13. return fib2(n - 2) + fib2(n - 1);
  14. }
  15. void
  16. test1(int32_t i32, int64_t i64, float f32, double f64)
  17. {
  18. printf("i32: %d, i64: %lld, f32: %f, f64: %f\n", i32, i64, f32, f64);
  19. }
  20. int64_t
  21. test2(int64_t x, int64_t y)
  22. {
  23. printf("%lld + %lld = %lld\n", x, y, x + y);
  24. return x + y;
  25. }
  26. double
  27. test3(float x, double y)
  28. {
  29. printf("%f * %f = %f\n", x, y, x * y);
  30. return x * y;
  31. }
  32. float
  33. test4(double x, int32_t y)
  34. {
  35. printf("%f / %d = %f\n", x, y, x / y);
  36. return x / y;
  37. }
  38. int
  39. main(int argc, char **argv)
  40. {
  41. char *buf;
  42. printf("Hello world!\n");
  43. buf = malloc(1024);
  44. if (!buf) {
  45. printf("malloc buf failed\n");
  46. return -1;
  47. }
  48. printf("buf ptr: %p\n", buf);
  49. snprintf(buf, 1024, "%s", "1234\n");
  50. printf("buf: %s", buf);
  51. free(buf);
  52. return 0;
  53. }