complex.cpp 905 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2022, Peter Elliott <pelliott@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <complex.h>
  7. extern "C" {
  8. // Function definitions of this form "type (name)(args)" are intentional, to
  9. // prevent macro versions of "name" from being incorrectly expanded. These
  10. // functions are here to provide external linkage to their macro implementations.
  11. // https://pubs.opengroup.org/onlinepubs/9699919799/functions/creal.html
  12. float(crealf)(float complex z)
  13. {
  14. return crealf(z);
  15. }
  16. double(creal)(double complex z)
  17. {
  18. return creal(z);
  19. }
  20. long double(creall)(long double complex z)
  21. {
  22. return creall(z);
  23. }
  24. // https://pubs.opengroup.org/onlinepubs/9699919799/functions/cimag.html
  25. double(cimag)(double complex z)
  26. {
  27. return cimag(z);
  28. }
  29. float(cimagf)(float complex z)
  30. {
  31. return cimagf(z);
  32. }
  33. long double(cimagl)(long double complex z)
  34. {
  35. return cimagl(z);
  36. }
  37. }