Stdlib.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2016-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <cstdlib>
  18. #if defined(__APPLE__)
  19. #if __has_include(<crt_externs.h>)
  20. #include <crt_externs.h> // @manual
  21. #endif
  22. #endif
  23. extern "C" {
  24. #ifdef _WIN32
  25. // These are technically supposed to be defined linux/limits.h and
  26. // sys/param.h respectively, but Windows defines _MAX_PATH in stdlib.h,
  27. // so, instead of creating two headers for a single define each, we put
  28. // them here, where they are likely to already have been included in the
  29. // code that needs them.
  30. #define PATH_MAX _MAX_PATH
  31. #define MAXPATHLEN _MAX_PATH
  32. char* mktemp(char* tn);
  33. char* mkdtemp(char* tn);
  34. int mkstemp(char* tn);
  35. char* realpath(const char* path, char* resolved_path);
  36. int setenv(const char* name, const char* value, int overwrite);
  37. int unsetenv(const char* name);
  38. #elif defined(__APPLE__)
  39. // environ doesn't work well with dylibs, so use _NSGetEnviron instead.
  40. #if !__has_include(<crt_externs.h>)
  41. char*** _NSGetEnviron(void);
  42. #endif
  43. #define environ (*_NSGetEnviron())
  44. #endif
  45. #if !__linux__ && !FOLLY_MOBILE
  46. int clearenv();
  47. #endif
  48. }