cgrouprc.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (C) 2019 The Android Open Source Project
  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 <stdint.h>
  18. __BEGIN_DECLS
  19. // For host builds, __INTRODUCED_IN is not defined.
  20. #ifndef __INTRODUCED_IN
  21. #define __INTRODUCED_IN(x)
  22. #endif
  23. struct ACgroupController;
  24. typedef struct ACgroupController ACgroupController;
  25. #if __ANDROID_API__ >= __ANDROID_API_Q__
  26. // ACgroupFile
  27. /**
  28. * Returns file version. See android::cgrouprc::format::CgroupFile for a list of valid versions
  29. * for the file.
  30. * If ACgroupFile_init() isn't called, initialization will be done first.
  31. * If initialization failed, return 0.
  32. */
  33. __attribute__((warn_unused_result)) uint32_t ACgroupFile_getVersion() __INTRODUCED_IN(29);
  34. /**
  35. * Returns the number of controllers.
  36. * If ACgroupFile_init() isn't called, initialization will be done first.
  37. * If initialization failed, return 0.
  38. */
  39. __attribute__((warn_unused_result)) uint32_t ACgroupFile_getControllerCount() __INTRODUCED_IN(29);
  40. /**
  41. * Returns the controller at the given index.
  42. * Returnss nullptr if the given index exceeds getControllerCount().
  43. * If ACgroupFile_init() isn't called, initialization will be done first.
  44. * If initialization failed, return 0.
  45. */
  46. __attribute__((warn_unused_result)) const ACgroupController* ACgroupFile_getController(
  47. uint32_t index) __INTRODUCED_IN(29);
  48. // ACgroupController
  49. /**
  50. * Returns the version of the given controller.
  51. * If the given controller is null, return 0.
  52. */
  53. __attribute__((warn_unused_result)) uint32_t ACgroupController_getVersion(const ACgroupController*)
  54. __INTRODUCED_IN(29);
  55. /**
  56. * Flag bitmask to be used when ACgroupController_getFlags can be exported
  57. */
  58. #define CGROUPRC_CONTROLLER_FLAG_MOUNTED 0x1
  59. /**
  60. * Returns the name of the given controller.
  61. * If the given controller is null, return nullptr.
  62. */
  63. __attribute__((warn_unused_result)) const char* ACgroupController_getName(const ACgroupController*)
  64. __INTRODUCED_IN(29);
  65. /**
  66. * Returns the path of the given controller.
  67. * If the given controller is null, return nullptr.
  68. */
  69. __attribute__((warn_unused_result)) const char* ACgroupController_getPath(const ACgroupController*)
  70. __INTRODUCED_IN(29);
  71. __END_DECLS
  72. #endif